From 6e7eef72164c00d6a5a7b0bce9fa01f5481f33cb Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 19 Mar 2023 09:13:10 -0600 Subject: Use rust_demangle to fix a crash PR rust/30211 points out a crash caused by a particular completion. This turns out to happen because a Rust minsym winds up in a C++-specific path in strncmp_iw_with_mode, which ultimately causes the completer to pass invalid arguments to string::append. This patch fixes the bug by reordering the language constants so that Rust comes before C++, and then using rust_demangle. This ensures that minsyms are correctly marked as "Rust", avoiding this code and thus the crash. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20367 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30211 Reviewed-By: Andrew Burgess --- gdb/rust-lang.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/rust-lang.h') diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index 37a22e7..efe721c 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -93,7 +93,7 @@ public: (const char *mangled, gdb::unique_xmalloc_ptr *demangled) const override { - *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); + demangled->reset (rust_demangle (mangled, 0)); return *demangled != NULL; } @@ -102,7 +102,7 @@ public: gdb::unique_xmalloc_ptr demangle_symbol (const char *mangled, int options) const override { - return gdb_demangle (mangled, options); + return gdb::unique_xmalloc_ptr (rust_demangle (mangled, options)); } /* See language.h. */ -- cgit v1.1