From a45f43da3407dbbf8ecd15ce8ecb361af677add7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20M=20G=C3=B3mez?= Date: Fri, 9 Feb 2024 12:23:36 +0000 Subject: [PATCH] MangleProcs following the Itanium spec so they are demangled in the debugger call stack (#23260) ![image](https://github.com/nim-lang/Nim/assets/1496571/0d796c5b-0bbf-4bb4-8c95-c3e3cce22f15) --------- Co-authored-by: Andreas Rumpf --- compiler/ccgtypes.nim | 28 ++++- compiler/ccgutils.nim | 61 +++++++++- compiler/cgendata.nim | 1 + tests/codegen/titaniummangle.nim | 192 +++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+), 6 deletions(-) create mode 100644 tests/codegen/titaniummangle.nim diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 6a51fe3a04fc1..e8054b9e48fc8 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -55,13 +55,31 @@ proc mangleField(m: BModule; name: PIdent): string = if isKeyword(name): result.add "_0" +proc mangleProc(m: BModule; s: PSym; makeUnique: bool): string = + result = "_Z" # Common prefix in Itanium ABI + result.add encodeSym(m, s, makeUnique) + if s.typ.len > 1: #we dont care about the return param + for i in 1..