aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2018-08-07 17:43:08 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2018-08-07 17:43:08 -0400
commit528e15722bf67d126e17218708c0314bcfadbf6a (patch)
tree8b17bb0ea9569e150917b27be97b3ecfdc96fe62 /gdb/breakpoint.c
parent96d68bd48c77fa44e517c3380ee8f224cbce00e5 (diff)
downloadgdb-528e15722bf67d126e17218708c0314bcfadbf6a.zip
gdb-528e15722bf67d126e17218708c0314bcfadbf6a.tar.gz
gdb-528e15722bf67d126e17218708c0314bcfadbf6a.tar.bz2
Replace some uses of xstrprintf with string_printf
This patch replaces some simple uses of xstrprintf with with string_printf, removing the need to do manual memory freeing. The change in ada-lang.c fixes an apparent memory leak. Regtested on the buildbot. gdb/ChangeLog: * common/filestuff.h (gdb_fopen_cloexec): New overload. (gdb_open_cloexec): Likewise. * nat/linux-osdata.c (command_from_pid): Use string_printf. (commandline_from_pid): Likewise. (linux_xfer_osdata_threads): Likewise. (linux_xfer_osdata_fds): Likewise. * ada-lang.c (is_package_name): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. * breakpoint.c (print_one_breakpoint_location): Use uiout::field_fmt. (print_one_catch_solib): Use string_printf. * coff-pe-read.c (add_pe_exported_sym): Likewise. (add_pe_forwarded_sym): Likewise. * dwarf2read.c (create_type_unit_group): Likewise. (build_error_marker_type): Likewise. * infcall.c (get_function_name): Likewise. * valprint.c (print_converted_chars_to_obstack): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 6b6e1f6..8f0feaa 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -6038,16 +6038,9 @@ print_one_breakpoint_location (struct breakpoint *b,
/* 1 */
annotate_field (0);
if (part_of_multiple)
- {
- char *formatted;
- formatted = xstrprintf ("%d.%d", b->number, loc_number);
- uiout->field_string ("number", formatted);
- xfree (formatted);
- }
+ uiout->field_fmt ("number", "%d.%d", b->number, loc_number);
else
- {
- uiout->field_int ("number", b->number);
- }
+ uiout->field_int ("number", b->number);
/* 2 */
annotate_field (1);
@@ -8048,7 +8041,6 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs)
struct solib_catchpoint *self = (struct solib_catchpoint *) b;
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- char *msg;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
@@ -8060,23 +8052,23 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs)
uiout->field_skip ("addr");
}
+ std::string msg;
annotate_field (5);
if (self->is_load)
{
if (self->regex)
- msg = xstrprintf (_("load of library matching %s"), self->regex);
+ msg = string_printf (_("load of library matching %s"), self->regex);
else
- msg = xstrdup (_("load of library"));
+ msg = _("load of library");
}
else
{
if (self->regex)
- msg = xstrprintf (_("unload of library matching %s"), self->regex);
+ msg = string_printf (_("unload of library matching %s"), self->regex);
else
- msg = xstrdup (_("unload of library"));
+ msg = _("unload of library");
}
uiout->field_string ("what", msg);
- xfree (msg);
if (uiout->is_mi_like_p ())
uiout->field_string ("catch-type", self->is_load ? "load" : "unload");