From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9269 invoked by alias); 2 Nov 2005 06:11:14 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 9260 invoked by uid 22791); 2 Nov 2005 06:11:11 -0000 Received: from nat1.alcatel-sbell.com.cn (HELO mail.alcatel-sbell.com.cn) (202.96.203.177) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 02 Nov 2005 06:11:11 +0000 Received: from asbmail4.sbell.com.cn (localhost [127.0.0.1]) by mail.alcatel-sbell.com.cn (8.12.11/8.12.11/Alcanet1.0) with ESMTP id jA267stc018977 for ; Wed, 2 Nov 2005 14:08:01 +0800 Received: from htmail.sbell.com.cn ([172.24.222.40]) by asbmail4.sbell.com.cn with Microsoft SMTPSVC(5.0.2195.6713); Wed, 2 Nov 2005 14:08:44 +0800 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: quoted-printable Subject: Why are NOT the function parametters in the stack. They are in the register! Date: Wed, 02 Nov 2005 06:11:00 -0000 Message-ID: <7E98B33B3500C0409DBEC5C0E3FDEF120230B583@htmail.sbell.com.cn> From: "MCG LU Fengcheng" To: X-imss-version: 2.033 X-imss-result: Passed X-imss-approveListMatch: *@alcatel-sbell.com.cn X-SW-Source: 2005-11/txt/msg00022.txt.bz2 Hello all In my program, I have a confused problem. Any helps are welcome! I have the following function with variable parameters void PrintTrace(char* fileName, int lineNo, char* traceType, char* fmt= ,...) { va_list args; char buf[MX_SIZE]; ........................................................... va_start(args,fmt); vsnprintf(buf,MX_SIZE,fmt,args); va_end(args); .............................................................. } Sometimes, program crash when PrintTrace is called. I use the gdb to an= alyze the problem. root@aaa-n3s30#gdb a.out core.1462=20 GNU gdb 6.1.1 ....................................... Core was generated by `/home/lfc/a.out'. Program terminated with signal 11, Segmentation fault. ..................................................... #0 0x4013641b in vfprintf () from /lib/libc.so.6=20=20 Then I run the bt, get the output: (gdb) bt #0 0x4013641b in vfprintf () from /lib/libc.so.6 #1 0x40154b7c in vsnprintf () from /lib/libc.so.6 #2 0x40079316 in PrintTrace (fileName=3D0x400a07a0 "/home/lfc/test.c",= lineNo=3D340, traceType=3D0x0, fmt=3D0x0) at test.c:248 #3 0x400934d2 in CmwInit (vceId=3D1003) at /home/lfc/test.c:340 #4 0x08049281 in main (argc=3D1, argv=3D0xbffff954) at test.c:463=20=20 In the PrintTrace, traceType and fmt are both NULL. It's impossible. I = always give the valid pointer for the traceType and fmt. I run f 2 and try to print the traceType and fmt address.=20 (gdb) f 2 #2 0x40079316 in PrintTrace (fileName=3D0x400a07a0 "/home/lfc/test.c",= lineNo=3D340, traceType=3D0x0, fmt=3D0x0) at test.c:248 (gdb) p &traceType Address requested for identifier "traceType" which is in register $eax (gdb) p &fmt Address requested for identifier "fmt" which is in register $eax=20=20 gdb complains fmt and traceType are in the register eax. Why not in th= e stack. In fact, lineNo and filename are in the stack. Gdb can print their= address out. I check the eax value. It is zero. I also check the stack. I found the= fmt and traceType address were in the stack. It's the gdb issue? I can't understand it. Help me!!!!!!!!!!!!!!!!!! B.R. Lu