[compiler-rt] [compiler-rt] Fix frame numbering for unparsable frames. (PR #148278)
David Justo via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 10:23:27 PDT 2025
================
@@ -507,20 +507,29 @@ def symbolize_address(self, addr, binary, offset, arch):
assert result
return result
- def get_symbolized_lines(self, symbolized_lines, inc_frame_counter=True):
+ def get_symbolized_lines(self, symbolized_lines):
if not symbolized_lines:
- if inc_frame_counter:
- self.frame_no += 1
- return [self.current_line]
- else:
- assert inc_frame_counter
- result = []
- for symbolized_frame in symbolized_lines:
- result.append(
- " #%s %s" % (str(self.frame_no), symbolized_frame.rstrip())
+ # If it is an unparsable frame, but contains a frame counter and address
+ # replace the frame counter so the stack is still consistent.
+ unknown_stack_frame_format = r"^( *#([0-9]+) +)(0x[0-9a-f]+) +.*"
+ match = re.match(unknown_stack_frame_format, self.current_line)
+ if match:
+ rewritten_line = (
+ self.current_line[: match.start(2)]
+ + str(self.frame_no)
+ + self.current_line[match.end(2) :]
----------------
davidmrdavid wrote:
dismissible nit, I would recommend introducing a variable for `match.start(2)`, to help with readability. The expression is already a bit complex, _in my opinion_.
```python
if match:
# update the frame counter
frame_no_index = match.start(2)
rewritten_line= (
self.current_line[: frame_no_index ]
+ str(self.frame_no)
+ self.current_line[frame_no_index :]
```
https://github.com/llvm/llvm-project/pull/148278
More information about the llvm-commits
mailing list