@@ -743,13 +743,13 @@ struct dwarf_data
743
743
/* Report an error for a DWARF buffer. */
744
744
745
745
static void
746
- dwarf_buf_error (struct dwarf_buf * buf , const char * msg )
746
+ dwarf_buf_error (struct dwarf_buf * buf , const char * msg , int errnum )
747
747
{
748
748
char b [200 ];
749
749
750
750
snprintf (b , sizeof b , "%s in %s at %d" ,
751
751
msg , buf -> name , (int ) (buf -> buf - buf -> start ));
752
- buf -> error_callback (buf -> data , b , 0 );
752
+ buf -> error_callback (buf -> data , b , errnum );
753
753
}
754
754
755
755
/* Require at least COUNT bytes in BUF. Return 1 if all is well, 0 on
@@ -763,7 +763,7 @@ require (struct dwarf_buf *buf, size_t count)
763
763
764
764
if (!buf -> reported_underflow )
765
765
{
766
- dwarf_buf_error (buf , "DWARF underflow" );
766
+ dwarf_buf_error (buf , "DWARF underflow" , 0 );
767
767
buf -> reported_underflow = 1 ;
768
768
}
769
769
@@ -925,7 +925,7 @@ read_address (struct dwarf_buf *buf, int addrsize)
925
925
case 8 :
926
926
return read_uint64 (buf );
927
927
default :
928
- dwarf_buf_error (buf , "unrecognized address size" );
928
+ dwarf_buf_error (buf , "unrecognized address size" , 0 );
929
929
return 0 ;
930
930
}
931
931
}
@@ -976,7 +976,7 @@ read_uleb128 (struct dwarf_buf *buf)
976
976
ret |= ((uint64_t ) (b & 0x7f )) << shift ;
977
977
else if (!overflow )
978
978
{
979
- dwarf_buf_error (buf , "LEB128 overflows uint64_t" );
979
+ dwarf_buf_error (buf , "LEB128 overflows uint64_t" , 0 );
980
980
overflow = 1 ;
981
981
}
982
982
shift += 7 ;
@@ -1011,7 +1011,7 @@ read_sleb128 (struct dwarf_buf *buf)
1011
1011
val |= ((uint64_t ) (b & 0x7f )) << shift ;
1012
1012
else if (!overflow )
1013
1013
{
1014
- dwarf_buf_error (buf , "signed LEB128 overflows uint64_t" );
1014
+ dwarf_buf_error (buf , "signed LEB128 overflows uint64_t" , 0 );
1015
1015
overflow = 1 ;
1016
1016
}
1017
1017
shift += 7 ;
@@ -1151,7 +1151,7 @@ read_attribute (enum dwarf_form form, uint64_t implicit_val,
1151
1151
offset = read_offset (buf , is_dwarf64 );
1152
1152
if (offset >= dwarf_sections -> size [DEBUG_STR ])
1153
1153
{
1154
- dwarf_buf_error (buf , "DW_FORM_strp out of range" );
1154
+ dwarf_buf_error (buf , "DW_FORM_strp out of range" , 0 );
1155
1155
return 0 ;
1156
1156
}
1157
1157
val -> encoding = ATTR_VAL_STRING ;
@@ -1166,7 +1166,7 @@ read_attribute (enum dwarf_form form, uint64_t implicit_val,
1166
1166
offset = read_offset (buf , is_dwarf64 );
1167
1167
if (offset >= dwarf_sections -> size [DEBUG_LINE_STR ])
1168
1168
{
1169
- dwarf_buf_error (buf , "DW_FORM_line_strp out of range" );
1169
+ dwarf_buf_error (buf , "DW_FORM_line_strp out of range" , 0 );
1170
1170
return 0 ;
1171
1171
}
1172
1172
val -> encoding = ATTR_VAL_STRING ;
@@ -1213,7 +1213,8 @@ read_attribute (enum dwarf_form form, uint64_t implicit_val,
1213
1213
if (form == DW_FORM_implicit_const )
1214
1214
{
1215
1215
dwarf_buf_error (buf ,
1216
- "DW_FORM_indirect to DW_FORM_implicit_const" );
1216
+ "DW_FORM_indirect to DW_FORM_implicit_const" ,
1217
+ 0 );
1217
1218
return 0 ;
1218
1219
}
1219
1220
return read_attribute ((enum dwarf_form ) form , 0 , buf , is_dwarf64 ,
@@ -1346,7 +1347,7 @@ read_attribute (enum dwarf_form form, uint64_t implicit_val,
1346
1347
}
1347
1348
if (offset >= altlink -> dwarf_sections .size [DEBUG_STR ])
1348
1349
{
1349
- dwarf_buf_error (buf , "DW_FORM_strp_sup out of range" );
1350
+ dwarf_buf_error (buf , "DW_FORM_strp_sup out of range" , 0 );
1350
1351
return 0 ;
1351
1352
}
1352
1353
val -> encoding = ATTR_VAL_STRING ;
@@ -1355,7 +1356,7 @@ read_attribute (enum dwarf_form form, uint64_t implicit_val,
1355
1356
return 1 ;
1356
1357
}
1357
1358
default :
1358
- dwarf_buf_error (buf , "unrecognized DWARF form" );
1359
+ dwarf_buf_error (buf , "unrecognized DWARF form" , -1 );
1359
1360
return 0 ;
1360
1361
}
1361
1362
}
@@ -1404,7 +1405,9 @@ resolve_string (const struct dwarf_sections *dwarf_sections, int is_dwarf64,
1404
1405
offset = read_offset (& offset_buf , is_dwarf64 );
1405
1406
if (offset >= dwarf_sections -> size [DEBUG_STR ])
1406
1407
{
1407
- dwarf_buf_error (& offset_buf , "DW_FORM_strx offset out of range" );
1408
+ dwarf_buf_error (& offset_buf ,
1409
+ "DW_FORM_strx offset out of range" ,
1410
+ 0 );
1408
1411
return 0 ;
1409
1412
}
1410
1413
* string = (const char * ) dwarf_sections -> data [DEBUG_STR ] + offset ;
@@ -2212,7 +2215,7 @@ add_ranges_from_rnglists (
2212
2215
break ;
2213
2216
2214
2217
default :
2215
- dwarf_buf_error (& rnglists_buf , "unrecognized DW_RLE value" );
2218
+ dwarf_buf_error (& rnglists_buf , "unrecognized DW_RLE value" , -1 );
2216
2219
return 0 ;
2217
2220
}
2218
2221
}
@@ -2479,7 +2482,7 @@ build_address_map (struct backtrace_state *state, uintptr_t base_address,
2479
2482
version = read_uint16 (& unit_buf );
2480
2483
if (version < 2 || version > 5 )
2481
2484
{
2482
- dwarf_buf_error (& unit_buf , "unrecognized DWARF version" );
2485
+ dwarf_buf_error (& unit_buf , "unrecognized DWARF version" , -1 );
2483
2486
goto fail ;
2484
2487
}
2485
2488
@@ -2758,7 +2761,8 @@ read_v2_paths (struct backtrace_state *state, struct unit *u,
2758
2761
{
2759
2762
dwarf_buf_error (hdr_buf ,
2760
2763
("invalid directory index in "
2761
- "line number program header" ));
2764
+ "line number program header" ),
2765
+ 0 );
2762
2766
return 0 ;
2763
2767
}
2764
2768
dir_len = strlen (dir );
@@ -2827,7 +2831,8 @@ read_lnct (struct backtrace_state *state, struct dwarf_data *ddata,
2827
2831
{
2828
2832
dwarf_buf_error (hdr_buf ,
2829
2833
("invalid directory index in "
2830
- "line number program header" ));
2834
+ "line number program header" ),
2835
+ 0 );
2831
2836
return 0 ;
2832
2837
}
2833
2838
dir = hdr -> dirs [val .u .uint ];
@@ -2842,7 +2847,8 @@ read_lnct (struct backtrace_state *state, struct dwarf_data *ddata,
2842
2847
if (path == NULL )
2843
2848
{
2844
2849
dwarf_buf_error (hdr_buf ,
2845
- "missing file name in line number program header" );
2850
+ "missing file name in line number program header" ,
2851
+ 0 );
2846
2852
return 0 ;
2847
2853
}
2848
2854
@@ -2969,7 +2975,7 @@ read_line_header (struct backtrace_state *state, struct dwarf_data *ddata,
2969
2975
hdr -> version = read_uint16 (line_buf );
2970
2976
if (hdr -> version < 2 || hdr -> version > 5 )
2971
2977
{
2972
- dwarf_buf_error (line_buf , "unsupported line number version" );
2978
+ dwarf_buf_error (line_buf , "unsupported line number version" , -1 );
2973
2979
return 0 ;
2974
2980
}
2975
2981
@@ -2983,7 +2989,8 @@ read_line_header (struct backtrace_state *state, struct dwarf_data *ddata,
2983
2989
if (read_byte (line_buf ) != 0 )
2984
2990
{
2985
2991
dwarf_buf_error (line_buf ,
2986
- "non-zero segment_selector_size not supported" );
2992
+ "non-zero segment_selector_size not supported" ,
2993
+ -1 );
2987
2994
return 0 ;
2988
2995
}
2989
2996
}
@@ -3124,7 +3131,8 @@ read_line_program (struct backtrace_state *state, struct dwarf_data *ddata,
3124
3131
{
3125
3132
dwarf_buf_error (line_buf ,
3126
3133
("invalid directory index "
3127
- "in line number program" ));
3134
+ "in line number program" ),
3135
+ 0 );
3128
3136
return 0 ;
3129
3137
}
3130
3138
dir_len = strlen (dir );
@@ -3190,7 +3198,8 @@ read_line_program (struct backtrace_state *state, struct dwarf_data *ddata,
3190
3198
{
3191
3199
dwarf_buf_error (line_buf ,
3192
3200
("invalid file number in "
3193
- "line number program" ));
3201
+ "line number program" ),
3202
+ 0 );
3194
3203
return 0 ;
3195
3204
}
3196
3205
filename = hdr -> filenames [fileno ];
@@ -3425,7 +3434,9 @@ read_referenced_name (struct dwarf_data *ddata, struct unit *u,
3425
3434
code = read_uleb128 (& unit_buf );
3426
3435
if (code == 0 )
3427
3436
{
3428
- dwarf_buf_error (& unit_buf , "invalid abstract origin or specification" );
3437
+ dwarf_buf_error (& unit_buf ,
3438
+ "invalid abstract origin or specification" ,
3439
+ 0 );
3429
3440
return NULL ;
3430
3441
}
3431
3442
@@ -3628,7 +3639,8 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
3628
3639
{
3629
3640
dwarf_buf_error (unit_buf ,
3630
3641
("invalid file number in "
3631
- "DW_AT_call_file attribute" ));
3642
+ "DW_AT_call_file attribute" ),
3643
+ 0 );
3632
3644
return 0 ;
3633
3645
}
3634
3646
function -> caller_filename =
0 commit comments