3 ms·
Oh god, this brings me back (I used to be the C++ maintainer for GDB eons ago) It's even more convoluted than the author suspects, because 1. GDB has to figur
by DannyBee 9y ago
Oh god, this brings me back (I used to be the C++ maintainer for GDB eons ago)
It's even more convoluted than the author suspects, because
1. GDB has to figure out which function to call (it does overload resolution for C++, for example, and this varies by language)
2. GDB has to do type coercion on the arguments if necessary (ditto)
3. There are significant ABI and other issues, both at the processor level, and at the language level, in where the arguments go (registers or memory), in calling the right thunks, etc.
This is one reason LLDB uses clang to do most of the work of telling it what the expression you are trying to call actually means, so it can just pretty much execute it.
- barrkel 9y agoThe Delphi compiler used the constant expression folder to evaluate debugger expressions; it had hooks for converting symbol references into values, and for performing method calls, but a good chunk of the evaluation was interpreted that way. I thought it was a nifty reuse. (Obviously, the expression is parsed, typed and bound using the compiler front end using the same symbols as the compiled code, so that bit is easy.)
- DannyBee 9y agoYeah, that works nicely if you can do it. GDB unfortunately reimplements a hacked up C/C++ frontend. (For some other languages, it doesn't have to because they have dynamic expression evaluation interfaces as part of their runtimes)
- dguaraglia 9y agoPoint 1 gave me the chills and that was bad enough, but point 2 made me curl into fetal position. You are a brave soul.