Ok, by single-stepping on malloc I didn't mean that I wanted to single-
step into the function, but simply over it (not "step" but "next" in gdb).
Watch this:
--------------------------------- malloc_gdb.c -------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
{
int num;
char *str;
if (argc < 2)
return (0);
if (!strcmp ("asdf", argv[1]))
printf ("asdf\n");
num = strlen (argv[1]);
str = (char *) malloc (num);
strcpy (str, argv[1]);
printf ("String: %s\n", str);
free (str);
return (0);
}
------------------------------ At the shellprompt ----------------------------
ajo@wopr ~/src/test >gcc -static -g -o malloc_gdb malloc_gdb.c
ajo@wopr ~/src/test >gdb malloc_gdb
GDB is free software and you are welcome to 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.
GDB 4.16 (alpha-unknown-linux), Copyright 1996 Free Software Foundation, Inc...
(gdb) break main
Breakpoint 1 at 0x1200005e8: file malloc_gdb.c, line 10.
(gdb) run asdfkasld
Starting program: /home/ajo/src/test/malloc_gdb asdfkasld
Breakpoint 1, main () at malloc_gdb.c:10
10 if (argc < 2)
(gdb) next
13 if (!strcmp ("asdf", argv[1]))
(gdb)
16 num = strlen (argv[1]);
(gdb)
18 str = (char *) malloc (num);
(gdb)
Segmentation fault (core dumped)
Exit 139
ajo@wopr ~/src/test >gdb /usr/bin/gdb core
GDB is free software and you are welcome to 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.
GDB 4.16 (alpha-unknown-linux), Copyright 1996 Free Software Foundation, Inc...
(no debugging symbols found)...
Core was generated by gdb malloc_gdb'.
Program terminated with signal 11, Segmentation fault.
#0 0x12005e8ec in make_function_type ()
(gdb) bt
#0 0x12005e8ec in make_function_type ()
#1 0x12005e988 in lookup_function_type ()
#2 0x1200ac7c8 in mdebug_build_psymtabs ()
#3 0x1200b1c70 in ecoff_relocate_efi ()
#4 0x1200bca28 in xmmalloc ()
#5 0x1200d0450 in bfd_find_target ()
warning: Hit beginning of text section without finding
warning: enclosing function for address 0x11ffff520
This warning occurs if you are debugging a function without any symbols
(for example, in a stripped executable). In that case, you may wish to
increase the size of the search with the set heuristic-fence-post' command.
Otherwise, you told GDB there was a function where there isn't one, or
(more likely) you have encountered a bug in GDB.
(gdb)
------------------------------------------------------------------------------
As you can see strcmp and strlen works quite ok, but malloc makes gdb
coredump. Curiously enough this only happends on statically linked elf-
binaries, but on the other hand, those are often much more practical to
debug.
--<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> : E-mail: ajo@wopr.campus.luth.se : : S-mail: Andreas Johansson, Karhusvagen 5 6:618, 977 54 Lulea, SWEDEN : : Have you had your dose of 261.62 BogoMIPS today? - Run Alpha! : <-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=->
-- To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null
Copyright © 1995-1997 Red Hat Software. Legal notices