Use GDB to debug a C++ program called from a shell script

前端 未结 6 1703
自闭症患者
自闭症患者 2020-12-24 13:18

I have a extremely complicated shell script, within which it calls a C++ program I want to debug via GDB. It is extremely hard to separate this c++ program from the shell si

6条回答
  •  醉话见心
    2020-12-24 13:57

    I would probably modify the script to always call gdb (and revert this later) or add an option to call gdb. This will almost always be the easiest solution.

    The next easiest would be to temporarily move your executable and replace it with a shell script that runs gdb on the moved program. For example, in the directory containing your program:

    $ mv program _program
    $ (echo "#!/bin/sh"; echo "exec gdb $PWD/_program") > program
    $ chmod +x program
    

提交回复
热议问题