gdb: introduce frame_debug_printf

Introduce frame_debug_printf, to convert the "frame" debug messages to
the new system.  Replace fprint_frame with a frame_info::to_string
method that returns a string, like what was done with
frame_id::to_string.  This makes it easier to use with
frame_debug_printf.

gdb/ChangeLog:

	* frame.h (frame_debug_printf): New.
	* frame.c: Use frame_debug_printf throughout when printing frame
	debug messages.
	* amd64-windows-tdep.c: Likewise.
	* value.c: Likewise.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-reg-undefined.exp: Update regexp.

Change-Id: I3c230b0814ea81c23af3e1aca1aac8d4ba91d726
This commit is contained in:
Simon Marchi 2021-06-29 12:03:50 -04:00
parent dd4f75f2b6
commit a05a883fba
7 changed files with 177 additions and 251 deletions

View file

@ -1,3 +1,11 @@
2021-06-29 Simon Marchi <simon.marchi@polymtl.ca>
* frame.h (frame_debug_printf): New.
* frame.c: Use frame_debug_printf throughout when printing frame
debug messages.
* amd64-windows-tdep.c: Likewise.
* value.c: Likewise.
2021-06-29 Simon Marchi <simon.marchi@polymtl.ca> 2021-06-29 Simon Marchi <simon.marchi@polymtl.ca>
* frame.h (frame_debug): Change type to bool. * frame.h (frame_debug): Change type to bool.

View file

@ -756,11 +756,7 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
(gdb_byte *) &ex_ui, sizeof (ex_ui)) != 0) (gdb_byte *) &ex_ui, sizeof (ex_ui)) != 0)
return; return;
if (frame_debug) frame_debug_printf ("%s: ver: %02x, plgsz: %02x, cnt: %02x, frame: %02x",
fprintf_unfiltered
(gdb_stdlog,
"amd64_windows_frame_decodes_insn: "
"%s: ver: %02x, plgsz: %02x, cnt: %02x, frame: %02x\n",
paddress (gdbarch, unwind_info), paddress (gdbarch, unwind_info),
ex_ui.Version_Flags, ex_ui.SizeOfPrologue, ex_ui.Version_Flags, ex_ui.SizeOfPrologue,
ex_ui.CountOfCodes, ex_ui.FrameRegisterOffset); ex_ui.CountOfCodes, ex_ui.FrameRegisterOffset);
@ -801,8 +797,7 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
get_frame_register (this_frame, frreg, buf); get_frame_register (this_frame, frreg, buf);
save_addr = extract_unsigned_integer (buf, 8, byte_order); save_addr = extract_unsigned_integer (buf, 8, byte_order);
if (frame_debug) frame_debug_printf (" frame_reg=%s, val=%s",
fprintf_unfiltered (gdb_stdlog, " frame_reg=%s, val=%s\n",
gdbarch_register_name (gdbarch, frreg), gdbarch_register_name (gdbarch, frreg),
paddress (gdbarch, save_addr)); paddress (gdbarch, save_addr));
} }
@ -835,9 +830,7 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
prologue has been fully executed. */ prologue has been fully executed. */
if (cache->pc >= start + p[0] || cache->pc < start) if (cache->pc >= start + p[0] || cache->pc < start)
{ {
if (frame_debug) frame_debug_printf (" op #%u: off=0x%02x, insn=0x%02x",
fprintf_unfiltered
(gdb_stdlog, " op #%u: off=0x%02x, insn=0x%02x\n",
(unsigned) (p - insns), p[0], p[1]); (unsigned) (p - insns), p[0], p[1]);
/* If there is no frame registers defined, the current value of /* If there is no frame registers defined, the current value of
@ -912,11 +905,11 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
} }
/* Display address where the register was saved. */ /* Display address where the register was saved. */
if (frame_debug && reg >= 0) if (reg >= 0)
fprintf_unfiltered frame_debug_printf (" [reg %s at %s]",
(gdb_stdlog, " [reg %s at %s]\n",
gdbarch_register_name (gdbarch, reg), gdbarch_register_name (gdbarch, reg),
paddress (gdbarch, cache->prev_reg_addr[reg])); paddress (gdbarch,
cache->prev_reg_addr[reg]));
} }
/* Adjust with the length of the opcode. */ /* Adjust with the length of the opcode. */
@ -978,11 +971,8 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
unwind_info = unwind_info =
extract_unsigned_integer (d.rva_UnwindData, 4, byte_order); extract_unsigned_integer (d.rva_UnwindData, 4, byte_order);
if (frame_debug) frame_debug_printf ("next in chain: unwind_data=%s, start_rva=%s, "
fprintf_unfiltered "end_rva=%s",
(gdb_stdlog,
"amd64_windows_frame_decodes_insn (next in chain):"
" unwind_data=%s, start_rva=%s, end_rva=%s\n",
paddress (gdbarch, unwind_info), paddress (gdbarch, unwind_info),
paddress (gdbarch, cache->start_rva), paddress (gdbarch, cache->start_rva),
paddress (gdbarch, cache->end_rva)); paddress (gdbarch, cache->end_rva));
@ -996,8 +986,7 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
cache->prev_rip_addr = cur_sp; cache->prev_rip_addr = cur_sp;
cache->prev_sp = cur_sp + 8; cache->prev_sp = cur_sp + 8;
if (frame_debug) frame_debug_printf (" prev_sp: %s, prev_pc @%s",
fprintf_unfiltered (gdb_stdlog, " prev_sp: %s, prev_pc @%s\n",
paddress (gdbarch, cache->prev_sp), paddress (gdbarch, cache->prev_sp),
paddress (gdbarch, cache->prev_rip_addr)); paddress (gdbarch, cache->prev_rip_addr));
} }
@ -1073,11 +1062,9 @@ amd64_windows_find_unwind_info (struct gdbarch *gdbarch, CORE_ADDR pc,
break; break;
} }
if (frame_debug) frame_debug_printf ("image_base=%s, unwind_data=%s",
fprintf_unfiltered paddress (gdbarch, base),
(gdb_stdlog, paddress (gdbarch, *unwind_info));
"amd64_windows_find_unwind_data: image_base=%s, unwind_data=%s\n",
paddress (gdbarch, base), paddress (gdbarch, *unwind_info));
return 0; return 0;
} }
@ -1139,9 +1126,7 @@ amd64_windows_frame_prev_register (struct frame_info *this_frame,
amd64_windows_frame_cache (this_frame, this_cache); amd64_windows_frame_cache (this_frame, this_cache);
CORE_ADDR prev; CORE_ADDR prev;
if (frame_debug) frame_debug_printf ("%s for sp=%s",
fprintf_unfiltered (gdb_stdlog,
"amd64_windows_frame_prev_register %s for sp=%s\n",
gdbarch_register_name (gdbarch, regnum), gdbarch_register_name (gdbarch, regnum),
paddress (gdbarch, cache->prev_sp)); paddress (gdbarch, cache->prev_sp));
@ -1160,8 +1145,8 @@ amd64_windows_frame_prev_register (struct frame_info *this_frame,
else else
prev = 0; prev = 0;
if (prev && frame_debug) if (prev != 0)
fprintf_unfiltered (gdb_stdlog, " -> at %s\n", paddress (gdbarch, prev)); frame_debug_printf (" -> at %s", paddress (gdbarch, prev));
if (prev) if (prev)
{ {

View file

@ -111,6 +111,9 @@ enum class frame_id_status
struct frame_info struct frame_info
{ {
/* Return a string representation of this frame. */
std::string to_string () const;
/* Level of this frame. The inner-most (youngest) frame is at level /* Level of this frame. The inner-most (youngest) frame is at level
0. As you move towards the outer-most (oldest) frame, the level 0. As you move towards the outer-most (oldest) frame, the level
increases. This is a cached value. It could just as easily be increases. This is a cached value. It could just as easily be
@ -414,95 +417,85 @@ frame_id::to_string () const
return res; return res;
} }
static void /* Return a string representation of TYPE. */
fprint_frame_type (struct ui_file *file, enum frame_type type)
static const char *
frame_type_str (frame_type type)
{ {
switch (type) switch (type)
{ {
case NORMAL_FRAME: case NORMAL_FRAME:
fprintf_unfiltered (file, "NORMAL_FRAME"); return "NORMAL_FRAME";
return;
case DUMMY_FRAME: case DUMMY_FRAME:
fprintf_unfiltered (file, "DUMMY_FRAME"); return "DUMMY_FRAME";
return;
case INLINE_FRAME: case INLINE_FRAME:
fprintf_unfiltered (file, "INLINE_FRAME"); return "INLINE_FRAME";
return;
case TAILCALL_FRAME: case TAILCALL_FRAME:
fprintf_unfiltered (file, "TAILCALL_FRAME"); return "TAILCALL_FRAME";
return;
case SIGTRAMP_FRAME: case SIGTRAMP_FRAME:
fprintf_unfiltered (file, "SIGTRAMP_FRAME"); return "SIGTRAMP_FRAME";
return;
case ARCH_FRAME: case ARCH_FRAME:
fprintf_unfiltered (file, "ARCH_FRAME"); return "ARCH_FRAME";
return;
case SENTINEL_FRAME: case SENTINEL_FRAME:
fprintf_unfiltered (file, "SENTINEL_FRAME"); return "SENTINEL_FRAME";
return;
default: default:
fprintf_unfiltered (file, "<unknown type>"); return "<unknown type>";
return;
}; };
} }
static void /* See struct frame_info. */
fprint_frame (struct ui_file *file, struct frame_info *fi)
std::string
frame_info::to_string () const
{ {
if (fi == NULL) const frame_info *fi = this;
{
fprintf_unfiltered (file, "<NULL frame>");
return;
}
fprintf_unfiltered (file, "{"); std::string res;
fprintf_unfiltered (file, "level=%d", fi->level);
fprintf_unfiltered (file, ","); res += string_printf ("{level=%d,", fi->level);
fprintf_unfiltered (file, "type=");
if (fi->unwind != NULL) if (fi->unwind != NULL)
fprint_frame_type (file, fi->unwind->type); res += string_printf ("type=%s,", frame_type_str (fi->unwind->type));
else else
fprintf_unfiltered (file, "<unknown>"); res += "type=<unknown>,";
fprintf_unfiltered (file, ",");
fprintf_unfiltered (file, "unwind=");
if (fi->unwind != NULL) if (fi->unwind != NULL)
gdb_print_host_address (fi->unwind, file); res += string_printf ("unwind=%p,", host_address_to_string (fi->unwind));
else else
fprintf_unfiltered (file, "<unknown>"); res += "unwind=<unknown>,";
fprintf_unfiltered (file, ",");
fprintf_unfiltered (file, "pc=");
if (fi->next == NULL || fi->next->prev_pc.status == CC_UNKNOWN) if (fi->next == NULL || fi->next->prev_pc.status == CC_UNKNOWN)
fprintf_unfiltered (file, "<unknown>"); res += "pc=<unknown>,";
else if (fi->next->prev_pc.status == CC_VALUE) else if (fi->next->prev_pc.status == CC_VALUE)
{ res += string_printf ("pc=%s%s,", hex_string (fi->next->prev_pc.value),
fprintf_unfiltered (file, "%s", hex_string (fi->next->prev_pc.value)); fi->next->prev_pc.masked ? "[PAC]" : "");
if (fi->next->prev_pc.masked)
fprintf_unfiltered (file, "[PAC]");
}
else if (fi->next->prev_pc.status == CC_NOT_SAVED) else if (fi->next->prev_pc.status == CC_NOT_SAVED)
val_print_not_saved (file); res += "pc=<not saved>,";
else if (fi->next->prev_pc.status == CC_UNAVAILABLE) else if (fi->next->prev_pc.status == CC_UNAVAILABLE)
val_print_unavailable (file); res += "pc=<unavailable>,";
fprintf_unfiltered (file, ",");
fprintf_unfiltered (file, "id=");
if (fi->this_id.p == frame_id_status::NOT_COMPUTED) if (fi->this_id.p == frame_id_status::NOT_COMPUTED)
fprintf_unfiltered (file, "<not computed>"); res += "id=<not computed>,";
else if (fi->this_id.p == frame_id_status::COMPUTING) else if (fi->this_id.p == frame_id_status::COMPUTING)
fprintf_unfiltered (file, "<computing>"); res += "id=<computing>,";
else else
fprintf_unfiltered (file, "%s", fi->this_id.value.to_string ().c_str ()); res += string_printf ("id=%s,", fi->this_id.value.to_string ().c_str ());
fprintf_unfiltered (file, ",");
fprintf_unfiltered (file, "func=");
if (fi->next != NULL && fi->next->prev_func.status == CC_VALUE) if (fi->next != NULL && fi->next->prev_func.status == CC_VALUE)
fprintf_unfiltered (file, "%s", hex_string (fi->next->prev_func.addr)); res += string_printf ("func=%s", hex_string (fi->next->prev_func.addr));
else else
fprintf_unfiltered (file, "<unknown>"); res += "func=<unknown>";
fprintf_unfiltered (file, "}");
res += "}";
return res;
} }
/* Given FRAME, return the enclosing frame as found in real frames read-in from /* Given FRAME, return the enclosing frame as found in real frames read-in from
@ -576,9 +569,7 @@ compute_frame_id (struct frame_info *fi)
/* Mark this frame's id as "being computed. */ /* Mark this frame's id as "being computed. */
fi->this_id.p = frame_id_status::COMPUTING; fi->this_id.p = frame_id_status::COMPUTING;
if (frame_debug) frame_debug_printf ("fi=%d", fi->level);
fprintf_unfiltered (gdb_stdlog, "{ compute_frame_id (fi=%d) ",
fi->level);
/* Find the unwinder. */ /* Find the unwinder. */
if (fi->unwind == NULL) if (fi->unwind == NULL)
@ -593,9 +584,7 @@ compute_frame_id (struct frame_info *fi)
/* Mark this frame's id as "computed". */ /* Mark this frame's id as "computed". */
fi->this_id.p = frame_id_status::COMPUTED; fi->this_id.p = frame_id_status::COMPUTED;
if (frame_debug) frame_debug_printf (" -> %s", fi->this_id.value.to_string ().c_str ());
fprintf_unfiltered (gdb_stdlog, "-> %s }\n",
fi->this_id.value.to_string ().c_str ());
} }
catch (const gdb_exception &ex) catch (const gdb_exception &ex)
{ {
@ -746,9 +735,7 @@ frame_id_p (frame_id l)
/* The frame is valid iff it has a valid stack address. */ /* The frame is valid iff it has a valid stack address. */
bool p = l.stack_status != FID_STACK_INVALID; bool p = l.stack_status != FID_STACK_INVALID;
if (frame_debug) frame_debug_printf ("l=%s -> %d", l.to_string ().c_str (), p);
fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=%s) -> %d }\n",
l.to_string ().c_str (), p);
return p; return p;
} }
@ -791,8 +778,7 @@ frame_id_eq (frame_id l, frame_id r)
/* Frames are equal. */ /* Frames are equal. */
eq = true; eq = true;
if (frame_debug) frame_debug_printf ("l=%s, r=%s -> %d",
fprintf_unfiltered (gdb_stdlog, "{ frame_id_eq (l=%s,r=%s) -> %d }\n",
l.to_string ().c_str (), r.to_string ().c_str (), eq); l.to_string ().c_str (), r.to_string ().c_str (), eq);
return eq; return eq;
@ -869,8 +855,7 @@ frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
different .code and/or .special address). */ different .code and/or .special address). */
inner = gdbarch_inner_than (gdbarch, l.stack_addr, r.stack_addr); inner = gdbarch_inner_than (gdbarch, l.stack_addr, r.stack_addr);
if (frame_debug) frame_debug_printf ("is l=%s inner than r=%s? %d",
fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=%s,r=%s) -> %d }\n",
l.to_string ().c_str (), r.to_string ().c_str (), l.to_string ().c_str (), r.to_string ().c_str (),
inner); inner);
@ -967,20 +952,14 @@ frame_unwind_pc (struct frame_info *this_frame)
{ {
this_frame->prev_pc.status = CC_UNAVAILABLE; this_frame->prev_pc.status = CC_UNAVAILABLE;
if (frame_debug) frame_debug_printf ("this_frame=%d -> <unavailable>",
fprintf_unfiltered (gdb_stdlog,
"{ frame_unwind_pc (this_frame=%d)"
" -> <unavailable> }\n",
this_frame->level); this_frame->level);
} }
else if (ex.error == OPTIMIZED_OUT_ERROR) else if (ex.error == OPTIMIZED_OUT_ERROR)
{ {
this_frame->prev_pc.status = CC_NOT_SAVED; this_frame->prev_pc.status = CC_NOT_SAVED;
if (frame_debug) frame_debug_printf ("this_frame=%d -> <not saved>",
fprintf_unfiltered (gdb_stdlog,
"{ frame_unwind_pc (this_frame=%d)"
" -> <not saved> }\n",
this_frame->level); this_frame->level);
} }
else else
@ -991,10 +970,8 @@ frame_unwind_pc (struct frame_info *this_frame)
{ {
this_frame->prev_pc.value = pc; this_frame->prev_pc.value = pc;
this_frame->prev_pc.status = CC_VALUE; this_frame->prev_pc.status = CC_VALUE;
if (frame_debug)
fprintf_unfiltered (gdb_stdlog, frame_debug_printf ("this_frame=%d -> %s",
"{ frame_unwind_pc (this_frame=%d) "
"-> %s }\n",
this_frame->level, this_frame->level,
hex_string (this_frame->prev_pc.value)); hex_string (this_frame->prev_pc.value));
} }
@ -1039,19 +1016,16 @@ get_frame_func_if_available (frame_info *this_frame, CORE_ADDR *pc)
if (!get_frame_address_in_block_if_available (this_frame, &addr_in_block)) if (!get_frame_address_in_block_if_available (this_frame, &addr_in_block))
{ {
next_frame->prev_func.status = CC_UNAVAILABLE; next_frame->prev_func.status = CC_UNAVAILABLE;
if (frame_debug)
fprintf_unfiltered (gdb_stdlog, frame_debug_printf ("this_frame=%d -> unavailable",
"{ get_frame_func (this_frame=%d)"
" -> unavailable }\n",
this_frame->level); this_frame->level);
} }
else else
{ {
next_frame->prev_func.status = CC_VALUE; next_frame->prev_func.status = CC_VALUE;
next_frame->prev_func.addr = get_pc_function_start (addr_in_block); next_frame->prev_func.addr = get_pc_function_start (addr_in_block);
if (frame_debug)
fprintf_unfiltered (gdb_stdlog, frame_debug_printf ("this_frame=%d -> %s",
"{ get_frame_func (this_frame=%d) -> %s }\n",
this_frame->level, this_frame->level,
hex_string (next_frame->prev_func.addr)); hex_string (next_frame->prev_func.addr));
} }
@ -1247,14 +1221,9 @@ frame_unwind_register_value (frame_info *next_frame, int regnum)
gdb_assert (next_frame != NULL); gdb_assert (next_frame != NULL);
gdbarch = frame_unwind_arch (next_frame); gdbarch = frame_unwind_arch (next_frame);
if (frame_debug) frame_debug_printf ("frame=%d, regnum=%d(%s)",
{
fprintf_unfiltered (gdb_stdlog,
"{ frame_unwind_register_value "
"(frame=%d,regnum=%d(%s),...) ",
next_frame->level, regnum, next_frame->level, regnum,
user_reg_map_regnum_to_name (gdbarch, regnum)); user_reg_map_regnum_to_name (gdbarch, regnum));
}
/* Find the unwinder. */ /* Find the unwinder. */
if (next_frame->unwind == NULL) if (next_frame->unwind == NULL)
@ -1267,40 +1236,42 @@ frame_unwind_register_value (frame_info *next_frame, int regnum)
if (frame_debug) if (frame_debug)
{ {
fprintf_unfiltered (gdb_stdlog, "->"); string_file debug_file;
fprintf_unfiltered (&debug_file, " ->");
if (value_optimized_out (value)) if (value_optimized_out (value))
{ {
fprintf_unfiltered (gdb_stdlog, " "); fprintf_unfiltered (&debug_file, " ");
val_print_not_saved (gdb_stdlog); val_print_not_saved (&debug_file);
} }
else else
{ {
if (VALUE_LVAL (value) == lval_register) if (VALUE_LVAL (value) == lval_register)
fprintf_unfiltered (gdb_stdlog, " register=%d", fprintf_unfiltered (&debug_file, " register=%d",
VALUE_REGNUM (value)); VALUE_REGNUM (value));
else if (VALUE_LVAL (value) == lval_memory) else if (VALUE_LVAL (value) == lval_memory)
fprintf_unfiltered (gdb_stdlog, " address=%s", fprintf_unfiltered (&debug_file, " address=%s",
paddress (gdbarch, paddress (gdbarch,
value_address (value))); value_address (value)));
else else
fprintf_unfiltered (gdb_stdlog, " computed"); fprintf_unfiltered (&debug_file, " computed");
if (value_lazy (value)) if (value_lazy (value))
fprintf_unfiltered (gdb_stdlog, " lazy"); fprintf_unfiltered (&debug_file, " lazy");
else else
{ {
int i; int i;
const gdb_byte *buf = value_contents (value); const gdb_byte *buf = value_contents (value);
fprintf_unfiltered (gdb_stdlog, " bytes="); fprintf_unfiltered (&debug_file, " bytes=");
fprintf_unfiltered (gdb_stdlog, "["); fprintf_unfiltered (&debug_file, "[");
for (i = 0; i < register_size (gdbarch, regnum); i++) for (i = 0; i < register_size (gdbarch, regnum); i++)
fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]); fprintf_unfiltered (&debug_file, "%02x", buf[i]);
fprintf_unfiltered (gdb_stdlog, "]"); fprintf_unfiltered (&debug_file, "]");
} }
} }
fprintf_unfiltered (gdb_stdlog, " }\n"); frame_debug_printf ("%s", debug_file.c_str ());
} }
return value; return value;
@ -1610,12 +1581,9 @@ create_sentinel_frame (struct program_space *pspace, struct regcache *regcache)
/* The sentinel frame has a special ID. */ /* The sentinel frame has a special ID. */
frame->this_id.p = frame_id_status::COMPUTED; frame->this_id.p = frame_id_status::COMPUTED;
frame->this_id.value = sentinel_frame_id; frame->this_id.value = sentinel_frame_id;
if (frame_debug)
{ frame_debug_printf (" -> %s", frame->to_string ().c_str ());
fprintf_unfiltered (gdb_stdlog, "{ create_sentinel_frame (...) -> ");
fprint_frame (gdb_stdlog, frame);
fprintf_unfiltered (gdb_stdlog, " }\n");
}
return frame; return frame;
} }
@ -1939,12 +1907,7 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
{ {
struct frame_info *fi; struct frame_info *fi;
if (frame_debug) frame_debug_printf ("addr=%s, pc=%s", hex_string (addr), hex_string (pc));
{
fprintf_unfiltered (gdb_stdlog,
"{ create_new_frame (addr=%s, pc=%s) ",
hex_string (addr), hex_string (pc));
}
fi = FRAME_OBSTACK_ZALLOC (struct frame_info); fi = FRAME_OBSTACK_ZALLOC (struct frame_info);
@ -1969,12 +1932,7 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
fi->this_id.p = frame_id_status::COMPUTED; fi->this_id.p = frame_id_status::COMPUTED;
fi->this_id.value = frame_id_build (addr, pc); fi->this_id.value = frame_id_build (addr, pc);
if (frame_debug) frame_debug_printf (" -> %s", fi->to_string ().c_str ());
{
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, fi);
fprintf_unfiltered (gdb_stdlog, " }\n");
}
return fi; return fi;
} }
@ -2047,8 +2005,8 @@ reinit_frame_cache (void)
sentinel_frame = NULL; /* Invalidate cache */ sentinel_frame = NULL; /* Invalidate cache */
select_frame (NULL); select_frame (NULL);
frame_stash_invalidate (); frame_stash_invalidate ();
if (frame_debug)
fprintf_unfiltered (gdb_stdlog, "{ reinit_frame_cache () }\n"); frame_debug_printf ("generation=%d", frame_cache_generation);
} }
/* Find where a register is saved (in memory or another register). /* Find where a register is saved (in memory or another register).
@ -2116,12 +2074,8 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame)
{ {
/* Another frame with the same id was already in the stash. We just /* Another frame with the same id was already in the stash. We just
detected a cycle. */ detected a cycle. */
if (frame_debug) frame_debug_printf (" -> nullptr // this frame has same ID");
{
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, NULL);
fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n");
}
this_frame->stop_reason = UNWIND_SAME_ID; this_frame->stop_reason = UNWIND_SAME_ID;
/* Unlink. */ /* Unlink. */
prev_frame->next = NULL; prev_frame->next = NULL;
@ -2157,23 +2111,17 @@ get_prev_frame_always_1 (struct frame_info *this_frame)
if (frame_debug) if (frame_debug)
{ {
fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame_always (this_frame=");
if (this_frame != NULL) if (this_frame != NULL)
fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level); frame_debug_printf ("this_frame=%d", this_frame->level);
else else
fprintf_unfiltered (gdb_stdlog, "<NULL>"); frame_debug_printf ("this_frame=nullptr");
fprintf_unfiltered (gdb_stdlog, ") ");
} }
/* Only try to do the unwind once. */ /* Only try to do the unwind once. */
if (this_frame->prev_p) if (this_frame->prev_p)
{ {
if (frame_debug) frame_debug_printf (" -> %s // cached",
{ this_frame->prev->to_string ().c_str ());
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, this_frame->prev);
fprintf_unfiltered (gdb_stdlog, " // cached \n");
}
return this_frame->prev; return this_frame->prev;
} }
@ -2220,15 +2168,9 @@ get_prev_frame_always_1 (struct frame_info *this_frame)
if (this_frame->stop_reason != UNWIND_NO_REASON) if (this_frame->stop_reason != UNWIND_NO_REASON)
{ {
if (frame_debug) frame_debug_printf
{ (" -> nullptr // %s",
enum unwind_stop_reason reason = this_frame->stop_reason; frame_stop_reason_symbol_string (this_frame->stop_reason));
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, NULL);
fprintf_unfiltered (gdb_stdlog, " // %s }\n",
frame_stop_reason_symbol_string (reason));
}
return NULL; return NULL;
} }
@ -2253,13 +2195,7 @@ get_prev_frame_always_1 (struct frame_info *this_frame)
morestack_name = morestack_msym->linkage_name (); morestack_name = morestack_msym->linkage_name ();
if (!morestack_name || strcmp (morestack_name, "__morestack") != 0) if (!morestack_name || strcmp (morestack_name, "__morestack") != 0)
{ {
if (frame_debug) frame_debug_printf (" -> nullptr // this frame ID is inner");
{
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, NULL);
fprintf_unfiltered (gdb_stdlog,
" // this frame ID is inner }\n");
}
this_frame->stop_reason = UNWIND_INNER_ID; this_frame->stop_reason = UNWIND_INNER_ID;
return NULL; return NULL;
} }
@ -2299,13 +2235,7 @@ get_prev_frame_always_1 (struct frame_info *this_frame)
if ((lval == lval_memory && lval == nlval && addr == naddr) if ((lval == lval_memory && lval == nlval && addr == naddr)
|| (lval == lval_register && lval == nlval && realnum == nrealnum)) || (lval == lval_register && lval == nlval && realnum == nrealnum))
{ {
if (frame_debug) frame_debug_printf (" -> nullptr // no saved PC");
{
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, NULL);
fprintf_unfiltered (gdb_stdlog, " // no saved PC }\n");
}
this_frame->stop_reason = UNWIND_NO_SAVED_PC; this_frame->stop_reason = UNWIND_NO_SAVED_PC;
this_frame->prev = NULL; this_frame->prev = NULL;
return NULL; return NULL;
@ -2407,12 +2337,7 @@ get_prev_frame_raw (struct frame_info *this_frame)
this_frame->prev = prev_frame; this_frame->prev = prev_frame;
prev_frame->next = this_frame; prev_frame->next = this_frame;
if (frame_debug) frame_debug_printf (" -> %s", prev_frame->to_string ().c_str ());
{
fprintf_unfiltered (gdb_stdlog, "-> ");
fprint_frame (gdb_stdlog, prev_frame);
fprintf_unfiltered (gdb_stdlog, " }\n");
}
return prev_frame; return prev_frame;
} }
@ -2425,12 +2350,10 @@ frame_debug_got_null_frame (struct frame_info *this_frame,
{ {
if (frame_debug) if (frame_debug)
{ {
fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame (this_frame=");
if (this_frame != NULL) if (this_frame != NULL)
fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level); frame_debug_printf ("this_frame=%d -> %s", this_frame->level, reason);
else else
fprintf_unfiltered (gdb_stdlog, "<NULL>"); frame_debug_printf ("this_frame=nullptr -> %s", reason);
fprintf_unfiltered (gdb_stdlog, ") -> // %s}\n", reason);
} }
} }
@ -2944,9 +2867,7 @@ frame_unwind_arch (struct frame_info *next_frame)
next_frame->prev_arch.arch = arch; next_frame->prev_arch.arch = arch;
next_frame->prev_arch.p = true; next_frame->prev_arch.p = true;
if (frame_debug) frame_debug_printf ("next_frame=%d -> %s",
fprintf_unfiltered (gdb_stdlog,
"{ frame_unwind_arch (next_frame=%d) -> %s }\n",
next_frame->level, next_frame->level,
gdbarch_bfd_arch_info (arch)->printable_name); gdbarch_bfd_arch_info (arch)->printable_name);
} }

