From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5564 invoked by alias); 16 Sep 2003 19:21:00 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 5557 invoked from network); 16 Sep 2003 19:21:00 -0000 Received: from unknown (HELO mail-srv2.micron.com) (137.201.242.130) by sources.redhat.com with SMTP; 16 Sep 2003 19:21:00 -0000 Received: from mail-srv2.micron.com (localhost [127.0.0.1]) by mail-srv2.micron.com (8.12.9/8.12.2) with ESMTP id h8GJL16b003649 for ; Tue, 16 Sep 2003 13:21:01 -0600 (MDT) Received: from ntxboimbx07.micron.com (ntxboimbx07.micron.com [137.201.80.94]) by mail-srv2.micron.com (8.12.9/8.12.2) with ESMTP id h8GJKxcW003600; Tue, 16 Sep 2003 13:20:59 -0600 (MDT) From: lrtaylor@micron.com X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: Regarding gcc debugging Date: Tue, 16 Sep 2003 19:21:00 -0000 Message-ID: <363801FFD7B74240A329CEC3F7FE4CC4A275DE@ntxboimbx07.micron.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: To: , X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-SW-Source: 2003-09/txt/msg00197.txt.bz2 Could it be because Sm_UnInit is getting called twice: once in your main ro= utine by you, and then again in the object's destructor? If Sm_UnInit is d= oing some cleanup work, and then tries to do it again, the structures it is= trying to clean up the second time would not longer be valid, and could ca= use a core dump. It seems to me that if you are calling in it the destruct= or, you probably shouldn't also be calling it directly in your "main" routi= ne. (That said, you'll know the API that you're working with - this is jus= t a thought...) Thanks, Lyle Taylor -----Original Message----- From: puneet girdhar [mailto:girdhar_puneet@yahoo.com] Sent: Tuesday, September 16, 2003 12:45 PM To: gcc-help@gcc.gnu.org Subject: Regarding gcc debugging Hi, I am trying to debug a C++ program with gdb on Linux AS 2.1. when the program terminates,the destructor is called and this destructor in turn calls the un-initializer routine.After the Un-inilization routine is over it does not give core dump.But then it goes in main and gives core dump. ***************source code starts*********** void SmAgentExample::Sm_UnInit( ) { int iResult; printf("Value of pSmApiHandle inside Sm_UnInit is %x\n",pSmApiHandle); if ( NULL !=3D pSmApiHandle ) { Sm_Logout(); // // UnInitialize the Agent API // // Return values: // SM_AGENTAPI_SUCCESS // SM_AGENTAPI_FAILURE // SM_AGENTAPI_NOCONNECTION iResult =3D Sm_AgentApi_UnInit( &pSmApiHandle ); if (SM_AGENTAPI_SUCCESS=3D=3DiResult) printf ( "Agent Released\n" ); else if (SM_AGENTAPI_FAILURE=3D=3DiResult) printf ( "UnInitialzation Failed\n" ); else if (SM_AGENTAPI_NOCONNECTION=3D=3DiResult) printf ( "Timeout for server response!\n" ); } printf("I am here\n"); login =3D 0; } SmAgentExample::~SmAgentExample() { pSmApiHandle =3D NULL; printf("Inside destructor\n"); Sm_AgentApi_FreeAttributes(iNumAttributes, pAttributes); printf("Before Sm_UnInit function\n"); Sm_UnInit( ); } int main() { ..... ..... while{ switch(input) case 'q' : break; ....... } a.Sm_UnInit( ); printf ( "Done, thank you for Testing the API.\n" ); return 0; } **************source code ends*********** -------------output of gdb--------- FTP> q Breakpoint 1, SmAgentExample::Sm_UnInit() (this=3D0x1) at smagentexample.cpp:220 220 { (gdb) s 0x0804a601 in main () (gdb) s Single stepping until exit from function main, which has no line number information. Value of pSmApiHandle inside Sm_UnInit is 8052728 Agent Released I am here Done, thank you for Testing the API. Inside destructor Before Sm_UnInit function Breakpoint 1, SmAgentExample::Sm_UnInit() (this=3D0xbffe5a50) at smagentexample.cpp:220 220 { (gdb) s 0x0804a601 in main () (gdb) s Single stepping until exit from function main, which has no line number information. Value of pSmApiHandle inside Sm_UnInit is 0 I am here Breakpoint 3, main () at smagentexample.cpp:778 778 } (gdb) s 0x4021a727 in __libc_start_main () from /lib/libc.so.6 (gdb) s Single stepping until exit from function __libc_start_main, which has no line number information. Program received signal SIGSEGV, Segmentation fault. 0x403c7112 in ?? (). When i gave bt command it gave: (gdb) bt #0 0x403c7112 in ?? () #1 0x4021a730 in __libc_start_main () from /lib/libc.so.6 -------------output of gdb--------------------- Can anybody give any ptrs on this that why it is dumping core. Thanks in advance. Regards Puneet ________________________________________________________________________ Yahoo! India Matrimony: Find your partner online. Go to http://yahoo.shaadi.com