From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30721 invoked by alias); 16 Jul 2010 18:58:25 -0000 Received: (qmail 30711 invoked by uid 22791); 16 Jul 2010 18:58:25 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-gx0-f169.google.com (HELO mail-gx0-f169.google.com) (209.85.161.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Jul 2010 18:58:20 +0000 Received: by gxk4 with SMTP id 4so1813793gxk.0 for ; Fri, 16 Jul 2010 11:58:18 -0700 (PDT) Received: by 10.101.173.23 with SMTP id a23mr1772507anp.47.1279306697825; Fri, 16 Jul 2010 11:58:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.19.10 with HTTP; Fri, 16 Jul 2010 11:57:57 -0700 (PDT) In-Reply-To: References: From: =?UTF-8?B?UGV0ciBIbHV6w61u?= Date: Fri, 16 Jul 2010 18:58:00 -0000 Message-ID: Subject: Re: Debugging variable arguments functions (stdarg) To: G Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00062.txt.bz2 On 15 July 2010 17:47, G wrote: > Hello, > > How can I look at the values of "..." in a function which can > take a variable number of arguments (i.e. uses va_start(), > va_end() etc.) in gdb? There is no nice way to do that. GCC does not record the actual types used in a call site of a variadic function, e.g. what is on the call-site of WriteLog(int,int,char*,...) in MysqlWrapper. Workaround A: Alter source code of the caller to: const char * msg = mysql_error(sql_handle) WriteLog(stuff1,stuff1,stuff3, query, msg); and hope the compiler does not optimize the local variable. Workaround B: Get value of stack pointer (RSP?) of frame MysqlWrapper() and dump raw memory around the address. You should see these values somewhere around: 0x00000000004041e2 (return address in MysqlWrapper) 0x406bf0 (the third argument to WriteLog) Between these two values should be the values of 3rd and 4th argument. (You have to cast them to char*.) -- Petr Hluzin