top | item 38390052

Writing a Debugger from Scratch: Stacks

118 points| ingve | 2 years ago |timdbg.com | reply

6 comments

order
[+] schemescape|2 years ago|reply
Interesting to read that frame pointer omission may not be worth it:

> You'd think that saving a whole register would mean a performance improvement, right? Especially on 32-bit x86 code where registers are at a premium. But it turns out that the cost savings are really pretty neglible. A Microsoft research paper from 2009 talks about measurements that were made in the performance of Windows with and without frame pointers. They found that there was no statistically provable benefit of FPO, and it was decided to disable FPO in Windows XP SP2! A similar investigation was done by Fedora and it was found that performance was typically only 2% different. When Meta enabled frame pointers sometime around 2017, they compared performance between a comparable set of hosts with and without FPO and found no difference.

> So why do we continue using FPO? Probably to make life more difficult for people who write debuggers.

[+] matheusmoreira|2 years ago|reply
That's really interesting. I'm gonna make -fno-omit-frame-pointer standard in my projects.
[+] leowwwa|2 years ago|reply
Ah. nice It is about the process of writing a debugger from scratch. Part 6 specifically focuses on walking call stacks, which is a crucial feature for understanding the state of a program during debugging. The author explains the complexities of stack walking in the context of an x64 Windows debugger, providing detailed insights and code examples. Thanks
[+] Ygg2|2 years ago|reply
Love the series. Not to mention debugging Rust felt somewhat neglected. I hope this works on Windows as well as Linux.