From 8edd5d01538ad56dcaf67b8d35bef65748ab62b4 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 11 Jul 2003 14:52:17 +0000 Subject: 2003-07-11 Andrew Cagney * frame.h (get_frame_address_in_block): Declare. (frame_unwind_address_in_block): Declare. * frame.c (frame_unwind_address_in_block): New function. (get_frame_address_in_block): New function. --- gdb/frame.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gdb/frame.c') diff --git a/gdb/frame.c b/gdb/frame.c index 23fb5b1..1e364bd 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2006,6 +2006,33 @@ get_frame_pc (struct frame_info *frame) return frame_pc_unwind (frame->next); } +/* Return an address of that falls within the frame's code block. */ + +CORE_ADDR +frame_unwind_address_in_block (struct frame_info *next_frame) +{ + /* A draft address. */ + CORE_ADDR pc = frame_pc_unwind (next_frame); + + /* If THIS frame is not inner most (i.e., NEXT isn't the sentinel), + and NEXT is `normal' (i.e., not a sigtramp, dummy, ....) THIS + frame's PC ends up pointing at the instruction fallowing the + "call". Adjust that PC value so that it falls on the call + instruction (which, hopefully, falls within THIS frame's code + block. So far it's proved to be a very good approximation. See + get_frame_type for why ->type can't be used. */ + if (next_frame->level >= 0 + && get_frame_type (next_frame) == NORMAL_FRAME) + --pc; + return pc; +} + +CORE_ADDR +get_frame_address_in_block (struct frame_info *this_frame) +{ + return frame_unwind_address_in_block (this_frame->next); +} + static int pc_notcurrent (struct frame_info *frame) { -- cgit v1.1