vgcore file should be changed, so gdb can directly display the thread that crashed. Reproducible: Always Steps to Reproduce: 1. Run crashing application 2. Run crashing application under valgrind 3. Open core and vgcore file in gdb and compare in which thread gdb is after start. Actual Results: For kernel coredump, gdb shows thread 1 and this is where the crash was. For vgcore this is not the crashing thread. Expected Results: vgcore should also show the crashing thread in gdb. Comparing output of gdb and "eu-readelf -n core": The first thread in the coredump is always the crashing one. Valgrind should be changed accordingly.
Created attachment 77323 [details] Refactor coredump writing of one thread: Extract function dump_one_thread
Created attachment 77324 [details] Move crashing thread to first position in coredump The attached patches change valgrind, so it writes the crashing thread first into the coredump.
Created attachment 86847 [details] Refactor coredump writing of one thread: Extract function dump_one_thread Update patches to apply to trunk, r13991
Created attachment 86848 [details] Move crashing thread to first position in coredump
Is there a reason not to commit this improvement? Btw. I don't know how to write a testcase for this.
So you say "the first thread in the coredump is always the crashing one" but in fact you seem to be forcing it to be written last? Is there some documentation somewhere that says how this should be done and how a debugger is supposed to know which is the faulting thread?
(In reply to Tom Hughes from comment #6) > So you say "the first thread in the coredump is always the crashing one" but > in fact you seem to be forcing it to be written last? Well, the code adds it last to the list, but it is written in the reverse order. Maybe I should add a comment to the code. > > Is there some documentation somewhere that says how this should be done and > how a debugger is supposed to know which is the faulting thread? For this question I only know how it behaves. I guess the gdb or binutils developers must know this. But there seem to be no real specification of how core-files are thought to be used.
(In reply to Matthias Schwarzott from comment #7) > > > Is there some documentation somewhere that says how this should be done and > > how a debugger is supposed to know which is the faulting thread? > For this question I only know how it behaves. > I guess the gdb or binutils developers must know this. > But there seem to be no real specification of how core-files are thought to > be used. From a usability point of view having the crashing thread listed first is a Good Thing IMHO.
Committed (with a couple of comments added) as r14181.