lkml.org 
[lkml]   [2022]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v9 17/27] scripts: decode_stacktrace: demangle Rust symbols
    Date
    Recent versions of both Binutils (`c++filt`) and LLVM (`llvm-cxxfilt`)
    provide Rust v0 mangling support.

    Reviewed-by: Kees Cook <keescook@chromium.org>
    Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
    Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
    Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
    Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
    Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
    ---
    scripts/decode_stacktrace.sh | 14 ++++++++++++++
    1 file changed, 14 insertions(+)

    diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
    index 7075e26ab2c4..564c5632e1a2 100755
    --- a/scripts/decode_stacktrace.sh
    +++ b/scripts/decode_stacktrace.sh
    @@ -8,6 +8,14 @@ usage() {
    echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]"
    }

    +# Try to find a Rust demangler
    +if type llvm-cxxfilt >/dev/null 2>&1 ; then
    + cppfilt=llvm-cxxfilt
    +elif type c++filt >/dev/null 2>&1 ; then
    + cppfilt=c++filt
    + cppfilt_opts=-i
    +fi
    +
    if [[ $1 == "-r" ]] ; then
    vmlinux=""
    basepath="auto"
    @@ -180,6 +188,12 @@ parse_symbol() {
    # In the case of inlines, move everything to same line
    code=${code//$'\n'/' '}

    + # Demangle if the name looks like a Rust symbol and if
    + # we got a Rust demangler
    + if [[ $name =~ ^_R && $cppfilt != "" ]] ; then
    + name=$("$cppfilt" "$cppfilt_opts" "$name")
    + fi
    +
    # Replace old address with pretty line numbers
    symbol="$segment$name ($code)"
    }
    --
    2.37.1
    \
     
     \ /
      Last update: 2022-08-05 17:48    [W:4.113 / U:0.104 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site