Fix demangling for symbols with dots in jump instructions (#8028)

For example Rust on AArch64: https://godbolt.org/z/e3q9Wv7zj
This commit is contained in:
narpfel
2025-08-14 17:09:02 +02:00
committed by GitHub
parent e9390bce6c
commit 5d1d7cf77b
2 changed files with 38 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ export class BaseDemangler extends AsmRegex {
readonly includeMetadata: boolean;
readonly compiler: BaseCompiler;
readonly jumpDef = /(j\w+|b|bl|blx)\s+([$_a-z][\w$@]*|"[$_a-z][\w$@]*")/i;
readonly jumpDef = /(j\w+|b|bl|blx)\s+([$_a-z][\w$.@]*|"[$_a-z][\w$.@]*")/i;
readonly callDef = /callq?\s+([$._a-z][\w$.@]*|"[$._a-z][\w$.@]*")/i;
readonly callPtrDef1 = /callq?.*ptr\s\[[a-z]*\s\+\s([$._a-z][\w$.@]*|"[$._a-z][\w$.@]*")]/i;
readonly callPtrDef2 = /callq?\s+([$*._a-z][\w$.@]*|"[$*._a-z][\w$.@]*")/i;

View File

@@ -198,6 +198,29 @@ describe('Basic demangling', () => {
]);
});
it('AArch64 branch with dotted symbol', () => {
const result = {
asm: [
{
text: 'b _ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17h0feee90717706137E',
},
],
};
const demangler = new DummyCppDemangler(cppfiltpath, new DummyCompiler(), ['-n']);
return Promise.all([
demangler
.process(result)
.then(output => {
expect(output.asm[0].text).toEqual(
'b core::fmt::num::imp::<impl core::fmt::Display for i32>::fmt::h0feee90717706137',
);
})
.catch(catchCppfiltNonexistence),
]);
});
it('Two destructors', () => {
const result = {
asm: [
@@ -251,7 +274,14 @@ describe('Basic demangling', () => {
});
it('Should also support ARM branch instructions', () => {
const result = {asm: [{text: ' bl _ZN3FooC1Ev'}]};
const result = {
asm: [
{text: ' bl _ZN3FooC1Ev'},
{
text: 'b _ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17h0feee90717706137E',
},
],
};
const demangler = new DummyCppDemangler(cppfiltpath, new DummyCompiler(), ['-n']);
@@ -260,7 +290,12 @@ describe('Basic demangling', () => {
demangler.collectLabels();
const output = demangler.othersymbols.listSymbols();
expect(output).toEqual(['_ZN3FooC1Ev']);
expect(output.sort()).toEqual(
[
'_ZN3FooC1Ev',
'_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17h0feee90717706137E',
].sort(),
);
});
it('Should NOT handle undecorated labels', () => {