I have a binary test that I want to debug with gdb. As you can see pwd is /tmp:$ gdb(gdb) file testReading symbols from /tmp/test...(no debugging symbols found)...done.(gdb) pwdWorking directory /tmp(gdb) runStarting program: /tmp/testor$ pwd/tmp$ gdb testReading symbols from /tmp/test...(no debugging symbols found)...done.The target architecture is assumed to be i386(gdb) runStarting program: /tmp/testThe problem is that gdb executes the file with the absolut path /tmp/test instead of the realtiv path test. Which means argv[0]=/tmp/test.How can I make gdb execute the file with the relativ path (argv[0]=test)?
How to debug a binary with the relative path in argv[0]?
linux;gdb
Figured it out myself with a cool trick I didn't know before - set exec-wrapper$ cat wrapper.sh#!/bin/bashp=testexec -a $p $@and in gdb(gdb) set exec-wrapper ./wrapper.shThis way you can set the argv[0] to whatever you want. source: https://sourceware.org/ml/gdb/2013-05/msg00049.html