How to attach a process in gdb

前端 未结 3 2000
渐次进展
渐次进展 2020-11-29 07:38

I have a simple C program that forks a process and then runs an executable.

I want to attach the child process to gdb.

I run the main program in a console

相关标签:
3条回答
  • 2020-11-29 08:18

    With a running instance of myExecutableName having a PID 15073:

    hitting Tab twice after $ gdb myExecu in the command line, will automagically autocompletes to:

    $ gdb myExecutableName 15073
    

    and will attach gdb to this process. That's nice!

    0 讨论(0)
  • 2020-11-29 08:24

    The first argument should be the path to the executable program. So

    gdb progname 12271
    
    0 讨论(0)
  • 2020-11-29 08:38

    Try one of these:

    gdb -p 12271
    gdb /path/to/exe 12271
    
    gdb /path/to/exe
    (gdb) attach 12271
    
    0 讨论(0)
提交回复
热议问题