From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29804 invoked by alias); 19 Sep 2009 11:52:05 -0000 Received: (qmail 29794 invoked by uid 22791); 19 Sep 2009 11:52:04 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_34,J_CHICKENPOX_44,J_CHICKENPOX_45,SPF_HELO_NEUTRAL X-Spam-Check-By: sourceware.org Received: from gate.lvk.cs.msu.su (HELO lvk.cs.msu.su) (158.250.17.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Sep 2009 11:51:59 +0000 Received: from desktopvm.lvknet ([192.168.132.1] helo=wind.localnet) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.63) (envelope-from ) id 1MoyTp-0007HS-QK; Sat, 19 Sep 2009 15:51:53 +0400 From: Vladimir Prus To: gdb@sources.redhat.com Subject: Symbols/blocks questions Date: Sat, 19 Sep 2009 11:52:00 -0000 User-Agent: KMail/1.11.90 (Linux/2.6.24-24-generic; KDE/4.2.90; i686; svn-979530; 2009-06-10) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200909191552.02677.ghost@cs.msu.su> 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: 2009-09/txt/msg00231.txt.bz2 I am trying to port some MI improvement from the Apple GDB, and got some questions about symbol/block handling. I'd appreciate if somebody comment on it. 1. Given 'struct block *b', is it true that block_for_pc (b.startaddr) == b ? 2. Uness I am mistaken, in case of lines inside templates, inline functions, and constructors, decode_line_1 returns just one sal. (And breakpoint.c explicitly expands thsoe in expand_line_sal). In what cases will decode_line_1 actually return multiple sals? For overloaded functions? Anything else? Would it be sensible, eventually, to make decode_line_1 return all locations corresponding to file:line? 3. The code below, from Apple GDB, first calls decode_line_1 and then checks, for each sal, if the line passed to decode_line_1 is less then sal.line. How could this happen at all? I though that if I ask decode_line_1 for line 10, then either it returns sals for line 10, or it returns no sal at all. (For context, the purpose of the code is, given file:line, to find block in which variables should be looked up and evaluated, for -var-create) Thanks, Volodya TRY_CATCH (except, RETURN_MASK_ALL) { /* The variable 's' will be advanced by decode_line_1. */ char *s = block_addr; sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL, NULL); } if (except.reason >= 0 && sals.nelts >= 1) { old_chain = make_cleanup (xfree, sals.sals); /* Default to global scope unless we find a better match. */ var_type = NO_FRAME_NEEDED; block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (sals.sals[0].symtab), GLOBAL_BLOCK); unsigned long line = 0; char *line_number_str = colon + 1; if (strlen (line_number_str) > 0) line = strtoul (line_number_str, NULL, 0); /* Get the currently selected frame for reference. */ struct frame_info *selected_frame = get_selected_frame (NULL); if (selected_frame) { unsigned i; struct symbol *func_sym; func_sym = get_frame_function (selected_frame); if (func_sym) /* Iterate through all symtab_and_line structures returned and find the one that has the same function symbol as our frame. */ for (i = 0; i < sals.nelts; i++) { struct symbol *sal_sym = find_pc_sect_function (sals.sals[i].pc, sals.sals[i].section); if (func_sym == sal_sym) { /* If the requested line is less than the line found in the matching symtab_and_line struct then we must use a global or static as the scope since it doesn't fall within the symtab_and_line struct that was returned. */ if (line && line < sal_sym->line) { /* Use a global scope. */ var_type = NO_FRAME_NEEDED; block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (sals.sals[i].symtab), GLOBAL_BLOCK); } else { /* We got a valid block match. */ var_type = USE_BLOCK_IN_FRAME; block = block_for_pc (sals.sals[i].pc); break; } } } } }