if (objfile == NULL)
return false;
- for (obj_section &osect : objfile->sections ())
+ if (objfile->sections_start == nullptr)
{
- if (section_is_overlay (&osect) && !section_is_mapped (&osect))
- continue;
+ /* Objfiles created dynamically by the JIT reader API (and possibly by
+ other means too) do not have sections. For such "dynamic" objfiles
+ walk over all compunits and check if any of them contains given
+ ADDR. */
+ for (const compunit_symtab &cu : objfile->compunits ())
+ if (cu.contains (addr))
+ return true;
+ }
+ else
+ {
+ for (obj_section &osect : objfile->sections ())
+ {
+ if (section_is_overlay (&osect) && !section_is_mapped (&osect))
+ continue;
- if (osect.contains (addr))
- return true;
+ if (osect.contains (addr))
+ return true;
+ }
}
+
return false;
}
/* A range adapter that makes it possible to iterate over all
compunits in one objfile. */
- compunit_symtab_range compunits ()
+ compunit_symtab_range compunits () const
{
auto begin = compunit_symtab_iterator (compunit_symtabs.begin ());
auto end = compunit_symtab_iterator (compunit_symtabs.end ());
/* See symtab.h. */
+bool
+compunit_symtab::contains (CORE_ADDR addr) const
+{
+ return blockvector ()->contains (addr);
+}
+
+/* See symtab.h. */
+
compunit_symtab::compunit_symtab (struct objfile *objfile,
const char *name_)
: m_objfile (objfile),
for ADDR are considered. */
struct symbol *symbol_at_address (CORE_ADDR addr) const;
+ /* True if ADDR is in this compunit_symtab, false otherwise. */
+ bool contains (CORE_ADDR addr) const;
+
/* Object file from which this symtab information was read. */
struct objfile *m_objfile;
gdb_test "python print( \[o for o in gdb.objfiles() if o.filename.startswith('<< JIT compiled code')\]\[0\].build_id )" \
"None" \
"python gdb.Objfile.build_id"
+
+ # Check that Progspace.objfile_for_address () finds "jitted"
+ # objfile
+ gdb_test "frame 0" \
+ "#0 $hex in jit_function_stack_mangle ()$any" \
+ "select frame 0"
+ gdb_test "python print( gdb.current_progspace().objfile_for_address(gdb.parse_and_eval('\$pc')) )" \
+ "<gdb.Objfile filename=<< JIT compiled code at $hex >>>" \
+ "python gdb.Progspace.objfile_for_address"
}
}
}