ARCHPY_REQUIRE_VALID (self, gdbarch);
name = (gdbarch_bfd_arch_info (gdbarch))->printable_name;
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Implementation of
}
if (count_obj)
{
- count = PyInt_AsLong (count_obj);
+ count = PyLong_AsLong (count_obj);
if (PyErr_Occurred () || count < 0)
{
PyErr_SetString (PyExc_TypeError,
if (pc_obj == nullptr)
return nullptr;
- gdbpy_ref<> asm_obj (PyString_FromString (!stb.empty ()
- ? stb.c_str ()
- : "<unknown>"));
+ gdbpy_ref<> asm_obj
+ (PyUnicode_FromString (!stb.empty () ? stb.c_str () : "<unknown>"));
if (asm_obj == nullptr)
return nullptr;
std::vector<const char *> name_list = gdbarch_printable_names ();
for (const char *name : name_list)
{
- gdbpy_ref <> py_name (PyString_FromString (name));
+ gdbpy_ref <> py_name (PyUnicode_FromString (name));
if (py_name == nullptr)
return nullptr;
if (PyList_Append (list.get (), py_name.get ()) < 0)
_("Cannot delete `thread' attribute."));
return -1;
}
- else if (PyInt_Check (newvalue))
+ else if (PyLong_Check (newvalue))
{
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
_("Cannot delete `task' attribute."));
return -1;
}
- else if (PyInt_Check (newvalue))
+ else if (PyLong_Check (newvalue))
{
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
_("Cannot delete `ignore_count' attribute."));
return -1;
}
- else if (! PyInt_Check (newvalue))
+ else if (!PyLong_Check (newvalue))
{
PyErr_SetString (PyExc_TypeError,
_("The value of `ignore_count' must be an integer."));
if (lineobj != NULL)
{
- if (PyInt_Check (lineobj))
- line = xstrprintf ("%ld", PyInt_AsLong (lineobj));
- else if (PyString_Check (lineobj))
+ if (PyLong_Check (lineobj))
+ line = xstrprintf ("%ld", PyLong_AsLong (lineobj));
+ else if (PyUnicode_Check (lineobj))
line = python_string_to_host_string (lineobj);
else
{
if (resultobj == NULL)
return;
- if (PyInt_Check (resultobj.get ()))
+ if (PyLong_Check (resultobj.get ()))
{
/* User code may also return one of the completion constants,
thus requesting that sort of completion. We are only
if (resultobj == NULL)
return;
- if (PyInt_Check (resultobj.get ()))
+ if (PyLong_Check (resultobj.get ()))
{
/* User code may also return one of the completion constants,
thus requesting that sort of completion. */
(PyObject *) &cmdpy_object_type) < 0)
return -1;
- invoke_cst = PyString_FromString ("invoke");
+ invoke_cst = PyUnicode_FromString ("invoke");
if (invoke_cst == NULL)
return -1;
- complete_cst = PyString_FromString ("complete");
+ complete_cst = PyUnicode_FromString ("complete");
if (complete_cst == NULL)
return -1;
for (char *arg : c_argv)
{
- gdbpy_ref<> argp (PyString_FromString (arg));
+ gdbpy_ref<> argp (PyUnicode_FromString (arg));
if (argp == NULL
|| PyList_Append (py_argv.get (), argp.get ()) < 0)
process_stratum_target *target = self->target;
if (target == nullptr)
- return PyString_FromFormat ("<%s (invalid)>", Py_TYPE (obj)->tp_name);
+ return PyUnicode_FromFormat ("<%s (invalid)>", Py_TYPE (obj)->tp_name);
- return PyString_FromFormat ("<%s num=%d, what=\"%s\">",
- Py_TYPE (obj)->tp_name,
- target->connection_number,
- make_target_connection_string (target).c_str ());
+ return PyUnicode_FromFormat ("<%s num=%d, what=\"%s\">",
+ Py_TYPE (obj)->tp_name,
+ target->connection_number,
+ make_target_connection_string (target).c_str ());
}
/* Implementation of gdb.TargetConnection.is_valid() -> Boolean. Returns
frapy_str (PyObject *self)
{
const frame_id &fid = ((frame_object *) self)->frame_id;
- return PyString_FromString (fid.to_string ().c_str ());
+ return PyUnicode_FromString (fid.to_string ().c_str ());
}
/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
inferior *inf = self->inferior;
if (inf == nullptr)
- return PyString_FromString ("<gdb.Inferior (invalid)>");
+ return PyUnicode_FromString ("<gdb.Inferior (invalid)>");
- return PyString_FromFormat ("<gdb.Inferior num=%d, pid=%d>",
- inf->num, inf->pid);
+ return PyUnicode_FromFormat ("<gdb.Inferior num=%d, pid=%d>",
+ inf->num, inf->pid);
}
if (name == NULL)
Py_RETURN_NONE;
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Return a string containing target specific additional information about
if (extra_info == nullptr)
Py_RETURN_NONE;
- return PyString_FromString (extra_info);
+ return PyUnicode_FromString (extra_info);
}
static int
/* An encoding can be set to NULL by the user, so check before
attempting a Python FromString call. If NULL return Py_None. */
if (self_string->encoding)
- result = PyString_FromString (self_string->encoding);
+ result = PyUnicode_FromString (self_string->encoding);
else
{
result = Py_None;
{
membuf_object *membuf_obj = (membuf_object *) self;
- return PyString_FromFormat (_("Memory buffer for address %s, \
+ return PyUnicode_FromFormat (_("Memory buffer for address %s, \
which is %s bytes long."),
- paddress (gdbpy_enter::get_gdbarch (),
- membuf_obj->addr),
- pulongest (membuf_obj->length));
+ paddress (gdbpy_enter::get_gdbarch (),
+ membuf_obj->addr),
+ pulongest (membuf_obj->length));
}
static int
py_object_to_mi_key (PyObject *key_obj)
{
/* The key must be a string. */
- if (!PyString_Check (key_obj))
+ if (!PyUnicode_Check (key_obj))
{
gdbpy_ref<> key_repr (PyObject_Repr (key_obj));
gdb::unique_xmalloc_ptr<char> key_repr_string;
serialize_mi_result_1 (value, key_string.get ());
}
}
- else if (PySequence_Check (result) && !PyString_Check (result))
+ else if (PySequence_Check (result) && !PyUnicode_Check (result))
{
ui_out_emit_list list_emitter (uiout, field_name);
Py_ssize_t len = PySequence_Size (result);
< 0)
return -1;
- invoke_cst = PyString_FromString ("invoke");
+ invoke_cst = PyUnicode_FromString ("invoke");
if (invoke_cst == nullptr)
return -1;
gdb_assert (micmd_obj->mi_command_name != nullptr);
std::string name_str = string_printf ("-%s", micmd_obj->mi_command_name);
- return PyString_FromString (name_str.c_str ());
+ return PyUnicode_FromString (name_str.c_str ());
}
/* Get the gdb.MICommand.installed property. Returns true if this MI
objfile *obj = self->objfile;
if (obj == nullptr)
- return PyString_FromString ("<gdb.Objfile (invalid)>");
+ return PyUnicode_FromString ("<gdb.Objfile (invalid)>");
- return PyString_FromFormat ("<gdb.Objfile filename=%s>",
- objfile_name (obj));
+ return PyUnicode_FromFormat ("<gdb.Objfile filename=%s>",
+ objfile_name (obj));
}
/* Subroutine of gdbpy_lookup_objfile_by_build_id to simplify it.
static PyObject *
get_attr (PyObject *obj, PyObject *attr_name)
{
- if (PyString_Check (attr_name)
+ if (PyUnicode_Check (attr_name)
&& ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
{
parmpy_object *self = (parmpy_object *) obj;
long l;
int ok;
- if (! PyInt_Check (value))
+ if (!PyLong_Check (value))
{
PyErr_SetString (PyExc_RuntimeError,
_("The value must be integer."));
static int
set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
{
- if (PyString_Check (attr_name)
+ if (PyUnicode_Check (attr_name)
&& ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
{
if (!val)
gdb::unique_xmalloc_ptr<char> set_doc_string;
gdbpy_enter enter_py;
- gdbpy_ref<> set_doc_func (PyString_FromString ("get_set_string"));
+ gdbpy_ref<> set_doc_func (PyUnicode_FromString ("get_set_string"));
if (set_doc_func == NULL)
{
gdb::unique_xmalloc_ptr<char> show_doc_string;
gdbpy_enter enter_py;
- gdbpy_ref<> show_doc_func (PyString_FromString ("get_show_string"));
+ gdbpy_ref<> show_doc_func (PyUnicode_FromString ("get_show_string"));
if (show_doc_func == NULL)
{
if (PyObject_HasAttr (obj, show_doc_func.get ()))
{
- gdbpy_ref<> val_obj (PyString_FromString (value));
+ gdbpy_ref<> val_obj (PyUnicode_FromString (value));
if (val_obj == NULL)
{
if (PyType_Ready (&parmpy_object_type) < 0)
return -1;
- set_doc_cst = PyString_FromString ("set_doc");
+ set_doc_cst = PyUnicode_FromString ("set_doc");
if (! set_doc_cst)
return -1;
- show_doc_cst = PyString_FromString ("show_doc");
+ show_doc_cst = PyUnicode_FromString ("show_doc");
if (! show_doc_cst)
return -1;
const Py_ssize_t length = btpy_list_length (self);
Py_ssize_t start, stop, step, slicelength;
- if (PyInt_Check (value))
+ if (PyLong_Check (value))
{
- Py_ssize_t index = PyInt_AsSsize_t (value);
+ Py_ssize_t index = PyLong_AsSsize_t (value);
/* Emulate Python behavior for negative indices. */
if (index < 0)
PyObject *
recpy_bt_method (PyObject *self, void *closure)
{
- return PyString_FromString ("btrace");
+ return PyUnicode_FromString ("btrace");
}
/* Implementation of
if (config == NULL)
Py_RETURN_NONE;
- return PyString_FromString (btrace_format_short_string (config->format));
+ return PyUnicode_FromString (btrace_format_short_string (config->format));
}
/* Implementation of
PyObject *
recpy_full_method (PyObject *self, void *closure)
{
- return PyString_FromString ("full");
+ return PyUnicode_FromString ("full");
}
/* Implementation of
PyObject *
recpy_full_format (PyObject *self, void *closure)
{
- return PyString_FromString ("full");
+ return PyUnicode_FromString ("full");
}
{
const recpy_gap_object * const obj = (const recpy_gap_object *) self;
- return PyString_FromString (obj->reason_string);
+ return PyUnicode_FromString (obj->reason_string);
}
/* Record method list. */
struct reggroup *reggroup = group->reggroup;
const char *name = reggroup_name (reggroup);
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Implement gdb.RegisterGroup.name (self) -> String.
int regnum = reg->regnum;
const char *name = gdbarch_register_name (gdbarch, regnum);
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Implement gdb.RegisterDescriptor.name attribute get function. Return a
}
}
/* The register could be its internal GDB register number. */
- else if (PyInt_Check (pyo_reg_id))
+ else if (PyLong_Check (pyo_reg_id))
{
long value;
if (gdb_py_int_as_long (pyo_reg_id, &value) && (int) value == value)
const char *signal_name = gdb_signal_to_name (stop_signal);
- gdbpy_ref<> signal_name_obj (PyString_FromString (signal_name));
+ gdbpy_ref<> signal_name_obj (PyUnicode_FromString (signal_name));
if (signal_name_obj == NULL)
return NULL;
if (evpy_add_attribute (signal_event_obj.get (),
SYMPY_REQUIRE_VALID (self, symbol);
- result = PyString_FromString (symbol->print_name ());
+ result = PyUnicode_FromString (symbol->print_name ());
return result;
}
SYMPY_REQUIRE_VALID (self, symbol);
- return PyString_FromString (symbol->natural_name ());
+ return PyUnicode_FromString (symbol->natural_name ());
}
static PyObject *
SYMPY_REQUIRE_VALID (self, symbol);
- return PyString_FromString (symbol->linkage_name ());
+ return PyUnicode_FromString (symbol->linkage_name ());
}
static PyObject *
STPY_REQUIRE_VALID (self, symtab);
- result = PyString_FromString (symtab_to_filename_for_display (symtab));
+ result = PyUnicode_FromString (symtab_to_filename_for_display (symtab));
return result;
}
filename = symtab_to_filename_for_display (symtab);
}
- return PyString_FromFormat ("symbol and line for %s, line %d", filename,
- sal->line);
+ return PyUnicode_FromFormat ("symbol and line for %s, line %d", filename,
+ sal->line);
}
static void
if (field_name[0] != '\0')
{
- arg.reset (PyString_FromString (type->field (field).name ()));
+ arg.reset (PyUnicode_FromString (type->field (field).name ()));
if (arg == NULL)
return NULL;
}
gdbpy_ref<> result;
if (type->field (field).name ())
- result.reset (PyString_FromString (type->field (field).name ()));
+ result.reset (PyUnicode_FromString (type->field (field).name ()));
else
result = gdbpy_ref<>::new_reference (Py_None);
{
std::string name = ada_decode (type->name (), false);
if (!name.empty ())
- return PyString_FromString (name.c_str ());
+ return PyUnicode_FromString (name.c_str ());
}
- return PyString_FromString (type->name ());
+ return PyUnicode_FromString (type->name ());
}
/* Return the type's tag, or None. */
if (tagname == nullptr)
Py_RETURN_NONE;
- return PyString_FromString (tagname);
+ return PyUnicode_FromString (tagname);
}
/* Return the type's objfile, or None. */
if (n2_obj)
{
- if (!PyInt_Check (n2_obj))
+ if (!PyLong_Check (n2_obj))
{
PyErr_SetString (PyExc_RuntimeError,
_("Array bound must be an integer"));
stb.puts (")");
}
- return PyString_FromString (stb.c_str ());
+ return PyUnicode_FromString (stb.c_str ());
}
/* Create UnwindInfo instance for given PendingFrame and frame ID.
const char *pc_str = NULL;
if (frame == NULL)
- return PyString_FromString ("Stale PendingFrame instance");
+ return PyUnicode_FromString ("Stale PendingFrame instance");
try
{
sp_str = core_addr_to_string_nz (get_frame_sp (frame));
GDB_PY_HANDLE_EXCEPTION (except);
}
- return PyString_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
+ return PyUnicode_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
}
/* Implementation of gdb.PendingFrame.read_register (self, reg) -> gdb.Value.
gdbpy_ref<>
host_string_to_python_string (const char *str)
{
- return gdbpy_ref<> (PyString_Decode (str, strlen (str), host_charset (),
- NULL));
+ return gdbpy_ref<> (PyUnicode_Decode (str, strlen (str), host_charset (),
+ NULL));
}
/* Return true if OBJ is a Python string or unicode object, false
return gdbpy_ref<> (PyLong_FromUnsignedLong (l));
}
-/* Like PyInt_AsLong, but returns 0 on failure, 1 on success, and puts
+/* Like PyLong_AsLong, but returns 0 on failure, 1 on success, and puts
the value into an out parameter. */
int
gdb_py_int_as_long (PyObject *obj, long *result)
{
- *result = PyInt_AsLong (obj);
+ *result = PyLong_AsLong (obj);
return ! (*result == -1 && PyErr_Occurred ());
}
if (match_method == NULL)
return NULL;
- gdbpy_ref<> py_xmethod_name (PyString_FromString (xmethod_name));
+ gdbpy_ref<> py_xmethod_name (PyUnicode_FromString (xmethod_name));
if (py_xmethod_name == NULL)
return NULL;
int
gdbpy_initialize_xmethods (void)
{
- py_match_method_name = PyString_FromString (match_method_name);
+ py_match_method_name = PyUnicode_FromString (match_method_name);
if (py_match_method_name == NULL)
return -1;
py_get_arg_types_method_name
- = PyString_FromString (get_arg_types_method_name);
+ = PyUnicode_FromString (get_arg_types_method_name);
if (py_get_arg_types_method_name == NULL)
return -1;
#define Py_TPFLAGS_CHECKTYPES 0
-#define PyInt_Check PyLong_Check
-#define PyInt_AsLong PyLong_AsLong
-#define PyInt_AsSsize_t PyLong_AsSsize_t
-
-#define PyString_FromString PyUnicode_FromString
-#define PyString_Decode PyUnicode_Decode
-#define PyString_FromFormat PyUnicode_FromFormat
-#define PyString_Check PyUnicode_Check
-
/* If Python.h does not define WITH_THREAD, then the various
GIL-related functions will not be defined. However,
PyGILState_STATE will be. */
#define PyMem_RawMalloc PyMem_Malloc
#endif
-/* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading
- to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors.
- Wrap it ourselves, so that callers don't need to care. */
-
-static inline void
-gdb_Py_DECREF (void *op) /* ARI: editCase function */
-{
- Py_DECREF (op);
-}
-
-#undef Py_DECREF
-#define Py_DECREF(op) gdb_Py_DECREF (op)
-
/* PyObject_CallMethod's 'method' and 'format' parameters were missing
the 'const' qualifier before Python 3.4. Hence, we wrap the
function in our own version to avoid errors with string literals.
}
if (to_string)
- return PyString_FromString (to_string_res.c_str ());
+ return PyUnicode_FromString (to_string_res.c_str ());
Py_RETURN_NONE;
}
if (arg != NULL && strlen (arg) > 0)
{
- unparsed.reset (PyString_FromString (arg));
+ unparsed.reset (PyUnicode_FromString (arg));
if (unparsed == NULL)
return NULL;
}
if (PyCallable_Check (hook.get ()))
{
- gdbpy_ref<> current_prompt (PyString_FromString (current_gdb_prompt));
+ gdbpy_ref<> current_prompt (PyUnicode_FromString (current_gdb_prompt));
if (current_prompt == NULL)
{
gdbpy_print_stack ();
/* Return type should be None, or a String. If it is None,
fall through, we will not set a prompt. If it is a
string, set PROMPT. Anything else, set an exception. */
- if (result != Py_None && ! PyString_Check (result.get ()))
+ if (result != Py_None && !PyUnicode_Check (result.get ()))
{
PyErr_Format (PyExc_RuntimeError,
_("Return from prompt_hook must " \
if (!PyCallable_Check (hook.get ()))
return {};
- gdbpy_ref<> fname_arg (PyString_FromString (filename.c_str ()));
+ gdbpy_ref<> fname_arg (PyUnicode_FromString (filename.c_str ()));
if (fname_arg == nullptr)
{
gdbpy_print_stack ();
/* Format the address, and return it as a string. */
string_file buf;
print_address (gdbarch, addr, &buf);
- return PyString_FromString (buf.c_str ());
+ return PyUnicode_FromString (buf.c_str ());
}
\f
#include "py-event-types.def"
#undef GDB_PY_DEFINE_EVENT_TYPE
- gdbpy_to_string_cst = PyString_FromString ("to_string");
+ gdbpy_to_string_cst = PyUnicode_FromString ("to_string");
if (gdbpy_to_string_cst == NULL)
return false;
- gdbpy_children_cst = PyString_FromString ("children");
+ gdbpy_children_cst = PyUnicode_FromString ("children");
if (gdbpy_children_cst == NULL)
return false;
- gdbpy_display_hint_cst = PyString_FromString ("display_hint");
+ gdbpy_display_hint_cst = PyUnicode_FromString ("display_hint");
if (gdbpy_display_hint_cst == NULL)
return false;
- gdbpy_doc_cst = PyString_FromString ("__doc__");
+ gdbpy_doc_cst = PyUnicode_FromString ("__doc__");
if (gdbpy_doc_cst == NULL)
return false;
- gdbpy_enabled_cst = PyString_FromString ("enabled");
+ gdbpy_enabled_cst = PyUnicode_FromString ("enabled");
if (gdbpy_enabled_cst == NULL)
return false;
- gdbpy_value_cst = PyString_FromString ("value");
+ gdbpy_value_cst = PyUnicode_FromString ("value");
if (gdbpy_value_cst == NULL)
return false;
}
if (sys_path && PyList_Check (sys_path))
{
- gdbpy_ref<> pythondir (PyString_FromString (gdb_pythondir.c_str ()));
+ gdbpy_ref<> pythondir (PyUnicode_FromString (gdb_pythondir.c_str ()));
if (pythondir == NULL || PyList_Insert (sys_path, 0, pythondir.get ()))
return false;
}