0

I would like to set a watchpoint for an environment variable while using gdb.

  • 1
    What are you trying to achieve? http://xyproblem.info may be relevant here. – Employed Russian Mar 28 '22 at 03:47
  • 1
    Your question does not make much sense. How is _gdb_ related to _bash_? _gdb_ is a debugger for compiled programs, so at least you would have to give some context on the programming language you are using. For instance, in C, you may want to catch all cases where the debugged program invokes the system function `putenv`. – user1934428 Mar 28 '22 at 06:19
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Mar 28 '22 at 11:22
  • @EmployedRussian I was hoping to run an attack for a project where an environment variable is changed and then later used (similar to TOCTOU attack), and I was able to step through this program by pausing it immediately and then attaching it to gdb, but it would be too much work to step through every instruction waiting for the environment variable to change. – Anonymoose Mar 28 '22 at 22:15
  • @user1934428 gdb allows me to step through a program that I did not write, which sets and then uses an environment variable. All that I can see in gdb is the assembly code – Anonymoose Mar 28 '22 at 22:17
  • Yes, that why I said that gdb is for debugging a **compiled** program. You did not say what language the program is you are going to debug. BTW, environment variables don't magically change "from the outside", except by using [this](https://stackoverflow.com/questions/205064/is-there-a-way-to-change-the-environment-variables-of-another-process-in-unix)` trick (but read **all** the answers and comments in this link!). Otherwise, the environment is changed via the `putenv` system call. – user1934428 Mar 29 '22 at 06:44

0 Answers0