TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Debugging with GDB

201 点作者 MarcellusDrum大约 3 年前

17 条评论

slavik81大约 3 年前
I&#x27;d also recommend &quot;Give me 15 minutes and I&#x27;ll change your view of GDB&quot; [1] by Greg Law at CppCon 2015. As someone who wasn&#x27;t very familiar with GDB, I learned a lot from seeing it used by someone skilled. [1]: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;PorfLSr3DDI" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;PorfLSr3DDI</a>
评论 #30522165 未加载
interroboink大约 3 年前
I like GDB, and use it a lot, but it always feels like it&#x27;s teetering on the brink of being a pile of bugs. I manage to crash it semi-regularly, and there are dozens of little quality-of-life peccadilloes that make things annoying before working out a .gdbinit for yourself. It&#x27;s like using Vim without a .vimrc (:<p>I don&#x27;t envy the maintainers&#x27; jobs, and I just gripe from the sidelines, but starting from scratch it&#x27;s too bad it&#x27;s such an intimidating experience, because it really is a great tool. And I say this as someone who has used MSVC&#x27;s debugger (which I&#x27;ve often seen applauded as the best) for some decades, and I still prefer GDB now that I&#x27;m past the significant initial learning curve.
评论 #30520983 未加载
easterncalculus大约 3 年前
GDB is great. I definitely recommend checking out watchpoints as well, a very useful tool for monitoring how a variable changes over time.<p>GDB also has many good plugins - pwndbg has tons of features and UI improvements over stock GDB.<p><a href="https:&#x2F;&#x2F;sourceware.org&#x2F;gdb&#x2F;onlinedocs&#x2F;gdb&#x2F;Set-Watchpoints.html" rel="nofollow">https:&#x2F;&#x2F;sourceware.org&#x2F;gdb&#x2F;onlinedocs&#x2F;gdb&#x2F;Set-Watchpoints.ht...</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;pwndbg&#x2F;pwndbg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pwndbg&#x2F;pwndbg</a>
Graziano_M大约 3 年前
Using vanilla GDB is painful. As a bit of a shameless plug I recommend you check out GEF[1]. It&#x27;s a large python script that extends GDB to make it a lot better to use. Notably it shows a lot of the state automatically every time the inferior stops. It&#x27;s oriented around reversing and exploit development, but it definitely doesn&#x27;t have to be used that way.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;hugsy&#x2F;gef" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hugsy&#x2F;gef</a>
评论 #30522425 未加载
评论 #30519046 未加载
ghoward大约 3 年前
I can&#x27;t believe no one has mentioned `gdb-dashboard` [1] yet! I use it extensively. [2]<p>Beyond that, I have recently learned how to write custom pretty printers for GDB. This saves a lot of screen space. I should probably update [2] soon with those new techniques.<p>GDB is powerful, useful, and after getting my start in IDE debuggers, including Visual Studio, I struggle whenever I have to go back.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;cyrus-and&#x2F;gdb-dashboard" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cyrus-and&#x2F;gdb-dashboard</a><p>[2]: <a href="https:&#x2F;&#x2F;gavinhoward.com&#x2F;2020&#x2F;12&#x2F;my-development-environment-and-how-i-got-there&#x2F;#gdb-dashboard" rel="nofollow">https:&#x2F;&#x2F;gavinhoward.com&#x2F;2020&#x2F;12&#x2F;my-development-environment-a...</a>
2c2c2c大约 3 年前
I haven&#x27;t seen anyone demonstrate using gdb via CLI in the way you can show off using vim proficiently and have people say &quot;I get it&quot;.<p>In the reverse engineering space there&#x27;s some folks that use gef. but maybe that&#x27;s because linux folks dont have olydbg?<p>would love to see a livestream of someone using gdb in the context of real world engineering. SHOW me the productivity wins here. every article and conference talk about gdb is just handwavey hypotheticals about what you could do, but in practice I just see people moving through basic debugging incredibly slowly
评论 #30527053 未加载
评论 #30521860 未加载
veganjay大约 3 年前
I came across this writeup: <a href="https:&#x2F;&#x2F;infosecwriteups.com&#x2F;pwndbg-gef-peda-one-for-all-and-all-for-one-714d71bf36b8" rel="nofollow">https:&#x2F;&#x2F;infosecwriteups.com&#x2F;pwndbg-gef-peda-one-for-all-and-...</a><p>It describes how to configure GDB with the GEF, PEDA and PWNDBG plugins.<p>(I&#x27;ve only really used gdb-peda, would be great to get some time to learn the others)
limmeau大约 3 年前
I can really recommend debugging with command-line gdb (inside a text editor, of course; we&#x27;re not barbarians). The transcript that lets you look back at the past of your debug session really adds a new dimension to the debug experience that a plain IDE integration just does not offer.<p>(Time-travelling debuggers are OK, too, I guess)
评论 #30517734 未加载
评论 #30518407 未加载
评论 #30517073 未加载
pflanze大约 3 年前
&gt; add the -g flag<p>I compile with -gdwarf-4 -g3 to include macro definitions in the binary. That way you can use macros at the gdb prompt. I can&#x27;t imagine life without those :)
评论 #30524893 未加载
maCDzP大约 3 年前
GDB has a really nice TUI mode that helps a lot while debugging.
评论 #30520561 未加载
评论 #30517838 未加载
phendrenad2大约 3 年前
After several decades of using GUI-based debugging in MSVC++ and CLion, I can&#x27;t bring myself to regress back to command-line debugging. And sadly the GUI tools for GDB are abysmal.<p>Recently I had to debug some bootloader code in QEMU, which provides a remote GDB port. I tried every GDB GUI and they all either (A) assumed that I would provide source code to the target code (it&#x27;s a binary blob bootloader, which I don&#x27;t have code for) or (B) flat out didn&#x27;t work. I ended up using TUI mode, which has it&#x27;s own problems (messes up my terminal when I disconnect&#x2F;reconnect the GDB port)
评论 #30524135 未加载
modeless大约 3 年前
I&#x27;m surprised to see people praising GDB so much here. Working on Chromium, using GDB was just hopeless. Difficult to get working, incredibly slow to the point of apparently hanging, practically no support for multi process debugging, absolutely atrociously bad GUI frontends. Visual Studio&#x27;s debugger works great in the same scenario. And windbg is there if you hate GUIs.<p>I have little hope for the state of Linux debugging in the future if people really think the current situation with GDB and its frontends is good or even acceptable.
brtkdotse大约 3 年前
Having spent my entire career inside of Visual Studio (nee VS Code), this strikes me as a quaint relic from a time past.<p>Can it be powerful? Probably. But the dev experience looks terrible.
评论 #30520318 未加载
评论 #30521008 未加载
评论 #30520394 未加载
IYasha大约 3 年前
The beginning was promising. I expected something for non-vim users. As a heavy VS user, I tried some Linux IDEs like KDevelop and Code::Blocks and, AFAIR, they integrated with GDB to resemble VS debugging process. For me personally, just pressing F5 (a hew hundreds of times a day) is a bit less cumbersome than running dgb program, start, etc. )
评论 #30519515 未加载
评论 #30523778 未加载
sharikous大约 3 年前
gdb has been mauled by Apple in macOS in the name of security<p>Maybe I am spoiled but I cannot bear the nagging about code-signing it yourself
评论 #30520146 未加载
shmerl大约 3 年前
cgdb can be helpful if you want a bit more visual experience: <a href="http:&#x2F;&#x2F;cgdb.github.io" rel="nofollow">http:&#x2F;&#x2F;cgdb.github.io</a>
评论 #30525929 未加载
评论 #30519581 未加载
leni536大约 3 年前
If you like gdb, I recomend to check out rr too. Reversible debugging is just a superpower.