Skip to content

Commit add07c6

Browse files
author
ga
committed
Fix build failure with libdwarf 0.11.1.
1 parent 4429dd0 commit add07c6

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

simavr/sim/sim_dwarf.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ static void process(struct ctx *ctxp, Dwarf_Die die)
9494
CHECK("dwarf_tag");
9595
if (tag == DW_TAG_variable) {
9696
Dwarf_Attribute attr;
97+
Dwarf_Addr c_addr, c_addr2;
9798
Dwarf_Unsigned count, op_count, symv, op2, op3, off1, off2;
9899
Dwarf_Loc_Head_c head;
99100
Dwarf_Locdesc_c loc;
100-
Dwarf_Small op, value, list_type;
101+
Dwarf_Small op, lle_value, kind;
102+
Dwarf_Bool addr_unavailable;
101103

102104
/* Get the location (address) information for this variable.
103105
* Only static allocations are of interest.
@@ -111,13 +113,14 @@ static void process(struct ctx *ctxp, Dwarf_Die die)
111113
rv = dwarf_get_loclist_c(attr, &head, &count, &err);
112114
CHECK("dwarf_get_loclist_c");
113115
if (rv == DW_DLV_NO_ENTRY)
114-
goto clean;
115-
rv = dwarf_get_locdesc_entry_c(head, 0, &value, &addr, &addr2,
116-
&op_count, &loc, &list_type,
117-
&off1, &off2, &err);
118-
CHECK("dwarf_get_locdesc_entry_c");
119-
120-
if (list_type == 0 && count == 1) {
116+
goto clean;
117+
rv = dwarf_get_locdesc_entry_d(head, 0, &lle_value, &addr, &addr2,
118+
&addr_unavailable, &c_addr, &c_addr2,
119+
&op_count, &loc, &kind,
120+
&off1, &off2, &err);
121+
CHECK("dwarf_get_locdesc_entry_d");
122+
123+
if (kind == DW_LKIND_expression && count == 1) {
121124
/* Probably statically-allocated. */
122125

123126
rv = dwarf_get_location_op_value_c(loc, 0, &op, &symv, &op2, &op3,
@@ -136,7 +139,6 @@ static void process(struct ctx *ctxp, Dwarf_Die die)
136139
if (symv > DATA_OFFSET) {
137140
symv -= DATA_OFFSET;
138141

139-
140142
/* Is it an I/O register or RAM? */
141143

142144
if (symv > 32 &&
@@ -158,7 +160,7 @@ static void process(struct ctx *ctxp, Dwarf_Die die)
158160
#endif
159161
}
160162
}
161-
dwarf_loc_head_c_dealloc(head);
163+
dwarf_dealloc_loc_head_c(head);
162164
#if CONFIG_SIMAVR_TRACE
163165
} else if (tag == DW_TAG_subprogram) {
164166
rv = dwarf_lowpc(die, &addr, &err);
@@ -206,7 +208,7 @@ static void traverse_tree(struct ctx *ctxp, Dwarf_Die start)
206208
if (rv == DW_DLV_OK)
207209
traverse_tree(ctxp, die);
208210
else
209-
CHECK("dwarf_child");
211+
CHECK("dwarf_child");
210212

211213
/* Examine siblings. */
212214

@@ -274,7 +276,7 @@ int avr_read_dwarf(avr_t *avr, const char *filename)
274276
}
275277

276278
ctx.avr = avr;
277-
rv = dwarf_init_b(fd, DW_DLC_READ, 0, NULL, NULL, &ctx.db, &err);
279+
rv = dwarf_init_b(fd, DW_GROUPNUMBER_ANY, NULL, NULL, &ctx.db, &err);
278280
if (rv != DW_DLV_OK) {
279281
if (rv == DW_DLV_NO_ENTRY)
280282
return 1;
@@ -283,7 +285,7 @@ int avr_read_dwarf(avr_t *avr, const char *filename)
283285
}
284286

285287
if (sigsetjmp(ctx.err_jmp, 0)) {
286-
dwarf_finish(ctx.db, &err);
288+
dwarf_finish(ctx.db);
287289
close(fd);
288290
return -1;
289291
}
@@ -303,6 +305,8 @@ int avr_read_dwarf(avr_t *avr, const char *filename)
303305
/* Sibling of NULL is Compiliation Unit's Debug Information Element. */
304306

305307
rv = dwarf_siblingof_b(ctx.db, NULL, 1, &die, &err);
308+
if (rv == DW_DLV_NO_ENTRY)
309+
continue;
306310
CHECK("dwarf_siblingof_b");
307311

308312
#if CONFIG_SIMAVR_TRACE
@@ -344,14 +348,13 @@ int avr_read_dwarf(avr_t *avr, const char *filename)
344348
*ep = strdup(buff);
345349
}
346350
dwarf_dealloc(ctx.db, ctx.cu_name, DW_DLA_STRING);
347-
dwarf_srclines_dealloc_b(ctx.lc);
351+
if (ctx.lc)
352+
dwarf_srclines_dealloc_b(ctx.lc);
348353
#else
349354
traverse_tree(&ctx, die);
350355
#endif
351356
}
352-
dwarf_finish(ctx.db, &err);
353-
if (rv == DW_DLV_ERROR)
354-
error("dwarf_finish", err);
357+
dwarf_finish(ctx.db);
355358
close(fd);
356359
return 0;
357360
}

0 commit comments

Comments
 (0)