Re:GDB 8.1 Released
by zython on Wednesday January 31, 2018 @12:29PM
(#16275554)
> New shortcuts for TUI Single-Key mode: 'i' for stepi, and 'o' for nexti;
TUI really is one of the best features to really get into gdb. visually stepping through the disassembly really makes debugging more appealing, I really wish they dont abandon this aspect of gdb
Re:GDB 8.1 Released
by simark1 on Wednesday January 31, 2018 @02:40PM
(#16276871)
GDB developers use it extensively, so it's not going to disappear anytime soon. Of course it's far from perfect and there are better visual interfaces for GDB, but the fact that it's a keystroke away is its strong point.
ptype already existed, but did not print out offsets. This is incredibly useful, and something Windbg does with dt. Pwndbg does this in GDB by adding new commands.
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @01:30PM
(#16276208)
I'd really like a way for a program to have an API for interacting with GDB: with that it could tell "I'm running under a debugger". There would be a file descriptor which talks to the debugger, if the debugger is present. Output sent to it goes to the debugger and perhaps it could obtain input from the debugger also. Maybe the API could provide some introspection: the program could ask what breakpoints have been set and things like that.
Re:GDB 8.1 Released
by modeless on Wednesday January 31, 2018 @02:08PM
(#16276575)
Having the program behave differently under a debugger is a great way to introduce bugs that disappear when the debugger is present. Any features of this type would have to be completely optional.
Re:GDB 8.1 Released
by jcelerier on Wednesday January 31, 2018 @04:13PM
(#16277592)
> Imagine malware that could react differently when a debugger is attached.
that has been the case for a long time: simply timing some instructions is generally enough to tell you that you're running under a debugger. It's also helpful for copy protection.
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @02:30PM
(#16276785)
The debugger could have a mode of "stealth attachment" under which that feature is not activated; the connection with that special interface is not made, and so the program is not informed that it's under a debugger, and those debug streams don't connect to anything.
Re:GDB 8.1 Released
by dustfinger on Wednesday January 31, 2018 @02:32PM
(#16276803)
Well, to be fair malware already exists that can detect when a system debugger is attached so maybe my concern is invalid. I guess the greater concern is the introduction of bugs after all.
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @02:40PM
(#16276865)
The program is what it is and it has bugs. There is a risk that bugs are irreproducible under a debugger (no matter how transparent the debugger). Oh well; you have to debug those in some other way. That risk shouldn't paralyze us from innovating debuggers.
There are bugs that won't reproduce when you debug via JTAG; so what.
Simply pausing on a breakpoint can make a bug irreproducible.
Programs can infer that they are being debugged via timings, and various side channels.
Re:GDB 8.1 Released
by saagarjha on Wednesday January 31, 2018 @03:26PM
(#16277239)
The issue is that by introducing this feature, you're increasing the number of programs that behave differently when a debugger is attached. Just because this can be an issue today doesn't mean that we should make it even more of an issue tomorrow.
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @05:46PM
(#16278251)
So that's a different approach: integrate a remote debugging GDB server into the program (could be a shared lib that is dlopen-ed, by the way). Then that server is always used, even in a local session. The server is deeply integrated into the program, taking advantage of the protocol to communicate between application code and the debugging client.
It sounds promising. A particularly interesting area is events:
Re:GDB 8.1 Released
by wazari972 on Wednesday January 31, 2018 @01:42PM
(#16276334)
this is not particularly hard to do with the Python interface: you define structures that are known by the process and the Python module + global variables, then you set an internal (silent) breakpoint on a given 'event' function.
In the program you fill the structure with some queries, and in the Python breakpoint callback, you process it as you need.
This is the way multi-thread debugging work (used to at least), shared library detection as well...
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @02:36PM
(#16276831)
Okay, good ideas there: so the program has some standard dispatch function that can be called to talk to the debugger. Normally that does nothing. The debugger can recognize this function and stick a breakpoint in it to alter the behavior.
The function can do something like put a request into a mailbox buffer, and then check for a reply in the inbox buffer. When there is no debugger, there is never any reply.
When the debugger stops the show with the breakpoint, it processes the request and prepares a reply, flipping some "reply present" flag; when the program is resumed then, it gets the reply.
It would be good not have any of that damned Python monkey business involved in this.
Re:GDB 8.1 Released
by wazari972 on Wednesday January 31, 2018 @03:07PM
(#16277080)
> It would be good not have any of that damned Python monkey business involved in this.
please, GDB internals are open source, you can do all of that in plain C :D That's what I did initially, to give GDB the ability to distinguish user-level threads (see libthread_db).
Having a high-level language / interface to GDB is a great again of time !
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @05:51PM
(#16278293)
One use case would be to have some debug_printf() in the program that shows up in the debugger, no matter whether the debugger is remote or local. It doesn't go to some console, or file, but always to the debugger.
The Microsoft environment has something like this: OutputDebugString. Very useful.
The debugging experience on Windows 20+ years ago was was ahead of debugging on GNU/Linux today, I'm afraid, so this stuff is above criticism from the "M$ SuX" angle.
Re:GDB 8.1 Released
by kazinator on Wednesday January 31, 2018 @09:40PM
(#16279321)
Well, stdout isn't a debug channel; you might want to debug a program that actually uses stdout for its output, not for debug chatter.
Never mind that though, we can take some other descriptor, like 3, and bind it to, say /dev/null.
What are the gdb commands to have whatever is going to file descriptor 3 be shown inside gdb?
I really do not care how it's implemented. However, "tightly integrated" is better than "flimsy hack"; "consumes breakpoints" is better than "doesn't consume breakpoints".
Re:GDB 8.1 Released
by kazinator on Thursday February 01, 2018 @01:13PM
(#16284164)
stderr also isn't for debug output.
If, say, a compiler puts out "hello.c: syntax error" on its standard error stream, that is not a debugging diagnostic regarding that compiler's internals; it's about "hello.c".
stderr is not an instrumentation tool which goes away when we're not debugging the program.
Re:GDB 8.1 Released
by tonyg on Wednesday January 31, 2018 @04:59PM
(#16277929)
TCP's checksum isn't even as good as CRC32. It's just a one's-complement sum of the packet and a few header words.
From this [0] helpful StackOverflow post:
> If you need to transfer data and you want to be sure the data didn't get corrupted, the TCP checksum alone is certainly not enough for this task. I would even dare to say that a CRC checksum is not enough for this task, since a CRC32 may not detect an error where more than 32 bits in a row are affected (these errors can "cancel out" each other). The minimum checksum you'd need for ensuring flawless data transfer is the MD5 value of the data.
Re:GDB 8.1 Released
by harikb on Wednesday January 31, 2018 @01:22PM
(#16276112)
File checksums are typically used when the checksum is still on the master site but the file could be in untrusted mirrors. TCP level stuff is useless in those scenarios.
TUI really is one of the best features to really get into gdb. visually stepping through the disassembly really makes debugging more appealing, I really wish they dont abandon this aspect of gdb
https://www.youtube.com/watch?v=PorfLSr3DDI
It really did change my opinion of gdb in just 15 min.
https://i.imgur.com/kY6NuXC.jpg
ptype already existed, but did not print out offsets. This is incredibly useful, and something Windbg does with dt. Pwndbg does this in GDB by adding new commands.
But I needed a C++ patch on osx with cc/clang. Apparently they added cxx files with the .c extension: gdb/probe.c:63
Programs behave differently under a debugger anyway; "bugs disappearing under a debugger" already happens now.
It's just a question of the risk/reward.
"This debugger feature increases the scope of situations when a bug disappears under the debugger": that's a risk.
"This debugger feature gives me a better overall debugging experience most of the time": benefit
Imagine malware that could react differently when a debugger is attached.
that has been the case for a long time: simply timing some instructions is generally enough to tell you that you're running under a debugger. It's also helpful for copy protection.
Here's [1] the tip of the iceberg on this issue.
[1] antukh.com/blog/2015/01/19/malware-techniques-cheat-sheet/
Edit - Other commenters beet me to this point :-P
There are bugs that won't reproduce when you debug via JTAG; so what.
Simply pausing on a breakpoint can make a bug irreproducible.
Programs can infer that they are being debugged via timings, and various side channels.
I think you’re missing the point as to why programs would do this. Usually it’s to protect some sort of DRM scheme through obscurity.
https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.ht...
In your program you would probably need to link in some code to implement the protocol, like the GDB remote stub:
https://sourceware.org/gdb/onlinedocs/gdb/Remote-Stub.html
Qemu and Valgrind both implement their own gdb stubs.
For ARM targets, there is a similar feature named "semihosting":
http://www.keil.com/support/man/docs/armcc/armcc_pge13587870...
It sounds promising. A particularly interesting area is events:
https://sourceware.org/gdb/onlinedocs/gdb/Notification-Packe...
The program could generate custom notifications.
The function can do something like put a request into a mailbox buffer, and then check for a reply in the inbox buffer. When there is no debugger, there is never any reply.
When the debugger stops the show with the breakpoint, it processes the request and prepares a reply, flipping some "reply present" flag; when the program is resumed then, it gets the reply.
It would be good not have any of that damned Python monkey business involved in this.
please, GDB internals are open source, you can do all of that in plain C :D That's what I did initially, to give GDB the ability to distinguish user-level threads (see libthread_db).
Having a high-level language / interface to GDB is a great again of time !
The Microsoft environment has something like this: OutputDebugString. Very useful.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
Also IsDebuggerPresent: https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
and other things.
The debugging experience on Windows 20+ years ago was was ahead of debugging on GNU/Linux today, I'm afraid, so this stuff is above criticism from the "M$ SuX" angle.
And I don't really know what IsDebuggerPresent gets you.
You're really focusing on features, rather than use cases.
Never mind that though, we can take some other descriptor, like 3, and bind it to, say /dev/null.
What are the gdb commands to have whatever is going to file descriptor 3 be shown inside gdb?
I really do not care how it's implemented. However, "tightly integrated" is better than "flimsy hack"; "consumes breakpoints" is better than "doesn't consume breakpoints".
What's your use case for this that makes stderr unsuitable?
If, say, a compiler puts out "hello.c: syntax error" on its standard error stream, that is not a debugging diagnostic regarding that compiler's internals; it's about "hello.c".
stderr is not an instrumentation tool which goes away when we're not debugging the program.
From this [0] helpful StackOverflow post:
> If you need to transfer data and you want to be sure the data didn't get corrupted, the TCP checksum alone is certainly not enough for this task. I would even dare to say that a CRC checksum is not enough for this task, since a CRC32 may not detect an error where more than 32 bits in a row are affected (these errors can "cancel out" each other). The minimum checksum you'd need for ensuring flawless data transfer is the MD5 value of the data.
[0] https://stackoverflow.com/questions/3830206/can-a-tcp-checks...
I had nothing interesting to say about the new GDB release, but the checksum used surprised me. Hence the question.