Skip to content

Commit 0c193ca

Browse files
libbacktrace: change PC variables from uint64_t to uintptr_t
Change variables holding PC values from uint64_t to uintptr_t. Patch by Björn Schäpers. * dwarf.c (struct function_addrs): Change low and high fields to uintptr_t. (struct unit_addrs): Likewise. (resolve_addr_index): Change address parameter to uintptr_t*. (add_unit_addr): Change lowpc and highpc parameters to uintptr_t. (add_function_range): Likewise. (struct pcrange): Change lowpc and highpc fields to uintptr_t. (add_low_high_range): Change add_range lowpc and highpc parameters to uintptr_t. (add_ranges_from_ranges): Likewise. (add_ranges_from_rnglists): Likewise. (add_low_high_range): Chnage lowpc and highpc variables to uintpr_t. (add_ranges_from_rnglists): Change some local variables to uintptr_t. (add_ranges_from_ranges): Change base parameter to uintptr_t. (add_ranges_from_rnglists): Likewise. (read_function_entry): Likewise. (resolve_addr_index): Add explicit casts to uintptr_t. (update_pcrange): Likewise. (add_ranges_from_ranges): Likewise. (add_ranges_from_rnglists): Likewise. (read_function_entry): Likewise.
1 parent f71354f commit 0c193ca

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

libbacktrace/dwarf.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ enum attr_val_encoding
136136
/* An address. */
137137
ATTR_VAL_ADDRESS,
138138
/* An index into the .debug_addr section, whose value is relative to
139-
* the DW_AT_addr_base attribute of the compilation unit. */
139+
the DW_AT_addr_base attribute of the compilation unit. */
140140
ATTR_VAL_ADDRESS_INDEX,
141141
/* A unsigned integer. */
142142
ATTR_VAL_UINT,
@@ -274,8 +274,8 @@ struct function
274274
struct function_addrs
275275
{
276276
/* Range is LOW <= PC < HIGH. */
277-
uint64_t low;
278-
uint64_t high;
277+
uintptr_t low;
278+
uintptr_t high;
279279
/* Function for this address range. */
280280
struct function *function;
281281
};
@@ -356,8 +356,8 @@ struct unit
356356
struct unit_addrs
357357
{
358358
/* Range is LOW <= PC < HIGH. */
359-
uint64_t low;
360-
uint64_t high;
359+
uintptr_t low;
360+
uintptr_t high;
361361
/* Compilation unit for this address range. */
362362
struct unit *u;
363363
};
@@ -1094,7 +1094,7 @@ resolve_addr_index (const struct dwarf_sections *dwarf_sections,
10941094
uint64_t addr_base, int addrsize, int is_bigendian,
10951095
uint64_t addr_index,
10961096
backtrace_error_callback error_callback, void *data,
1097-
uint64_t *address)
1097+
uintptr_t *address)
10981098
{
10991099
uint64_t offset;
11001100
struct dwarf_buf addr_buf;
@@ -1115,7 +1115,7 @@ resolve_addr_index (const struct dwarf_sections *dwarf_sections,
11151115
addr_buf.data = data;
11161116
addr_buf.reported_underflow = 0;
11171117

1118-
*address = read_address (&addr_buf, addrsize);
1118+
*address = (uintptr_t) read_address (&addr_buf, addrsize);
11191119
return 1;
11201120
}
11211121

@@ -1194,7 +1194,7 @@ function_addrs_search (const void *vkey, const void *ventry)
11941194

11951195
static int
11961196
add_unit_addr (struct backtrace_state *state, void *rdata,
1197-
uint64_t lowpc, uint64_t highpc,
1197+
uintptr_t lowpc, uintptr_t highpc,
11981198
backtrace_error_callback error_callback, void *data,
11991199
void *pvec)
12001200
{
@@ -1530,10 +1530,10 @@ lookup_abbrev (struct abbrevs *abbrevs, uint64_t code,
15301530
lowpc/highpc is set or ranges is set. */
15311531

15321532
struct pcrange {
1533-
uint64_t lowpc; /* The low PC value. */
1533+
uintptr_t lowpc; /* The low PC value. */
15341534
int have_lowpc; /* Whether a low PC value was found. */
15351535
int lowpc_is_addr_index; /* Whether lowpc is in .debug_addr. */
1536-
uint64_t highpc; /* The high PC value. */
1536+
uintptr_t highpc; /* The high PC value. */
15371537
int have_highpc; /* Whether a high PC value was found. */
15381538
int highpc_is_relative; /* Whether highpc is relative to lowpc. */
15391539
int highpc_is_addr_index; /* Whether highpc is in .debug_addr. */
@@ -1553,12 +1553,12 @@ update_pcrange (const struct attr* attr, const struct attr_val* val,
15531553
case DW_AT_low_pc:
15541554
if (val->encoding == ATTR_VAL_ADDRESS)
15551555
{
1556-
pcrange->lowpc = val->u.uint;
1556+
pcrange->lowpc = (uintptr_t) val->u.uint;
15571557
pcrange->have_lowpc = 1;
15581558
}
15591559
else if (val->encoding == ATTR_VAL_ADDRESS_INDEX)
15601560
{
1561-
pcrange->lowpc = val->u.uint;
1561+
pcrange->lowpc = (uintptr_t) val->u.uint;
15621562
pcrange->have_lowpc = 1;
15631563
pcrange->lowpc_is_addr_index = 1;
15641564
}
@@ -1567,18 +1567,18 @@ update_pcrange (const struct attr* attr, const struct attr_val* val,
15671567
case DW_AT_high_pc:
15681568
if (val->encoding == ATTR_VAL_ADDRESS)
15691569
{
1570-
pcrange->highpc = val->u.uint;
1570+
pcrange->highpc = (uintptr_t) val->u.uint;
15711571
pcrange->have_highpc = 1;
15721572
}
15731573
else if (val->encoding == ATTR_VAL_UINT)
15741574
{
1575-
pcrange->highpc = val->u.uint;
1575+
pcrange->highpc = (uintptr_t) val->u.uint;
15761576
pcrange->have_highpc = 1;
15771577
pcrange->highpc_is_relative = 1;
15781578
}
15791579
else if (val->encoding == ATTR_VAL_ADDRESS_INDEX)
15801580
{
1581-
pcrange->highpc = val->u.uint;
1581+
pcrange->highpc = (uintptr_t) val->u.uint;
15821582
pcrange->have_highpc = 1;
15831583
pcrange->highpc_is_addr_index = 1;
15841584
}
@@ -1613,16 +1613,16 @@ add_low_high_range (struct backtrace_state *state,
16131613
uintptr_t base_address, int is_bigendian,
16141614
struct unit *u, const struct pcrange *pcrange,
16151615
int (*add_range) (struct backtrace_state *state,
1616-
void *rdata, uint64_t lowpc,
1617-
uint64_t highpc,
1616+
void *rdata, uintptr_t lowpc,
1617+
uintptr_t highpc,
16181618
backtrace_error_callback error_callback,
16191619
void *data, void *vec),
16201620
void *rdata,
16211621
backtrace_error_callback error_callback, void *data,
16221622
void *vec)
16231623
{
1624-
uint64_t lowpc;
1625-
uint64_t highpc;
1624+
uintptr_t lowpc;
1625+
uintptr_t highpc;
16261626

16271627
lowpc = pcrange->lowpc;
16281628
if (pcrange->lowpc_is_addr_index)
@@ -1660,10 +1660,10 @@ add_ranges_from_ranges (
16601660
struct backtrace_state *state,
16611661
const struct dwarf_sections *dwarf_sections,
16621662
uintptr_t base_address, int is_bigendian,
1663-
struct unit *u, uint64_t base,
1663+
struct unit *u, uintptr_t base,
16641664
const struct pcrange *pcrange,
16651665
int (*add_range) (struct backtrace_state *state, void *rdata,
1666-
uint64_t lowpc, uint64_t highpc,
1666+
uintptr_t lowpc, uintptr_t highpc,
16671667
backtrace_error_callback error_callback, void *data,
16681668
void *vec),
16691669
void *rdata,
@@ -1702,12 +1702,12 @@ add_ranges_from_ranges (
17021702
break;
17031703

17041704
if (is_highest_address (low, u->addrsize))
1705-
base = high;
1705+
base = (uintptr_t) high;
17061706
else
17071707
{
17081708
if (!add_range (state, rdata,
1709-
low + base + base_address,
1710-
high + base + base_address,
1709+
(uintptr_t) low + base + base_address,
1710+
(uintptr_t) high + base + base_address,
17111711
error_callback, data, vec))
17121712
return 0;
17131713
}
@@ -1727,10 +1727,10 @@ add_ranges_from_rnglists (
17271727
struct backtrace_state *state,
17281728
const struct dwarf_sections *dwarf_sections,
17291729
uintptr_t base_address, int is_bigendian,
1730-
struct unit *u, uint64_t base,
1730+
struct unit *u, uintptr_t base,
17311731
const struct pcrange *pcrange,
17321732
int (*add_range) (struct backtrace_state *state, void *rdata,
1733-
uint64_t lowpc, uint64_t highpc,
1733+
uintptr_t lowpc, uintptr_t highpc,
17341734
backtrace_error_callback error_callback, void *data,
17351735
void *vec),
17361736
void *rdata,
@@ -1796,8 +1796,8 @@ add_ranges_from_rnglists (
17961796
case DW_RLE_startx_endx:
17971797
{
17981798
uint64_t index;
1799-
uint64_t low;
1800-
uint64_t high;
1799+
uintptr_t low;
1800+
uintptr_t high;
18011801

18021802
index = read_uleb128 (&rnglists_buf);
18031803
if (!resolve_addr_index (dwarf_sections, u->addr_base,
@@ -1819,8 +1819,8 @@ add_ranges_from_rnglists (
18191819
case DW_RLE_startx_length:
18201820
{
18211821
uint64_t index;
1822-
uint64_t low;
1823-
uint64_t length;
1822+
uintptr_t low;
1823+
uintptr_t length;
18241824

18251825
index = read_uleb128 (&rnglists_buf);
18261826
if (!resolve_addr_index (dwarf_sections, u->addr_base,
@@ -1850,16 +1850,16 @@ add_ranges_from_rnglists (
18501850
break;
18511851

18521852
case DW_RLE_base_address:
1853-
base = read_address (&rnglists_buf, u->addrsize);
1853+
base = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
18541854
break;
18551855

18561856
case DW_RLE_start_end:
18571857
{
1858-
uint64_t low;
1859-
uint64_t high;
1858+
uintptr_t low;
1859+
uintptr_t high;
18601860

1861-
low = read_address (&rnglists_buf, u->addrsize);
1862-
high = read_address (&rnglists_buf, u->addrsize);
1861+
low = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
1862+
high = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
18631863
if (!add_range (state, rdata, low + base_address,
18641864
high + base_address, error_callback, data,
18651865
vec))
@@ -1869,11 +1869,11 @@ add_ranges_from_rnglists (
18691869

18701870
case DW_RLE_start_length:
18711871
{
1872-
uint64_t low;
1873-
uint64_t length;
1872+
uintptr_t low;
1873+
uintptr_t length;
18741874

1875-
low = read_address (&rnglists_buf, u->addrsize);
1876-
length = read_uleb128 (&rnglists_buf);
1875+
low = (uintptr_t) read_address (&rnglists_buf, u->addrsize);
1876+
length = (uintptr_t) read_uleb128 (&rnglists_buf);
18771877
low += base_address;
18781878
if (!add_range (state, rdata, low, low + length,
18791879
error_callback, data, vec))
@@ -1903,9 +1903,9 @@ static int
19031903
add_ranges (struct backtrace_state *state,
19041904
const struct dwarf_sections *dwarf_sections,
19051905
uintptr_t base_address, int is_bigendian,
1906-
struct unit *u, uint64_t base, const struct pcrange *pcrange,
1906+
struct unit *u, uintptr_t base, const struct pcrange *pcrange,
19071907
int (*add_range) (struct backtrace_state *state, void *rdata,
1908-
uint64_t lowpc, uint64_t highpc,
1908+
uintptr_t lowpc, uintptr_t highpc,
19091909
backtrace_error_callback error_callback,
19101910
void *data, void *vec),
19111911
void *rdata,
@@ -3183,7 +3183,7 @@ read_referenced_name (struct dwarf_data *ddata, struct unit *u,
31833183

31843184
static int
31853185
add_function_range (struct backtrace_state *state, void *rdata,
3186-
uint64_t lowpc, uint64_t highpc,
3186+
uintptr_t lowpc, uintptr_t highpc,
31873187
backtrace_error_callback error_callback, void *data,
31883188
void *pvec)
31893189
{
@@ -3223,7 +3223,7 @@ add_function_range (struct backtrace_state *state, void *rdata,
32233223

32243224
static int
32253225
read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
3226-
struct unit *u, uint64_t base, struct dwarf_buf *unit_buf,
3226+
struct unit *u, uintptr_t base, struct dwarf_buf *unit_buf,
32273227
const struct line_header *lhdr,
32283228
backtrace_error_callback error_callback, void *data,
32293229
struct function_vector *vec_function,
@@ -3287,7 +3287,7 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
32873287
&& abbrev->attrs[i].name == DW_AT_low_pc)
32883288
{
32893289
if (val.encoding == ATTR_VAL_ADDRESS)
3290-
base = val.u.uint;
3290+
base = (uintptr_t) val.u.uint;
32913291
else if (val.encoding == ATTR_VAL_ADDRESS_INDEX)
32923292
{
32933293
if (!resolve_addr_index (&ddata->dwarf_sections,

0 commit comments

Comments
 (0)