bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need Quick Help on GDB crash (Did I do something wrong ?)


From: Chi-Cheong Weng
Subject: Need Quick Help on GDB crash (Did I do something wrong ?)
Date: Mon, 3 Sep 2001 11:20:09 -0700 (PDT)

Hi I was trying to see if I can invoke c functions within
GDB. But it crashed. I remembered I was able to do this
before.
Basically two files debug.c and test.cc
I set a break point at foo(1), then i try to
invoke prt by doing "p prt(1)". I expect it
to print 1 but the GDB crashed.
Did I do some thing wrong ?? If you know the answer, pls
reply to my email address asap. thank you,
address@hidden
Chi-Cheong

-------------------------------------
debug.c:
void prt(int k)
{
        printf("prt(int %d)\n",k);
}
-------------------------------------

#include <stdio.h>
extern void prt(int);
int foo(int i)
{
        int j;
        j = i;
        printf("integer = %d\n",j);
}

void main (int argc, char ** argv)
{
        foo(1);
}

---------------------------------------

Log:

:~> cat debug.c
void prt(int k)
{
        printf("prt(int %d)\n",k);
}
:~> cat test.cc
#include <stdio.h>
extern void prt(int);
int foo(int i)
{
        int j;
        j = i;
        printf("integer = %d\n",j);
}

void main (int argc, char ** argv)
{
        foo(1);
}
:~> gdb test
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 (sparc-sun-solaris2.5), Copyright 1996 Free Software Foundation, Inc...
(gdb) show version
3       int foo(int i)
4       {
5               int j;
6               j = i;
7               printf("integer = %d\n",j);
8       }
9       
10      void main (int argc, char ** argv)
11      {
12              foo(1);
(gdb) break 12
Breakpoint 1 at 0x109c8: file test.cc, line 12.
(gdb) r
Starting program: test 
warning: Unable to find dynamic linker breakpoint function.
warning: GDB will be unable to debug shared library initializers
warning: and track explicitly loaded dynamic code.

Breakpoint 1, main (argc=1, argv=0xeffffadc) at test.cc:12
12              foo(1);
(gdb) p prt(1)

Program received signal SIGSEGV, Segmentation fault.
<function called from gdb>
The program being debugged stopped while in a function called from GDB.
When the function (prt) is done executing, GDB will silently
stop (instead of continuing to evaluate the expression containing
the function call).
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
:~> exit
exit







reply via email to

[Prev in Thread] Current Thread [Next in Thread]