-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gdb.debug() - exe
parameter is not respected
#1273
Comments
before this commit, it was not was possible to specify `argv[0]` using `gdb.debug`, nor run the program with `argc = 0` (see for example Gallopsled#1273) this commit adds support for specifying both `argv` and `exe`, thus allowing further customization of the provided arguments.
before this commit, it was not was possible to specify `argv[0]` using `gdb.debug`, nor run the program with `argc = 0` (see for example Gallopsled#1273) this commit adds support for specifying both `argv` and `exe`, thus allowing further customization of the provided arguments.
before this commit, it was not was possible to specify `argv[0]` using `gdb.debug`, nor run the program with `argc = 0` (see for example Gallopsled#1273) this commit adds support for specifying both `argv` and `exe`, thus allowing further customization of the provided arguments.
What is the issue with Pull request #2024? If noone is working on it I have a few ideas that I want to test. |
I think it doesn't keep the environment variables in the specified order for python versions not keeping the insert order on dicts from Arusekk's comment, but lets discuss this in that PR please. If @giladreti doesn't have time to work on it anymore, you're more than welcome to open your own PR! |
I don't think I will have time to work on it anytime soon. I do agree with the response on my PR that we should probably use the same process customization method as with normal exec's (via a python script exec'ing our program at the end), as it will give us more feature support for free. |
This feature currently only works for context.native, i.e for LOCAL debugging on 'i386' or 'amd64' Implementation Challenges and solution: 1. `gdbserver` has no immediate support for manipulating argv[0] * Use the `--wrapper` flag, to execve the binary * Note that it must be an execve and not an fork+execve, since otherwise gdbserver doesn't attach 2. In python3 `os.execve` doesn't allow empty argv[0]. * Use `ctypes` to effectively call the execve function from Libc via python * `_generate_execve_script` generates this script and stores in a temp file * `gdbserver --wrapper python script.py -- dummy` to call it
This feature currently only works for context.native, i.e for LOCAL debugging on 'i386' or 'amd64' Implementation Challenges and solution: 1. `gdbserver` has no immediate support for manipulating argv[0] * Use the `--wrapper` flag, to execve the binary * Note that it must be an execve and not an fork+execve, since otherwise gdbserver doesn't attach 2. In python3 `os.execve` doesn't allow empty argv[0]. * Use `ctypes` to effectively call the execve function from Libc via python * `_generate_execve_script` generates this script and stores in a temp file * `gdbserver --wrapper python script.py -- dummy` to call it
This feature currently only works for context.native, i.e for LOCAL debugging on 'i386' or 'amd64' Implementation Challenges and solution: 1. `gdbserver` has no immediate support for manipulating argv[0] * Use the `--wrapper` flag, to execve the binary * Note that it must be an execve and not an fork+execve, since otherwise gdbserver doesn't attach 2. In python3 `os.execve` doesn't allow empty argv[0]. * Use `ctypes` to effectively call the execve function from Libc via python * `_generate_execve_script` generates this script and stores in a temp file * `gdbserver --wrapper python script.py -- dummy` to call it
Given executable:
I'd like to run and debug this binary with modified argv[0]. First, I've tried:
and everything works great - argv[0] is properly replaced in process.
Due to process of real binary I want to debug ends before
gdb.attach()
has time to be called I tried to usegdb.debug()
:but I get error:
Further investigation showed that
gdb.debug()
still tries to execute binary formargs[0]
, in this example"fake_argv[0]"
. It seems thatexe
parameter is not respected.I need some kind of temporary solution while this issue occurs - is there any option to yield process created with
process()
to attach to it before this process starts execution?The text was updated successfully, but these errors were encountered: