Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* fix for gdb
@ 1997-06-02  1:15 Jeff Odom
  0 siblings, 0 replies; only message in thread
From: Jeff Odom @ 1997-06-02  1:15 UTC (permalink / 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-06-02  1:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-06-02  1:15 fix for gdb Jeff Odom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox