0

I am writing and debugging a Window Manager for X.

I would like to be able to run gdb on my application. The application requires an X display. I want two sessions in parallel: one where I develop, run gdb and the application, and one to which I redirect my application.

I have tried multiple VT.

  • login to my development session with gdm
  • go to another VT with Ctrl+Alt+F3 (I am using Ubuntu 20.04)
  • start a new X session with sudo X :2

This last command kills everything else, both my development session in tty2, and the gdm login in tty1. I am left with black screens.

I also tried startx, but that opens a Desktop Environment (it looks like gnome). I've tried to modify ~/.xinitrc, to unset XDG_RUNTIME_DIR && sleep 60, but then I lost access to my other ttys for the 60 seconds.

unset XDG_RUNTIME_DIR && X :2 does not really fail, but returns immediately.

How can I get a separate X session in a TTY, so that I can run and debug my application from another TTY?

12
  • It looks like the driver of your GPU might not like having multiple instances of itself running at the same time, and doing so perhaps causes your GPU to crash. Are you perhaps using proprietary Nvidia or AMD drivers? Also, sudo X :2 would not start a complete new X session, just a new X server with nothing running on it. You would have to manage its session cookie yourself (or disable the X authentication, which is not secure), then start at least a window manager (or a complete desktop environment) on your :2 display to make it useful.
    – telcoM
    Commented Oct 8, 2022 at 14:04
  • 2
    Have you considered running your application within a nested X server (Xnest or Xephyr)? Or does the application use DRI or otherwise do something that requires access to the real GPU? (If yes, that is important information that should be added to your question, as that will restrict your options quite a bit.)
    – telcoM
    Commented Oct 8, 2022 at 14:08
  • 1
    You can run your app with second instance of X server in e.g. tty8 with xinit /full/path/to/your_app -- :1 vt8. Also Xephyr or Xnest may help.
    – dimich
    Commented Oct 8, 2022 at 14:12
  • @telcoM Awesome, I didn't know about Xnest. Now starting it with XDG_RUNTIME_DIR= Xnest :1, and my application with DISPLAY=:1 gdb ./my_app, and I can hunt my segfault. Thanks! It would still be great to learn what was wrong with my attempt at using the VT...
    – Gauthier
    Commented Oct 8, 2022 at 14:42
  • @dimich That did not work for me, and above all, I want to run my application through gdb and have debugging access. Would I be able to put gdb in the xinit command, you mean?
    – Gauthier
    Commented Oct 8, 2022 at 14:44

1 Answer 1

0

Strangely on my Ubuntu 20.04, I cannot start a second X server with X :1 vt3 &, without crashing my first server.

I can start it with startx, though.


My current solution:

In ~/.xinitrc:

unset XDG_RUNTIME_DIR && xhost +local: && tail -f /dev/null

XDG_RUNTIME_DIR for not mixing files, xhost for allowing a program in my other VT to output to the new VT, tail to wait while doing nothing.

In a new VT (VT3), I can now login and start an X server with startx.

Then in my first VT (VT2), I can check the DISPLAY variable of my other VT with the command w, and run gdb with my application:

DISPLAY=:1 gdb ./my_app

This definitely feels like a work-around. There must be a way to start a new X server without killing the first one, with X. But this seems functional enough for now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .