aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/version.h2
-rw-r--r--gdb/NEWS13
-rw-r--r--gdb/aarch64-linux-tdep.c4
-rw-r--r--gdb/aarch64-tdep.c2
-rw-r--r--gdb/breakpoint.c2
-rw-r--r--gdb/bsd-uthread.c2
-rw-r--r--gdb/cli/cli-style.c110
-rw-r--r--gdb/cli/cli-style.h14
-rw-r--r--gdb/doc/gdb.texinfo24
-rw-r--r--gdb/dwarf2/read.c15
-rw-r--r--gdb/exceptions.c3
-rw-r--r--gdb/main.c2
-rw-r--r--gdb/main.h3
-rw-r--r--gdb/mingw-hdep.c42
-rw-r--r--gdb/ravenscar-thread.c2
-rw-r--r--gdb/remote.c24
-rw-r--r--gdb/solib-svr4.c6
-rw-r--r--gdb/testsuite/gdb.ada/array_subscript_addr/p.adb5
-rw-r--r--gdb/testsuite/gdb.ada/bp_inlined_func.exp4
-rw-r--r--gdb/testsuite/gdb.ada/null_overload/foo.adb4
-rw-r--r--gdb/testsuite/gdb.ada/null_overload/pck.adb23
-rw-r--r--gdb/testsuite/gdb.ada/null_overload/pck.ads22
-rw-r--r--gdb/testsuite/gdb.ada/type-tick-size/prog.adb2
-rw-r--r--gdb/testsuite/gdb.base/style.exp12
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp35
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw-form-strx.exp23
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl60
-rw-r--r--gdb/testsuite/gdb.reverse/time-reverse.exp43
-rw-r--r--gdb/testsuite/gdb.threads/inf-thr-count.exp55
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout-asm.exp106
-rw-r--r--gdb/testsuite/lib/dwarf.exp42
-rw-r--r--gdb/tracefile-tfile.c12
-rw-r--r--gdb/tracepoint.c2
-rw-r--r--gdb/utils.c1
-rw-r--r--gdbserver/server.cc2
-rw-r--r--gdbserver/target.cc2
-rw-r--r--gdbserver/tracepoint.cc6
-rw-r--r--gdbserver/utils.cc2
-rw-r--r--gdbsupport/print-utils.cc16
-rw-r--r--gdbsupport/print-utils.h30
-rw-r--r--readline/readline/tcap.h12
41 files changed, 646 insertions, 145 deletions
diff --git a/bfd/version.h b/bfd/version.h
index c5aa1ab..569a931 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -16,7 +16,7 @@
In releases, the date is not included in either version strings or
sonames. */
-#define BFD_VERSION_DATE 20250502
+#define BFD_VERSION_DATE 20250503
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
#define REPORT_BUGS_TO @report_bugs_to@
diff --git a/gdb/NEWS b/gdb/NEWS
index 077d28a..a82b7e3 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -65,6 +65,19 @@ show riscv numeric-register-names
(e.g 'x1') or their abi names (e.g. 'ra').
Defaults to 'off', matching the old behaviour (abi names).
+set style emoji on|off|auto
+show style emoji
+ Controls whether GDB can display emoji. The default is "auto",
+ which means emoji will be displayed in some situations when
+ the host charset is UTF-8.
+
+set style warning-prefix STRING
+set style error-prefix STRING
+ These commands control the prefix that is printed before warnings
+ and errors, respectively. This functionality is intended for use
+ with emoji display, and so the prefixes are only displayed if emoji
+ styling is enabled.
+
info linker-namespaces
info linker-namespaces [[N]]
Print information about the given linker namespace (identified as N),
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index b6cdcf0..a194ac8 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -2599,8 +2599,8 @@ aarch64_linux_fill_memtag_section (struct gdbarch *gdbarch, asection *osec)
static_cast<int> (memtag_type::allocation)))
{
warning (_("Failed to read MTE tags from memory range [%s,%s)."),
- phex_nz (start_address, sizeof (start_address)),
- phex_nz (end_address, sizeof (end_address)));
+ phex_nz (start_address),
+ phex_nz (end_address));
return false;
}
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index bf5b5d3..8d54e59 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -4236,7 +4236,7 @@ aarch64_memtag_to_string (struct gdbarch *gdbarch, struct value *tag_value)
CORE_ADDR tag = value_as_address (tag_value);
- return string_printf ("0x%s", phex_nz (tag, sizeof (tag)));
+ return string_printf ("0x%s", phex_nz (tag));
}
/* See aarch64-tdep.h. */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 23e5051..f44ac45 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10289,7 +10289,7 @@ masked_watchpoint::print_recreate (struct ui_file *fp) const
}
gdb_printf (fp, " %s mask 0x%s", exp_string.get (),
- phex (hw_wp_mask, sizeof (CORE_ADDR)));
+ phex (hw_wp_mask));
print_recreate_thread (fp);
}
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 51dafed..341aea9 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -536,7 +536,7 @@ bsd_uthread_target::pid_to_str (ptid_t ptid)
if (ptid.tid () != 0)
return string_printf ("process %d, thread 0x%s",
ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
return normal_pid_to_str (ptid);
}
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 30c7afb..34592f0 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -23,6 +23,7 @@
#include "cli/cli-style.h"
#include "source-cache.h"
#include "observable.h"
+#include "charset.h"
/* True if styling is enabled. */
@@ -42,6 +43,10 @@ bool source_styling = true;
bool disassembler_styling = true;
+/* User-settable variable controlling emoji output. */
+
+static auto_boolean emoji_styling = AUTO_BOOLEAN_AUTO;
+
/* Names of intensities; must correspond to
ui_file_style::intensity. */
static const char * const cli_intensities[] = {
@@ -410,6 +415,85 @@ show_style_disassembler (struct ui_file *file, int from_tty,
gdb_printf (file, _("Disassembler output styling is disabled.\n"));
}
+/* Implement 'show style emoji'. */
+
+static void
+show_emoji_styling (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ if (emoji_styling == AUTO_BOOLEAN_TRUE)
+ gdb_printf (file, _("CLI emoji styling is enabled.\n"));
+ else if (emoji_styling == AUTO_BOOLEAN_FALSE)
+ gdb_printf (file, _("CLI emoji styling is disabled.\n"));
+ else
+ gdb_printf (file, _("CLI emoji styling is automatic (currently %s).\n"),
+ emojis_ok () ? _("enabled") : _("disabled"));
+}
+
+/* See cli-style.h. */
+
+bool
+emojis_ok ()
+{
+ if (!cli_styling || emoji_styling == AUTO_BOOLEAN_FALSE)
+ return false;
+ if (emoji_styling == AUTO_BOOLEAN_TRUE)
+ return true;
+ return strcmp (host_charset (), "UTF-8") == 0;
+}
+
+/* See cli-style.h. */
+
+void
+no_emojis ()
+{
+ emoji_styling = AUTO_BOOLEAN_FALSE;
+}
+
+/* Emoji warning prefix. */
+static std::string warning_prefix = "⚠️ ";
+
+/* Implement 'show warning-prefix'. */
+
+static void
+show_warning_prefix (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ gdb_printf (file, _("Warning prefix is \"%s\".\n"),
+ warning_prefix.c_str ());
+}
+
+/* See cli-style.h. */
+
+void
+print_warning_prefix (ui_file *file)
+{
+ if (emojis_ok ())
+ gdb_puts (warning_prefix.c_str (), file);
+}
+
+/* Emoji error prefix. */
+static std::string error_prefix = "❌️ ";
+
+/* Implement 'show error-prefix'. */
+
+static void
+show_error_prefix (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ gdb_printf (file, _("Error prefix is \"%s\".\n"),
+ error_prefix.c_str ());
+}
+
+/* See cli-style.h. */
+
+void
+print_error_prefix (ui_file *file)
+{
+ if (emojis_ok ())
+ gdb_puts (error_prefix.c_str (), file);
+}
+
void _initialize_cli_style ();
void
_initialize_cli_style ()
@@ -431,6 +515,13 @@ If enabled, output to the terminal is styled."),
set_style_enabled, show_style_enabled,
&style_set_list, &style_show_list);
+ add_setshow_auto_boolean_cmd ("emoji", no_class, &emoji_styling, _("\
+Set whether emoji output is enabled."), _("\
+Show whether emoji output is enabled."), _("\
+If enabled, emojis may be displayed."),
+ nullptr, show_emoji_styling,
+ &style_set_list, &style_show_list);
+
add_setshow_boolean_cmd ("sources", no_class, &source_styling, _("\
Set whether source code styling is enabled."), _("\
Show whether source code styling is enabled."), _("\
@@ -627,4 +718,23 @@ coming from your source code."),
&style_disasm_set_list);
add_alias_cmd ("symbol", function_prefix_cmds.show, no_class, 0,
&style_disasm_show_list);
+
+ add_setshow_string_cmd ("warning-prefix", no_class,
+ &warning_prefix,
+ _("Set the warning prefix text."),
+ _("Show the warning prefix text."),
+ _("\
+The warning prefix text is displayed before any warning, when\n\
+emoji output is enabled."),
+ nullptr, show_warning_prefix,
+ &style_set_list, &style_show_list);
+ add_setshow_string_cmd ("error-prefix", no_class,
+ &error_prefix,
+ _("Set the error prefix text."),
+ _("Show the error prefix text."),
+ _("\
+The error prefix text is displayed before any error, when\n\
+emoji output is enabled."),
+ nullptr, show_error_prefix,
+ &style_set_list, &style_show_list);
}
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 77f4ac2..b1a950a 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -190,4 +190,18 @@ private:
bool m_old_value;
};
+/* Return true if emoji styling is allowed. */
+extern bool emojis_ok ();
+
+/* Disable emoji styling. This is here so that Windows can disable
+ emoji when the console is in use. It shouldn't be called
+ elsewhere. */
+extern void no_emojis ();
+
+/* Print the warning prefix, if desired. */
+extern void print_warning_prefix (ui_file *file);
+
+/* Print the error prefix, if desired. */
+extern void print_error_prefix (ui_file *file);
+
#endif /* GDB_CLI_CLI_STYLE_H */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9b4aa5b..b9fc160 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27974,6 +27974,19 @@ value, then @value{GDBN} will change this to @samp{off} at startup.
@item show style enabled
Show the current state of styling.
+@item set style emoji @samp{auto|on|off}
+Enable or disable the use of emoji. On most hosts, the default is
+@samp{auto}, meaning that emoji will only be used if the host
+character set is @samp{UTF-8}; however, on Windows the default is
+@samp{off} when using the console. Note that disabling styling as a
+whole will also prevent emoji display.
+
+Currently, emoji are printed whenever @value{GDBN} reports an error or
+a warning.
+
+@item show style emoji
+Show the current state of emoji output.
+
@item set style sources @samp{on|off}
Enable or disable source code styling. This affects whether source
code, such as the output of the @code{list} command, is styled. The
@@ -27987,6 +28000,17 @@ is used. Otherwise, if @value{GDBN} was configured with Python
scripting support, and if the Python Pygments package is available,
then it will be used.
+@item set style warning-prefix
+@itemx show style warning-prefix
+@itemx set style error-prefix
+@itemx show style error-prefix
+
+These commands control the prefix that is printed before warnings and
+errors, respectively. This functionality is intended for use with
+emoji display, and so the prefixes are only displayed if emoji styling
+is enabled. The defaults are the warning sign emoji for warnings, and
+and the cross mark emoji for errors.
+
@item show style sources
Show the current state of source code styling.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0eb248f..6848f63 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1322,7 +1322,7 @@ dwarf2_per_bfd::locate_sections (asection *sectp,
bfd_size_type size = sectp->size;
warning (_("Discarding section %s which has an invalid size (%s) "
"[in module %s]"),
- bfd_section_name (sectp), phex_nz (size, sizeof (size)),
+ bfd_section_name (sectp), phex_nz (size),
this->filename ());
}
else if (names.info.matches (sectp->name))
@@ -15333,9 +15333,16 @@ read_str_index (struct dwarf2_cu *cu,
" in CU at offset %s [in module %s]"),
form_name, str_section->get_name (),
sect_offset_str (cu->header.sect_off), objf_name);
- info_ptr = (str_offsets_section->buffer
- + str_offsets_base
- + str_index * offset_size);
+
+ ULONGEST str_offsets_offset = str_offsets_base + str_index * offset_size;
+ if (str_offsets_offset >= str_offsets_section->size)
+ error (_(DWARF_ERROR_PREFIX
+ "Offset from %s pointing outside of %s section in CU at offset %s"
+ " [in module %s]"),
+ form_name, str_offsets_section->get_name (),
+ sect_offset_str (cu->header.sect_off), objf_name);
+ info_ptr = str_offsets_section->buffer + str_offsets_offset;
+
if (offset_size == 4)
str_offset = bfd_get_32 (abfd, info_ptr);
else
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 6af3a7e..35400f3 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -25,6 +25,7 @@
#include "serial.h"
#include "ui.h"
#include <optional>
+#include "cli/cli-style.h"
static void
print_flush (void)
@@ -105,6 +106,7 @@ exception_print (struct ui_file *file, const struct gdb_exception &e)
if (e.reason < 0 && e.message != NULL)
{
print_flush ();
+ print_error_prefix (file);
print_exception (file, e);
}
}
@@ -118,6 +120,7 @@ exception_fprintf (struct ui_file *file, const struct gdb_exception &e,
va_list args;
print_flush ();
+ print_error_prefix (file);
/* Print the prefix. */
va_start (args, prefix);
diff --git a/gdb/main.c b/gdb/main.c
index 9220092..2dcb67d 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -672,6 +672,8 @@ captured_main_1 (struct captured_main_args *context)
/* Ensure stderr is unbuffered. A Cygwin pty or pipe is implemented
as a Windows pipe, and Windows buffers on pipes. */
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+
+ windows_initialize_console ();
#endif
/* Note: `error' cannot be called before this point, because the
diff --git a/gdb/main.h b/gdb/main.h
index 4830b59..0f50b71 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -44,6 +44,9 @@ extern std::string interpreter_p;
return value is in malloc'ed storage. */
extern char *windows_get_absolute_argv0 (const char *argv0);
+/* Initialize Windows console settings. */
+extern void windows_initialize_console ();
+
extern void set_gdb_data_directory (const char *new_data_dir);
#endif /* GDB_MAIN_H */
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index dc7ca42..84a7b9f 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -22,6 +22,7 @@
#include "gdbsupport/event-loop.h"
#include "gdbsupport/gdb_select.h"
#include "inferior.h"
+#include "cli/cli-style.h"
#include <windows.h>
#include <signal.h>
@@ -212,7 +213,30 @@ static int mingw_console_initialized;
static HANDLE hstdout = INVALID_HANDLE_VALUE;
/* Text attribute to use for normal text (the "none" pseudo-color). */
-static SHORT norm_attr;
+static SHORT norm_attr;
+
+/* Initialize settings related to the console. */
+
+void
+windows_initialize_console ()
+{
+ hstdout = (HANDLE)_get_osfhandle (fileno (stdout));
+ DWORD cmode;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ if (hstdout != INVALID_HANDLE_VALUE
+ && GetConsoleMode (hstdout, &cmode) != 0
+ && GetConsoleScreenBufferInfo (hstdout, &csbi))
+ {
+ norm_attr = csbi.wAttributes;
+ mingw_console_initialized = 1;
+ }
+ else if (hstdout != INVALID_HANDLE_VALUE)
+ mingw_console_initialized = -1; /* valid, but not a console device */
+
+ if (mingw_console_initialized > 0)
+ no_emojis ();
+}
/* The most recently applied style. */
static ui_file_style last_style;
@@ -223,22 +247,6 @@ static ui_file_style last_style;
int
gdb_console_fputs (const char *linebuf, FILE *fstream)
{
- if (!mingw_console_initialized)
- {
- hstdout = (HANDLE)_get_osfhandle (fileno (fstream));
- DWORD cmode;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- if (hstdout != INVALID_HANDLE_VALUE
- && GetConsoleMode (hstdout, &cmode) != 0
- && GetConsoleScreenBufferInfo (hstdout, &csbi))
- {
- norm_attr = csbi.wAttributes;
- mingw_console_initialized = 1;
- }
- else if (hstdout != INVALID_HANDLE_VALUE)
- mingw_console_initialized = -1; /* valid, but not a console device */
- }
/* If our stdout is not a console device, let the default 'fputs'
handle the task. */
if (mingw_console_initialized <= 0)
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 13258c4..45205a0 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -503,7 +503,7 @@ ravenscar_thread_target::pid_to_str (ptid_t ptid)
return beneath ()->pid_to_str (ptid);
return string_printf ("Ravenscar Thread 0x%s",
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
}
CORE_ADDR
diff --git a/gdb/remote.c b/gdb/remote.c
index 73dc426..1c49cdf 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11650,7 +11650,7 @@ remote_target::remote_write_qxfer (const char *object_name,
i = snprintf (rs->buf.data (), max_size,
"qXfer:%s:write:%s:%s:",
object_name, annex ? annex : "",
- phex_nz (offset, sizeof offset));
+ phex_nz (offset));
max_size -= (i + 1);
/* Escape as much data as fits into rs->buf. */
@@ -11715,8 +11715,8 @@ remote_target::remote_read_qxfer (const char *object_name,
snprintf (rs->buf.data (), get_remote_packet_size () - 4,
"qXfer:%s:read:%s:%s,%s",
object_name, annex ? annex : "",
- phex_nz (offset, sizeof offset),
- phex_nz (n, sizeof n));
+ phex_nz (offset),
+ phex_nz (n));
i = putpkt (rs->buf);
if (i < 0)
return TARGET_XFER_E_IO;
@@ -12014,7 +12014,7 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
i = snprintf (rs->buf.data (), max_size,
"qSearch:memory:%s;%s;",
phex_nz (start_addr, addr_size),
- phex_nz (search_space_len, sizeof (search_space_len)));
+ phex_nz (search_space_len));
max_size -= (i + 1);
/* Escape as much data as fits into rs->buf. */
@@ -13763,7 +13763,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
tpaddr = loc->address;
- strcpy (addrbuf, phex (tpaddr, sizeof (CORE_ADDR)));
+ strcpy (addrbuf, phex (tpaddr));
ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x",
b->number, addrbuf, /* address */
(b->enable_state == bp_enabled ? 'E' : 'D'),
@@ -14027,7 +14027,7 @@ remote_target::enable_tracepoint (struct bp_location *location)
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTEnable:%x:%s",
location->owner->number,
- phex (location->address, sizeof (CORE_ADDR)));
+ phex (location->address));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
@@ -14043,7 +14043,7 @@ remote_target::disable_tracepoint (struct bp_location *location)
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTDisable:%x:%s",
location->owner->number,
- phex (location->address, sizeof (CORE_ADDR)));
+ phex (location->address));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
@@ -15569,7 +15569,7 @@ remote_target::commit_requested_thread_options ()
*obuf_p++ = ';';
obuf_p += xsnprintf (obuf_p, obuf_endp - obuf_p, "%s",
- phex_nz (options, sizeof (options)));
+ phex_nz (options));
if (tp->ptid != magic_null_ptid)
{
*obuf_p++ = ':';
@@ -15808,8 +15808,8 @@ create_fetch_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
std::string request = string_printf ("qMemTags:%s,%s:%s",
phex_nz (address, addr_size),
- phex_nz (len, sizeof (len)),
- phex_nz (type, sizeof (type)));
+ phex_nz (len),
+ phex_nz (type));
strcpy (packet.data (), request.c_str ());
}
@@ -15843,8 +15843,8 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address,
/* Put together the main packet, address and length. */
std::string request = string_printf ("QMemTags:%s,%s:%s:",
phex_nz (address, addr_size),
- phex_nz (len, sizeof (len)),
- phex_nz (type, sizeof (type)));
+ phex_nz (len),
+ phex_nz (type));
request += bin2hex (tags.data (), tags.size ());
/* Check if we have exceeded the maximum packet size. */
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 458c4ba..9f56d86 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2058,9 +2058,9 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base,
/* Unknown key=value pairs are ignored by the gdbstub. */
xsnprintf (annex, sizeof (annex), "lmid=%s;start=%s;prev=%s",
- phex_nz (debug_base, sizeof (debug_base)),
- phex_nz (lm, sizeof (lm)),
- phex_nz (prev_lm, sizeof (prev_lm)));
+ phex_nz (debug_base),
+ phex_nz (lm),
+ phex_nz (prev_lm));
if (!svr4_current_sos_via_xfer_libraries (&library_list, annex))
return 0;
diff --git a/gdb/testsuite/gdb.ada/array_subscript_addr/p.adb b/gdb/testsuite/gdb.ada/array_subscript_addr/p.adb
index eaa35c5..057d7a0 100644
--- a/gdb/testsuite/gdb.ada/array_subscript_addr/p.adb
+++ b/gdb/testsuite/gdb.ada/array_subscript_addr/p.adb
@@ -14,11 +14,12 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
procedure P is
- type Table is array (1 .. 3) of Integer;
+ -- Make this large enough to force it into memory with gnat-llvm.
+ type Table is array (1 .. 15) of Integer;
function Create (I : Integer) return Table is
begin
- return (4 + I, 8 * I, 7 * I + 4);
+ return (4 + I, 8 * I, 7 * I + 4, others => 72);
end Create;
A : Table := Create (7);
diff --git a/gdb/testsuite/gdb.ada/bp_inlined_func.exp b/gdb/testsuite/gdb.ada/bp_inlined_func.exp
index 6593d1e..04cf755 100644
--- a/gdb/testsuite/gdb.ada/bp_inlined_func.exp
+++ b/gdb/testsuite/gdb.ada/bp_inlined_func.exp
@@ -41,8 +41,10 @@ gdb_test "break read_small" \
for {set i 0} {$i < 4} {incr i} {
with_test_prefix "iteration $i" {
+ # gnat-llvm may emit a call to an out-of-line copy, so allow
+ # for this here.
gdb_test "continue" \
- "Breakpoint $bkptno_num_re, b\\.read_small \\(\\).*" \
+ "Breakpoint $bkptno_num_re, ($hex in )?b\\.read_small \\(\\).*" \
"stopped in read_small"
}
}
diff --git a/gdb/testsuite/gdb.ada/null_overload/foo.adb b/gdb/testsuite/gdb.ada/null_overload/foo.adb
index 002238f..55d3fd6 100644
--- a/gdb/testsuite/gdb.ada/null_overload/foo.adb
+++ b/gdb/testsuite/gdb.ada/null_overload/foo.adb
@@ -13,6 +13,8 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+with pck; use pck;
+
procedure Foo is
type R_Type is null record;
@@ -38,5 +40,5 @@ procedure Foo is
U_Ptr : U_P_T := null;
begin
- null; -- START
+ Do_Nothing (U_Ptr'Address); -- START
end Foo;
diff --git a/gdb/testsuite/gdb.ada/null_overload/pck.adb b/gdb/testsuite/gdb.ada/null_overload/pck.adb
new file mode 100644
index 0000000..95bd90a
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/null_overload/pck.adb
@@ -0,0 +1,23 @@
+-- Copyright 2020-2025 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package body Pck is
+
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/null_overload/pck.ads b/gdb/testsuite/gdb.ada/null_overload/pck.ads
new file mode 100644
index 0000000..114aee0
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/null_overload/pck.ads
@@ -0,0 +1,22 @@
+-- Copyright 2020-2025 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with System;
+
+package Pck is
+
+ procedure Do_Nothing (A : System.Address);
+
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/type-tick-size/prog.adb b/gdb/testsuite/gdb.ada/type-tick-size/prog.adb
index 34a9fca..a7457fd 100644
--- a/gdb/testsuite/gdb.ada/type-tick-size/prog.adb
+++ b/gdb/testsuite/gdb.ada/type-tick-size/prog.adb
@@ -50,6 +50,8 @@ procedure Prog is
Rec_Type_Size : Integer := Rec'Object_Size;
begin
+ Do_Nothing (Simple_Val'Address);
+ Do_Nothing (Rec_Val'Address);
Do_Nothing (Static_Blob'Address);
Do_Nothing (Dynamic_Blob'Address);
null; -- STOP
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 59c93ee..c10be3b 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -329,6 +329,18 @@ proc run_style_tests { } {
"The \033\\\[38;2;254;210;16;48;5;255;22;27m.*\".*version.*\".*style.*\033\\\[m foreground color is: #FED210" \
"Version's TrueColor foreground style"
}
+
+ gdb_test_no_output "set host-charset UTF-8"
+ # Chosen since it will print an error.
+ gdb_test "maint translate-address" \
+ "❌️ requires argument.*" \
+ "emoji output"
+
+ gdb_test_no_output "set style error-prefix abcd:" \
+ "set the error prefix"
+ gdb_test "maint translate-address" \
+ "abcd:requires argument.*" \
+ "error prefix"
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp
new file mode 100644
index 0000000..f2123fa
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp
@@ -0,0 +1,35 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that an out-of-bounds DW_FORM_strx attribute triggers a DWARF error.
+
+# Out of bounds index.
+set int_str_idx 1
+
+source $srcdir/$subdir/dw-form-strx.exp.tcl
+
+set re_dwarf_error \
+ [string_list_to_regexp \
+ "DWARF Error: Offset from DW_FORM_GNU_str_index or DW_FORM_strx" \
+ " pointing outside of .debug_str_offsets section in CU at offset"\
+ " "]$hex
+set re_in_module \
+ {in module [^\r\n]+}
+set re_in_module [string_to_regexp {[}]$re_in_module[string_to_regexp {]}]
+set re_no_symbol [string_to_regexp {No symbol "global_var" in current context.}]
+gdb_test "ptype global_var" \
+ [multi_line \
+ "$re_dwarf_error $re_in_module"\
+ $re_no_symbol]
diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp
new file mode 100644
index 0000000..9b62edf
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp
@@ -0,0 +1,23 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that DW_FORM_strx works.
+
+# Correct index.
+set int_str_idx 0
+
+source $srcdir/$subdir/dw-form-strx.exp.tcl
+
+gdb_test "ptype global_var" "type = int"
diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl
new file mode 100644
index 0000000..15cfe27
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl
@@ -0,0 +1,60 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile main.c -dw.S
+
+set asm_file [standard_output_file $srcfile2]
+
+# Debug info in the main file.
+Dwarf::assemble $asm_file {
+ declare_labels base_offset
+
+ debug_str_offsets base_offset int
+
+ cu {
+ version 5
+ } {
+ DW_TAG_compile_unit {
+ {DW_AT_str_offsets_base $base_offset sec_offset}
+ } {
+ declare_labels int4_type
+
+ int4_type: DW_TAG_base_type {
+ {DW_AT_byte_size 4 DW_FORM_sdata}
+ {DW_AT_encoding @DW_ATE_signed}
+ {DW_AT_name $::int_str_idx DW_FORM_strx_id}
+ }
+
+ DW_TAG_variable {
+ {DW_AT_name global_var}
+ {DW_AT_type :$int4_type}
+ {DW_AT_location {
+ DW_OP_const1u 12
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ }
+ }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+}
diff --git a/gdb/testsuite/gdb.reverse/time-reverse.exp b/gdb/testsuite/gdb.reverse/time-reverse.exp
index fe191a0..58dcdde 100644
--- a/gdb/testsuite/gdb.reverse/time-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/time-reverse.exp
@@ -20,6 +20,7 @@
#
require supports_reverse
+require supports_process_record
standard_testfile
@@ -38,23 +39,49 @@ proc test {mode} {
return
}
- runto marker1
-
- if [supports_process_record] {
- # Activate process record/replay
- gdb_test_no_output "record" "turn on process record"
+ if { ![runto marker1] } {
+ return
}
+ # Activate process record/replay
+ gdb_test_no_output "record" "turn on process record"
+ gdb_test_no_output "set record full stop-at-limit on"
+ gdb_test_no_output "set record full insn-number-max 2000"
+
+ set re_srcfile [string_to_regexp $::srcfile]
+
gdb_test "break marker2" \
- "Breakpoint $::decimal at $::hex: file .*$::srcfile, line $::decimal.*" \
+ "Breakpoint $::decimal at $::hex: file .*$re_srcfile, line $::decimal.*" \
"set breakpoint at marker2"
- gdb_continue_to_breakpoint "marker2" ".*$::srcfile:.*"
+ set re_question \
+ [string_list_to_regexp \
+ "Do you want to auto delete previous execution log entries when" \
+ " record/replay buffer becomes full" \
+ { (record full stop-at-limit)?([y] or n)}]
+ set re_program_stopped \
+ [multi_line \
+ [string_to_regexp "Process record: stopped by user."] \
+ "" \
+ [string_to_regexp "Program stopped."]]
+ set re_marker2 [string_to_regexp "marker2 ()"]
+ gdb_test_multiple "continue" "continue to breakpoint: marker2" {
+ -re "$re_question " {
+ send_gdb "n\n"
+ exp_continue
+ }
+ -re -wrap "Breakpoint $::decimal, $re_marker2 .*" {
+ pass $gdb_test_name
+ }
+ -re -wrap "\r\n$re_program_stopped\r\n.*" {
+ unsupported $gdb_test_name
+ }
+ }
# Show how many instructions we've recorded.
gdb_test "info record" "Active record target: .*"
- gdb_test "reverse-continue" ".*$::srcfile:$::decimal.*" "reverse to marker1"
+ gdb_test "reverse-continue" ".*$re_srcfile:$::decimal.*" "reverse to marker1"
# If the variable was recorded properly, the old contents (-1)
# will be remembered. If not, new contents (current time) will be
diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.exp b/gdb/testsuite/gdb.threads/inf-thr-count.exp
index 9f52655..61533ab 100644
--- a/gdb/testsuite/gdb.threads/inf-thr-count.exp
+++ b/gdb/testsuite/gdb.threads/inf-thr-count.exp
@@ -43,7 +43,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
# Start GDB. Ensure we are in non-stop mode as we need to read from
# the inferior while it is running.
save_vars {GDBFLAGS} {
- append GDBFLAGS " -ex \"set non-stop on\""
+ append GDBFLAGS { -ex "set non-stop on"}
clean_restart $binfile
}
@@ -54,22 +54,20 @@ if ![runto_main] {
gdb_breakpoint breakpt
gdb_continue_to_breakpoint "first breakpt call"
+set re_var [string_to_regexp "$"]$decimal
+
# Check we can see a single thread to begin with.
-gdb_test "p \$_inferior_thread_count" \
- "^\\\$$::decimal = 1" \
- "only one thread in \$_inferior_thread_count"
+gdb_test {p $_inferior_thread_count} \
+ "^$re_var = 1" \
+ {only one thread in $_inferior_thread_count}
# We don't want thread events, it makes it harder to match GDB's
# output.
gdb_test_no_output "set print thread-events off"
# Continue the program in the background.
-set test "continue&"
-gdb_test_multiple "continue&" $test {
- -re "Continuing\\.\r\n$gdb_prompt " {
- pass $test
- }
-}
+gdb_test -no-prompt-anchor "continue&" \
+ [string_to_regexp "Continuing."]
# Read the 'stage' flag from the inferior. This is initially 0, but
# will be set to 1 once the extra thread has been created, and then 2
@@ -88,8 +86,17 @@ proc wait_for_stage { num } {
set failure_count 0
set cmd "print /d stage"
set stage_flag 0
+
+ set re_int -?$::decimal
+
+ set re_msg \
+ [multi_line \
+ "Cannot execute this command while the target is running" \
+ {Use the "interrupt" command to stop the target} \
+ [string_to_regexp "and then try again."]]
+
gdb_test_multiple "$cmd" "wait for 'stage' flag to be $num" {
- -re -wrap "^Cannot execute this command while the target is running\\.\r\nUse the \"interrupt\" command to stop the target\r\nand then try again\\." {
+ -re -wrap ^$re_msg {
fail "$gdb_test_name (can't read asynchronously)"
gdb_test_no_output "interrupt"
@@ -101,7 +108,7 @@ proc wait_for_stage { num } {
}
}
- -re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
+ -re -wrap "^$::re_var = ($re_int).*" {
set stage_flag $expect_out(1,string)
if {$stage_flag != $num} {
set stage_flag 0
@@ -131,8 +138,8 @@ if {![wait_for_stage 1]} {
if {[target_info exists gdb_protocol]
&& ([target_info gdb_protocol] == "remote"
|| [target_info gdb_protocol] == "extended-remote")} {
- set new_thread_re "\\\[New Thread \[^\r\n\]+\\\]\r\n"
- set exit_thread_re "\\\[Thread \[^\r\n\]+ exited\\\]\r\n"
+ set new_thread_re {\[New Thread [^\r\n]+\]\r\n}
+ set exit_thread_re {\[Thread [^\r\n]+ exited\]\r\n}
} else {
set new_thread_re ""
set exit_thread_re ""
@@ -141,9 +148,9 @@ if {[target_info exists gdb_protocol]
# This is the test we actually care about. Check that the
# $_inferior_thread_count convenience variable shows the correct
# thread count; the new thread should be visible.
-gdb_test "with print thread-events on -- p \$_inferior_thread_count" \
- "^${new_thread_re}\\\$$::decimal = 2" \
- "second thread visible in \$_inferior_thread_count"
+gdb_test {with print thread-events on -- p $_inferior_thread_count} \
+ "^${new_thread_re}$re_var = 2" \
+ {second thread visible in $_inferior_thread_count}
# Set a variable in the inferior, this will cause the second thread to
# exit.
@@ -157,9 +164,9 @@ if {![wait_for_stage 2]} {
}
# Check that the second thread has gone away.
-gdb_test "with print thread-events on -- p \$_inferior_thread_count" \
- "^${exit_thread_re}\\\$$::decimal = 1" \
- "back to one thread visible in \$_inferior_thread_count"
+gdb_test {with print thread-events on -- p $_inferior_thread_count} \
+ "^${exit_thread_re}$re_var = 1" \
+ {back to one thread visible in $_inferior_thread_count}
# Set a variable in the inferior, this will cause the second thread to
# exit.
@@ -168,8 +175,14 @@ gdb_test_no_output -no-prompt-anchor "set variable spin = 0" \
# When the second thread exits, the main thread joins with it, and
# then proceeds to hit the breakpt function again.
+set re_breakpt [string_to_regexp "breakpt ()"]
+set re \
+ [multi_line \
+ "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, $re_breakpt\[^\r\n\]+" \
+ "\[^\r\n\]+" \
+ ""]
gdb_test_multiple "" "wait for main thread to stop" {
- -re "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, breakpt \\(\\)\[^\r\n\]+\r\n\[^\r\n\]+\r\n" {
+ -re $re {
pass $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm.exp b/gdb/testsuite/gdb.tui/tui-layout-asm.exp
index ec78a0c..333276e 100644
--- a/gdb/testsuite/gdb.tui/tui-layout-asm.exp
+++ b/gdb/testsuite/gdb.tui/tui-layout-asm.exp
@@ -24,7 +24,9 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
return -1
}
-# PPC currently needs a minimum window width of 90 to work correctly.
+# The wider the window is, the less line truncation happens, so matching
+# pre-scroll to post-scroll lines is more accurate. But 100% accurate line
+# matching isn't a goal of the test-case.
set tui_asm_window_width 90
Term::clean_restart 24 ${tui_asm_window_width} $testfile
@@ -33,15 +35,41 @@ if {![Term::prepare_for_tui]} {
return
}
-# Helper proc, returns a count of the ' ' characters in STRING.
-proc count_whitespace { string } {
- return [expr {[llength [split $string { }]] - 1}]
-}
-
# This puts us into TUI mode, and should display the ASM window.
Term::command_no_prompt_prefix "layout asm"
Term::check_box_contents "check asm box contents" 0 0 ${tui_asm_window_width} 15 "<main>"
+set re_border [string_to_regexp "|"]
+
+proc drop_borders { line } {
+ # Drop left border.
+ set line [regsub -- ^$::re_border $line {}]
+ # Drop right border.
+ set line [regsub -- $::re_border$ $line {}]
+
+ return $line
+}
+
+proc lines_match { line1 line2 } {
+ set line1 [drop_borders $line1]
+ set line2 [drop_borders $line2]
+
+ foreach line [list $line1 $line2] re [list $line2 $line1] {
+ # Convert to regexp.
+ set re [string_to_regexp $re]
+
+ # Ignore whitespace mismatches.
+ regsub -all {\s+} $re {\s+} re
+
+ # Allow a substring match.
+ if { [regexp -- $re $line] } {
+ return 1
+ }
+ }
+
+ return 0
+}
+
# Scroll the ASM window down using the down arrow key. In an ideal
# world we'd like to use PageDown here, but currently our terminal
# library doesn't support such advanced things.
@@ -58,51 +86,55 @@ while (1) {
# below will just timeout. So for now we avoid testing the edge
# case.
if {[regexp -- "^\\| +\\|$" $line]} {
- # Second line is blank, we're at the end of the assembler.
- pass $testname
+ # Second line is blank, we're at the end of the assembly.
+ pass "$testname (end of assembly reached)"
break
}
# Send the down key to GDB.
send_gdb "\033\[B"
incr down_count
- set re_line [string_to_regexp $line]
- # Ignore whitespace mismatches.
- regsub -all {\s+} $re_line {\s+} re_line
+
+ # Get address from the line.
+ regexp \
+ [join \
+ [list \
+ ^ \
+ $re_border \
+ {\s+} \
+ ($hex) \
+ {\s+}] \
+ ""] \
+ $line \
+ match \
+ address
+
+ # Regexp to match line containing address.
+ set re_line \
+ [join \
+ [list \
+ ^ \
+ $re_border \
+ {\s+} \
+ $address \
+ {\s+} \
+ {[^\r\n]+} \
+ $re_border \
+ $] \
+ ""]
+
if {[Term::wait_for $re_line] \
- && [regexp $re_line [Term::get_line 1]]} {
+ && [lines_match $line [Term::get_line 1]]} {
# We scrolled successfully.
} else {
- if {[count_whitespace ${line}] != \
- [count_whitespace [Term::get_line 1]]} {
- # GDB's TUI assembler display will widen columns based on
- # the longest item that appears in a column on any line.
- # As we have just scrolled, and so revealed a new line, it
- # is possible that the width of some columns has changed.
- #
- # As a result it is possible that part of the line we were
- # expected to see in the output is now off the screen. And
- # this test will fail.
- #
- # This is unfortunate, but, right now, there's no easy way
- # to "lock" the format of the TUI assembler window. The
- # only option appears to be making the window width wider,
- # this can be done by adjusting TUI_ASM_WINDOW_WIDTH.
- verbose -log "WARNING: The following failure is probably due to the TUI window"
- verbose -log " width. See the comments in the test script for more"
- verbose -log " details."
- }
-
fail "$testname (scroll failed)"
Term::dump_screen
break
}
- if { $down_count > 250 } {
- # Maybe we should accept this as a pass in case a target
- # really does have loads of assembler to scroll through.
- fail "$testname (too much assembler)"
- Term::dump_screen
+ if { $down_count > 25 } {
+ # We've scrolled enough, we're done.
+ pass "$testname (scroll limit reached)"
break
}
}
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 7e8778a..b347437 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -678,6 +678,11 @@ namespace eval Dwarf {
}
}
close $fd
+
+ variable _constants
+
+ # Add DW_FORM_strx_id as alias of DW_FORM_strx.
+ _process_one_constant DW_FORM_strx_id $_constants(DW_FORM_strx)
}
proc _quote {string} {
@@ -823,6 +828,12 @@ namespace eval Dwarf {
DW_FORM_indirect -
DW_FORM_exprloc -
+ # Generate a DW_FORM_str index, but assume generation of .debug_str and
+ # .debug_str_offsets is taken care of elsewhere.
+ DW_FORM_strx_id {
+ _op .uleb128 $value
+ }
+
DW_FORM_strx -
DW_FORM_strx1 -
DW_FORM_strx2 -
@@ -3385,6 +3396,37 @@ namespace eval Dwarf {
debug_names_end:
}
+ # Add the strings in ARGS to the .debug_str section, and create a
+ # .debug_str_offsets section pointing to those strings.
+ # BASE_OFFSET is the label for DW_AT_str_offsets_base.
+ proc debug_str_offsets { base_offset args } {
+ _section .debug_str
+ set num 0
+ foreach arg $args {
+ set str_label [_compute_label "str_${num}"]
+ define_label $str_label
+ _op .asciz \"$arg\" ".debug_str_offsets string $num"
+ incr num
+ }
+
+ declare_labels debug_str_offsets_start debug_str_offsets_end
+ set initial_length "$debug_str_offsets_end - $debug_str_offsets_start"
+
+ _section .debug_str_offsets
+ _op .4byte $initial_length "Initial_length"
+ debug_str_offsets_start:
+ _op .2byte 0x5 "version"
+ _op .2byte 0x0 "padding"
+ $base_offset:
+ set num 0
+ foreach arg $args {
+ set str_label [_compute_label "str_${num}"]
+ _op .4byte $str_label "string $num"
+ incr num
+ }
+ debug_str_offsets_end:
+ }
+
# The top-level interface to the DWARF assembler.
# OPTIONS is a list with an even number of elements containing
# option-name and option-value pairs.
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index c2b5e3b..5f8b338 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -194,12 +194,12 @@ tfile_write_status (struct trace_file_writer *self,
if (ts->start_time)
{
fprintf (writer->fp, ";starttime:%s",
- phex_nz (ts->start_time, sizeof (ts->start_time)));
+ phex_nz (ts->start_time));
}
if (ts->stop_time)
{
fprintf (writer->fp, ";stoptime:%s",
- phex_nz (ts->stop_time, sizeof (ts->stop_time)));
+ phex_nz (ts->stop_time));
}
if (ts->notes != NULL)
{
@@ -254,7 +254,7 @@ tfile_write_uploaded_tp (struct trace_file_writer *self,
char buf[MAX_TRACE_UPLOAD];
fprintf (writer->fp, "tp T%x:%s:%c:%x:%x",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
+ utp->number, phex_nz (utp->addr),
(utp->enabled ? 'E' : 'D'), utp->step, utp->pass);
if (utp->type == bp_fast_tracepoint)
fprintf (writer->fp, ":F%x", utp->orig_size);
@@ -265,10 +265,10 @@ tfile_write_uploaded_tp (struct trace_file_writer *self,
fprintf (writer->fp, "\n");
for (const auto &act : utp->actions)
fprintf (writer->fp, "tp A%x:%s:%s\n",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)), act.get ());
+ utp->number, phex_nz (utp->addr), act.get ());
for (const auto &act : utp->step_actions)
fprintf (writer->fp, "tp S%x:%s:%s\n",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)), act.get ());
+ utp->number, phex_nz (utp->addr), act.get ());
if (utp->at_string)
{
encode_source_string (utp->number, utp->addr,
@@ -290,7 +290,7 @@ tfile_write_uploaded_tp (struct trace_file_writer *self,
fprintf (writer->fp, "tp Z%s\n", buf);
}
fprintf (writer->fp, "tp V%x:%s:%x:%s\n",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
+ utp->number, phex_nz (utp->addr),
utp->hit_count,
phex_nz (utp->traceframe_usage,
sizeof (utp->traceframe_usage)));
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index a2f1a75..b431468 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2818,7 +2818,7 @@ encode_source_string (int tpnum, ULONGEST addr,
if (80 + strlen (srctype) > buf_size)
error (_("Buffer too small for source encoding"));
sprintf (buf, "%x:%s:%s:%x:%x:",
- tpnum, phex_nz (addr, sizeof (addr)),
+ tpnum, phex_nz (addr),
srctype, 0, (int) strlen (src));
if (strlen (buf) + strlen (src) * 2 >= buf_size)
error (_("Source string too long for buffer"));
diff --git a/gdb/utils.c b/gdb/utils.c
index ce3c26e..6cdc3f4 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -177,6 +177,7 @@ vwarning (const char *string, va_list args)
target_terminal::ours_for_output ();
}
gdb_puts (warning_pre_print, gdb_stderr);
+ print_warning_prefix (gdb_stderr);
gdb_puts (_("warning: "), gdb_stderr);
gdb_vprintf (gdb_stderr, string, args);
gdb_printf (gdb_stderr, "\n");
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 4b1f4b2..ab69400 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2864,7 +2864,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
{
char *end_buf = own_buf + strlen (own_buf);
sprintf (end_buf, ";QThreadOptions=%s",
- phex_nz (supported_options, sizeof (supported_options)));
+ phex_nz (supported_options));
}
strcat (own_buf, ";QThreadEvents+");
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 4838b39..e812785 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -258,7 +258,7 @@ target_pid_to_str (ptid_t ptid)
else if (ptid.tid () != 0)
return string_printf("Thread %d.0x%s",
ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
else if (ptid.lwp () != 0)
return string_printf("LWP %d.%ld",
ptid.pid (), ptid.lwp ());
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 715cc63..b308c82 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -3461,8 +3461,8 @@ cmd_qtstatus (char *packet)
free_space (), phex_nz (trace_buffer_hi - trace_buffer_lo, 0),
circular_trace_buffer,
disconnected_tracing,
- phex_nz (tracing_start_time, sizeof (tracing_start_time)),
- phex_nz (tracing_stop_time, sizeof (tracing_stop_time)),
+ phex_nz (tracing_start_time),
+ phex_nz (tracing_stop_time),
buf1, buf2);
}
@@ -4990,7 +4990,7 @@ build_traceframe_info_xml (char blocktype, unsigned char *dataptr, void *data)
dataptr += sizeof (mlen);
string_xml_appendf (*buffer,
"<memory start=\"0x%s\" length=\"0x%s\"/>\n",
- paddress (maddr), phex_nz (mlen, sizeof (mlen)));
+ paddress (maddr), phex_nz (mlen));
break;
}
case 'V':
diff --git a/gdbserver/utils.cc b/gdbserver/utils.cc
index 092fe47..a86405e 100644
--- a/gdbserver/utils.cc
+++ b/gdbserver/utils.cc
@@ -102,5 +102,5 @@ internal_vwarning (const char *file, int line, const char *fmt, va_list args)
const char *
paddress (CORE_ADDR addr)
{
- return phex_nz (addr, sizeof (CORE_ADDR));
+ return phex_nz (addr);
}
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc
index 84a7485..a798713 100644
--- a/gdbsupport/print-utils.cc
+++ b/gdbsupport/print-utils.cc
@@ -145,7 +145,7 @@ static int thirty_two = 32;
/* See print-utils.h. */
const char *
-phex (ULONGEST l, int sizeof_l)
+phex_ulongest (ULONGEST l, int sizeof_l)
{
char *str;
@@ -170,7 +170,7 @@ phex (ULONGEST l, int sizeof_l)
xsnprintf (str, PRINT_CELL_SIZE, "%02x", (unsigned short) (l & 0xff));
break;
default:
- return phex (l, sizeof (l));
+ return phex (l);
break;
}
@@ -180,7 +180,7 @@ phex (ULONGEST l, int sizeof_l)
/* See print-utils.h. */
const char *
-phex_nz (ULONGEST l, int sizeof_l)
+phex_nz_ulongest (ULONGEST l, int sizeof_l)
{
char *str;
@@ -212,7 +212,7 @@ phex_nz (ULONGEST l, int sizeof_l)
xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xff));
break;
default:
- return phex_nz (l, sizeof (l));
+ return phex_nz (l);
break;
}
@@ -226,7 +226,7 @@ hex_string (LONGEST num)
{
char *result = get_print_cell ();
- xsnprintf (result, PRINT_CELL_SIZE, "0x%s", phex_nz (num, sizeof (num)));
+ xsnprintf (result, PRINT_CELL_SIZE, "0x%s", phex_nz (num));
return result;
}
@@ -237,7 +237,7 @@ hex_string_custom (LONGEST num, int width)
{
char *result = get_print_cell ();
char *result_end = result + PRINT_CELL_SIZE - 1;
- const char *hex = phex_nz (num, sizeof (num));
+ const char *hex = phex_nz (num);
int hex_len = strlen (hex);
if (hex_len > width)
@@ -305,7 +305,7 @@ core_addr_to_string (const CORE_ADDR addr)
char *str = get_print_cell ();
strcpy (str, "0x");
- strcat (str, phex (addr, sizeof (addr)));
+ strcat (str, phex (addr));
return str;
}
@@ -317,7 +317,7 @@ core_addr_to_string_nz (const CORE_ADDR addr)
char *str = get_print_cell ();
strcpy (str, "0x");
- strcat (str, phex_nz (addr, sizeof (addr)));
+ strcat (str, phex_nz (addr));
return str;
}
diff --git a/gdbsupport/print-utils.h b/gdbsupport/print-utils.h
index e50d96f..dc5011c 100644
--- a/gdbsupport/print-utils.h
+++ b/gdbsupport/print-utils.h
@@ -34,15 +34,35 @@ extern const char *pulongest (ULONGEST u);
extern const char *plongest (LONGEST l);
-/* Convert a ULONGEST into a HEX string, like %lx, with leading zeros.
+/* Convert L (of type ULONGEST) into a hex string, like %lx, with leading
+ zeros. The result is stored in a circular static buffer, NUMCELLS
+ deep. */
+
+extern const char *phex_ulongest (ULONGEST l, int sizeof_l);
+
+/* Convert L into a HEX string, like %lx, with leading zeros.
The result is stored in a circular static buffer, NUMCELLS deep. */
-extern const char *phex (ULONGEST l, int sizeof_l);
+template<typename T>
+const char *phex (T l, int sizeof_l = sizeof (T))
+{
+ return phex_ulongest (l, sizeof_l);
+}
+
+/* Convert L (of type ULONGEST) into a hex string, like %lx, without leading
+ zeros. The result is stored in a circular static buffer, NUMCELLS
+ deep. */
-/* Convert a ULONGEST into a HEX string, like %lx, without leading zeros.
- The result is stored in a circular static buffer, NUMCELLS deep. */
+extern const char *phex_nz_ulongest (ULONGEST l, int sizeof_l);
+
+/* Convert L into a hex string, like %lx, without leading zeros.
+ The result is stored in a circular static buffer, NUMCELLS deep. */
-extern const char *phex_nz (ULONGEST l, int sizeof_l);
+template<typename T>
+const char *phex_nz (T l, int sizeof_l = sizeof (T))
+{
+ return phex_nz_ulongest (l, sizeof_l);
+}
/* Converts a LONGEST to a C-format hexadecimal literal and stores it
in a static string. Returns a pointer to this string. */
diff --git a/readline/readline/tcap.h b/readline/readline/tcap.h
index 859e6ee..9e2ed12 100644
--- a/readline/readline/tcap.h
+++ b/readline/readline/tcap.h
@@ -46,14 +46,14 @@ extern char *UP, *BC;
extern short ospeed;
-extern int tgetent ();
-extern int tgetflag ();
-extern int tgetnum ();
-extern char *tgetstr ();
+extern int tgetent (char *bp, const char *name);
+extern int tgetflag (char *id);
+extern int tgetnum (char *id);
+extern char *tgetstr (char *id, char **area);
-extern int tputs ();
+extern int tputs (const char *str, int affcnt, int (*putc)(int));
-extern char *tgoto ();
+extern char *tgoto (const char *cap, int col, int row);
#endif /* HAVE_TERMCAP_H */