Check gdb_python_module in gdbpy_handle_missing_debuginfo

If you run gdb in the build tree without --data-directory, on a
program that does not have debug info, it will crash, because
gdbpy_handle_missing_debuginfo unconditionally uses gdb_python_module.

Other code in gdb using gdb_python_module checks it first and it
seemes harmless to do the same thing here.  (gdb_python_initialized
does not cover this case so that python can be partially initialized
and still somewhat work.)
This commit is contained in:
Tom Tromey
2023-11-15 06:48:55 -07:00
parent e1ccbfffb5
commit 7d21600b31

View File

@@ -1703,7 +1703,7 @@ gdbpy_handle_missing_debuginfo (const struct extension_language_defn *extlang,
struct objfile *objfile)
{
/* Early exit if Python is not initialised. */
if (!gdb_python_initialized)
if (!gdb_python_initialized || gdb_python_module == nullptr)
return {};
struct gdbarch *gdbarch = objfile->arch ();