View file

@ -216,6 +216,11 @@ extern const struct frame_id outer_frame_id;
extern bool frame_debug; extern bool frame_debug;
/* Print a "frame" debug statement. */
#define frame_debug_printf(fmt, ...) \
debug_prefixed_printf_cond (frame_debug, "frame", fmt, ##__VA_ARGS__)
/* Construct a frame ID. The first parameter is the frame's constant /* Construct a frame ID. The first parameter is the frame's constant
stack address (typically the outer-bound), and the second the stack address (typically the outer-bound), and the second the
frame's constant code address (typically the entry point). frame's constant code address (typically the entry point).

View file

@ -1,3 +1,7 @@
2021-06-29 Simon Marchi <simon.marchi@polymtl.ca>
* gdb.dwarf2/dw2-reg-undefined.exp: Update regexp.
2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com> 2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.base/info_sources_2-header.h: New file. * gdb.base/info_sources_2-header.h: New file.

View file

@ -78,7 +78,10 @@ for {set f 0} {$f < 3} {incr f} {
# Test that the debug log statement in frame_unwind_register_value produces # Test that the debug log statement in frame_unwind_register_value produces
# "not saved" and not "optimized out". # "not saved" and not "optimized out".
gdb_test "set debug frame 1" gdb_test "set debug frame 1"
gdb_test {print $rax} {frame_unwind_register_value[^\r\n]+rax[^\r\n]+not saved.*} gdb_test {print $rax} [multi_line \
{\[frame\] frame_unwind_register_value: frame=0, regnum=0\(rax\)} \
{\[frame\] frame_unwind_register_value: -> <not saved>} \
{.*}]
gdb_test "set debug frame 0" gdb_test "set debug frame 0"
# Test that history values show "not saved" and not "optimized out". # Test that history values show "not saved" and not "optimized out".

View file

@ -3956,17 +3956,17 @@ value_fetch_lazy_register (struct value *val)
regnum = VALUE_REGNUM (val); regnum = VALUE_REGNUM (val);
gdbarch = get_frame_arch (frame); gdbarch = get_frame_arch (frame);
fprintf_unfiltered (gdb_stdlog, string_file debug_file;
"{ value_fetch_lazy " fprintf_unfiltered (&debug_file,
"(frame=%d, regnum=%d(%s), ...) ", "(frame=%d, regnum=%d(%s), ...) ",
frame_relative_level (frame), regnum, frame_relative_level (frame), regnum,
user_reg_map_regnum_to_name (gdbarch, regnum)); user_reg_map_regnum_to_name (gdbarch, regnum));
fprintf_unfiltered (gdb_stdlog, "->"); fprintf_unfiltered (&debug_file, "->");
if (value_optimized_out (new_val)) if (value_optimized_out (new_val))
{ {
fprintf_unfiltered (gdb_stdlog, " "); fprintf_unfiltered (&debug_file, " ");
val_print_optimized_out (new_val, gdb_stdlog); val_print_optimized_out (new_val, &debug_file);
} }
else else
{ {
@ -3974,23 +3974,23 @@ value_fetch_lazy_register (struct value *val)
const gdb_byte *buf = value_contents (new_val); const gdb_byte *buf = value_contents (new_val);
if (VALUE_LVAL (new_val) == lval_register) if (VALUE_LVAL (new_val) == lval_register)
fprintf_unfiltered (gdb_stdlog, " register=%d", fprintf_unfiltered (&debug_file, " register=%d",
VALUE_REGNUM (new_val)); VALUE_REGNUM (new_val));
else if (VALUE_LVAL (new_val) == lval_memory) else if (VALUE_LVAL (new_val) == lval_memory)
fprintf_unfiltered (gdb_stdlog, " address=%s", fprintf_unfiltered (&debug_file, " address=%s",
paddress (gdbarch, paddress (gdbarch,
value_address (new_val))); value_address (new_val)));
else else
fprintf_unfiltered (gdb_stdlog, " computed"); fprintf_unfiltered (&debug_file, " computed");
fprintf_unfiltered (gdb_stdlog, " bytes="); fprintf_unfiltered (&debug_file, " bytes=");
fprintf_unfiltered (gdb_stdlog, "["); fprintf_unfiltered (&debug_file, "[");
for (i = 0; i < register_size (gdbarch, regnum); i++) for (i = 0; i < register_size (gdbarch, regnum); i++)
fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]); fprintf_unfiltered (&debug_file, "%02x", buf[i]);
fprintf_unfiltered (gdb_stdlog, "]"); fprintf_unfiltered (&debug_file, "]");
} }
fprintf_unfiltered (gdb_stdlog, " }\n"); frame_debug_printf ("%s", debug_file.c_str ());
} }
/* Dispose of the intermediate values. This prevents /* Dispose of the intermediate values. This prevents