Log in

No account? Create an account
'Twas brillig, and the slithy toves did gyre and gimble in the wabe [entries|archive|friends|userinfo]

[ website | Beware the Jabberwock... ]
[ deviantArt | the-boggyb ]
[ FanFiction | Torkell ]
[ Tumblr | torkellr ]

[Random links| BBC news | Vulture Central | Slashdot | Dangerous Prototypes | LWN | Raspberry Pi]
[Fellow blogs| a Half Empty Glass | the Broken Cube | The Music Jungle | Please remove your feet | A letter from home]
[Other haunts| Un4seen Developments | Jazz 2 Online | EmuTalk.net | Feng's shui]

gdb fail [Friday 11th September 2009 at 8:07 pm]

[Tags|, , ]
[Where |Chichester station]
[Playing |Walled City internet radio]

It never ceases to amaze me just how backward the Linux development environment is.

Today I attempted to debug a test program that segfaults about 5 minutes after startup for no apparent reason. I managed to get a core dump of it, and loaded it into gdb in the hope of finding what was going on. Hahaha.

gdb could give me a valid stack trace showing the error, and could disassemble the program around the error to show me the actual instructions involved. However, gdb could not tell me the value of all the variables there (it claimed that some variables weren't even defined, nevermind that the program uses them all over the place!), nor could it actually match the disassembly up to the source.

Come on, folks, Visual C++ has been able to do this for decades! The Windows debugging tools are so far ahead it's embarassing for Linux.

I did actually discover a patch to gdb to achieve this, submitted April last year. Unfortuantly it's not in the latest released version of gdb (released March last year), and I really don't fancy building gdb from source myself.
Link | Previous Entry | Share | Flag | Next Entry[ 4 pennies | Penny for your thoughts? ]

[User Picture]From: 13th_einherjar
Friday 11th September 2009 at 8:06 pm (UTC)
I wonder if this is at all related to any of the randomization techniques applied a while ago to make buffer overflows fail most of the time. In that it's supposed to be non-trivial to figure out how all of the variables are laid out in memory, because that way hackers can't write 8 bytes to 4 byte int a and know that the next 4 bytes are definitely going to int b. Probably no relation.

I find this strange, because one of my first reasons for switching to Linux was the ease of compiling and developing software. Back then, Linux systems still assumed you wanted to compile something, so the toolchain was already installed and pretty well standardized. And Windows offered 2 options a) pay thousands of dollars to have your IDE installed for you b) spend several days groping through undocumented system calls and crippleware compiler toolchains to write "Hello World" in the language and library of choice.
(Reply) (Thread)
[User Picture]From: boggyb
Monday 14th September 2009 at 8:02 pm (UTC)
Nope, the lack of variable names turned out to be mainly due to optimisation. I say mainly - even after removing "-O2" from the compiler flags it still wouldn't reliably show the variables, possibly because some were declared in blocks within functions (as opposed to being at function scope).
(Reply) (Parent) (Thread)