From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36272 invoked by alias); 16 Jan 2019 16:34:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 36241 invoked by uid 89); 16 Jan 2019 16:34:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 spammy=3016 X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Jan 2019 16:34:04 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EBD9CACEA; Wed, 16 Jan 2019 16:34:01 +0000 (UTC) Subject: Re: [PATCH 2/9] [libbacktrace] Add altlink field to struct dwarf_data From: Tom de Vries To: Ian Lance Taylor Cc: gcc-patches References: <20181211101411.7067-1-tdevries@suse.de> <20181211101411.7067-3-tdevries@suse.de> <26bdcafc-da73-56c1-f6a0-2966d33f0788@suse.de> Message-ID: Date: Wed, 16 Jan 2019 16:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <26bdcafc-da73-56c1-f6a0-2966d33f0788@suse.de> Content-Type: multipart/mixed; boundary="------------5C9BE7F047791016F4BE8B64" X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00926.txt.bz2 This is a multi-part message in MIME format. --------------5C9BE7F047791016F4BE8B64 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2734 On 16-01-19 17:33, Tom de Vries wrote: > On 16-01-19 02:02, Ian Lance Taylor wrote: >> On Tue, Dec 11, 2018 at 2:14 AM Tom de Vries wrote: >>> >>> Add an altlink field to struct dwarf_data, and initialize it with the pointer >>> to the struct dwarf_data for the .gnu_debugaltlink. >>> >>> 2018-11-11 Tom de Vries >>> >>> * dwarf.c (struct dwarf_data): Add altlink field. >>> (backtrace_dwarf_add): Add and handle fileline_entry and >>> fileline_altlink parameters. >>> * elf.c (elf_add): Add and handle fileline_entry parameter. Add args to >>> backtrace_dwarf_add call. >>> (phdr_callback, backtrace_initialize): Add arguments to elf_add calls. >>> * internal.h (backtrace_dwarf_add): Add fileline_entry and >>> fileline_altlink parameters. >>> * pecoff.c (coff_add): Add args to backtrace_dwarf_add call. >>> * xcoff.c (xcoff_add): Same. >> >> >>> @@ -2968,7 +2970,7 @@ build_dwarf_data (struct backtrace_state *state, >>> size_t dwarf_str_size, >>> int is_bigendian, >>> backtrace_error_callback error_callback, >>> - void *data) >>> + void *data, struct dwarf_data *altlink) >>> { >> >> error_callback and data should remain the last two parameters, as they >> are for many of the functions in this file. >> >> > > Done. > >>> @@ -3031,7 +3034,8 @@ backtrace_dwarf_add (struct backtrace_state *state, >>> size_t dwarf_str_size, >>> int is_bigendian, >>> backtrace_error_callback error_callback, >>> - void *data, fileline *fileline_fn) >>> + void *data, fileline *fileline_fn, void **fileline_entry, >>> + void *fileline_altlink) >> >> The new fileline_altlink parameter should come before error_callback, >> as it is not error_callback/data and is not a result parameter. >> > > Done. > >> What is fileline_entry for? > > There are two bits to this patch: > - add fileline_entry parameter to elf_add. This allows the callers of > elf_add access to the struct dwarf_data pointer corresponding to the > added elf. > - add an altlink field to struct dwarf_data, and initialize it with the > pointer to the struct dwarf_data for the .gnu_debugaltlink. > > I've split the patch up this way now, hoping it will make things clearer > and/or easier to review. > >> Why is it void**? > > It's really struct dwarf_data *, but struct dwarf_data is a type > declared in dwarf.c, so it's not known in other files. > > Thanks, > - Tom > > Here's the first part. > And here's the second part. --------------5C9BE7F047791016F4BE8B64 Content-Type: text/x-patch; name="0003-libbacktrace-Add-altlink-field-to-struct-dwarf_data.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0003-libbacktrace-Add-altlink-field-to-struct-dwarf_data.pat"; filename*1="ch" Content-length: 4931 [libbacktrace] Add altlink field to struct dwarf_data Add an altlink field to struct dwarf_data, and initialize it with the pointer to the struct dwarf_data for the .gnu_debugaltlink. 2018-11-11 Tom de Vries * dwarf.c (struct dwarf_data): Add altlink field. (backtrace_dwarf_add): Add and handle fileline_altlink parameter. * elf.c (elf_add): Add argument to backtrace_dwarf_add call. (phdr_callback, backtrace_initialize): Add argument to elf_add calls. * internal.h (backtrace_dwarf_add): Add fileline_altlink parameter. * pecoff.c (coff_add): Add argument to backtrace_dwarf_add call. * xcoff.c (xcoff_add): Same. --- libbacktrace/dwarf.c | 7 ++++++- libbacktrace/elf.c | 4 +++- libbacktrace/internal.h | 1 + libbacktrace/pecoff.c | 1 + libbacktrace/xcoff.c | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index c7913f43617..5469f968468 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -343,6 +343,8 @@ struct dwarf_data { /* The data for the next file we know about. */ struct dwarf_data *next; + /* The data for .gnu_debugaltlink. */ + struct dwarf_data *altlink; /* The base address for this file. */ uintptr_t base_address; /* A sorted list of address ranges. */ @@ -2981,6 +2983,7 @@ build_dwarf_data (struct backtrace_state *state, const unsigned char *dwarf_str, size_t dwarf_str_size, int is_bigendian, + struct dwarf_data *altlink, backtrace_error_callback error_callback, void *data) { @@ -3009,6 +3012,7 @@ build_dwarf_data (struct backtrace_state *state, return NULL; fdata->next = NULL; + fdata->altlink = altlink; fdata->base_address = base_address; fdata->addrs = addrs; fdata->addrs_count = addrs_count; @@ -3044,6 +3048,7 @@ backtrace_dwarf_add (struct backtrace_state *state, const unsigned char *dwarf_str, size_t dwarf_str_size, int is_bigendian, + void *fileline_altlink, backtrace_error_callback error_callback, void *data, fileline *fileline_fn, void **fileline_entry) @@ -3054,7 +3059,7 @@ backtrace_dwarf_add (struct backtrace_state *state, dwarf_line, dwarf_line_size, dwarf_abbrev, dwarf_abbrev_size, dwarf_ranges, dwarf_ranges_size, dwarf_str, dwarf_str_size, is_bigendian, - error_callback, data); + fileline_altlink, error_callback, data); if (fdata == NULL) return 0; diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 6f99461db84..88987edb6f4 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -3097,6 +3097,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, debuglink_view_valid = 0; } + void *fileline_altlink = NULL; if (debugaltlink_name != NULL) { int d; @@ -3108,7 +3109,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, int ret; ret = elf_add (state, filename, d, base_address, error_callback, data, - fileline_fn, found_sym, found_dwarf, NULL, + fileline_fn, found_sym, found_dwarf, &fileline_altlink, 0, 1, debugaltlink_buildid_data, debugaltlink_buildid_size); backtrace_release_view (state, &debugaltlink_view, error_callback, @@ -3272,6 +3273,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, sections[DEBUG_STR].data, sections[DEBUG_STR].size, ehdr.e_ident[EI_DATA] == ELFDATA2MSB, + fileline_altlink, error_callback, data, fileline_fn, fileline_entry)) goto fail; diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h index 0664b2e10c3..febdaeebc21 100644 --- a/libbacktrace/internal.h +++ b/libbacktrace/internal.h @@ -301,6 +301,7 @@ extern int backtrace_dwarf_add (struct backtrace_state *state, const unsigned char *dwarf_str, size_t dwarf_str_size, int is_bigendian, + void *fileline_altlink, backtrace_error_callback error_callback, void *data, fileline *fileline_fn, void **fileline_entry); diff --git a/libbacktrace/pecoff.c b/libbacktrace/pecoff.c index cd20cbe17a7..da1982fd3ca 100644 --- a/libbacktrace/pecoff.c +++ b/libbacktrace/pecoff.c @@ -867,6 +867,7 @@ coff_add (struct backtrace_state *state, int descriptor, sections[DEBUG_STR].data, sections[DEBUG_STR].size, 0, /* FIXME */ + NULL, error_callback, data, fileline_fn, NULL)) goto fail; diff --git a/libbacktrace/xcoff.c b/libbacktrace/xcoff.c index 095800b4f71..d50b5bc517e 100644 --- a/libbacktrace/xcoff.c +++ b/libbacktrace/xcoff.c @@ -1315,6 +1315,7 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, dwsect[DWSECT_STR].data, dwsect[DWSECT_STR].size, 1, /* big endian */ + NULL, error_callback, data, fileline_fn, NULL)) goto fail; --------------5C9BE7F047791016F4BE8B64--