From: Alan Modra Date: Sat, 15 May 2021 05:39:20 +0000 (+0930) Subject: display_debug_macro X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0d461ec373e35fd380a060e6027d781f8a3f752;p=binutils-gdb.git display_debug_macro * dwarf.c (display_debug_macro): Print strings that might not be zero terminated with %*s. Don't bump curr if unterminated. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index ecf389af9fd..1926afbdcf7 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2021-05-15 Alan Modra + + * dwarf.c (display_debug_macro): Print strings that might not + be zero terminated with %*s. Don't bump curr if unterminated. + 2021-05-15 Alan Modra * dwarf.c (get_line_filename_and_dirname): Delete initial_length_size. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 9d782912208..68732cf491b 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -6042,17 +6042,21 @@ display_debug_macro (struct dwarf_section *section, case DW_MACRO_define: READ_ULEB (lineno, curr, end); string = curr; - curr += strnlen ((char *) string, end - string) + 1; - printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"), - lineno, string); + curr += strnlen ((char *) string, end - string); + printf (_(" DW_MACRO_define - lineno : %d macro : %*s\n"), + lineno, (int) (curr - string), string); + if (curr < end) + curr++; break; case DW_MACRO_undef: READ_ULEB (lineno, curr, end); string = curr; - curr += strnlen ((char *) string, end - string) + 1; - printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"), - lineno, string); + curr += strnlen ((char *) string, end - string); + printf (_(" DW_MACRO_undef - lineno : %d macro : %*s\n"), + lineno, (int) (curr - string), string); + if (curr < end) + curr++; break; case DW_MACRO_start_file: