简体   繁体   中英

debugging a running daemon with GDB

I want to debug a running daemon with the GDB. I have the process id of respective process. I typed: gdb attach process id info threads

I am getting the list of threads. * one is the current one running thread (correct me if I am wrong)

Now I am sending:

systemctl kill daemonname (this command I am running on some other terminal)

now I want to check that after hitting this command which thread is getting run.

since my daemon is getting stuck. it is not killing properly. I tried with the service-name status command. Since it is getting stuck after the above " servicename status " command. I want to trace the last thread that is getting stuck since my daemon is still not killed but running the command for checking the status of that daemon is stucked, no output is coming on output. while it should show that the service is not running or command not found if it gets killed properly.

Please help me.. i am new

I tried with the service-name status command.

You may be holding it wrong.

After you execute systemctl kill daemonname , you want to attach GDB to the process and see where it is stuck (use thread apply all where ).

You will likely see that your threads are deadlocked (eg thread T1 is waiting for mutex A, which is held by thread T2; thread T2 is waiting for mutex B, held by thread T1).

I want to trace the last thread that is getting stuck

In general, tracing multithreaded processes is a fools errand, because the fact that you are tracing the process changes the execution environment and often causes it to no longer match execution without tracing.

Instead you should think about invariants, and make sure they are not violated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM