New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telescope display ret addr #1071 #1889
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1889 +/- ##
==========================================
- Coverage 59.55% 59.44% -0.12%
==========================================
Files 187 191 +4
Lines 23484 24327 +843
Branches 2278 2421 +143
==========================================
+ Hits 13985 14460 +475
- Misses 8754 9091 +337
- Partials 745 776 +31 ☔ View full report in Codecov by Sentry. |
stack = pwndbg.gdblib.vmmap.find(sp) | ||
|
||
# Enumerate all return addresses | ||
frame = gdb.newest_frame() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if GDB can't figure out stack frames?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure 🤷♂️ this pattern is used in a lot of places ( just getting the frame and assuming its valid ) fwiw
There are couple of things here:
|
@dmur1 ping :P |
This would be great to add. Perhaps a compromise for the issue of performance (reading the entire stack every time) would be to pass in a range to |
@dmur1 any chance u can update this PR/fix conflicts etc? |
yes! |
d810007
to
eeabdbf
Compare
@OBarronCS would u perhaps want to make a review of this PR? :) |
@dmur1 RE: non-existent stack frame - run
Pls fix :) |
for i in range(start, stop, step): | ||
values = list(reg_values[i]) | ||
values = list(name_values[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a list already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@disconnect3d i think its name_values = collections.defaultdict(lambda: [])
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already a list in this case (print(type(name_values[i]))
to show this). In line 180, we also iterate name_values[i+width] as a list.
fixed :) |
for i in range(start, stop, step): | ||
values = list(reg_values[i]) | ||
values = list(name_values[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already a list in this case (print(type(name_values[i]))
to show this). In line 180, we also iterate name_values[i+width] as a list.
name_values = collections.defaultdict(lambda: []) | ||
for reg in regs.common: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we add a type + comment here:
# Map of address to string (register name, retX)
: DefaultDict[int, list[str]]
I had to look ahead and read the rest of the code to see what the types/structure of the data here was, a type would add some readability/save time for future contributors.
# Find all registers which show up in the trace, map address to regs | ||
regs: dict[int, str] = {} | ||
# Find all names which show up in the trace | ||
names = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names: dict[int, str] = {}
( | ||
regs_or_frame_offset(addr, bp, regs, longest_regs), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer called - frame offset isn't being printed.
separator, | ||
) | ||
), | ||
T.register(names[addr].ljust(longest_names)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple changes that were discarded during the rebase that we should continue to have:
To bring back both stackframe base offset printing and looks like some logic for reverse printing (#1978), could replace whole section with:
if inverse:
line_offset = addr - (stop + ptrsize) + (telescope.offset * ptrsize)
idx_offset = int((start - stop - ptrsize) / ptrsize) - (i + telescope.offset)
else:
line_offset = addr - start + (telescope.offset * ptrsize)
idx_offset = i + telescope.offset
line = T.offset(
"%02x%s%04x%s"
% (
idx_offset,
delimiter,
line_offset,
separator,
)
) + " ".join(
(
regs_or_frame_offset(addr, bp, names, longest_names),
pwndbg.chain.format(addr),
)
)
@dmur1 could you rebase this? |
@dmur1 ping about rebase/conflicts |
seeks to fix #1071