Forum > Debugger

[Solved] Attach GDB to a TDaemon application

(1/5) > >>

Nimral:
Hi,

this question has been asked a while before (I found threads back until 2009), but IMHO never got a satisfactory answer.

Is it possible to attach GDB and the Lazuarus IDE holding the source code to a running daemon (TDaemon) bullt with the debug configuration/switches, obviously to debug the daemon with the same level of functionality one is used to from "normal" applications?

Thnx, Armin.

Martin_fr:
I haven't tried....

What happens if you use the attach feature of the IDE? (Run > Attach)
If your daemon process runs as different user, you may have to start the entire IDE with sufficient rights.

Note, if your daemon forks new processes (processes, not threads), only the process to which you attached will be debugged. So obviously at the time of attaching the process you are interested in has to be running already.

Martin_fr:
Or try gdbserver (search wiki). You may need to install the package LazDebuggerGdbmiServer.

Then you can start the daemon using:
  gdbserver [--host...]  your_daemon

Nimral:

--- Quote from: Martin_fr on February 09, 2022, 01:00:53 pm ---I haven't tried....

What happens if you use the attach feature of the IDE? (Run > Attach)
If your daemon process runs as different user, you may have to start the entire IDE with sufficient rights.

Note, if your daemon forks new processes (processes, not threads), only the process to which you attached will be debugged. So obviously at the time of attaching the process you are interested in has to be running already.

--- End quote ---

IDE and Service are running under the same account. No forking involved.

Nevertheless, attach to process fails.

Martin_fr:
What OS ?

In order to comment on the gdb error, I would need a log / or the gdb "debug output":
https://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

Have you tried FpDebug? Or is there a reason it has to be gdb?

Navigation

[0] Message Index

[#] Next page

Go to full version