gdb: replace fprint_frame_id
Replace fprint_frame_id with a member function frame_id::to_string that returns a std::string. Convert all of the previous users of fprint_frame_id to use the new member function. This means that instead of writing things like this: fprintf_unfiltered (file, " id="); fprint_frame_id (file, s->id.id); We can write this: fprintf_unfiltered (file, " id=%s", s->id.id.to_string ().c_str ()); There should be no user visible changes after this commit. gdb/ChangeLog: * dummy-frame.c (fprint_dummy_frames): Convert use of fprint_frame_id to use frame_id::to_string. * frame.c (fprint_field): Delete. (fprint_frame_id): Moved to... (frame_id::to_string): ...this, rewritten to return a string. (fprint_frame): Convert use of fprint_frame_id to use frame_id::to_string. (compute_frame_id): Likewise. (frame_id_p): Likewise. (frame_id_eq): Likewise. (frame_id_inner): Likewise. * frame.h (struct frame_id) <to_string>: New member function. (fprint_frame_id): Delete declaration. * guile/scm-frame.c (frscm_print_frame_smob): Convert use of fprint_frame_id to use frame_id::to_string. * python/py-frame.c (frame_object_to_frame_info): Likewise. * python/py-unwind.c (unwind_infopy_str): Likewise. (pyuw_this_id): Likewise.
This commit is contained in:
parent
4821e618ad
commit
927c4e355e
7 changed files with 68 additions and 75 deletions
|
@ -1,3 +1,24 @@
|
||||||
|
2021-05-09 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
|
* dummy-frame.c (fprint_dummy_frames): Convert use of
|
||||||
|
fprint_frame_id to use frame_id::to_string.
|
||||||
|
* frame.c (fprint_field): Delete.
|
||||||
|
(fprint_frame_id): Moved to...
|
||||||
|
(frame_id::to_string): ...this, rewritten to return a string.
|
||||||
|
(fprint_frame): Convert use of fprint_frame_id to use
|
||||||
|
frame_id::to_string.
|
||||||
|
(compute_frame_id): Likewise.
|
||||||
|
(frame_id_p): Likewise.
|
||||||
|
(frame_id_eq): Likewise.
|
||||||
|
(frame_id_inner): Likewise.
|
||||||
|
* frame.h (struct frame_id) <to_string>: New member function.
|
||||||
|
(fprint_frame_id): Delete declaration.
|
||||||
|
* guile/scm-frame.c (frscm_print_frame_smob): Convert use of
|
||||||
|
fprint_frame_id to use frame_id::to_string.
|
||||||
|
* python/py-frame.c (frame_object_to_frame_info): Likewise.
|
||||||
|
* python/py-unwind.c (unwind_infopy_str): Likewise.
|
||||||
|
(pyuw_this_id): Likewise.
|
||||||
|
|
||||||
2021-05-08 Simon Marchi <simon.marchi@polymtl.ca>
|
2021-05-08 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* nat/linux-waitpid.c (status_to_str): Return std::string.
|
* nat/linux-waitpid.c (status_to_str): Return std::string.
|
||||||
|
|
|
@ -408,8 +408,7 @@ fprint_dummy_frames (struct ui_file *file)
|
||||||
{
|
{
|
||||||
gdb_print_host_address (s, file);
|
gdb_print_host_address (s, file);
|
||||||
fprintf_unfiltered (file, ":");
|
fprintf_unfiltered (file, ":");
|
||||||
fprintf_unfiltered (file, " id=");
|
fprintf_unfiltered (file, " id=%s", s->id.id.to_string ().c_str ());
|
||||||
fprint_frame_id (file, s->id.id);
|
|
||||||
fprintf_unfiltered (file, ", ptid=%s",
|
fprintf_unfiltered (file, ", ptid=%s",
|
||||||
target_pid_to_str (s->id.thread->ptid).c_str ());
|
target_pid_to_str (s->id.thread->ptid).c_str ());
|
||||||
fprintf_unfiltered (file, "\n");
|
fprintf_unfiltered (file, "\n");
|
||||||
|
|
84
gdb/frame.c
84
gdb/frame.c
|
@ -373,43 +373,44 @@ show_backtrace_limit (struct ui_file *file, int from_tty,
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See frame.h. */
|
||||||
|
|
||||||
static void
|
std::string
|
||||||
fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR addr)
|
frame_id::to_string () const
|
||||||
{
|
{
|
||||||
if (p)
|
const struct frame_id &id = *this;
|
||||||
fprintf_unfiltered (file, "%s=%s", name, hex_string (addr));
|
|
||||||
else
|
|
||||||
fprintf_unfiltered (file, "!%s", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
std::string res = "{";
|
||||||
fprint_frame_id (struct ui_file *file, struct frame_id id)
|
|
||||||
{
|
|
||||||
fprintf_unfiltered (file, "{");
|
|
||||||
|
|
||||||
if (id.stack_status == FID_STACK_INVALID)
|
if (id.stack_status == FID_STACK_INVALID)
|
||||||
fprintf_unfiltered (file, "!stack");
|
res += "!stack";
|
||||||
else if (id.stack_status == FID_STACK_UNAVAILABLE)
|
else if (id.stack_status == FID_STACK_UNAVAILABLE)
|
||||||
fprintf_unfiltered (file, "stack=<unavailable>");
|
res += "stack=<unavailable>";
|
||||||
else if (id.stack_status == FID_STACK_SENTINEL)
|
else if (id.stack_status == FID_STACK_SENTINEL)
|
||||||
fprintf_unfiltered (file, "stack=<sentinel>");
|
res += "stack=<sentinel>";
|
||||||
else if (id.stack_status == FID_STACK_OUTER)
|
else if (id.stack_status == FID_STACK_OUTER)
|
||||||
fprintf_unfiltered (file, "stack=<outer>");
|
res += "stack=<outer>";
|
||||||
else
|
else
|
||||||
fprintf_unfiltered (file, "stack=%s", hex_string (id.stack_addr));
|
res += std::string ("stack=") + hex_string (id.stack_addr);
|
||||||
|
|
||||||
fprintf_unfiltered (file, ",");
|
/* Helper function to format 'N=A' if P is true, otherwise '!N'. */
|
||||||
|
auto field_to_string = [] (const char *n, bool p, CORE_ADDR a) -> std::string
|
||||||
|
{
|
||||||
|
if (p)
|
||||||
|
return std::string (n) + "=" + core_addr_to_string (a);
|
||||||
|
else
|
||||||
|
return std::string ("!") + std::string (n);
|
||||||
|
};
|
||||||
|
|
||||||
fprint_field (file, "code", id.code_addr_p, id.code_addr);
|
res += (std::string (",")
|
||||||
fprintf_unfiltered (file, ",");
|
+ field_to_string ("code", id.code_addr_p, id.code_addr)
|
||||||
|
+ std::string (",")
|
||||||
fprint_field (file, "special", id.special_addr_p, id.special_addr);
|
+ field_to_string ("special", id.special_addr_p, id.special_addr));
|
||||||
|
|
||||||
if (id.artificial_depth)
|
if (id.artificial_depth)
|
||||||
fprintf_unfiltered (file, ",artificial=%d", id.artificial_depth);
|
res += ",artificial=" + std::to_string (id.artificial_depth);
|
||||||
|
res += "}";
|
||||||
fprintf_unfiltered (file, "}");
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -492,7 +493,7 @@ fprint_frame (struct ui_file *file, struct frame_info *fi)
|
||||||
else if (fi->this_id.p == frame_id_status::COMPUTING)
|
else if (fi->this_id.p == frame_id_status::COMPUTING)
|
||||||
fprintf_unfiltered (file, "<computing>");
|
fprintf_unfiltered (file, "<computing>");
|
||||||
else
|
else
|
||||||
fprint_frame_id (file, fi->this_id.value);
|
fprintf_unfiltered (file, "%s", fi->this_id.value.to_string ().c_str ());
|
||||||
fprintf_unfiltered (file, ",");
|
fprintf_unfiltered (file, ",");
|
||||||
|
|
||||||
fprintf_unfiltered (file, "func=");
|
fprintf_unfiltered (file, "func=");
|
||||||
|
@ -592,11 +593,8 @@ compute_frame_id (struct frame_info *fi)
|
||||||
fi->this_id.p = frame_id_status::COMPUTED;
|
fi->this_id.p = frame_id_status::COMPUTED;
|
||||||
|
|
||||||
if (frame_debug)
|
if (frame_debug)
|
||||||
{
|
fprintf_unfiltered (gdb_stdlog, "-> %s }\n",
|
||||||
fprintf_unfiltered (gdb_stdlog, "-> ");
|
fi->this_id.value.to_string ().c_str ());
|
||||||
fprint_frame_id (gdb_stdlog, fi->this_id.value);
|
|
||||||
fprintf_unfiltered (gdb_stdlog, " }\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (const gdb_exception &ex)
|
catch (const gdb_exception &ex)
|
||||||
{
|
{
|
||||||
|
@ -748,11 +746,8 @@ frame_id_p (frame_id l)
|
||||||
bool p = l.stack_status != FID_STACK_INVALID;
|
bool p = l.stack_status != FID_STACK_INVALID;
|
||||||
|
|
||||||
if (frame_debug)
|
if (frame_debug)
|
||||||
{
|
fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=%s) -> %d }\n",
|
||||||
fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=");
|
l.to_string ().c_str (), p);
|
||||||
fprint_frame_id (gdb_stdlog, l);
|
|
||||||
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -796,13 +791,8 @@ frame_id_eq (frame_id l, frame_id r)
|
||||||
eq = true;
|
eq = true;
|
||||||
|
|
||||||
if (frame_debug)
|
if (frame_debug)
|
||||||
{
|
fprintf_unfiltered (gdb_stdlog, "{ frame_id_eq (l=%s,r=%s) -> %d }\n",
|
||||||
fprintf_unfiltered (gdb_stdlog, "{ frame_id_eq (l=");
|
l.to_string ().c_str (), r.to_string ().c_str (), eq);
|
||||||
fprint_frame_id (gdb_stdlog, l);
|
|
||||||
fprintf_unfiltered (gdb_stdlog, ",r=");
|
|
||||||
fprint_frame_id (gdb_stdlog, r);
|
|
||||||
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", eq);
|
|
||||||
}
|
|
||||||
|
|
||||||
return eq;
|
return eq;
|
||||||
}
|
}
|
||||||
|
@ -879,13 +869,9 @@ frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
|
||||||
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)
|
if (frame_debug)
|
||||||
{
|
fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=%s,r=%s) -> %d }\n",
|
||||||
fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=");
|
l.to_string ().c_str (), r.to_string ().c_str (),
|
||||||
fprint_frame_id (gdb_stdlog, l);
|
inner);
|
||||||
fprintf_unfiltered (gdb_stdlog, ",r=");
|
|
||||||
fprint_frame_id (gdb_stdlog, r);
|
|
||||||
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
return inner;
|
return inner;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,9 @@ struct frame_id
|
||||||
Caller of inlined function will have it zero, each more inner called frame
|
Caller of inlined function will have it zero, each more inner called frame
|
||||||
will have it increasingly one, two etc. Similarly for TAILCALL_FRAME. */
|
will have it increasingly one, two etc. Similarly for TAILCALL_FRAME. */
|
||||||
int artificial_depth;
|
int artificial_depth;
|
||||||
|
|
||||||
|
/* Return a string representation of this frame id. */
|
||||||
|
std::string to_string () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Save and restore the currently selected frame. */
|
/* Save and restore the currently selected frame. */
|
||||||
|
@ -258,11 +261,6 @@ extern bool frame_id_artificial_p (frame_id l);
|
||||||
/* Returns true when L and R identify the same frame. */
|
/* Returns true when L and R identify the same frame. */
|
||||||
extern bool frame_id_eq (frame_id l, frame_id r);
|
extern bool frame_id_eq (frame_id l, frame_id r);
|
||||||
|
|
||||||
/* Write the internal representation of a frame ID on the specified
|
|
||||||
stream. */
|
|
||||||
extern void fprint_frame_id (struct ui_file *file, struct frame_id id);
|
|
||||||
|
|
||||||
|
|
||||||
/* Frame types. Some are real, some are signal trampolines, and some
|
/* Frame types. Some are real, some are signal trampolines, and some
|
||||||
are completely artificial (dummy). */
|
are completely artificial (dummy). */
|
||||||
|
|
||||||
|
|
|
@ -156,14 +156,9 @@ frscm_print_frame_smob (SCM self, SCM port, scm_print_state *pstate)
|
||||||
{
|
{
|
||||||
frame_smob *f_smob = (frame_smob *) SCM_SMOB_DATA (self);
|
frame_smob *f_smob = (frame_smob *) SCM_SMOB_DATA (self);
|
||||||
|
|
||||||
gdbscm_printf (port, "#<%s ", frame_smob_name);
|
gdbscm_printf (port, "#<%s %s>",
|
||||||
|
frame_smob_name,
|
||||||
string_file strfile;
|
f_smob->frame_id.to_string ().c_str ());
|
||||||
fprint_frame_id (&strfile, f_smob->frame_id);
|
|
||||||
gdbscm_printf (port, "%s", strfile.c_str ());
|
|
||||||
|
|
||||||
scm_puts (">", port);
|
|
||||||
|
|
||||||
scm_remember_upto_here_1 (self);
|
scm_remember_upto_here_1 (self);
|
||||||
|
|
||||||
/* Non-zero means success. */
|
/* Non-zero means success. */
|
||||||
|
|
|
@ -79,10 +79,8 @@ frame_object_to_frame_info (PyObject *obj)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
frapy_str (PyObject *self)
|
frapy_str (PyObject *self)
|
||||||
{
|
{
|
||||||
string_file strfile;
|
const frame_id &fid = ((frame_object *) self)->frame_id;
|
||||||
|
return PyString_FromString (fid.to_string ().c_str ());
|
||||||
fprint_frame_id (&strfile, ((frame_object *) self)->frame_id);
|
|
||||||
return PyString_FromString (strfile.c_str ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
|
/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
|
||||||
|
|
|
@ -163,8 +163,7 @@ unwind_infopy_str (PyObject *self)
|
||||||
unwind_info_object *unwind_info = (unwind_info_object *) self;
|
unwind_info_object *unwind_info = (unwind_info_object *) self;
|
||||||
string_file stb;
|
string_file stb;
|
||||||
|
|
||||||
stb.puts ("Frame ID: ");
|
stb.printf ("Frame ID: %s", unwind_info->frame_id.to_string ().c_str ());
|
||||||
fprint_frame_id (&stb, unwind_info->frame_id);
|
|
||||||
{
|
{
|
||||||
const char *sep = "";
|
const char *sep = "";
|
||||||
struct value_print_options opts;
|
struct value_print_options opts;
|
||||||
|
@ -433,11 +432,8 @@ pyuw_this_id (struct frame_info *this_frame, void **cache_ptr,
|
||||||
{
|
{
|
||||||
*this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
|
*this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
|
||||||
if (pyuw_debug >= 1)
|
if (pyuw_debug >= 1)
|
||||||
{
|
fprintf_unfiltered (gdb_stdlog, "%s: frame_id: %s\n", __FUNCTION__,
|
||||||
fprintf_unfiltered (gdb_stdlog, "%s: frame_id: ", __FUNCTION__);
|
this_id->to_string ().c_str ());
|
||||||
fprint_frame_id (gdb_stdlog, *this_id);
|
|
||||||
fprintf_unfiltered (gdb_stdlog, "\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* frame_unwind.prev_register. */
|
/* frame_unwind.prev_register. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue