+2020-09-15 Tom Tromey <tromey@adacore.com>
+
+ * python/python-internal.h (gdb_py_long_from_ulongest): Remove
+ defines.
+ * python/py-value.c (valpy_long): Use
+ gdb_py_object_from_ulongest.
+ * python/py-symtab.c (salpy_get_pc): Use
+ gdb_py_object_from_ulongest.
+ (salpy_get_last): Likewise.
+ * python/py-record-btrace.c (recpy_bt_insn_pc): Use
+ gdb_py_object_from_ulongest.
+ * python/py-lazy-string.c (stpy_get_address): Use
+ gdb_py_object_from_ulongest.
+ * python/py-frame.c (frapy_pc): Use gdb_py_object_from_ulongest.
+ * python/py-arch.c (archpy_disassemble): Use
+ gdb_py_object_from_ulongest and gdb_py_object_from_longest. Fix
+ error handling.
+
2020-09-15 Tom Tromey <tromey@adacore.com>
* python/python-internal.h (gdb_py_long_from_longest): Remove
return NULL;
}
- if (PyDict_SetItemString (insn_dict.get (), "addr",
- gdb_py_long_from_ulongest (pc))
- || PyDict_SetItemString (insn_dict.get (), "asm",
- PyString_FromString (!stb.empty ()
- ? stb.c_str ()
- : "<unknown>"))
- || PyDict_SetItemString (insn_dict.get (), "length",
- PyInt_FromLong (insn_len)))
+ gdbpy_ref<> pc_obj = gdb_py_object_from_ulongest (pc);
+ if (pc_obj == nullptr)
+ return nullptr;
+
+ gdbpy_ref<> asm_obj (PyString_FromString (!stb.empty ()
+ ? stb.c_str ()
+ : "<unknown>"));
+ if (asm_obj == nullptr)
+ return nullptr;
+
+ gdbpy_ref<> len_obj = gdb_py_object_from_longest (insn_len);
+ if (len_obj == nullptr)
+ return nullptr;
+
+ if (PyDict_SetItemString (insn_dict.get (), "addr", pc_obj.get ())
+ || PyDict_SetItemString (insn_dict.get (), "asm", asm_obj.get ())
+ || PyDict_SetItemString (insn_dict.get (), "length", len_obj.get ()))
return NULL;
pc += insn_len;
GDB_PY_HANDLE_EXCEPTION (except);
}
- return gdb_py_long_from_ulongest (pc);
+ return gdb_py_object_from_ulongest (pc).release ();
}
/* Implementation of gdb.Frame.read_register (self, register) -> gdb.Value.
{
lazy_string_object *self_string = (lazy_string_object *) self;
- return gdb_py_long_from_ulongest (self_string->address);
+ return gdb_py_object_from_ulongest (self_string->address).release ();
}
static PyObject *
if (insn == NULL)
return NULL;
- return gdb_py_long_from_ulongest (insn->pc);
+ return gdb_py_object_from_ulongest (insn->pc).release ();
}
/* Implementation of RecordInstruction.size [int] for btrace.
SALPY_REQUIRE_VALID (self, sal);
- return gdb_py_long_from_ulongest (sal->pc);
+ return gdb_py_object_from_ulongest (sal->pc).release ();
}
/* Implementation of the get method for the 'last' attribute of
SALPY_REQUIRE_VALID (self, sal);
if (sal->end > 0)
- return gdb_py_long_from_ulongest (sal->end - 1);
+ return gdb_py_object_from_ulongest (sal->end - 1).release ();
else
Py_RETURN_NONE;
}
}
if (type->is_unsigned ())
- return gdb_py_long_from_ulongest (l);
+ return gdb_py_object_from_ulongest (l).release ();
else
return gdb_py_object_from_longest (l).release ();
}
#define GDB_PY_LLU_ARG "K"
typedef PY_LONG_LONG gdb_py_longest;
typedef unsigned PY_LONG_LONG gdb_py_ulongest;
-#define gdb_py_long_from_ulongest PyLong_FromUnsignedLongLong
#define gdb_py_long_as_ulongest PyLong_AsUnsignedLongLong
#else /* HAVE_LONG_LONG */
#define GDB_PY_LLU_ARG "K"
typedef long gdb_py_longest;
typedef unsigned long gdb_py_ulongest;
-#define gdb_py_long_from_ulongest PyLong_FromUnsignedLong
#define gdb_py_long_as_ulongest PyLong_AsUnsignedLong
#endif /* HAVE_LONG_LONG */