Compare commits

...

5 Commits

  1. 18
      backtrace.h
  2. 29
      elf.c
  3. 4
      fileline.c
  4. 4
      internal.h
  5. 4
      macho.c
  6. 4
      pecoff.c

18
backtrace.h

@ -41,6 +41,9 @@ POSSIBILITY OF SUCH DAMAGE. */ @@ -41,6 +41,9 @@ POSSIBILITY OF SUCH DAMAGE. */
extern "C" {
#endif
/* [for Zrythm] flag to detect if we have the modified API */
#define BACKTRACE_HAVE_BIN_FILENAME_AND_BASE_ADDR 1
/* The backtrace state. This struct is intentionally not defined in
the public interface. */
@ -157,15 +160,20 @@ extern int backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc, @@ -157,15 +160,20 @@ extern int backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc,
void *data);
/* The type of the callback argument to backtrace_syminfo. DATA and
PC are the arguments passed to backtrace_syminfo. SYMNAME is the
name of the symbol for the corresponding code. SYMVAL is the
value and SYMSIZE is the size of the symbol. SYMNAME will be NULL
if no error occurred but the symbol could not be found. */
PC are the arguments passed to backtrace_syminfo. SYMNAME is the name of
the symbol for the corresponding code. SYMVAL is the value and SYMSIZE is
the size of the symbol. SYMNAME will be NULL if no error occurred but the
symbol could not be found. BINARY_FILENAME is the name of the shared object
filename or NULL if the symbol was found in the executable itself or the
symbol could not be found. BASE_ADDRESS is the base address of the shared
object or 0 if the symbol could not be found.*/
typedef void (*backtrace_syminfo_callback) (void *data, uintptr_t pc,
const char *symname,
uintptr_t symval,
uintptr_t symsize);
uintptr_t symsize,
const char* binary_filename,
uintptr_t base_address);
/* Given ADDR, an address or program counter in the current program,
call the callback information with the symbol name and value

29
elf.c

@ -388,6 +388,10 @@ struct elf_syminfo_data @@ -388,6 +388,10 @@ struct elf_syminfo_data
struct elf_symbol *symbols;
/* The number of symbols. */
size_t count;
/* The name of the shared object (see dl_iterate_phdr's dlpi_name) */
const char* binary_file_name;
/* Base address/offset of the shared object (see dl_iterate_phdr's dlpi_addr) */
uintptr_t base_address;
};
/* A view that works for either a file or memory. */
@ -631,7 +635,8 @@ elf_initialize_syminfo (struct backtrace_state *state, @@ -631,7 +635,8 @@ elf_initialize_syminfo (struct backtrace_state *state,
const unsigned char *strtab, size_t strtab_size,
backtrace_error_callback error_callback,
void *data, struct elf_syminfo_data *sdata,
struct elf_ppc64_opd_data *opd)
struct elf_ppc64_opd_data *opd,
const char *binary_filename)
{
size_t sym_count;
const b_elf_sym *sym;
@ -703,6 +708,8 @@ elf_initialize_syminfo (struct backtrace_state *state, @@ -703,6 +708,8 @@ elf_initialize_syminfo (struct backtrace_state *state,
sdata->next = NULL;
sdata->symbols = elf_symbols;
sdata->count = elf_symbol_count;
sdata->binary_file_name = binary_filename;
sdata->base_address = base_address;
return 1;
}
@ -795,9 +802,9 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr, @@ -795,9 +802,9 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
}
if (sym == NULL)
callback (data, addr, NULL, 0, 0);
callback(data, addr, NULL, 0, 0, NULL, 0);
else
callback (data, addr, sym->name, sym->address, sym->size);
callback(data, addr, sym->name, sym->address, sym->size, edata->binary_file_name, edata->base_address);
}
/* Return whether FILENAME is a symlink. */
@ -3987,7 +3994,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, @@ -3987,7 +3994,7 @@ 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,
struct dwarf_data **fileline_entry, int exe, int debuginfo,
const char *with_buildid_data, uint32_t with_buildid_size)
const char *with_buildid_data, uint32_t with_buildid_size, const char *binary_filename)
{
struct elf_view ehdr_view;
b_elf_ehdr ehdr;
@ -4392,7 +4399,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, @@ -4392,7 +4399,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
if (!elf_initialize_syminfo (state, base_address,
symtab_view.view.data, symtab_shdr->sh_size,
strtab_view.view.data, strtab_shdr->sh_size,
error_callback, data, sdata, opd))
error_callback, data, sdata, opd, binary_filename))
{
backtrace_free (state, sdata, sizeof *sdata, error_callback, data);
goto fail;
@ -4433,7 +4440,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, @@ -4433,7 +4440,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
elf_release_view (state, &debugaltlink_view, error_callback, data);
ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
data, fileline_fn, found_sym, found_dwarf, NULL, 0,
1, NULL, 0);
1, NULL, 0, binary_filename);
if (ret < 0)
backtrace_close (d, error_callback, data);
else if (descriptor >= 0)
@ -4470,7 +4477,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, @@ -4470,7 +4477,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
elf_release_view (state, &debugaltlink_view, error_callback, data);
ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
data, fileline_fn, found_sym, found_dwarf, NULL, 0,
1, NULL, 0);
1, NULL, 0, binary_filename);
if (ret < 0)
backtrace_close (d, error_callback, data);
else if (descriptor >= 0)
@ -4499,7 +4506,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, @@ -4499,7 +4506,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
ret = elf_add (state, filename, d, NULL, 0, base_address,
error_callback, data, fileline_fn, found_sym,
found_dwarf, &fileline_altlink, 0, 1,
debugaltlink_buildid_data, debugaltlink_buildid_size);
debugaltlink_buildid_data, debugaltlink_buildid_size, binary_filename);
elf_release_view (state, &debugaltlink_view, error_callback, data);
debugaltlink_view_valid = 0;
if (ret < 0)
@ -4535,7 +4542,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, @@ -4535,7 +4542,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
ret = elf_add (state, filename, -1, gnu_debugdata_uncompressed,
gnu_debugdata_uncompressed_size, base_address,
error_callback, data, fileline_fn, found_sym,
found_dwarf, NULL, 0, 0, NULL, 0);
found_dwarf, NULL, 0, 0, NULL, 0, binary_filename);
if (ret >= 0 && descriptor >= 0)
backtrace_close(descriptor, error_callback, data);
return ret;
@ -4847,7 +4854,7 @@ phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED, @@ -4847,7 +4854,7 @@ phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED,
if (elf_add (pd->state, filename, descriptor, NULL, 0, info->dlpi_addr,
pd->error_callback, pd->data, &elf_fileline_fn, pd->found_sym,
&found_dwarf, NULL, 0, 0, NULL, 0))
&found_dwarf, NULL, 0, 0, NULL, 0, info->dlpi_name))
{
if (found_dwarf)
{
@ -4876,7 +4883,7 @@ backtrace_initialize (struct backtrace_state *state, const char *filename, @@ -4876,7 +4883,7 @@ backtrace_initialize (struct backtrace_state *state, const char *filename,
ret = elf_add (state, filename, descriptor, NULL, 0, 0, error_callback, data,
&elf_fileline_fn, &found_sym, &found_dwarf, NULL, 1, 0, NULL,
0);
0, NULL);
if (!ret)
return 0;

4
fileline.c

@ -326,7 +326,9 @@ void @@ -326,7 +326,9 @@ void
backtrace_syminfo_to_full_callback (void *data, uintptr_t pc,
const char *symname,
uintptr_t symval ATTRIBUTE_UNUSED,
uintptr_t symsize ATTRIBUTE_UNUSED)
uintptr_t symsize ATTRIBUTE_UNUSED,
const char *binary_filename ATTRIBUTE_UNUSED,
uintptr_t base_address ATTRIBUTE_UNUSED)
{
struct backtrace_call_full *bdata = (struct backtrace_call_full *) data;

4
internal.h

@ -351,7 +351,9 @@ struct backtrace_call_full @@ -351,7 +351,9 @@ struct backtrace_call_full
extern void backtrace_syminfo_to_full_callback (void *data, uintptr_t pc,
const char *symname,
uintptr_t symval,
uintptr_t symsize);
uintptr_t symsize,
const char * binary_filename,
uintptr_t base_address);
/* An error callback that corresponds to
backtrace_syminfo_to_full_callback. */

4
macho.c

@ -746,9 +746,9 @@ macho_syminfo (struct backtrace_state *state, uintptr_t addr, @@ -746,9 +746,9 @@ macho_syminfo (struct backtrace_state *state, uintptr_t addr,
}
if (sym == NULL)
callback (data, addr, NULL, 0, 0);
callback (data, addr, NULL, 0, 0, 0, 0);
else
callback (data, addr, sym->name, sym->address, 0);
callback (data, addr, sym->name, sym->address, 0, 0, 0);
}
/* Look through a fat file to find the relevant executable. Returns 1

4
pecoff.c

@ -569,9 +569,9 @@ coff_syminfo (struct backtrace_state *state, uintptr_t addr, @@ -569,9 +569,9 @@ coff_syminfo (struct backtrace_state *state, uintptr_t addr,
}
if (sym == NULL)
callback (data, addr, NULL, 0, 0);
callback (data, addr, NULL, 0, 0, 0, 0);
else
callback (data, addr, sym->name, sym->address, 0);
callback (data, addr, sym->name, sym->address, 0, 0, 0);
}
/* Add the backtrace data for one PE/COFF file. Returns 1 on success,

Loading…
Cancel
Save