Update Rust demangling to use rustc-demangle
The rust-demangle-capi crate hasn't been updated since 2016 and out-of-date. Instead, Breakpad needs to use C API offered by the rustc-demangle to demangle Rust symbols. *** TESTING *** 1) Set up rustc-demangle > git clone https://github.com/rust-lang/rustc-demangle.git > cd rustc-demangle > cargo build -p rustc-demangle-capi --release 2) Breakpad > ./configure --with-rustc-demangle=<path to rustc-demangle> > make check src/common/dward_cu_to_module Change-Id: Ib68b62ef329f1397bc379a1d04c632781e4b2069 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3273324 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
fe35cd43f2
commit
38ee0be4d1
6 changed files with 56 additions and 55 deletions
12
Makefile.am
12
Makefile.am
|
@ -623,9 +623,9 @@ src_tools_linux_dump_syms_dump_syms_SOURCES = \
|
|||
src/common/linux/safe_readlink.cc \
|
||||
src/tools/linux/dump_syms/dump_syms.cc
|
||||
src_tools_linux_dump_syms_dump_syms_CXXFLAGS = \
|
||||
$(RUST_DEMANGLE_CFLAGS)
|
||||
$(RUSTC_DEMANGLE_CFLAGS)
|
||||
src_tools_linux_dump_syms_dump_syms_LDADD = \
|
||||
$(RUST_DEMANGLE_LIBS)
|
||||
$(RUSTC_DEMANGLE_LIBS)
|
||||
|
||||
src_tools_linux_md2core_minidump_2_core_SOURCES = \
|
||||
src/common/linux/memory_mapped_file.cc \
|
||||
|
@ -683,10 +683,10 @@ src_tools_mac_dump_syms_dump_syms_mac_SOURCES = \
|
|||
src/tools/mac/dump_syms/dump_syms_tool.cc
|
||||
src_tools_mac_dump_syms_dump_syms_mac_CXXFLAGS= \
|
||||
-I$(top_srcdir)/src/third_party/mac_headers \
|
||||
$(RUST_DEMANGLE_CFLAGS) \
|
||||
$(RUSTC_DEMANGLE_CFLAGS) \
|
||||
-DHAVE_MACH_O_NLIST_H
|
||||
src_tools_mac_dump_syms_dump_syms_mac_LDADD= \
|
||||
$(RUST_DEMANGLE_LIBS)
|
||||
$(RUSTC_DEMANGLE_LIBS)
|
||||
|
||||
src_common_dumper_unittest_SOURCES = \
|
||||
src/common/byte_cursor_unittest.cc \
|
||||
|
@ -748,11 +748,11 @@ src_common_dumper_unittest_SOURCES = \
|
|||
src/common/tests/file_utils.cc
|
||||
src_common_dumper_unittest_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) $(TEST_CFLAGS) \
|
||||
$(RUST_DEMANGLE_CFLAGS) \
|
||||
$(RUSTC_DEMANGLE_CFLAGS) \
|
||||
$(PTHREAD_CFLAGS)
|
||||
src_common_dumper_unittest_LDADD = \
|
||||
$(TEST_LIBS) \
|
||||
$(RUST_DEMANGLE_LIBS) \
|
||||
$(RUSTC_DEMANGLE_LIBS) \
|
||||
$(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
|
||||
|
||||
src_common_mac_macho_reader_unittest_SOURCES = \
|
||||
|
|
16
Makefile.in
16
Makefile.in
|
@ -2371,8 +2371,8 @@ PTHREAD_CC = @PTHREAD_CC@
|
|||
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
|
||||
PTHREAD_LIBS = @PTHREAD_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
RUST_DEMANGLE_CFLAGS = @RUST_DEMANGLE_CFLAGS@
|
||||
RUST_DEMANGLE_LIBS = @RUST_DEMANGLE_LIBS@
|
||||
RUSTC_DEMANGLE_CFLAGS = @RUSTC_DEMANGLE_CFLAGS@
|
||||
RUSTC_DEMANGLE_LIBS = @RUSTC_DEMANGLE_LIBS@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
|
@ -2833,10 +2833,10 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
|||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/dump_syms/dump_syms.cc
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_dump_syms_dump_syms_CXXFLAGS = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUST_DEMANGLE_CFLAGS)
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUSTC_DEMANGLE_CFLAGS)
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_dump_syms_dump_syms_LDADD = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUST_DEMANGLE_LIBS)
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUSTC_DEMANGLE_LIBS)
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_md2core_minidump_2_core_SOURCES = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/memory_mapped_file.cc \
|
||||
|
@ -2895,11 +2895,11 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
|||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_mac_dump_syms_dump_syms_mac_CXXFLAGS = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ -I$(top_srcdir)/src/third_party/mac_headers \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUST_DEMANGLE_CFLAGS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUSTC_DEMANGLE_CFLAGS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ -DHAVE_MACH_O_NLIST_H
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_mac_dump_syms_dump_syms_mac_LDADD = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUST_DEMANGLE_LIBS)
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUSTC_DEMANGLE_LIBS)
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_common_dumper_unittest_SOURCES = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/byte_cursor_unittest.cc \
|
||||
|
@ -2962,12 +2962,12 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
|||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_common_dumper_unittest_CPPFLAGS = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(AM_CPPFLAGS) $(TEST_CFLAGS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUST_DEMANGLE_CFLAGS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUSTC_DEMANGLE_CFLAGS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(PTHREAD_CFLAGS)
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_common_dumper_unittest_LDADD = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(TEST_LIBS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUST_DEMANGLE_LIBS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(RUSTC_DEMANGLE_LIBS) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
|
||||
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_common_mac_macho_reader_unittest_SOURCES = \
|
||||
|
|
40
configure
vendored
40
configure
vendored
|
@ -628,8 +628,8 @@ LTLIBOBJS
|
|||
LIBOBJS
|
||||
TESTS_AS_ROOT_FALSE
|
||||
TESTS_AS_ROOT_TRUE
|
||||
RUST_DEMANGLE_LIBS
|
||||
RUST_DEMANGLE_CFLAGS
|
||||
RUSTC_DEMANGLE_LIBS
|
||||
RUSTC_DEMANGLE_CFLAGS
|
||||
SELFTEST_FALSE
|
||||
SELFTEST_TRUE
|
||||
GTEST_LIBS
|
||||
|
@ -781,7 +781,7 @@ enable_processor
|
|||
enable_tools
|
||||
enable_system_test_libs
|
||||
enable_selftest
|
||||
with_rust_demangle
|
||||
with_rustc_demangle
|
||||
with_tests_as_root
|
||||
'
|
||||
ac_precious_vars='build_alias
|
||||
|
@ -802,8 +802,8 @@ GMOCK_CFLAGS
|
|||
GMOCK_LIBS
|
||||
GTEST_CFLAGS
|
||||
GTEST_LIBS
|
||||
RUST_DEMANGLE_CFLAGS
|
||||
RUST_DEMANGLE_LIBS'
|
||||
RUSTC_DEMANGLE_CFLAGS
|
||||
RUSTC_DEMANGLE_LIBS'
|
||||
|
||||
|
||||
# Initialize some variables set by options.
|
||||
|
@ -1455,8 +1455,8 @@ Optional Features:
|
|||
Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--with-rust-demangle=/path/to/rust-demangle-capi
|
||||
Link against the rust-demangle library to demangle
|
||||
--with-rustc-demangle=/path/to/rustc-demangle
|
||||
Link against the rustc-demangle library to demangle
|
||||
Rust language symbols during symbol dumping (default
|
||||
is no) Pass the path to the crate root.
|
||||
--with-tests-as-root Run the tests as root. Use this on platforms like
|
||||
|
@ -1482,10 +1482,10 @@ Some influential environment variables:
|
|||
GTEST_CFLAGS
|
||||
Compiler flags for gtest
|
||||
GTEST_LIBS Linker flags for gtest
|
||||
RUST_DEMANGLE_CFLAGS
|
||||
Compiler flags for rust-demangle
|
||||
RUST_DEMANGLE_LIBS
|
||||
Linker flags for rust-demangle
|
||||
RUSTC_DEMANGLE_CFLAGS
|
||||
Compiler flags for rustc-demangle
|
||||
RUSTC_DEMANGLE_LIBS
|
||||
Linker flags for rustc-demangle
|
||||
|
||||
Use these variables to override the choices made by `configure' or to help
|
||||
it to find libraries and programs with nonstandard names/locations.
|
||||
|
@ -7690,25 +7690,25 @@ fi
|
|||
|
||||
|
||||
|
||||
# Check whether --with-rust-demangle was given.
|
||||
if test "${with_rust_demangle+set}" = set; then :
|
||||
withval=$with_rust_demangle; case "${withval}" in
|
||||
# Check whether --with-rustc-demangle was given.
|
||||
if test "${with_rustc_demangle+set}" = set; then :
|
||||
withval=$with_rustc_demangle; case "${withval}" in
|
||||
yes)
|
||||
as_fn_error $? "You must pass the path to the rust-demangle-capi crate for --with-rust-demangle" "$LINENO" 5
|
||||
as_fn_error $? "You must pass the path to the rustc-demangle crate for --with-rustc-demangle" "$LINENO" 5
|
||||
;;
|
||||
no)
|
||||
rust_demangle=false
|
||||
rustc_demangle=false
|
||||
;;
|
||||
*)
|
||||
if ! test -f "${withval}/Cargo.toml"; then
|
||||
as_fn_error $? "You must pass the path to the rust-demangle-capi crate for --with-rust-demangle" "$LINENO" 5
|
||||
as_fn_error $? "You must pass the path to the rustc-demangle crate for --with-rustc-demangle" "$LINENO" 5
|
||||
fi
|
||||
RUST_DEMANGLE_CFLAGS="-DHAVE_RUST_DEMANGLE -I${withval}/target/include"
|
||||
RUST_DEMANGLE_LIBS="-L${withval}/target/release -lrust_demangle -lpthread -ldl"
|
||||
RUSTC_DEMANGLE_CFLAGS="-DHAVE_RUSTC_DEMANGLE -I${withval}/crates/capi/include"
|
||||
RUSTC_DEMANGLE_LIBS="-L${withval}/target/release -lrustc_demangle -lpthread -ldl"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
rust_demangle=false
|
||||
rustc_demangle=false
|
||||
fi
|
||||
|
||||
|
||||
|
|
22
configure.ac
22
configure.ac
|
@ -219,30 +219,30 @@ AC_ARG_ENABLE(selftest,
|
|||
[selftest=false])
|
||||
AM_CONDITIONAL(SELFTEST, test x$selftest = xtrue)
|
||||
|
||||
AC_ARG_WITH(rust-demangle,
|
||||
AS_HELP_STRING([--with-rust-demangle=/path/to/rust-demangle-capi],
|
||||
[Link against the rust-demangle library]
|
||||
AC_ARG_WITH(rustc-demangle,
|
||||
AS_HELP_STRING([--with-rustc-demangle=/path/to/rustc-demangle],
|
||||
[Link against the rustc-demangle library]
|
||||
[to demangle Rust language symbols during]
|
||||
[symbol dumping (default is no)]
|
||||
[Pass the path to the crate root.]),
|
||||
[case "${withval}" in
|
||||
yes)
|
||||
AC_MSG_ERROR(You must pass the path to the rust-demangle-capi crate for --with-rust-demangle)
|
||||
AC_MSG_ERROR(You must pass the path to the rustc-demangle crate for --with-rustc-demangle)
|
||||
;;
|
||||
no)
|
||||
rust_demangle=false
|
||||
rustc_demangle=false
|
||||
;;
|
||||
*)
|
||||
if ! test -f "${withval}/Cargo.toml"; then
|
||||
AC_MSG_ERROR(You must pass the path to the rust-demangle-capi crate for --with-rust-demangle)
|
||||
AC_MSG_ERROR(You must pass the path to the rustc-demangle crate for --with-rustc-demangle)
|
||||
fi
|
||||
RUST_DEMANGLE_CFLAGS="-DHAVE_RUST_DEMANGLE -I${withval}/target/include"
|
||||
RUST_DEMANGLE_LIBS="-L${withval}/target/release -lrust_demangle -lpthread -ldl"
|
||||
RUSTC_DEMANGLE_CFLAGS="-DHAVE_RUSTC_DEMANGLE -I${withval}/crates/capi/include"
|
||||
RUSTC_DEMANGLE_LIBS="-L${withval}/target/release -lrustc_demangle -lpthread -ldl"
|
||||
;;
|
||||
esac],
|
||||
[rust_demangle=false])
|
||||
AC_ARG_VAR([RUST_DEMANGLE_CFLAGS], [Compiler flags for rust-demangle])
|
||||
AC_ARG_VAR([RUST_DEMANGLE_LIBS], [Linker flags for rust-demangle])
|
||||
[rustc_demangle=false])
|
||||
AC_ARG_VAR([RUSTC_DEMANGLE_CFLAGS], [Compiler flags for rustc-demangle])
|
||||
AC_ARG_VAR([RUSTC_DEMANGLE_LIBS], [Linker flags for rustc-demangle])
|
||||
|
||||
AC_ARG_WITH(tests-as-root,
|
||||
AS_HELP_STRING([--with-tests-as-root],
|
||||
|
|
|
@ -1268,12 +1268,12 @@ TEST_F(Specifications, MangledNameRust) {
|
|||
|
||||
TestFunctionCount(1);
|
||||
TestFunction(0,
|
||||
#ifndef HAVE_RUST_DEMANGLE
|
||||
#ifndef HAVE_RUSTC_DEMANGLE
|
||||
// Rust mangled names should pass through untouched if not
|
||||
// using rust-demangle.
|
||||
// using rustc-demangle.
|
||||
kName,
|
||||
#else
|
||||
// If rust-demangle is available this should be properly
|
||||
// If rustc-demangle is available this should be properly
|
||||
// demangled.
|
||||
"rustc_demangle::demangle",
|
||||
#endif
|
||||
|
|
|
@ -35,13 +35,14 @@
|
|||
#include "common/language.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <array>
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_RUST_DEMANGLE)
|
||||
#include <rust_demangle.h>
|
||||
#if defined(HAVE_RUSTC_DEMANGLE)
|
||||
#include <rustc_demangle.h>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
|
@ -178,13 +179,13 @@ class RustLanguage: public Language {
|
|||
// abi_demangle doesn't produce stellar results due to them having
|
||||
// another layer of encoding.
|
||||
// If callers provide rustc-demangle, use that.
|
||||
#if defined(HAVE_RUST_DEMANGLE)
|
||||
char* rust_demangled = rust_demangle(mangled.c_str());
|
||||
if (rust_demangled == nullptr) {
|
||||
#if defined(HAVE_RUSTC_DEMANGLE)
|
||||
std::array<char, 1 * 1024 * 1024> rustc_demangled;
|
||||
if (rustc_demangle(mangled.c_str(), rustc_demangled.data(),
|
||||
rustc_demangled.size()) == 0) {
|
||||
return kDemangleFailure;
|
||||
}
|
||||
demangled->assign(rust_demangled);
|
||||
free_rust_demangled_name(rust_demangled);
|
||||
demangled->assign(rustc_demangled.data());
|
||||
#else
|
||||
// Otherwise, pass through the mangled name so callers can demangle
|
||||
// after the fact.
|
||||
|
|
Loading…
Reference in a new issue