From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 415 invoked by alias); 20 Jun 2010 09:13:06 -0000 Received: (qmail 407 invoked by uid 22791); 20 Jun 2010 09:13:05 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_DB,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-px0-f169.google.com (HELO mail-px0-f169.google.com) (209.85.212.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 20 Jun 2010 09:13:00 +0000 Received: by pxi14 with SMTP id 14so2847178pxi.0 for ; Sun, 20 Jun 2010 02:12:59 -0700 (PDT) Received: by 10.114.242.14 with SMTP id p14mr2648278wah.156.1277025179134; Sun, 20 Jun 2010 02:12:59 -0700 (PDT) Received: from [172.16.153.222] ([60.12.143.11]) by mx.google.com with ESMTPS id c14sm27013511waa.1.2010.06.20.02.12.54 (version=SSLv3 cipher=RC4-MD5); Sun, 20 Jun 2010 02:12:58 -0700 (PDT) Message-ID: <4C1DDBB0.9010202@gmail.com> Date: Sun, 20 Jun 2010 09:13:00 -0000 From: asmwarrior User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5 MIME-Version: 1.0 To: gdb@sourceware.org Subject: About the "info locals" command of gdb and python pretty printer Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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-06/txt/msg00080.txt.bz2 Hi, I have some problems to show some uninitialized local variables. For example, here is the test code: void test() { int aaaa = 1; int bbbb = 2; int cccc = 3; } int main() { test(); return 0; } Here, if I set a breakpoint at the first statement of the "test()", then run "info locals" command. gdb will plot all the information about both "aaaa, bbbb and cccc". Things becomes more complex when bbbb and cccc are not simple type, but instead, they are stl containers like vector or maps. like: void test() { int aaaa = 1; vector bbbb; mapcccc; } At this time, if we run the "info locals" with python stl pretty printer enabled, as you see, if you breakpoint is still at the first line "int aaa = 1;", then bbbb and cccc are not initialized, this may cause the python script to plot random values, some times, gdb or python will get crashed. A more detailed discussion can be found : http://sourceware.org/bugzilla/show_bug.cgi?id=11407 Also, this kind of problem is exist some other situations, In the QTCreator's manual: http://doc.qt.nokia.com/qtcreator-1.2/creator-debugging.html > The debug information provided by gcc does not include enough > information about the time when a variable is initialized. Therefore, > Qt Creator can not tell whether the contents of a local variable > contains "real data", or "initial noise". If a QObject appears > uninitialized, its value will be reported as "out of scope". However, > not all uninitialized objects can be recognized as such. I asked this kind of question on the GCC maillist, some one replies in this post: http://gcc.gnu.org/ml/gcc/2010-06/msg00633.html He suggest that we can use the GCC option: -fvar-tracking With this option, the variable location was recorded in the output file. I have just do a test on my first example code. (I tested under MinGW GCC 4.4.4) objdump -W MyTarget.exe >> log.txt will give all the debug information, like below: ----------------------------------- ... <1><5f>: Abbrev Number: 2 (DW_TAG_subprogram) <60> DW_AT_external : 1 <61> DW_AT_name : test <66> DW_AT_decl_file : 1 <67> DW_AT_decl_line : 1 <68> DW_AT_MIPS_linkage_name: _Z4testv <71> DW_AT_low_pc : 0x4013d0 <75> DW_AT_high_pc : 0x4013ed <79> DW_AT_frame_base : 0x0 (location list) <7d> DW_AT_sibling : <0xb9> <2><81>: Abbrev Number: 3 (DW_TAG_lexical_block) <82> DW_AT_low_pc : 0x4013d6 <86> DW_AT_high_pc : 0x4013eb <3><8a>: Abbrev Number: 4 (DW_TAG_variable) <8b> DW_AT_name : aaaa <90> DW_AT_decl_file : 1 <91> DW_AT_decl_line : 3 <92> DW_AT_type : <0xb9> <96> DW_AT_location : 2 byte block: 75 74 (DW_OP_breg5: -12) <3><99>: Abbrev Number: 4 (DW_TAG_variable) <9a> DW_AT_name : bbbb <9f> DW_AT_decl_file : 1 DW_AT_decl_line : 4 DW_AT_type : <0xb9> DW_AT_location : 2 byte block: 75 78 (DW_OP_breg5: -8) <3>: Abbrev Number: 4 (DW_TAG_variable) DW_AT_name : cccc DW_AT_decl_file : 1 DW_AT_decl_line : 5 DW_AT_type : <0xb9> DW_AT_location : 2 byte block: 75 7c (DW_OP_breg5: -4) <1>: Abbrev Number: 5 (DW_TAG_base_type) DW_AT_byte_size : 4 DW_AT_encoding : 5 (signed) DW_AT_name : int ... ---------------------------------------- So, you can see, there are some information about "DW_AT_decl_line", this information tells us that this variable is initialized after this line. So, I think if GCC can use this information, then we can nicely solved the "info locals" command problem. Any ideas? By the way, there are other ways to give the "DW_AT_start_scope" information about a variable, but Currently, GCC don't have this kind of debug information generated. See here: http://gcc.gnu.org/ml/gcc/2007-04/msg00138.html Thanks for reading my post. asmwarrior ollydbg from codeblocks' forum