Skip to content

Commit

Permalink
Change the arguments of a dynamic printf with dprintf-args
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbssa committed Sep 29, 2024
1 parent 7cc75a1 commit ee04de6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions gdb/breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -9645,6 +9645,30 @@ dprintf_command (const char *arg, int from_tty)
0);
}

static void
dprintf_args_command (const char *arg, int from_tty)
{
const char *p = arg;
int bpnum = get_number (&p);

if (p[0] == '\0')
error (_("Format string required"));

for (breakpoint &b : all_breakpoints ())
if (b.number == bpnum)
{
if (b.type != bp_dprintf)
error (_("This is not a dprintf brakpoint."));

b.extra_string.reset (xstrdup (p));
update_dprintf_command_list (&b);

return;
}

error (_("No breakpoint number %d."), bpnum);
}

static void
agent_printf_command (const char *arg, int from_tty)
{
Expand Down Expand Up @@ -15322,6 +15346,10 @@ location may be a linespec, explicit, or address location.\n"
"\n" LOCATION_SPEC_HELP_STRING));
set_cmd_completer (c, location_completer);

c = add_com ("dprintf-args", class_breakpoint, dprintf_args_command, _("\
Change the arguments of a dynamic printf.\n\
Usage is `dprintf-args N format-string,arg1,arg2,...`."));

add_setshow_enum_cmd ("dprintf-style", class_support,
dprintf_style_enums, &dprintf_style, _("\
Set the style of usage for dynamic printf."), _("\
Expand Down

0 comments on commit ee04de6

Please sign in to comment.