fixes #24705; encode static parameters into function names for debugging (#24707)

fixes #24705

```nim
proc xxx(v: static int) =
  echo v
xxx(10)
xxx(20)
```

They are mangled as `_ZN14titaniummangle7xxx_s10E` and
`_ZN14titaniummangle7xxx_s20E` with `--debugger:native`. Static
parameters are prefixed with `_s` to distinguish simple cases like
`xxx(10, 15)` and `xxx(101, 5)` if `xxx` supports two `static[int]`
parameters

(cherry picked from commit c452275e29)
This commit is contained in:
ringabout
2025-02-27 23:45:04 +08:00
committed by narimiran
parent dac77cc97e
commit f20e6ef901
3 changed files with 27 additions and 11 deletions

View File

@@ -29,6 +29,8 @@ discard """
ccodecheck: "'_ZN14titaniummangle8testFuncE9ContainerI3intE'"
ccodecheck: "'_ZN14titaniummangle8testFuncE10Container2I5int325int32E'"
ccodecheck: "'_ZN14titaniummangle8testFuncE9ContainerI10Container2I5int325int32EE'"
ccodecheck: "'_ZN14titaniummangle7xxx_s10E'"
ccodecheck: "'_ZN14titaniummangle7xxx_s20E'"
"""
#When debugging this notice that if one check fails, it can be due to any of the above.
@@ -151,6 +153,9 @@ proc testFunc(a: int, xs: varargs[string]) =
for x in xs:
echo x
proc xxx(v: static int) =
echo v
proc testFunc() =
var a = 2
var aPtr = a.addr
@@ -188,6 +193,8 @@ proc testFunc() =
let c2 = Container2[int32, int32](data: 10, data2: 20)
testFunc(c2)
testFunc(Container[Container2[int32, int32]](data: c2))
xxx(10)
xxx(20)
testFunc()