current c instruction address

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone. I am trying to lay down some breadcrumbs for debugging perposes and cant seem to find a way for gcc to give me the current instruction address. Any ideas. P.S. I want to use the code in ARM projects too so a pure gcc solution would be most portable.
Thanks.
Murray.

Murray Horn.
http://www.opend.co.za

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look up the listing file? Of course if you have a JTAG or other debugger there is no problem.
The use of disassembly view with Studio also will tell you where you are at at any step.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got it!
This multi line macro gets program counter wherever
breadcrumbs_mark is placed and passes it on as a 32bit unsigned integer to function breadcrumbs_p_x

#define breadcrumbs_mark \
{ \
__label__ found; \
found:; \
breadcrumbs_p_x((uint32_t) &&found); \
}

The crumb storage function prototype looks like this
void breadcrumbs_p_x(uint32_t addr);

Murray

Murray Horn.
http://www.opend.co.za

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi js. Thanks.
This is for quick on the go Program counter capture. Just put one line of code down and the address is recorded.

This is for trace debuging code. Useful as after an error has occurred, i can backtrack the cpu's markers to try figure out what happened. Very useful in processors like ARM as they have a prefetch abort interrupt.

A generally useful tool for debugging. especially when one has rouge pointers running around.

Murray Horn.
http://www.opend.co.za

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting that you chose a forum dedicated to AVR 8 bit micros to ask a question about ARM programming! ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thats the beauty of GCC. one compiler for all.

Murray Horn.
http://www.opend.co.za