* gdb and core files revisited
@ 1999-04-10 18:08 Jack Wathey
1999-04-12 4:11 ` Mikolaj J. Habryn
0 siblings, 1 reply; 4+ messages in thread
From: Jack Wathey @ 1999-04-10 18:08 UTC (permalink / raw)
To: axp-list
Dear fellow Alpha-Linux folks,
Back in January 1998, when I was using RedHat 4.2, I posted to this
list a trivial C program to demonstrate that gdb did not understand
an elf core file generated on an Alpha, although it worked fine on
a Pentium machine.
I had hoped that by now some brilliant and benevolent soul would have
fixed this, but after upgrading to RedHat 5.2 and a 2.2 kernel, I find
that gdb is still broken in this way. Yes, I know that gdb works if you
run the crashing program from within gdb and wait for it to re-encounter
the offending code, and this is how I've managed to survive for the last
year. But I write some fairly substantial stochastic simulations that
run for days. If a program like that crashes because of some insidious
bug that chokes on a rare set of circumstances, after running for many
hours or even days, then it is a major pain to rerun it for that length
of time under gdb just to find out where the crash occurred.
Is it really asking too much to have a debugger that can read and
understand a core file?
I've spent about 3 days digging through the internals of gdb, trying
to fix this, but it is just beyond my meager brain. Has anyone,
anywhere (possibly Debian types?), managed to get gdb to work with
a core file on an Alpha Linux machine running a 2.2 kernel? If so,
please tell me how.
If not, I'd be grateful for suggestions as to who (gdb maintainers,
kernel developers, others?) is most likely to be able to fix this
problem, so that I can make some kind of official bug report to them.
TIA,
Jack
My little test program follows:
---------------------- start Makefile ------------------------------
CFLAGS = -g
crash:
------------------------ end Makefile ------------------------------
---------------------- start crash.c -------------------------------
main() {
int i;
int *p_int = 0;
i = *p_int;
return( 0 );
}
------------------------ end crash.c -------------------------------
To run it, create the files Makefile and crash.c by snipping out the
text as shown. Then type "make", and "crash". The program "crash"
will do exactly that, dumping a core file in the process. [You may need
first to do something like "limit coredumpsize 10m", if your
coredumpsize is limited to 0 by default.]
If I do this experiment on my Alpha and then run "gdb crash core",
I get this:
GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "alpha-redhat-linux"...
Core was generated by `crash'.
Couldn't fetch registers from core file: File in wrong format
Couldn't fetch register set 2 from core file: File in wrong format
Reading symbols from /lib/libc.so.6.1...done.
Reading symbols from /lib/ld-linux.so.2...done.
Couldn't fetch registers from core file: File in wrong format
Couldn't fetch register set 2 from core file: File in wrong format
#0 0x0 in ?? ()
(gdb)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gdb and core files revisited
1999-04-10 18:08 gdb and core files revisited Jack Wathey
@ 1999-04-12 4:11 ` Mikolaj J. Habryn
1999-04-14 8:01 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Mikolaj J. Habryn @ 1999-04-12 4:11 UTC (permalink / raw)
To: axp-list
>>>>> "JW" == Jack Wathey <wathey@salk.edu> writes:
JW> I've spent about 3 days digging through the internals of gdb,
JW> trying to fix this, but it is just beyond my meager brain.
JW> Has anyone, anywhere (possibly Debian types?), managed to get
JW> gdb to work with a core file on an Alpha Linux machine running
JW> a 2.2 kernel? If so, please tell me how.
Yes, but this was quite a while ago. I didn't propagate the patch
beyond the debian list since it was embarrassingly crude. It also
didn't get much testing, since this was the heyday of the
register_frame_info confusion. Anyhow - it think it might have used to
work for me (maybe).
m.
PS: as an addendum, someone (rth?) posted a guide to solving this. I
can't remember what it was, but I couldn't work out how to do it
without making a lot more deltas than this.
diff -Nru gdb-orig/bfd/elf.c gdb-4.17.19981224/bfd/elf.c
--- gdb-orig/bfd/elf.c Mon Dec 7 08:33:14 1998
+++ gdb-4.17.19981224/bfd/elf.c Mon Jan 18 10:58:52 1999
@@ -4839,6 +4839,28 @@
*/
#if defined (HAVE_PRSTATUS_T)
+struct newtimeval {
+ long tv_sec;
+ long tv_usec;
+};
+
+struct newprstat {
+ struct elf_siginfo pr_info; /* Info associated with signal */
+ short pr_cursig; /* Current signal */
+ unsigned long pr_sigpend; /* Set of pending signals */
+ unsigned long pr_sighold; /* Set of held signals */
+ pid_t pr_pid;
+ pid_t pr_ppid;
+ pid_t pr_pgrp;
+ pid_t pr_sid;
+ struct newtimeval pr_utime; /* User time */
+ struct newtimeval pr_stime; /* System time */
+ struct newtimeval pr_cutime; /* Cumulative user time */
+ struct newtimeval pr_cstime; /* Cumulative system time */
+ elf_gregset_t pr_reg; /* GP registers */
+ int pr_fpvalid; /* True if math co-processor being used. */
+};
+
static boolean
elfcore_grok_prstatus (abfd, note)
bfd* abfd;
@@ -4850,9 +4872,35 @@
asection* sect;
if (note->descsz != sizeof (prstat))
+#ifdef alpha
+ if(note->descsz == sizeof(struct newprstat)) {
+ prstat.pr_info = ((struct newprstat *)note->descdata)->pr_info;
+ prstat.pr_cursig = ((struct newprstat *)note->descdata)->pr_cursig;
+ prstat.pr_sigpend = ((struct newprstat *)note->descdata)->pr_sigpend;
+ prstat.pr_sighold = ((struct newprstat *)note->descdata)->pr_sighold;
+ prstat.pr_pid = ((struct newprstat *)note->descdata)->pr_pid;
+ prstat.pr_ppid = ((struct newprstat *)note->descdata)->pr_ppid;
+ prstat.pr_pgrp = ((struct newprstat *)note->descdata)->pr_pgrp;
+ prstat.pr_sid = ((struct newprstat *)note->descdata)->pr_sid;
+ prstat.pr_utime.tv_sec = ((struct newprstat *)note->descdata)->pr_utime.tv_sec;
+ prstat.pr_utime.tv_usec = ((struct newprstat *)note->descdata)->pr_utime.tv_usec;
+ prstat.pr_stime.tv_sec = ((struct newprstat *)note->descdata)->pr_stime.tv_sec;
+ prstat.pr_stime.tv_usec = ((struct newprstat *)note->descdata)->pr_stime.tv_usec;
+ prstat.pr_cutime.tv_sec = ((struct newprstat *)note->descdata)->pr_cutime.tv_sec;
+ prstat.pr_cutime.tv_usec = ((struct newprstat *)note->descdata)->pr_cutime.tv_usec;
+ prstat.pr_cstime.tv_sec = ((struct newprstat *)note->descdata)->pr_cstime.tv_sec;
+ prstat.pr_cstime.tv_usec = ((struct newprstat *)note->descdata)->pr_cstime.tv_usec;
+ memcpy(&prstat.pr_reg, &((struct newprstat *)note->descdata)->pr_reg,
+ sizeof(elf_gregset_t));
+ prstat.pr_fpvalid = ((struct newprstat *)note->descdata)->pr_fpvalid;
+ } else {
+ return true;
+ }
+#else
return true;
memcpy (&prstat, note->descdata, sizeof (prstat));
+#endif
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
elf_tdata (abfd)->core_pid = prstat.pr_pid;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gdb and core files revisited
1999-04-12 4:11 ` Mikolaj J. Habryn
@ 1999-04-14 8:01 ` Richard Henderson
1999-04-14 8:47 ` Mikolaj J. Habryn
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 1999-04-14 8:01 UTC (permalink / raw)
To: axp-list
On Mon, Apr 12, 1999 at 12:11:21PM +0800, Mikolaj J. Habryn wrote:
> Yes, but this was quite a while ago. I didn't propagate the patch
> beyond the debian list since it was embarrassingly crude.
This is the correct fix in essence, but for it to actually be
applied to anything, you'd have to play games with the BFD
vectors to abstract this out so that there's no ifdef. You'd
also get a chance to recognize 2.0 and 2.2 core files in the
same binary.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gdb and core files revisited
1999-04-14 8:01 ` Richard Henderson
@ 1999-04-14 8:47 ` Mikolaj J. Habryn
0 siblings, 0 replies; 4+ messages in thread
From: Mikolaj J. Habryn @ 1999-04-14 8:47 UTC (permalink / raw)
To: axp-list
>>>>> "RH" == Richard Henderson <rth@twiddle.net> writes:
RH> This is the correct fix in essence, but for it to actually be
RH> applied to anything, you'd have to play games with the BFD
RH> vectors to abstract this out so that there's no ifdef. You'd
RH> also get a chance to recognize 2.0 and 2.2 core files in the
RH> same binary.
That was what I started out intending to do, but this is deep inside
a chain of static functions, so it wasn't immediately apparent where
it should hook in without a large amount of code duplication. What did
I miss?
m.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-04-14 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-04-10 18:08 gdb and core files revisited Jack Wathey
1999-04-12 4:11 ` Mikolaj J. Habryn
1999-04-14 8:01 ` Richard Henderson
1999-04-14 8:47 ` Mikolaj J. Habryn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox