While playing with JIT reader I experienced GDB to crash on null-pointer
dereference when stepping through non-jitted code.
The problem was that dwarf2_frame_find_fde () assumed that all objfiles
have BFD but that's not always true. To address this problem, this
commit skips such objfiles.
To test the fix we put breakpoint in jit_function_add (). The JIT reader
does not know how unwind this function so unwinding eventually falls
back to DWARF unwinder which in turn iterates over objfiles. Since the
the code is jitted, it is guaranteed it would eventually process JIT
objfile.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
CORE_ADDR offset;
CORE_ADDR seek_pc;
+ if (objfile->obfd == nullptr)
+ continue;
+
comp_unit *unit = find_comp_unit (objfile);
if (unit == NULL)
{
struct compunit_symtab *compunit_symtabs = nullptr;
/* The object file's BFD. Can be null if the objfile contains only
- minimal symbols, e.g. the run time common symbols for SunOS4. */
+ minimal symbols (e.g. the run time common symbols for SunOS4) or
+ if the objfile is a dynamic objfile (e.g. created by JIT reader
+ API). */
gdb_bfd_ref_ptr obfd;
"True" \
"at least one file-based objfile"
}
+
+ with_test_prefix "test dwarf unwinder" {
+ # Check that the DWARF unwinder does not crash in presence of
+ # JIT objfiles.
+ gdb_test "up"
+ gdb_breakpoint "*function_add" temporary
+ gdb_test "cont" ".*Temporary breakpoint ${any} in jit_function_add .*"
+ gdb_test "bt" \
+ [multi_line \
+ "#0 ${any} in jit_function_add ${any}" \
+ "#1 ${any} in main ${any}" \
+ ]
+ }
}
jit_reader_test