From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128630 invoked by alias); 16 Jan 2019 22:18:50 -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 128610 invoked by uid 89); 16 Jan 2019 22:18:49 -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= 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 22:18:47 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C2009AD5E; Wed, 16 Jan 2019 22:18:44 +0000 (UTC) Subject: Re: [PATCH 2/9] [libbacktrace] Add altlink field to struct dwarf_data 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> From: Tom de Vries Message-ID: <2bfdb107-8e31-f853-56e1-8f847ea24fd7@suse.de> Date: Wed, 16 Jan 2019 22:18: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: Content-Type: multipart/mixed; boundary="------------2FC0B2445353049144FD86AD" X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00950.txt.bz2 This is a multi-part message in MIME format. --------------2FC0B2445353049144FD86AD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 431 On 16-01-19 18:17, Ian Lance Taylor wrote: > On Wed, Jan 16, 2019 at 8:33 AM Tom de Vries wrote: >> >>> 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. > > It woud be OK to add "struct dwarf_data;" to internal.h and refer to > the struct, without dereferencing it, in elf.c. Updated accordingly. Thanks, - Tom --------------2FC0B2445353049144FD86AD Content-Type: text/x-patch; name="0003-libbacktrace-Return-struct-dwarf_data-pointer-from-elf_add.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0003-libbacktrace-Return-struct-dwarf_data-pointer-from-elf_"; filename*1="add.patch" Content-length: 6515 [libbacktrace] Return struct dwarf_data pointer from elf_add Allow the caller of elf_add access to the struct dwarf_data pointer corresponding to the added elf. 2018-11-11 Tom de Vries * internal.h (backtrace_dwarf_add): Add fileline_entry parameter. * dwarf.c (backtrace_dwarf_add): Add and handle fileline_entry parameter. * elf.c (elf_add): Add and handle fileline_entry parameter. Add argument to backtrace_dwarf_add call. (phdr_callback, backtrace_initialize): Add argument to elf_add calls. * pecoff.c (coff_add): Add argument to backtrace_dwarf_add call. * xcoff.c (xcoff_add): Same. --- libbacktrace/dwarf.c | 6 +++++- libbacktrace/elf.c | 23 ++++++++++++++--------- libbacktrace/internal.h | 5 ++++- libbacktrace/pecoff.c | 3 ++- libbacktrace/xcoff.c | 3 ++- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index dca5d909d9f..190c6fc131f 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -3064,7 +3064,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, + struct dwarf_data **fileline_entry) { struct dwarf_data *fdata; @@ -3076,6 +3077,9 @@ backtrace_dwarf_add (struct backtrace_state *state, if (fdata == NULL) return 0; + if (fileline_entry != NULL) + *fileline_entry = fdata; + if (!state->threaded) { struct dwarf_data **pp; diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index e363e470525..2841c06cdb2 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -2638,8 +2638,8 @@ static int elf_add (struct backtrace_state *state, const char *filename, int descriptor, uintptr_t base_address, backtrace_error_callback error_callback, void *data, fileline *fileline_fn, int *found_sym, int *found_dwarf, - int exe, int debuginfo, const char *with_buildid_data, - uint32_t with_buildid_size) + struct dwarf_data **fileline_entry, int exe, int debuginfo, + const char *with_buildid_data, uint32_t with_buildid_size) { struct backtrace_view ehdr_view; b_elf_ehdr ehdr; @@ -3042,7 +3042,8 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, backtrace_release_view (state, &debugaltlink_view, error_callback, data); ret = elf_add (state, NULL, d, base_address, error_callback, data, - fileline_fn, found_sym, found_dwarf, 0, 1, NULL, 0); + fileline_fn, found_sym, found_dwarf, NULL, 0, 1, NULL, + 0); if (ret < 0) backtrace_close (d, error_callback, data); else @@ -3080,7 +3081,8 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, backtrace_release_view (state, &debugaltlink_view, error_callback, data); ret = elf_add (state, NULL, d, base_address, error_callback, data, - fileline_fn, found_sym, found_dwarf, 0, 1, NULL, 0); + fileline_fn, found_sym, found_dwarf, NULL, 0, 1, NULL, + 0); if (ret < 0) backtrace_close (d, error_callback, data); else @@ -3106,8 +3108,9 @@ 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, 0, 1, - debugaltlink_buildid_data, debugaltlink_buildid_size); + fileline_fn, found_sym, found_dwarf, NULL, + 0, 1, debugaltlink_buildid_data, + debugaltlink_buildid_size); backtrace_release_view (state, &debugaltlink_view, error_callback, data); debugaltlink_view_valid = 0; @@ -3269,7 +3272,8 @@ 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, - error_callback, data, fileline_fn)) + error_callback, data, fileline_fn, + fileline_entry)) goto fail; *found_dwarf = 1; @@ -3359,7 +3363,7 @@ phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED, if (elf_add (pd->state, filename, descriptor, info->dlpi_addr, pd->error_callback, pd->data, &elf_fileline_fn, pd->found_sym, - &found_dwarf, 0, 0, NULL, 0)) + &found_dwarf, NULL, 0, 0, NULL, 0)) { if (found_dwarf) { @@ -3387,7 +3391,8 @@ backtrace_initialize (struct backtrace_state *state, const char *filename, struct phdr_data pd; ret = elf_add (state, filename, descriptor, 0, error_callback, data, - &elf_fileline_fn, &found_sym, &found_dwarf, 1, 0, NULL, 0); + &elf_fileline_fn, &found_sym, &found_dwarf, NULL, 1, 0, NULL, + 0); if (!ret) return 0; diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h index bf3e7d1989f..d9ab401ce41 100644 --- a/libbacktrace/internal.h +++ b/libbacktrace/internal.h @@ -286,6 +286,8 @@ extern int backtrace_initialize (struct backtrace_state *state, void *data, fileline *fileline_fn); +struct dwarf_data; + /* Add file/line information for a DWARF module. */ extern int backtrace_dwarf_add (struct backtrace_state *state, @@ -302,7 +304,8 @@ extern int 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, + struct dwarf_data **fileline_entry); /* A test-only hook for elf_uncompress_zdebug. */ diff --git a/libbacktrace/pecoff.c b/libbacktrace/pecoff.c index f51fc0f13c5..cd20cbe17a7 100644 --- a/libbacktrace/pecoff.c +++ b/libbacktrace/pecoff.c @@ -867,7 +867,8 @@ coff_add (struct backtrace_state *state, int descriptor, sections[DEBUG_STR].data, sections[DEBUG_STR].size, 0, /* FIXME */ - error_callback, data, fileline_fn)) + error_callback, data, fileline_fn, + NULL)) goto fail; *found_dwarf = 1; diff --git a/libbacktrace/xcoff.c b/libbacktrace/xcoff.c index 111134d4d21..095800b4f71 100644 --- a/libbacktrace/xcoff.c +++ b/libbacktrace/xcoff.c @@ -1315,7 +1315,8 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, dwsect[DWSECT_STR].data, dwsect[DWSECT_STR].size, 1, /* big endian */ - error_callback, data, fileline_fn)) + error_callback, data, fileline_fn, + NULL)) goto fail; } --------------2FC0B2445353049144FD86AD--