From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6151 invoked by alias); 2 Oct 2003 15:35:01 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 6144 invoked from network); 2 Oct 2003 15:35:00 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 2 Oct 2003 15:35:00 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h92FZ0111415 for ; Thu, 2 Oct 2003 11:35:00 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h92FZ0c30770 for ; Thu, 2 Oct 2003 11:35:00 -0400 Received: from localhost.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id h92FYxbe029154 for ; Thu, 2 Oct 2003 11:34:59 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id 413F02CCAA; Thu, 2 Oct 2003 11:45:17 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16252.18444.746262.239761@localhost.redhat.com> Date: Thu, 02 Oct 2003 15:35:00 -0000 To: Roul Oldenburger Cc: gdb@sources.redhat.com Subject: Re: gdb-internal: determining the type of a variable In-Reply-To: <3F7C1F5F.5030102@rheinmetall-de.com> References: <3F7C1F5F.5030102@rheinmetall-de.com> X-SW-Source: 2003-10/txt/msg00059.txt.bz2 Roul Oldenburger writes: > Hello everybody, > > I hope to find advice here although this might be a gcc or 'stabs > debuginformation format' related question. > > gdb can show lots of information for a variable or instance of a > structure type but I need to know where and how it gets it from. > > Our executables are compiled with at least stabs debuginformation and I > use 'objdump --stabs my_exe' to make use of it. > The aim is to reconstruct arbitrarily nested structure type descriptions > down to their final components. I try doing this by parsing objdump's > output. > > Given the full name of a structure type inlcuding the name of the > package where it is defined I will get the description of it. > If the components are from other structure types I can determine them > quit easily through the given typenumber/-identifier, but if the > components are from a traditional basic type or a self-defined basic > type I am not able to determine its type clearly. > > As an example I have the description of a structure 'sonar_description' > given in the package 'awu_siso_shared_memory': > > 73884 LSYM 0 0 00000000 1565985 > awu_siso_shared_memory__sonar_description:T(0,426)=s2500status:(0,123),0,8;\ > 73885 LSYM 0 0 00000000 1566062 > ref_count:(0,5),32,32;id:(0,7),64,32;transmit_method:(0,139),96,8;\ > 73886 LSYM 0 0 00000000 1566130 > transmit_power_level:(0,397),128,32;measuring_range:(0,382),160,384;\ > 73887 LSYM 0 0 00000000 1566200 > search_sector:(0,400),544,32;search_rotation:(0,148),576,8;\ > 73888 LSYM 0 0 00000000 1566261 > cw_pulse:(0,425),608,32;multi_number_of:(0,7),640,32;\ > 73889 LSYM 0 0 00000000 1566316 > multi_duration_of:(0,33),672,64;; > > The given information decribes the structure, but if I want to determine > of what type the component 'multi_duration_of' is (grep > ':t(0,33)=[r|@]'), I will get multiple possibilities - here are some: > > 210 LSYM 0 71 00000000 8722 > awu_common__debug_mode_range___XDLU_1__1:t(0,33)=@s8;r(0,27);1;1; > 371 LSYM 0 84 00000000 12939 > awu_common__types__nlink_t:t(0,33)=r(0,29);0;-1; > 441 LSYM 0 44 00000000 15165 > awu_common__stdio__TTstringS2bP1___XDLU_1__71:t(0,33)=r(0,1);1;71; > 6592 LSYM 0 120 00000000 184371 > system__address:t(0,33)=r(0,33);0;-1; > 19690 LSYM 0 109 00000000 425771 > duration___XF_1_1000000000:t(0,33)=@s64;r(0,33);01000000000000000000000;0777777777777777777777; > 180473 LSYM 0 120 00000000 184371 > 122185 LSYM 0 100 00000000 2948958 > system__secondary_stack__Tmark_idB:t(0,33)=r(0,33);0;-1; > 6835 LSYM 0 81 00000000 75724 > awu_common__ipc__Tipc_permissionB:t(0,33)=r(0,33);-2147483648;2147483647; > > > In fact the type is duration, but my problem is to distinguish between > the different possibilities ... so looking for the typenumber alone is > not enough. > > How does gdb does it?? I see that Ian answered your questions on the binutils list. As far as how gdb does it, look at stabsread.c, there is a big switch statement that handles the cases. elena > > What am I doing wrong? > > Probably looking at stabs does not give the right information to do > this; or do i misinterpret stabs format? > > Thanks for any comments and help! > > Roul Oldenburger