Repository navigation
Fix symbolizer empty stack frame names - #68
Conversation
34b7a14 to
ddad77d
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses cases where demangled C++ symbols contain (anonymous namespace):: (including inside argument types), which previously caused the profiler/assert symbol printing to strip from the wrong ( and produce empty/truncated frame names (leading to ...+0x... frames in the output).
Changes:
- Switch stack-trace printing in
assert.cppfrom first(to last(when splitting name vs args. - Introduce
Symbolizer::demangle(..., SymbolizerDemangleOptions)with support for stripping anonymous namespaces and/or arguments, and use it inSymbolizer::resolve. - Add a dedicated
Symbolizer.Demangleunit test with a variety of mangled symbols.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/util/assert.cpp |
Adjusts stack-trace demangle formatting to avoid empty names when (anonymous namespace):: is present. |
src/profiler/symbolizer.h |
Adds demangling options enum and a new Symbolizer::demangle API. |
src/profiler/symbolizer.cpp |
Centralizes demangling/stripping logic and updates resolve() to use it. |
src/profiler/tests/symbolizer-test.cpp |
Adds unit tests for demangling and stripping behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ddad77d to
a550dc8
Compare
a550dc8 to
5675fdc
Compare
5675fdc to
b834f73
Compare
b834f73 to
9353bf0
Compare
9353bf0 to
2345dda
Compare
2345dda to
ebc7c6e
Compare
ebc7c6e to
2a0cbd0
Compare
| const char * paren = std::strrchr(demangled, '('); | ||
| if (paren) | ||
| { | ||
| std::fwrite(demangled, 1, static_cast<size_t>(paren - demangled), stderr); |
There was a problem hiding this comment.
I would keep this part in assert.cpp as simple as possible.
Even if we find a wrong start position (quite rare cases), worst thing that happens - incorrect coloring of the arguments part.
| const std::string & resolve(uint64_t addr); | ||
|
|
||
| // Demangle a C++ symbol and optionally strip anonymous namespaces and/or arguments. | ||
| static std::string demangle(const std::string & mangled, SymbolizerDemangleOptions options); |
There was a problem hiding this comment.
Inside the function we use .c_str(), so string_view is not acceptable.
| if ((options & SymbolizerDemangleOptions::StripAnonymousNamespace) == SymbolizerDemangleOptions::StripAnonymousNamespace) | ||
| { | ||
| constexpr std::string_view anonymousNamespace = "(anonymous namespace)::"; | ||
| if (size_t pos = result.find(anonymousNamespace); pos != std::string::npos) | ||
| { |
There was a problem hiding this comment.
It's just two places. Introducing hasFlag helper triggers infinite loop with Copilit unhappy.
In some projects the root stack frame started with `(anonymous namespace)::`. Also this may appear in the middle of demangled result and even in arguments. So the result became just an empty string and this stack frame became `<process>+0x12345` in result svg.
2a0cbd0 to
ae1c006
Compare
Notes
In some projects the root stack frame started with
(anonymous namespace)::. Also this may appear in the middle of demangled result and even in arguments.So the
resultbecame just an empty string and this stack frame became<process>+0x12345in result svg.Testing