Search code examples
debugginggdbelfgdbinit

How to set arg using gdbinit but just when a specific binary is loaded in gdb?


How to set arg -d through the file ~/.gdbinit but just when a specific binary is loaded in gdb?


Solution

  • with python you can add something like the following to your gdbinit

    py
    def on_bin_echo(): gdb.execute("set arg -d")
    exec_funcs = {"/bin/echo" : on_bin_echo}
    map(lambda x: exec_funcs[x.filename]() if exec_funcs.has_key(x.filename) else None, gdb.objfiles())
    end