foss-for-synopsys-dwc-arc-processors/gdb — pull request #4 by anthony-kolesov (2013-08-26 15:36:43+00:00)
Title: ARC: Return correct frame code address without full debug symbols

There was an issue with GDB improperly performing "nexti" command. Instead of stepping over function it was stepping into function. This issue was happening only when binary was compiled without debug symbols. Also it was observed on initialization functions from newlib (for example __start and _init), because they are written in assembly and can't have full debug symbols. It is important to understand that when performing nexti GDB first issues command "single instruction" that steps into function, then GDB sets breakpoint at instruction after branch-and-link and then resumes until it is hit. So the real issue was that after performing single step GDB was stopping instead of resuming.

The problem was tracked down to how frame_id->code_addr (frame code address) is evaluated. This field should point to first instruction in a function. When application is compiled with debug symbols then GDB uses DWARF info to get this address. If debug symbols are missing then GDB relies on architecture specific functions to get corrrect code address for frame. In case of ARC this is a function arc_frame_this_id(). This function was returning current PC value as a code address. Nothing is wrong with this approach and it is used by other architectures too as a fallback when nothing else works. However even when full debug symbols are not present usually there is still enough data for this function to work properly. This patch adds an invocation to generic function get_frame_func() which works fine in most cases and returns the address of first instruction in function. There is only one case when it will not work: when *all* symbols have been stripped, then it will return 0x0, so function arc_frame_this_id will() return current PC value as a code address as it was before.

To recap:
* Object files have been compiled with -g: DWARF info is used, this patch has no effect.
* Object files have been compiled without -g but not stripped: this patch fixes behaviour if nexti (and possibly something else).
* Object files have been stripped with `strip -g` (strip debug symbols): Likewise.
* Object files have been stripped with `strip -s` (strip all symbols): This patch has not effect, it did not worked before and will not work after.

Signed-off-by: Anton Kolesov