How to use gdb with LD_PRELOAD

后端 未结 5 1384
攒了一身酷
攒了一身酷 2020-12-23 16:24

I run a program with LD_PRELOADing a specific library. Like this.

LD_PRELOAD=./my.so ./my_program

How do I run this program with gdb<

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 16:40

    Here is a way to run everything (with arguments and environment) as one command:

    Example:

    gdb --args env LD_PRELOAD=/usr/local/lib/libstderred.so ls -l
    

    The keen observer will notice that env serves here as an exec wrapper (like Alexey Romanov's answer).

提交回复
热议问题