Re: [patch] circ.exp

Pedro Alves
2013-04-17T21:26:02Z

On 04/17/2013 10:18 PM, Pedro Alves wrote:

> I see. The issue is that when haven't collected any registers in the
> the tracepoint (collect $regs), we end up with a frames that are
> un-unwindable (UNWIND_UNAVAILABLE). All frames in that case have the same
> id (outer_frame_id), even if they represent different functions. I started
> out with a local fix in tfind_1, but that got ugly quick.

Below's that version. It feels very much like a workaround.
outer_frame_id should die.

> I think we should fix this in the frame machinery itself.

---

gdb/tracepoint.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4113999..fa2ce5d 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2270,6 +2270,9 @@ tfind_1 (enum trace_find_type type, int num,
struct frame_id old_frame_id = null_frame_id;
struct tracepoint *tp;
struct ui_out *uiout = current_uiout;
+ enum unwind_stop_reason old_frame_stop_reason = UNWIND_NO_REASON;
+ int old_frame_func_pc_p = 0;
+ CORE_ADDR old_frame_func_pc;

/* Only try to get the current stack frame if we have a chance of
succeeding. In particular, if we're trying to get a first trace
@@ -2279,7 +2282,17 @@ tfind_1 (enum trace_find_type type, int num,
trace frame. */
if (!(type == tfind_number && num == -1)
&& (has_stack_frames () || traceframe_number >= 0))
- old_frame_id = get_frame_id (get_current_frame ());
+ {
+ struct frame_info *frame = get_current_frame ();
+
+ old_frame_id = get_frame_id (frame);
+
+ get_prev_frame (frame);
+ old_frame_stop_reason = get_frame_unwind_stop_reason (frame);
+
+ old_frame_func_pc_p = get_frame_func_if_available (frame,
+ &old_frame_func_pc);
+ }

target_frameno = target_trace_find (type, num, addr1, addr2,
&target_tracept);
@@ -2384,8 +2397,19 @@ tfind_1 (enum trace_find_type type, int num,
function and it's arguments) -- otherwise we'll just show the
new source line. */

- if (frame_id_eq (old_frame_id,
- get_frame_id (get_current_frame ())))
+ struct frame_info *frame = get_current_frame ();
+ CORE_ADDR frame_func_pc;
+
+ get_prev_frame (frame);
+
+ if ((old_frame_stop_reason == UNWIND_UNAVAILABLE
+ || get_frame_unwind_stop_reason (frame) == UNWIND_UNAVAILABLE)
+ && ((old_frame_func_pc_p
+ != get_frame_func_if_available (frame, &frame_func_pc))
+ || old_frame_func_pc != frame_func_pc))
+ print_what = SRC_AND_LOC;
+ else if (frame_id_eq (old_frame_id,
+ get_frame_id (get_current_frame ())))
print_what = SRC_LINE;
else
print_what = SRC_AND_LOC;