Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* GDB process (on Linux) cooperating with the debugged process (some particular pthread on it)
@ 2025-05-15  9:12 Basile Starynkevitch
  2025-05-15 11:04 ` Andrew Burgess via Gdb
  0 siblings, 1 reply; 4+ messages in thread
From: Basile Starynkevitch @ 2025-05-15  9:12 UTC (permalink / raw)
  To: Gdb; +Cc: team

Hello all,

Is it possible for the debugged process (for me the RefPerSys inference engine,
GPL licensed, see below) which has several threads to send GDB commands or
interact with the debugger process.


This on Linux only (often x86-64, kernel 6.12.27); some event loop of the
debugged process could run in a particular pthread (which I don't want to debug
with such a weird GDB).

In general help on debugging a multithreaded Linux process is welcome. Can I
stop (or GDB step) only one thread and let the others run?

The debugged program is compiled by GCC and I probably could install the source
code of most libraries it is linked to.

(If writing some simple GCC compiler plugin is required I might consider it, see
https://arxiv.org/abs/1109.0779 ...)

Regards.
-- 
Basile STARYNKEVITCH                            <basile@starynkevitch.net>
8 rue de la Faïencerie                       http://starynkevitch.net/Basile/  
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSys

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GDB process (on Linux) cooperating with the debugged process (some particular pthread on it)
  2025-05-15  9:12 GDB process (on Linux) cooperating with the debugged process (some particular pthread on it) Basile Starynkevitch
@ 2025-05-15 11:04 ` Andrew Burgess via Gdb
  2025-05-15 11:29   ` Basile Starynkevitch
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Burgess via Gdb @ 2025-05-15 11:04 UTC (permalink / raw)
  To: Basile Starynkevitch, Gdb; +Cc: team

Basile Starynkevitch <basile@starynkevitch.net> writes:

> Hello all,
>
> Is it possible for the debugged process (for me the RefPerSys inference engine,
> GPL licensed, see below) which has several threads to send GDB commands or
> interact with the debugger process.

I'm not aware of any existing, general technique for having the debuggee
send commands to the debugger.  There is some limited support for JIT
like processes to allow the process to give GDB debug information for
the dynamically generated code, but nothing beyond that.

>
> This on Linux only (often x86-64, kernel 6.12.27); some event loop of the
> debugged process could run in a particular pthread (which I don't want to debug
> with such a weird GDB).
>
> In general help on debugging a multithreaded Linux process is welcome. Can I
> stop (or GDB step) only one thread and let the others run?

You can turn on non-stop mode with 'set non-stop on'.  In non-stop mode,
when one thread stops, other threads are left running.

HTH
Thanks,
Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GDB process (on Linux) cooperating with the debugged process (some particular pthread on it)
  2025-05-15 11:04 ` Andrew Burgess via Gdb
@ 2025-05-15 11:29   ` Basile Starynkevitch
  2025-05-16  9:54     ` Andrew Burgess via Gdb
  0 siblings, 1 reply; 4+ messages in thread
From: Basile Starynkevitch @ 2025-05-15 11:29 UTC (permalink / raw)
  To: Andrew Burgess, Gdb; +Cc: team

On Thu, 2025-05-15 at 12:04 +0100, Andrew Burgess via Gdb wrote:
> Basile Starynkevitch <basile@starynkevitch.net> writes:
> 
> > Hello all,
> > 
> > Is it possible for the debugged process (for me the RefPerSys inference
> > engine,
> > GPL licensed, see below) which has several threads to send GDB commands or
> > interact with the debugger process.
> 
> I'm not aware of any existing, general technique for having the debuggee
> send commands to the debugger.  There is some limited support for JIT
> like processes to allow the process to give GDB debug information for
> the dynamically generated code, but nothing beyond that.

Thanks. Do you mind explaining how that works? or in what GDB source files does
that happen?

RefPerSys is generating dynamically code with libgccjit and GNU lightning....

Thanks.

-- 
Basile STARYNKEVITCH                            <basile@starynkevitch.net>
8 rue de la Faïencerie                       http://starynkevitch.net/Basile/  
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSys

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GDB process (on Linux) cooperating with the debugged process (some particular pthread on it)
  2025-05-15 11:29   ` Basile Starynkevitch
@ 2025-05-16  9:54     ` Andrew Burgess via Gdb
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess via Gdb @ 2025-05-16  9:54 UTC (permalink / raw)
  To: Basile Starynkevitch, Gdb; +Cc: team

Basile Starynkevitch <basile@starynkevitch.net> writes:

> On Thu, 2025-05-15 at 12:04 +0100, Andrew Burgess via Gdb wrote:
>> Basile Starynkevitch <basile@starynkevitch.net> writes:
>> 
>> > Hello all,
>> > 
>> > Is it possible for the debugged process (for me the RefPerSys inference
>> > engine,
>> > GPL licensed, see below) which has several threads to send GDB commands or
>> > interact with the debugger process.
>> 
>> I'm not aware of any existing, general technique for having the debuggee
>> send commands to the debugger.  There is some limited support for JIT
>> like processes to allow the process to give GDB debug information for
>> the dynamically generated code, but nothing beyond that.
>
> Thanks. Do you mind explaining how that works? or in what GDB source files does
> that happen?

Start by reading:

 https://sourceware.org/gdb/current/onlinedocs/gdb.html/JIT-Interface.html#JIT-Interface

Though the documentation isn't great, I think it could be improved with
some examples maybe.  But you can find some example code in the
testsuite, look in gdb/testsuite/gdb.base/ and read through any of the
files starting with 'jit-'.

In GDB source the entry point for jit handling is in jit.c, but if your
interest is being a user then hopefully the docs should be enough.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-16  9:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-15  9:12 GDB process (on Linux) cooperating with the debugged process (some particular pthread on it) Basile Starynkevitch
2025-05-15 11:04 ` Andrew Burgess via Gdb
2025-05-15 11:29   ` Basile Starynkevitch
2025-05-16  9:54     ` Andrew Burgess via Gdb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox