invalid after this function returns.
As a special case, the ERRNUM argument will be passed as -1 if no
- debug info can be found for the executable, but the function
- requires debug info (e.g., backtrace_full, backtrace_pcinfo). The
- MSG in this case will be something along the lines of "no debug
- info". Similarly, ERRNUM will be passed as -1 if there is no
- symbol table, but the function requires a symbol table (e.g.,
- backtrace_syminfo). This may be used as a signal that some other
- approach should be tried. */
+ debug info can be found for the executable, or if the debug info
+ exists but has an unsupported version, but the function requires
+ debug info (e.g., backtrace_full, backtrace_pcinfo). The MSG in
+ this case will be something along the lines of "no debug info".
+ Similarly, ERRNUM will be passed as -1 if there is no symbol table,
+ but the function requires a symbol table (e.g., backtrace_syminfo).
+ This may be used as a signal that some other approach should be
+ tried. */
typedef void (*backtrace_error_callback) (void *data, const char *msg,
int errnum);
/* Report an error for a DWARF buffer. */
static void
-dwarf_buf_error (struct dwarf_buf *buf, const char *msg)
+dwarf_buf_error (struct dwarf_buf *buf, const char *msg, int errnum)
{
char b[200];
snprintf (b, sizeof b, "%s in %s at %d",
msg, buf->name, (int) (buf->buf - buf->start));
- buf->error_callback (buf->data, b, 0);
+ buf->error_callback (buf->data, b, errnum);
}
/* Require at least COUNT bytes in BUF. Return 1 if all is well, 0 on
if (!buf->reported_underflow)
{
- dwarf_buf_error (buf, "DWARF underflow");
+ dwarf_buf_error (buf, "DWARF underflow", 0);
buf->reported_underflow = 1;
}
case 8:
return read_uint64 (buf);
default:
- dwarf_buf_error (buf, "unrecognized address size");
+ dwarf_buf_error (buf, "unrecognized address size", 0);
return 0;
}
}
ret |= ((uint64_t) (b & 0x7f)) << shift;
else if (!overflow)
{
- dwarf_buf_error (buf, "LEB128 overflows uint64_t");
+ dwarf_buf_error (buf, "LEB128 overflows uint64_t", 0);
overflow = 1;
}
shift += 7;
val |= ((uint64_t) (b & 0x7f)) << shift;
else if (!overflow)
{
- dwarf_buf_error (buf, "signed LEB128 overflows uint64_t");
+ dwarf_buf_error (buf, "signed LEB128 overflows uint64_t", 0);
overflow = 1;
}
shift += 7;
offset = read_offset (buf, is_dwarf64);
if (offset >= dwarf_sections->size[DEBUG_STR])
{
- dwarf_buf_error (buf, "DW_FORM_strp out of range");
+ dwarf_buf_error (buf, "DW_FORM_strp out of range", 0);
return 0;
}
val->encoding = ATTR_VAL_STRING;
offset = read_offset (buf, is_dwarf64);
if (offset >= dwarf_sections->size[DEBUG_LINE_STR])
{
- dwarf_buf_error (buf, "DW_FORM_line_strp out of range");
+ dwarf_buf_error (buf, "DW_FORM_line_strp out of range", 0);
return 0;
}
val->encoding = ATTR_VAL_STRING;
if (form == DW_FORM_implicit_const)
{
dwarf_buf_error (buf,
- "DW_FORM_indirect to DW_FORM_implicit_const");
+ "DW_FORM_indirect to DW_FORM_implicit_const",
+ 0);
return 0;
}
return read_attribute ((enum dwarf_form) form, 0, buf, is_dwarf64,
}
if (offset >= altlink->dwarf_sections.size[DEBUG_STR])
{
- dwarf_buf_error (buf, "DW_FORM_strp_sup out of range");
+ dwarf_buf_error (buf, "DW_FORM_strp_sup out of range", 0);
return 0;
}
val->encoding = ATTR_VAL_STRING;
return 1;
}
default:
- dwarf_buf_error (buf, "unrecognized DWARF form");
+ dwarf_buf_error (buf, "unrecognized DWARF form", -1);
return 0;
}
}
offset = read_offset (&offset_buf, is_dwarf64);
if (offset >= dwarf_sections->size[DEBUG_STR])
{
- dwarf_buf_error (&offset_buf, "DW_FORM_strx offset out of range");
+ dwarf_buf_error (&offset_buf,
+ "DW_FORM_strx offset out of range",
+ 0);
return 0;
}
*string = (const char *) dwarf_sections->data[DEBUG_STR] + offset;
break;
default:
- dwarf_buf_error (&rnglists_buf, "unrecognized DW_RLE value");
+ dwarf_buf_error (&rnglists_buf, "unrecognized DW_RLE value", -1);
return 0;
}
}
version = read_uint16 (&unit_buf);
if (version < 2 || version > 5)
{
- dwarf_buf_error (&unit_buf, "unrecognized DWARF version");
+ dwarf_buf_error (&unit_buf, "unrecognized DWARF version", -1);
goto fail;
}
{
dwarf_buf_error (hdr_buf,
("invalid directory index in "
- "line number program header"));
+ "line number program header"),
+ 0);
return 0;
}
dir_len = strlen (dir);
{
dwarf_buf_error (hdr_buf,
("invalid directory index in "
- "line number program header"));
+ "line number program header"),
+ 0);
return 0;
}
dir = hdr->dirs[val.u.uint];
if (path == NULL)
{
dwarf_buf_error (hdr_buf,
- "missing file name in line number program header");
+ "missing file name in line number program header",
+ 0);
return 0;
}
hdr->version = read_uint16 (line_buf);
if (hdr->version < 2 || hdr->version > 5)
{
- dwarf_buf_error (line_buf, "unsupported line number version");
+ dwarf_buf_error (line_buf, "unsupported line number version", -1);
return 0;
}
if (read_byte (line_buf) != 0)
{
dwarf_buf_error (line_buf,
- "non-zero segment_selector_size not supported");
+ "non-zero segment_selector_size not supported",
+ -1);
return 0;
}
}
{
dwarf_buf_error (line_buf,
("invalid directory index "
- "in line number program"));
+ "in line number program"),
+ 0);
return 0;
}
dir_len = strlen (dir);
{
dwarf_buf_error (line_buf,
("invalid file number in "
- "line number program"));
+ "line number program"),
+ 0);
return 0;
}
filename = hdr->filenames[fileno];
code = read_uleb128 (&unit_buf);
if (code == 0)
{
- dwarf_buf_error (&unit_buf, "invalid abstract origin or specification");
+ dwarf_buf_error (&unit_buf,
+ "invalid abstract origin or specification",
+ 0);
return NULL;
}
{
dwarf_buf_error (unit_buf,
("invalid file number in "
- "DW_AT_call_file attribute"));
+ "DW_AT_call_file attribute"),
+ 0);
return 0;
}
function->caller_filename =