Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How is this better than just attaching GDB?


1. You can enter arbitrarily C++ code (gdb can only call some functions, it cannot even instantiate c++ classes) 2. Variables in Inspector's scope are never optimized away by the compiler 3. You can use it with default optimizations flags (In gdb you often want `-O0 -g`)


1. GDB can instantiate classes, but it's a bit wonky, I agree. You have to evaluate malloc manually and then cast the pointer to the right type and call the constructor. You can write python scripts to automate this.

2. That's good.

3. You can generally compile with -Og -g for faster execution while preserving enough of the program's structure to make sense of what's happening.

I can see how it can be useful though. Do you have to prebuild every cpp file, or just the one you put "#include INSPECTOR" in? Can you include inspector in more than one file?


You only need to prebuild files, where the include statement is included. Ideally this task would be also automatically done in future by sneaking into the build system.


On some university projects (to be delivered in C), as part of my edit-compile-debug loop, I was usually writing additional functions just to navigate the data structures using the GDB expression evaluator.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: