+2020-09-15 Tom Tromey <tromey@adacore.com>
+
+ * python/python-internal.h (PyInt_FromLong): Remove define.
+ * python/py-value.c (convert_value_from_python): Use
+ gdb_py_object_from_longest.
+ * python/py-type.c (typy_get_code): Use
+ gdb_py_object_from_longest.
+ * python/py-symtab.c (salpy_get_line): Use
+ gdb_py_object_from_longest.
+ * python/py-symbol.c (sympy_get_addr_class, sympy_line): Use
+ gdb_py_object_from_longest.
+ * python/py-record.c (recpy_gap_reason_code): Use
+ gdb_py_object_from_longest.
+ * python/py-record-btrace.c (recpy_bt_insn_size)
+ (recpy_bt_func_level, btpy_list_count): Use
+ gdb_py_object_from_longest.
+ * python/py-infthread.c (gdbpy_create_ptid_object): Use
+ gdb_py_object_from_longest. Fix error handling.
+ * python/py-framefilter.c (bootstrap_python_frame_filters): Use
+ gdb_py_object_from_longest.
+ * python/py-frame.c (frapy_type, frapy_unwind_stop_reason): Use
+ gdb_py_object_from_longest.
+ * python/py-breakpoint.c (bppy_get_type, bppy_get_number)
+ (bppy_get_thread, bppy_get_task, bppy_get_hit_count)
+ (bppy_get_ignore_count): Use gdb_py_object_from_longest.
+
2020-09-15 Tom Tromey <tromey@adacore.com>
* python/python.c (gdbpy_parameter_value): Use
BPPY_REQUIRE_VALID (self_bp);
- return PyInt_FromLong (self_bp->bp->type);
+ return gdb_py_object_from_longest (self_bp->bp->type).release ();
}
/* Python function to get the visibility of the breakpoint. */
BPPY_REQUIRE_VALID (self_bp);
- return PyInt_FromLong (self_bp->number);
+ return gdb_py_object_from_longest (self_bp->number).release ();
}
/* Python function to get the breakpoint's thread ID. */
if (self_bp->bp->thread == -1)
Py_RETURN_NONE;
- return PyInt_FromLong (self_bp->bp->thread);
+ return gdb_py_object_from_longest (self_bp->bp->thread).release ();
}
/* Python function to get the breakpoint's task ID (in Ada). */
if (self_bp->bp->task == 0)
Py_RETURN_NONE;
- return PyInt_FromLong (self_bp->bp->task);
+ return gdb_py_object_from_longest (self_bp->bp->task).release ();
}
/* Python function to get the breakpoint's hit count. */
BPPY_REQUIRE_VALID (self_bp);
- return PyInt_FromLong (self_bp->bp->hit_count);
+ return gdb_py_object_from_longest (self_bp->bp->hit_count).release ();
}
/* Python function to get the breakpoint's ignore count. */
BPPY_REQUIRE_VALID (self_bp);
- return PyInt_FromLong (self_bp->bp->ignore_count);
+ return gdb_py_object_from_longest (self_bp->bp->ignore_count).release ();
}
/* Internal function to validate the Python parameters/keywords
GDB_PY_HANDLE_EXCEPTION (except);
}
- return PyInt_FromLong (type);
+ return gdb_py_object_from_longest (type).release ();
}
/* Implementation of gdb.Frame.architecture (self) -> gdb.Architecture.
stop_reason = get_frame_unwind_stop_reason (frame);
- return PyInt_FromLong (stop_reason);
+ return gdb_py_object_from_longest (stop_reason).release ();
}
/* Implementation of gdb.Frame.pc (self) -> Long.
if (sort_func == NULL)
return NULL;
- gdbpy_ref<> py_frame_low (PyInt_FromLong (frame_low));
+ gdbpy_ref<> py_frame_low = gdb_py_object_from_longest (frame_low);
if (py_frame_low == NULL)
return NULL;
- gdbpy_ref<> py_frame_high (PyInt_FromLong (frame_high));
+ gdbpy_ref<> py_frame_high = gdb_py_object_from_longest (frame_high);
if (py_frame_high == NULL)
return NULL;
lwp = ptid.lwp ();
tid = ptid.tid ();
- PyTuple_SET_ITEM (ret, 0, PyInt_FromLong (pid));
- PyTuple_SET_ITEM (ret, 1, PyInt_FromLong (lwp));
- PyTuple_SET_ITEM (ret, 2, PyInt_FromLong (tid));
-
+ gdbpy_ref<> pid_obj = gdb_py_object_from_longest (pid);
+ if (pid_obj == nullptr)
+ return nullptr;
+ gdbpy_ref<> lwp_obj = gdb_py_object_from_longest (lwp);
+ if (lwp_obj == nullptr)
+ return nullptr;
+ gdbpy_ref<> tid_obj = gdb_py_object_from_longest (tid);
+ if (tid_obj == nullptr)
+ return nullptr;
+
+ /* Note that these steal references, hence the use of 'release'. */
+ PyTuple_SET_ITEM (ret, 0, pid_obj.release ());
+ PyTuple_SET_ITEM (ret, 1, lwp_obj.release ());
+ PyTuple_SET_ITEM (ret, 2, tid_obj.release ());
+
return ret;
}
if (insn == NULL)
return NULL;
- return PyInt_FromLong (insn->size);
+ return gdb_py_object_from_longest (insn->size).release ();
}
/* Implementation of RecordInstruction.is_speculative [bool] for btrace.
return NULL;
tinfo = ((recpy_element_object *) self)->thread;
- return PyInt_FromLong (tinfo->btrace.level + func->level);
+ return gdb_py_object_from_longest (tinfo->btrace.level
+ + func->level).release ();
}
/* Implementation of RecordFunctionSegment.symbol [gdb.Symbol] for btrace.
{
/* We know that if an element is in the list, it is so exactly one time,
enabling us to reuse the "is element of" check. */
- return PyInt_FromLong (btpy_list_contains (self, value));
+ return gdb_py_object_from_longest (btpy_list_contains (self,
+ value)).release ();
}
/* Python rich compare function to allow for equality and inequality checks
{
const recpy_gap_object * const obj = (const recpy_gap_object *) self;
- return PyInt_FromLong (obj->reason_code);
+ return gdb_py_object_from_longest (obj->reason_code).release ();
}
/* Implementation of RecordGap.error_string [str]. */
SYMPY_REQUIRE_VALID (self, symbol);
- return PyInt_FromLong (SYMBOL_CLASS (symbol));
+ return gdb_py_object_from_longest (SYMBOL_CLASS (symbol)).release ();
}
static PyObject *
SYMPY_REQUIRE_VALID (self, symbol);
- return PyInt_FromLong (SYMBOL_LINE (symbol));
+ return gdb_py_object_from_longest (SYMBOL_LINE (symbol)).release ();
}
/* Implementation of gdb.Symbol.is_valid (self) -> Boolean.
SALPY_REQUIRE_VALID (self, sal);
- return PyInt_FromLong (sal->line);
+ return gdb_py_object_from_longest (sal->line).release ();
}
static PyObject *
{
struct type *type = ((type_object *) self)->type;
- return PyInt_FromLong (type->code ());
+ return gdb_py_object_from_longest (type->code ()).release ();
}
/* Helper function for typy_fields which converts a single field to a
if (PyErr_ExceptionMatches (PyExc_OverflowError))
{
gdbpy_err_fetch fetched_error;
- gdbpy_ref<> zero (PyInt_FromLong (0));
+ gdbpy_ref<> zero = gdb_py_object_from_longest (0);
/* Check whether obj is positive. */
if (PyObject_RichCompareBool (obj, zero.get (), Py_GT) > 0)
#define Py_TPFLAGS_CHECKTYPES 0
#define PyInt_Check PyLong_Check
-#define PyInt_FromLong PyLong_FromLong
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AsSsize_t PyLong_AsSsize_t