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.

1
  • 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. Commented Jul 2, 2014 at 9:09

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.