From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3751 invoked by alias); 13 Jul 2010 15:08:12 -0000 Received: (qmail 3733 invoked by uid 22791); 13 Jul 2010 15:08:10 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,TW_DL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Jul 2010 15:07:36 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6DF7Y5N030862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 Jul 2010 11:07:35 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6DF7XBO029020; Tue, 13 Jul 2010 11:07:34 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o6DF7W46012783; Tue, 13 Jul 2010 11:07:33 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 832ED3782A3; Tue, 13 Jul 2010 09:07:32 -0600 (MDT) From: Tom Tromey To: Jan Kratochvil Cc: gdb-patches@sourceware.org Subject: Re: RFC: fix bug when debugging prelink'd library References: <20100712194738.GA6846@host0.dyn.jankratochvil.net> <20100712212207.GA12165@host0.dyn.jankratochvil.net> Date: Tue, 13 Jul 2010 15:08:00 -0000 In-Reply-To: <20100712212207.GA12165@host0.dyn.jankratochvil.net> (Jan Kratochvil's message of "Mon, 12 Jul 2010 23:22:07 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00220.txt.bz2 Jan> Yes, I like the patch this way. Great. Jan> The same comment needs to be updated at the function definition in Jan> dwarf2read.c. [...] Jan> Suggesting to extend the comment: [...] Here is what I am checking in. Tom 2010-07-13 Tom Tromey * dwarf2loc.h (dwarf2_per_cu_text_offset): Declare. * dwarf2loc.c (find_location_expression): Use dwarf2_per_cu_text_offset. (dwarf2_evaluate_loc_desc): Likewise. (dwarf2_loc_desc_needs_frame): Likewise. (compile_dwarf_to_ax): Likewise. (loclist_describe_location): Likewise. * dwarf2read.c (dwarf2_per_cu_text_offset): New function. (dwarf2_per_cu_objfile): Update comment. diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 4106b7f..2a8e557 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -70,8 +70,7 @@ find_location_expression (struct dwarf2_loclist_baton *baton, int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd); CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); /* Adjust base_address for relocatable objects. */ - CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + CORE_ADDR base_offset = dwarf2_per_cu_text_offset (baton->per_cu); CORE_ADDR base_address = baton->base_address + base_offset; loc_ptr = baton->data; @@ -909,7 +908,7 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, ctx->gdbarch = get_objfile_arch (objfile); ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); - ctx->offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + ctx->offset = dwarf2_per_cu_text_offset (per_cu); ctx->baton = &baton; ctx->read_reg = dwarf_expr_read_reg; ctx->read_mem = dwarf_expr_read_mem; @@ -1095,7 +1094,7 @@ dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size, ctx->gdbarch = get_objfile_arch (objfile); ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); - ctx->offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + ctx->offset = dwarf2_per_cu_text_offset (per_cu); ctx->baton = &baton; ctx->read_reg = needs_frame_read_reg; ctx->read_mem = needs_frame_read_mem; @@ -1304,12 +1303,7 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc, index, not an address. We don't support things like branching between the address and the TLS op. */ if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address) - { - struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); - - uoffset += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); - } + uoffset += dwarf2_per_cu_text_offset (per_cu); ax_const_l (expr, uoffset); break; @@ -2511,8 +2505,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd); CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); /* Adjust base_address for relocatable objects. */ - CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + CORE_ADDR base_offset = dwarf2_per_cu_text_offset (dlbaton->per_cu); CORE_ADDR base_address = dlbaton->base_address + base_offset; loc_ptr = dlbaton->data; diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h index 3ff595e..826bc45 100644 --- a/gdb/dwarf2loc.h +++ b/gdb/dwarf2loc.h @@ -28,7 +28,9 @@ struct dwarf2_per_cu_data; /* This header is private to the DWARF-2 reader. It is shared between dwarf2read.c and dwarf2loc.c. */ -/* Return the OBJFILE associated with the compilation unit CU. */ +/* Return the OBJFILE associated with the compilation unit CU. If CU + came from a separate debuginfo file, then the master objfile is + returned. */ struct objfile *dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *cu); /* Return the address size given in the compilation unit header for CU. */ @@ -37,6 +39,12 @@ CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu); /* Return the offset size given in the compilation unit header for CU. */ int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu); +/* Return the text offset of the CU. The returned offset comes from + this CU's objfile. If this objfile came from a separate debuginfo + file, then the offset may be different from the corresponding + offset in the parent objfile. */ +CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu); + struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block (unsigned int offset, struct dwarf2_per_cu_data *per_cu); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e4ab034..16381de 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -12047,7 +12047,9 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, } } -/* Return the OBJFILE associated with the compilation unit CU. */ +/* Return the OBJFILE associated with the compilation unit CU. If CU + came from a separate debuginfo file, then the master objfile is + returned. */ struct objfile * dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu) @@ -12106,6 +12108,19 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu) } } +/* Return the text offset of the CU. The returned offset comes from + this CU's objfile. If this objfile came from a separate debuginfo + file, then the offset may be different from the corresponding + offset in the parent objfile. */ + +CORE_ADDR +dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu) +{ + struct objfile *objfile = per_cu->psymtab->objfile; + + return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); +} + /* Locate the .debug_info compilation unit from CU's objfile which contains the DIE at OFFSET. Raises an error on failure. */