crates/backtrace-sys2/src/libbacktrace/dwarf.c in pf2-0.6.0 vs crates/backtrace-sys2/src/libbacktrace/dwarf.c in pf2-0.7.0
- old
+ new
@@ -1,7 +1,7 @@
/* dwarf.c -- Get file/line information from DWARF for backtraces.
- Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ Copyright (C) 2012-2024 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
@@ -720,12 +720,12 @@
{
/* 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;
+ /* The base address mapping for this file. */
+ struct libbacktrace_base_address base_address;
/* A sorted list of address ranges. */
struct unit_addrs *addrs;
/* Number of address ranges in list. */
size_t addrs_count;
/* A sorted list of units. */
@@ -1942,12 +1942,13 @@
error. */
static int
add_low_high_range (struct backtrace_state *state,
const struct dwarf_sections *dwarf_sections,
- uintptr_t base_address, int is_bigendian,
- struct unit *u, const struct pcrange *pcrange,
+ struct libbacktrace_base_address base_address,
+ int is_bigendian, struct unit *u,
+ const struct pcrange *pcrange,
int (*add_range) (struct backtrace_state *state,
void *rdata, uintptr_t lowpc,
uintptr_t highpc,
backtrace_error_callback error_callback,
void *data, void *vec),
@@ -1978,12 +1979,12 @@
if (pcrange->highpc_is_relative)
highpc += lowpc;
/* Add in the base address of the module when recording PC values,
so that we can look up the PC directly. */
- lowpc += base_address;
- highpc += base_address;
+ lowpc = libbacktrace_add_base (lowpc, base_address);
+ highpc = libbacktrace_add_base (highpc, base_address);
return add_range (state, rdata, lowpc, highpc, error_callback, data, vec);
}
/* Call ADD_RANGE for each range read from .debug_ranges, as used in
@@ -1991,11 +1992,11 @@
static int
add_ranges_from_ranges (
struct backtrace_state *state,
const struct dwarf_sections *dwarf_sections,
- uintptr_t base_address, int is_bigendian,
+ struct libbacktrace_base_address base_address, int is_bigendian,
struct unit *u, uintptr_t base,
const struct pcrange *pcrange,
int (*add_range) (struct backtrace_state *state, void *rdata,
uintptr_t lowpc, uintptr_t highpc,
backtrace_error_callback error_callback, void *data,
@@ -2037,14 +2038,15 @@
if (is_highest_address (low, u->addrsize))
base = (uintptr_t) high;
else
{
- if (!add_range (state, rdata,
- (uintptr_t) low + base + base_address,
- (uintptr_t) high + base + base_address,
- error_callback, data, vec))
+ uintptr_t rl, rh;
+
+ rl = libbacktrace_add_base ((uintptr_t) low + base, base_address);
+ rh = libbacktrace_add_base ((uintptr_t) high + base, base_address);
+ if (!add_range (state, rdata, rl, rh, error_callback, data, vec))
return 0;
}
}
if (ranges_buf.reported_underflow)
@@ -2058,11 +2060,11 @@
static int
add_ranges_from_rnglists (
struct backtrace_state *state,
const struct dwarf_sections *dwarf_sections,
- uintptr_t base_address, int is_bigendian,
+ struct libbacktrace_base_address base_address, int is_bigendian,
struct unit *u, uintptr_t base,
const struct pcrange *pcrange,
int (*add_range) (struct backtrace_state *state, void *rdata,
uintptr_t lowpc, uintptr_t highpc,
backtrace_error_callback error_callback, void *data,
@@ -2141,13 +2143,14 @@
index = read_uleb128 (&rnglists_buf);
if (!resolve_addr_index (dwarf_sections, u->addr_base,
u->addrsize, is_bigendian, index,
error_callback, data, &high))
return 0;
- if (!add_range (state, rdata, low + base_address,
- high + base_address, error_callback, data,
- vec))
+ if (!add_range (state, rdata,
+ libbacktrace_add_base (low, base_address),
+ libbacktrace_add_base (high, base_address),
+ error_callback, data, vec))
return 0;
}
break;
case DW_RLE_startx_length:
@@ -2160,11 +2163,11 @@
if (!resolve_addr_index (dwarf_sections, u->addr_base,
u->addrsize, is_bigendian, index,
error_callback, data, &low))
return 0;
length = read_uleb128 (&rnglists_buf);
- low += base_address;
+ low = libbacktrace_add_base (low, base_address);
if (!add_range (state, rdata, low, low + length,
error_callback, data, vec))
return 0;
}
break;
@@ -2174,12 +2177,13 @@
uint64_t low;
uint64_t high;
low = read_uleb128 (&rnglists_buf);
high = read_uleb128 (&rnglists_buf);
- if (!add_range (state, rdata, low + base + base_address,
- high + base + base_address,
+ if (!add_range (state, rdata,
+ libbacktrace_add_base (low + base, base_address),
+ libbacktrace_add_base (high + base, base_address),
error_callback, data, vec))
return 0;
}
break;
@@ -2192,13 +2196,14 @@
uintptr_t low;
uintptr_t high;
low = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
high = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
- if (!add_range (state, rdata, low + base_address,
- high + base_address, error_callback, data,
- vec))
+ if (!add_range (state, rdata,
+ libbacktrace_add_base (low, base_address),
+ libbacktrace_add_base (high, base_address),
+ error_callback, data, vec))
return 0;
}
break;
case DW_RLE_start_length:
@@ -2206,11 +2211,11 @@
uintptr_t low;
uintptr_t length;
low = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
length = (uintptr_t) read_uleb128 (&rnglists_buf);
- low += base_address;
+ low = libbacktrace_add_base (low, base_address);
if (!add_range (state, rdata, low, low + length,
error_callback, data, vec))
return 0;
}
break;
@@ -2234,13 +2239,13 @@
Returns 1 on success, 0 on error. */
static int
add_ranges (struct backtrace_state *state,
const struct dwarf_sections *dwarf_sections,
- uintptr_t base_address, int is_bigendian,
+ struct libbacktrace_base_address base_address, int is_bigendian,
struct unit *u, uintptr_t base, const struct pcrange *pcrange,
- int (*add_range) (struct backtrace_state *state, void *rdata,
+ int (*add_range) (struct backtrace_state *state, void *rdata,
uintptr_t lowpc, uintptr_t highpc,
backtrace_error_callback error_callback,
void *data, void *vec),
void *rdata,
backtrace_error_callback error_callback, void *data,
@@ -2270,11 +2275,12 @@
/* Find the address range covered by a compilation unit, reading from
UNIT_BUF and adding values to U. Returns 1 if all data could be
read, 0 if there is some error. */
static int
-find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
+find_address_ranges (struct backtrace_state *state,
+ struct libbacktrace_base_address base_address,
struct dwarf_buf *unit_buf,
const struct dwarf_sections *dwarf_sections,
int is_bigendian, struct dwarf_data *altlink,
backtrace_error_callback error_callback, void *data,
struct unit *u, struct unit_addrs_vector *addrs,
@@ -2425,11 +2431,12 @@
/* Build a mapping from address ranges to the compilation units where
the line number information for that range can be found. Returns 1
on success, 0 on failure. */
static int
-build_address_map (struct backtrace_state *state, uintptr_t base_address,
+build_address_map (struct backtrace_state *state,
+ struct libbacktrace_base_address base_address,
const struct dwarf_sections *dwarf_sections,
int is_bigendian, struct dwarf_data *altlink,
backtrace_error_callback error_callback, void *data,
struct unit_addrs_vector *addrs,
struct unit_vector *unit_vec)
@@ -2644,11 +2651,11 @@
if (ln == NULL)
return 0;
/* Add in the base address here, so that we can look up the PC
directly. */
- ln->pc = pc + ddata->base_address;
+ ln->pc = libbacktrace_add_base (pc, ddata->base_address);
ln->filename = filename;
ln->lineno = lineno;
ln->idx = vec->count;
@@ -4283,11 +4290,11 @@
/* Initialize our data structures from the DWARF debug info for a
file. Return NULL on failure. */
static struct dwarf_data *
build_dwarf_data (struct backtrace_state *state,
- uintptr_t base_address,
+ struct libbacktrace_base_address base_address,
const struct dwarf_sections *dwarf_sections,
int is_bigendian,
struct dwarf_data *altlink,
backtrace_error_callback error_callback,
void *data)
@@ -4341,10 +4348,10 @@
Set FILELINE_FN and STATE->FILELINE_DATA. Return 1 on success, 0
on failure. */
int
backtrace_dwarf_add (struct backtrace_state *state,
- uintptr_t base_address,
+ struct libbacktrace_base_address base_address,
const struct dwarf_sections *dwarf_sections,
int is_bigendian,
struct dwarf_data *fileline_altlink,
backtrace_error_callback error_callback,
void *data, fileline *fileline_fn,