diff options
author | Tom Tromey <tom@tromey.com> | 2023-03-19 09:13:10 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-03-20 07:47:15 -0600 |
commit | 6e7eef72164c00d6a5a7b0bce9fa01f5481f33cb (patch) | |
tree | e07c0c6a3e13a4d367fec7b44f025195a6368ff7 /gdb/rust-lang.h | |
parent | 0fea10f327466dbe949aef39cef5a6bdea91163f (diff) | |
download | gdb-6e7eef72164c00d6a5a7b0bce9fa01f5481f33cb.zip gdb-6e7eef72164c00d6a5a7b0bce9fa01f5481f33cb.tar.gz gdb-6e7eef72164c00d6a5a7b0bce9fa01f5481f33cb.tar.bz2 |
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 <aburgess@redhat.com>
Diffstat (limited to 'gdb/rust-lang.h')
-rw-r--r-- | gdb/rust-lang.h | 4 |
1 files changed, 2 insertions, 2 deletions
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<char> *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<char> demangle_symbol (const char *mangled, int options) const override { - return gdb_demangle (mangled, options); + return gdb::unique_xmalloc_ptr<char> (rust_demangle (mangled, options)); } /* See language.h. */ |