Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / python / py-arch.c
index 4fece397d1cf40c08539580d2515a957b1a4bae3..60cc5a9dd2671512175287ec652219e61e58d60b 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to architecture
 
-   Copyright (C) 2013-2015 Free Software Foundation, Inc.
+   Copyright (C) 2013-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -141,10 +141,12 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
         conversion process.  */
       if (PyLong_Check (end_obj))
         end = PyLong_AsUnsignedLongLong (end_obj);
+#if PY_MAJOR_VERSION == 2
       else if (PyInt_Check (end_obj))
         /* If the end_pc value is specified without a trailing 'L', end_obj will
            be an integer and not a long integer.  */
         end = PyInt_AsLong (end_obj);
+#endif
       else
         {
           Py_DECREF (end_obj);
@@ -196,7 +198,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
        || (end_obj == NULL && count_obj == NULL && pc == start);)
     {
       int insn_len = 0;
-      char *as = NULL;
       struct ui_file *memfile = mem_fileopen ();
       PyObject *insn_dict = PyDict_New ();
 
@@ -230,18 +231,20 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
         }
       END_CATCH
 
-      as = ui_file_xstrdup (memfile, NULL);
+      std::string as = ui_file_as_string (memfile);
+
       if (PyDict_SetItemString (insn_dict, "addr",
                                 gdb_py_long_from_ulongest (pc))
           || PyDict_SetItemString (insn_dict, "asm",
-                                   PyString_FromString (*as ? as : "<unknown>"))
+                                   PyString_FromString (!as.empty ()
+                                                       ? as.c_str ()
+                                                       : "<unknown>"))
           || PyDict_SetItemString (insn_dict, "length",
                                    PyInt_FromLong (insn_len)))
         {
           Py_DECREF (result_list);
 
           ui_file_delete (memfile);
-          xfree (as);
 
           return NULL;
         }
@@ -249,7 +252,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
       pc += insn_len;
       i++;
       ui_file_delete (memfile);
-      xfree (as);
     }
 
   return result_list;
This page took 0.024538 seconds and 4 git commands to generate.