How to access environment variables inside .gdbinit and inside gdb itself?

后端 未结 4 1199
夕颜
夕颜 2021-02-18 18:20

I am looking to set up the path for the source code when debugging with gdb. I chose to do that with a .gdbinit file.

Basically, it contains a command:

d         


        
4条回答
  •  迷失自我
    2021-02-18 18:49

    (6 year late!)

    Don't use .gdbinit for this purpose. It does not expand env vars. Instead, use this commandline to launch gdb:

    gdb --init-eval-command="set dir $SOURCESROOT/src"
    
    (gdb) show dir
    /path/to/src
    

    FYI this technique can be used to set other critical variables, e.g

    gdb --eval-command="set sysroot $SYSROOTDIR"
    

    Which sets sysroot and solib-absolute-prefix in gdb

提交回复
热议问题