gdb: make debug_target use one-liners

Turn the debug prints in debug_target's method to be one liners.  For
instance, change this:

    gdb_printf (gdb_stdlog, "<- %s->wait (", this->beneath ()->shortname ());
    gdb_puts (target_debug_print_ptid_t (arg0), gdb_stdlog);
    gdb_puts (", ", gdb_stdlog);
    gdb_puts (target_debug_print_target_waitstatus_p (arg1), gdb_stdlog);
    gdb_puts (", ", gdb_stdlog);
    gdb_puts (target_debug_print_target_wait_flags (arg2), gdb_stdlog);
    gdb_puts (") = ", gdb_stdlog);
    target_debug_print_ptid_t (result);
    gdb_puts ("\n", gdb_stdlog);

into this:

    gdb_printf (gdb_stdlog,
               "<- %s->wait (%s, %s, %s) = %s\n",
               this->beneath ()->shortname (),
               target_debug_print_ptid_t (arg0).c_str (),
               target_debug_print_target_waitstatus_p (arg1).c_str (),
               target_debug_print_target_wait_flags (arg2).c_str (),
               target_debug_print_ptid_t (result).c_str ());

This makes it possible for a subsequent patch to turn this gdb_printf
call into a `target_debug_printf` call.

Change-Id: I808202438972fac1bba2f8ccb63e66a4fcef20c9
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Simon Marchi
2024-04-19 15:46:52 -04:00
committed by Simon Marchi
parent a887499c6b
commit b38f70086d
3 changed files with 835 additions and 864 deletions

View File

@@ -290,28 +290,34 @@ def write_debugmethod(
print(", ".join(names), file=f, end="")
print(");", file=f)
# Now print the arguments.
# Generate the debug printf call.
args_fmt = ", ".join(["%s"] * len(argtypes))
args = "".join(
[
(",\n\t {printer} (arg{i}).c_str ()").format(
printer=munge_type(t), i=i
)
for i, t in enumerate(argtypes)
]
)
if return_type != "void":
ret_fmt = " = %s"
ret = ",\n\t {printer} (result).c_str ()".format(
printer=munge_type(return_type)
)
else:
ret_fmt = ""
ret = ""
print(
' gdb_printf (gdb_stdlog, "<- %s->'
+ name
+ ' (", this->beneath ()->shortname ());',
(
" gdb_printf (gdb_stdlog,\n"
'\t "<- %s->{name} ({args_fmt}){ret_fmt}\\n",\n'
"\t this->beneath ()->shortname (){args}{ret});"
).format(name=name, args_fmt=args_fmt, args=args, ret_fmt=ret_fmt, ret=ret),
file=f,
)
for i in range(len(argtypes)):
if i > 0:
print(' gdb_puts (", ", gdb_stdlog);', file=f)
printer = munge_type(argtypes[i])
print(
" gdb_puts (" + printer + " (" + names[i] + "), gdb_stdlog);",
file=f,
)
if return_type != "void":
print(' gdb_puts (") = ", gdb_stdlog);', file=f)
printer = munge_type(return_type)
print(" " + printer + " (result);", file=f)
print(' gdb_puts ("\\n", gdb_stdlog);', file=f)
else:
print(' gdb_puts (")\\n", gdb_stdlog);', file=f)
if return_type != "void":
print(" return result;", file=f)

View File

@@ -308,7 +308,7 @@ target_debug_print_target_waitstatus_p (struct target_waitstatus *status)
/* Functions that are used via TARGET_DEBUG_PRINTER. */
static const char *
static std::string
target_debug_print_step (int step)
{ return step ? "step" : "continue"; }
@@ -331,7 +331,7 @@ target_debug_print_signals (gdb::array_view<const unsigned char> sigs)
return s;
}
static const char *
static std::string
target_debug_print_size_t (size_t size)
{
return pulongest (size);

View File

File diff suppressed because it is too large Load Diff