0

I am attempting to use this answer to generate an instruction trace between two lines of code.

Unfortunately, the condition in the while loop is a simple count, and I need to keep running the loop until a particular line of code in the source code is reached.

Does there exists a way to check whether we are either on a particular line of code, or at a particular breakpoint, within a pure gdb script?

I am aware of the solution here which uses the Python API. I am also aware of pin-instat, but I want to know whether this can done with pure gdb.

Community
  • 1
  • 1
merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • What if 1) use `info line ` or use `disas /m` to get information about addresses of the particular line of code and when 2) `while $pc != ADDRESS` | `si` | `end` ?. This way you will keep running the loop until a particular line of code in the source code is reached. –  Jul 02 '14 at 09:09

1 Answers1

1

What if do what you want in this way

1) Get information about pc for the line which you would like to reach

Use info line or use disas /m to get information about addresses of the particular line of code.

2) Write the similar loop as in Tracing/profiling instructions

 while $pc != ADDRESS-FROM-FIRST-STEP
   si 
 end. 

This way you will keep running the loop until a particular line of code in the source code is reached

Community
  • 1
  • 1
  • With ASLR, which is enabled on most systems, the address will change across runs. By the way, I had meant to respond to the comment but I lost track of it. – merlin2011 Jul 04 '14 at 09:17
  • 1) You are running under `gdb`, aren't you? It is possible to disable randomization under gdb with `set disable-randomization`. 2) ASLR on Linux can have three possible values. On my computer its value is 2 and it seems that when I run a program addresses of functions are the same yet addresses of heap are different. –  Jul 04 '14 at 10:20