Added support for debugging emacs daemon

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Added support for debugging emacs daemon

Michael Welsh Duggan-3
I was recently in a position where I wanted to run "emacs --daemon"
under gdb.  After a few fumbles, I hit upon the following. I suggest
either adding this or something like this to .gdbinit or mentioning it
in DEBUG:

  # Follow forks until any possible daemonization is over
  set follow-fork-mode child
  tbreak init_signals
  commands
    set follow-fork-mode parent
  end

Mind you, init_signals is only used since it is the first emacs function
called after daemonization currently.  If things were to be moved
around, this snippet would have to change.

--
Michael Welsh Duggan
([hidden email])

Reply | Threaded
Open this post in threaded view
|

Re: Added support for debugging emacs daemon

Eli Zaretskii
> From: Michael Welsh Duggan <[hidden email]>
> Date: Tue, 12 Feb 2019 10:44:01 -0500
>
> I was recently in a position where I wanted to run "emacs --daemon"
> under gdb.  After a few fumbles, I hit upon the following. I suggest
> either adding this or something like this to .gdbinit or mentioning it
> in DEBUG:
>
>   # Follow forks until any possible daemonization is over
>   set follow-fork-mode child
>   tbreak init_signals
>   commands
>     set follow-fork-mode parent
>   end

Wouldn't this get in the way when debugging Emacs which launches
subprocesses?

It'd be OK to put this in etc/DEBUG, of course.  Patches welcome.

Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: Added support for debugging emacs daemon

Michael Welsh Duggan-3
Eli Zaretskii <[hidden email]> writes:

>> From: Michael Welsh Duggan <[hidden email]>
>> Date: Tue, 12 Feb 2019 10:44:01 -0500
>>
>> I was recently in a position where I wanted to run "emacs --daemon"
>> under gdb.  After a few fumbles, I hit upon the following. I suggest
>> either adding this or something like this to .gdbinit or mentioning it
>> in DEBUG:
>>
>>   # Follow forks until any possible daemonization is over
>>   set follow-fork-mode child
>>   tbreak init_signals
>>   commands
>>     set follow-fork-mode parent
>>   end
>
> Wouldn't this get in the way when debugging Emacs which launches
> subprocesses?

No.  That's why follow-fork-mode is turned back to parent after hitting
init_signals.

--
Michael Welsh Duggan
([hidden email])

Reply | Threaded
Open this post in threaded view
|

Re: Added support for debugging emacs daemon

Eli Zaretskii
> From: Michael Welsh Duggan <[hidden email]>
> Date: Tue, 12 Feb 2019 11:59:15 -0500
>
> >>   # Follow forks until any possible daemonization is over
> >>   set follow-fork-mode child
> >>   tbreak init_signals
> >>   commands
> >>     set follow-fork-mode parent
> >>   end
> >
> > Wouldn't this get in the way when debugging Emacs which launches
> > subprocesses?
>
> No.  That's why follow-fork-mode is turned back to parent after hitting
> init_signals.

Right, sorry for not paying attention.