From: Jeff Odom <zeus@jhu.edu>
Subject: fix for gdb
Date: Sun, 1 Jun 1997 21:15:18 -0400 (EDT) [thread overview]
Message-ID: <f77e8c3a13d487b4c09e44ae94cc9e0d.axp-list@archive.invalid> (raw)
It seems that gdb still has a problem stepping over calls to malloc().
This is not isolated to only dynamic binaries, but includes static ones as
well. After spending a while tracing through the code, I found the
offending code. This segment, taken from the gdb-4.16axp.patch.gz, seems
to break calls to malloc():
diff -urN gdb-4.16/gdb/mdebugread.c gdb-4.16axp/gdb/mdebugread.c
--- gdb-4.16/gdb/mdebugread.c Sat Apr 6 02:09:55 1996
+++ gdb-4.16axp/gdb/mdebugread.c Wed May 22 19:17:06 1996
@@ -835,7 +835,23 @@
if (sh->sc == scUndefined || sh->sc == scNil)
t = mdebug_type_int;
else
- t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
+ {
+ t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
+ if (STREQ(name, "malloc") && t->code == TYPE_CODE_VOID)
+ {
+ /* I don't know why, but, at least under Linux/Alpha,
+ when linking against a malloc without debugging
+ symbols, its read as a function returning void---this
+ is bad because it means we cannot call functions with
+ string arguments interactively; i.e., "call
+ printf("howdy\n")" would fail with the error message
+ "program has no memory available". To avoid this, we
+ patch up the type and make it void*
+ instead. (davidm@azstarnet.com)
+ */
+ t = t->pointer_type;
+ }
+ }
b = top_stack->cur_block;
if (sh->st == stProc)
{
The problem that this code looks like it is trying to address is that gdb,
on Linux/Alpha, sees malloc() as returning a type void, instead of
(void *). In this code, t is a block with information about a type, and
t->pointer_type is a block with information about a pointer to that type.
I'm guessing that, in the case of t describing (void), t->pointer_type
should describe (void *). However, in the case of a void type,
t->pointer_type is always NULL.
I've removed this patch from the source build, and the resulting gdb seems
to work fine. However, I can't help but wonder if the problem that this
patch addressed has been resolved elsewhere, or if I'm just breaking some
other functionality.
Jeff Odom
System Administrator
The Johns Hopkins Kreiger Mind/Brain Institute
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
reply other threads:[~1997-06-02 1:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox