1. 27 Jan, 2018 1 commit
    • Eli Zaretskii's avatar
      Avoid compilation errors in MinGW native builds of GDB · b2a426e2
      Eli Zaretskii authored
      The error is triggered by including python-internal.h, and the
      error message is:
      
           In file included from d:\usr\lib\gcc\mingw32\6.3.0\include\c++\math.h:36:0,
      	      from build-gnulib/import/math.h:27,
      	      from d:/usr/Python26/include/pyport.h:235,
      	      from d:/usr/Python26/include/Python.h:58,
      	      from python/python-internal.h:94,
      	      from python/py-arch.c:24:
           d:\usr\lib\gcc\mingw32\6.3.0\include\c++\cmath:1157:11: error: '::hypot' has not been declared
              using ::hypot;
      	        ^~~~~
      
      This happens because Python headers define 'hypot' to expand to
      '_hypot' in the Windows builds.
      
      gdb/ChangeLog:
      2018-01-27  Eli Zaretskii  <eliz@gnu.org>
      
      	* python/python-internal.h (_hypot) [__MINGW32__]: Define back to
      	'hypoth'.  This avoids a compilation error.
      b2a426e2
  2. 07 Jan, 2018 1 commit
    • Simon Marchi's avatar
      C++ify xmethod_worker, get rid of VEC(xmethod_worker_ptr) · ba18742c
      Simon Marchi authored
      The initial goal of this patch was to remove the usage of
      VEC(xmethod_worker_ptr) and corresponding cleanups.  I ended up having
      to  C++ify the xmethod_worker code, to be able to have xmethod_workers
      free their data in destructors, and therefore be able to use vectors of
      xmethod_worker unique_ptr.
      
      The operations in extension_language_ops that act on one instance of
      xmethod_worker (get result type, get args type, invoke) are transformed
      to methods of xmethod_worker.  xmethod_worker becomes an abstract base
      class with virtual pure methods which python_xmethod_worker implements.
      The only xmethod-related operation left in extension_language_ops is
      get_matching_xmethod_workers, which returns a list of xmethod_workers.
      
      The changes are relatively straightforward, but here are some notes on
      things that may raise eyebrows:
      
        - I was not really comfortable with the value_of_xmethod function.  At
        first it looks like a simple getter, so I considered making it a
        method of xmethod_worker.  But actually it creates a value and
        transfers the ownership of the xmethod_worker to it.  It would be a
        bit weird and error-prone if calling a method on an object silently
        removed the ownership of the object from the caller.  To reflect the
        behavior more accurately, I renamed it to value_from_xmethod and made
        it accept an rvalue-reference (so the caller knows it gives away the
        ownership).  I noticed the backlink from xmethod_worker to its owning
        value was not used, so I removed it.
      
        - Some code, like get_matching_xmethod_workers, made each callee fill
        a new vector, which was then merged in the result vector.  I think
        it's safe if we always pass the same vector around, and each
        implementation just appends to it.
      
        - The clone operation does not seem particularly useful, it is removed
        in the following patch.
      
      gdb/ChangeLog:
      
      	* extension-priv.h (enum ext_lang_rc): Remove, move to extension.h.
      	(struct extension_language_ops) <clone_xmethod_worker_data>: Remove.
      	<free_xmethod_worker_data>: Remove.
      	<get_matching_xmethod_workers>: Chance VEC to std::vector.
      	<get_xmethod_arg_types>: Remove.
      	<get_xmethod_result_type>: Remove.
      	<invoke_xmethod>: Remove.
      	* extension.c (new_xmethod_worker): Remove.
      	(clone_xmethod_worker): Remove.
      	(get_matching_xmethod_workers): Return void, pass std::vector by
      	pointer.
      	(get_xmethod_arg_types): Rename to...
      	(xmethod_worker::get_arg_types): ... this, and adjust.
      	(get_xmethod_result_type): Rename to...
      	(xmethod_worker::get_result_type): ... this, and adjust.
      	(invoke_xmethod): Remove.
      	(free_xmethod_worker): Remove.
      	(free_xmethod_worker_vec): Remove.
      	* extension.h (enum ext_lang_rc): Move here from
      	extension-priv.h.
      	(struct xmethod_worker): Add constructor and destructor.
      	<data>: Remove.
      	<value>: Remove.
      	<invoke, clone, do_get_result_type, do_get_arg_types>: New
      	virtual pure methods.
      	<get_arg_types, get_result_type>: New methods.
      	(xmethod_worker_ptr): Remove typedef.
      	(DEF_VEC_P (xmethod_worker_ptr)): Remove.
      	(xmethod_worker_vec): Remove typedef.
      	(xmethod_worker_up): New typedef.
      	(invoke_xmethod): Remove.
      	(clone_xmethod_worker): Remove.
      	(free_xmethod_worker): Remove.
      	(free_xmethod_worker_vec): Remove.
      	(get_xmethod_arg_types): Remove.
      	(get_xmethod_result_type): Remove.
      	* valops.c (find_method_list): Use std::vector, don't use
      	intermediate vector.
      	(value_find_oload_method_list): Use std::vector.
      	(find_overload_match): Use std::vector.
      	(find_oload_champ): Use std::vector.
      	* value.c (value_free): Use operator delete.
      	(value_of_xmethod): Rename to...
      	(value_from_xmethod): ... this.  Don't assign
      	xmethod_worker::value, take rvalue-reference.
      	(result_type_of_xmethod): Adjust.
      	(call_xmethod): Adjust.
      	* value.h: Include extension.h.
      	(struct xmethod_worker): Don't forward-declare.
      	(value_of_xmethod): Rename to...
      	(value_from_xmethod): ... this, take rvalue-reference.
      	* python/py-xmethods.c (struct gdbpy_worker_data): Rename to...
      	(struct python_xmethod_worker): ... this, add constructor and
      	destructor.
      	<invoke, clone, do_get_arg_types, do_get_result_type>: Implement.
      	(gdbpy_free_xmethod_worker_data): Rename to...
      	(python_xmethod_worker::~python_xmethod_worker): ... this and
      	adjust.
      	(gdbpy_clone_xmethod_worker_data): Rename to...
      	(python_xmethod_worker::clone): ... this and adjust.
      	(gdbpy_get_matching_xmethod_workers): Use std::vector, don't use
      	temporary vector.
      	(gdbpy_get_xmethod_arg_types): Rename to...
      	(python_xmethod_worker::do_get_arg_types): ... this and adjust.
      	(gdbpy_get_xmethod_result_type): Rename to...
      	(python_xmethod_worker::do_get_result_type): ... this and
      	adjust.
      	(gdbpy_invoke_xmethod): Rename to...
      	(python_xmethod_worker::invoke): ... this and adjust.
      	(new_python_xmethod_worker): Rename to...
      	(python_xmethod_worker::python_xmethod_worker): ... this and
      	adjust.
      	* python/python-internal.h (gdbpy_clone_xmethod_worker_data):
      	Remove.
      	(gdbpy_free_xmethod_worker_data): Remove.
      	(gdbpy_get_matching_xmethod_workers): Use std::vector.
      	(gdbpy_get_xmethod_arg_types): Remove.
      	(gdbpy_get_xmethod_result_type): Remove.
      	(gdbpy_invoke_xmethod): Remove.
      	* python/python.c (python_extension_ops): Remove obsolete
      	callbacks.
      ba18742c
  3. 02 Jan, 2018 1 commit
  4. 21 Sep, 2017 1 commit
  5. 19 Sep, 2017 1 commit
    • Yao Qi's avatar
      Use DISABLE_COPY_AND_ASSIGN · d6541620
      Yao Qi authored
      We have many classes that copy cotr and assignment operator are deleted,
      so this patch replaces these existing mechanical code with macro
      DISABLE_COPY_AND_ASSIGN.
      
      gdb:
      
      2017-09-19  Yao Qi  <yao.qi@linaro.org>
      
      	* annotate.h (struct annotate_arg_emitter): Use
      	DISABLE_COPY_AND_ASSIGN.
      	* common/refcounted-object.h (refcounted_object): Likewise.
      	* completer.h (struct completion_result): Likewise.
      	* dwarf2read.c (struct dwarf2_per_objfile): Likewise.
      	* filename-seen-cache.h (filename_seen_cache): Likewise.
      	* gdbcore.h (thread_section_name): Likewise.
      	* gdb_regex.h (compiled_regex): Likewise.
      	* gdbthread.h (scoped_restore_current_thread): Likewise.
      	* inferior.h (scoped_restore_current_inferior): Likewise.
      	* jit.c (jit_reader): Likewise.
      	* linespec.h (struct linespec_result): Likewise.
      	* mi/mi-parse.h (struct mi_parse): Likewise.
      	* nat/fork-inferior.c (execv_argv): Likewise.
      	* progspace.h (scoped_restore_current_program_space): Likewise.
      	* python/python-internal.h (class gdbpy_enter): Likewise.
      	* regcache.h (regcache): Likewise.
      	* target-descriptions.c (struct tdesc_reg): Likewise.
      	(struct tdesc_type): Likewise.
      	(struct tdesc_feature): Likewise.
      	* ui-out.h (ui_out_emit_type): Likewise.
      d6541620
  6. 11 Sep, 2017 2 commits
    • Tom Tromey's avatar
      Make it simpler to add events to Python · 7d221d74
      Tom Tromey authored
      The first patch in this series went through several iterations as I'd
      forgotten how many places had to be touched to add a new event and a
      new event type.
      
      This patch simplifies the process using two new ".def" files.  Now, a
      new event type can be added by adding a line to "py-event-types.def",
      and a new event registry can be added by adding a line to
      "py-all-events.def".
      
      ChangeLog
      2017-09-11  Tom Tromey  <tom@tromey.com>
      
      	* python/python.c (do_start_initialization): Use
      	py-event-types.def to initialize types.
      	Define all object type structures.
      	* python/python-internal.h: Don't declare event initialization
      	functions.
      	* python/py-threadevent.c (thread_event_object_type): Don't
      	define.
      	* python/py-stopevent.c (stop_event_object_type): Don't define.
      	* python/py-signalevent.c (signal_event_object_type): Don't
      	declare or define.
      	* python/py-newobjfileevent.c (new_objfile_event_object_type)
      	(clear_objfiles_event_object_type): Don't declare or define.
      	* python/py-infevents.c (inferior_call_pre_event_object_type)
      	(inferior_call_post_event_object_type)
      	(register_changed_event_object_type)
      	(memory_changed_event_object_type): Don't declare or define.
      	* python/py-inferior.c (new_thread_event_object_type)
      	(new_inferior_event_object_type)
      	(inferior_deleted_event_object_type): Don't declare or define.
      	* python/py-exitedevent.c (exited_event_object_type): Don't
      	declare or define.
      	* python/py-evts.c (gdbpy_initialize_py_events): Use
      	py-all-events.def.
      	* python/py-events.h (thread_event_object_type): Don't declare.
      	(events_object): Use py-all-events.def.
      	* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove.  Use
      	py-event-types.def.
      	* python/py-event-types.def: New file.
      	* python/py-continueevent.c (create_continue_event_object): Don't
      	declare or define.
      	* python/py-bpevent.c (breakpoint_event_object_type): Don't
      	declare or define.
      	* python/py-all-events.def: New file.
      7d221d74
    • Tom Tromey's avatar
      Add new_inferior, inferior_deleted, and new_thread events · 7c96f8c1
      Tom Tromey authored
      This adds a few new events to gdb's Python layer: new_inferior,
      inferior_deleted, and new_thread.  I wanted to be able to add a
      combined inferior/thread display window to my GUI, and I needed a few
      events to make this work.  This is PR python/15622.
      
      ChangeLog
      2017-09-11  Tom Tromey  <tom@tromey.com>
      
      	PR python/15622:
      	* NEWS: Add entry.
      	* python/python.c (do_start_initialization): Initialize new event
      	types.
      	* python/python-internal.h (gdbpy_initialize_new_inferior_event)
      	(gdbpy_initialize_inferior_deleted_event)
      	(gdbpy_initialize_new_thread_event): Declare.
      	* python/py-threadevent.c (create_thread_event_object): Add option
      	"thread" parameter.
      	* python/py-inferior.c (new_thread_event_object_type)
      	(new_inferior_event_object_type)
      	(inferior_deleted_event_object_type): Declare.
      	(python_new_inferior, python_inferior_deleted): New functions.
      	(add_thread_object): Emit new_thread event.
      	(gdbpy_initialize_inferior): Attach new functions to corresponding
      	observers.
      	(new_thread, new_inferior, inferior_deleted): Define new event
      	types.
      	* python/py-evts.c (gdbpy_initialize_py_events): Add new
      	registries.
      	* python/py-events.h (events_object) <new_inferior,
      	inferior_deleted, new_thread>: New fields.
      	* python/py-event.h (create_thread_event_breakpoint): Add optional
      	"thread" parameter.
      
      doc/ChangeLog
      2017-09-11  Tom Tromey  <tom@tromey.com>
      
      	* python.texi (Events In Python): Document new events.
      
      testsuite/ChangeLog
      2017-09-11  Tom Tromey  <tom@tromey.com>
      
      	* gdb.python/py-infthread.exp: Add tests for new_thread event.
      	* gdb.python/py-inferior.exp: Add tests for new inferior events.
      7c96f8c1
  7. 02 May, 2017 1 commit
  8. 05 Apr, 2017 3 commits
    • Pedro Alves's avatar
      -Wwrite-strings: Add a PyArg_ParseTupleAndKeywords "const char *" overload · 2adadf51
      Pedro Alves authored
      -Wwrite-strings flags code like:
      
         static char *keywords[] = {"command", "from_tty", "to_string", NULL };
      
      as needing "(char *)" casts, because string literals are "const char []".
      
      We can get rid of the casts by changing the array type like this:
      
       -  static char *keywords[] = {"command", "from_tty", "to_string", NULL };
       +  static const char *keywords[] = {"command", "from_tty", "to_string", NULL };
      
      However, passing the such array to PyArg_ParseTupleAndKeywords no longer
      works OOTB, because PyArg_ParseTupleAndKeywords expects a "char **":
      
        PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw,
                                    const char *format,
      			      char *keywords[], ...);
      
      and "const char **" is not implicitly convertible to "char **".  C++
      is more tolerant that C here WRT aliasing, and a const_cast<char **>
      is fine.  However, to avoid having all callers do the cast themselves,
      this commit defines a gdb_PyArg_ParseTupleAndKeywords function here
      with a corresponding 'keywords' parameter type that does the cast in a
      single place.
      
      gdb/ChangeLog:
      2017-04-05  Pedro Alves  <palves@redhat.com>
      
      	* python/python-internal.h (gdb_PyArg_ParseTupleAndKeywords): New
      	static inline function.
      	* python/py-arch.c (archpy_disassemble): Constify 'keywords'
      	array and use gdb_PyArg_ParseTupleAndKeywords.
      	* python/py-cmd.c (cmdpy_init): Likewise.
      	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
      	* python/py-inferior.c (infpy_read_memory, infpy_write_memory)
      	(infpy_search_memory): Likewise.
      	* python/py-objfile.c (objfpy_add_separate_debug_file)
      	(gdbpy_lookup_objfile): Likewise.
      	* python/py-symbol.c (gdbpy_lookup_symbol)
      	(gdbpy_lookup_global_symbol): Likewise.
      	* python/py-type.c (gdbpy_lookup_type): Likewise.
      	* python/py-value.c (valpy_lazy_string, valpy_string): Likewise.
      	* python/python.c (execute_gdb_command, gdbpy_write, gdbpy_flush):
      	Likewise.
      2adadf51
    • Pedro Alves's avatar
      -Wwrite-strings: Wrap PyGetSetDef for construction with string literals · 0d1f4ceb
      Pedro Alves authored
      Unfortunately, PyGetSetDef's 'name' and 'doc' members are 'char *'
      instead of 'const char *', meaning that in order to list-initialize
      PyGetSetDef arrays using string literals requires writing explicit
      'char *' casts.  For example:
      
          static PyGetSetDef value_object_getset[] = {
         -  { "address", valpy_get_address, NULL, "The address of the value.",
         +  { (char *) "address", valpy_get_address, NULL,
         +    (char *) "The address of the value.",
      	NULL },
         -  { "is_optimized_out", valpy_get_is_optimized_out, NULL,
         -    "Boolean telling whether the value is optimized "
         +  { (char *) "is_optimized_out", valpy_get_is_optimized_out, NULL,
         +    (char *) "Boolean telling whether the value is optimized "
      	"out (i.e., not available).",
      	NULL },
         -  { "type", valpy_get_type, NULL, "Type of the value.", NULL },
         -  { "dynamic_type", valpy_get_dynamic_type, NULL,
         -    "Dynamic type of the value.", NULL },
         -  { "is_lazy", valpy_get_is_lazy, NULL,
         -    "Boolean telling whether the value is lazy (not fetched yet\n\
         +  { (char *) "type", valpy_get_type, NULL,
         +    (char *) "Type of the value.", NULL },
         +  { (char *) "dynamic_type", valpy_get_dynamic_type, NULL,
         +    (char *) "Dynamic type of the value.", NULL },
         +  { (char *) "is_lazy", valpy_get_is_lazy, NULL,
         +    (char *) "Boolean telling whether the value is lazy (not fetched yet\n\
          from the inferior).  A lazy value is fetched when needed, or when\n\
          the \"fetch_lazy()\" method is called.", NULL },
            {NULL}  /* Sentinel */
      
      We have ~20 such arrays, and I first wrote a patch that fixed all of
      them like that...  It's not pretty...
      
      One way to make these a bit less ugly would be add a new macro that
      hides the casts, like:
      
        #define GDBPY_GSDEF(NAME, GET, SET, DOC, CLOSURE) \
           { (char *) NAME, GET, SET, (char *) DOC, CLOSURE }
      
      and then use it like:
      
          static PyGetSetDef value_object_getset[] = {
             GDBPY_GSDEF ("address", valpy_get_address, NULL,
             		    "The address of the value.", NULL),
             GDBPY_GSDEF ("is_optimized_out", valpy_get_is_optimized_out, NULL,
             		    "Boolean telling whether the value is optimized ", NULL),
            {NULL}  /* Sentinel */
          };
      
      But since we have C++11, which gives us constexpr and list
      initialization, I thought of a way that requires no changes where the
      arrays are initialized:
      
      We add a new type that extends PyGetSetDef (called gdb_PyGetSetDef),
      and add constexpr constructors that accept const 'name' and 'doc', and
      then list/aggregate initialization simply "calls" these matching
      constructors instead.
      
      I put "calls" in quotes, because given "constexpr", it's all done at
      compile time, and there's no overhead either in binary size or at run
      time.  In fact, we get identical binaries, before/after this change.
      
      Unlike the fixes that fix some old Python API to match the API of more
      recent Python, this switches to using explicit "gdb_PyGetSetDef"
      everywhere, just to be clear that we are using our own version of it.
      
      gdb/ChangeLog:
      2017-04-05  Pedro Alves  <palves@redhat.com>
      
      	* python/python-internal.h (gdb_PyGetSetDef): New type.
      	* python/py-block.c (block_object_getset)
      	(breakpoint_object_getset): Now a gdb_PyGetSetDef array.
      	* python/py-event.c (event_object_getset)
      	(finish_breakpoint_object_getset): Likewise.
      	* python/py-inferior.c (inferior_object_getset): Likewise.
      	* python/py-infthread.c (thread_object_getset): Likewise.
      	* python/py-lazy-string.c (lazy_string_object_getset): Likewise.
      	* python/py-linetable.c (linetable_entry_object_getset): Likewise.
      	* python/py-objfile.c (objfile_getset): Likewise.
      	* python/py-progspace.c (pspace_getset): Likewise.
      	* python/py-record-btrace.c (btpy_insn_getset, btpy_call_getset):
      	Likewise.
      	* python/py-record.c (recpy_record_getset): Likewise.
      	* python/py-symbol.c (symbol_object_getset): Likewise.
      	* python/py-symtab.c (symtab_object_getset, sal_object_getset):
      	Likewise.
      	* python/py-type.c (type_object_getset, field_object_getset):
      	Likewise.
      	* python/py-value.c (value_object_getset): Likewise.
      0d1f4ceb
    • Pedro Alves's avatar
      -Wwrite-strings: More fix-old-Python-API wrappers · 4d759979
      Pedro Alves authored
      When building against Python 2.7, -Wwrite-strings flags several cases
      of passing a string literal to Python functions that expect a "char
      *".  This commit addresses the issue like we already handle several
      other similar cases -- wrap the Python API with our own fixed
      version that adds the necessary constification.
      
      gdb/ChangeLog:
      2017-04-05  Pedro Alves  <palves@redhat.com>
      
      	* python/python-internal.h (gdb_PyObject_CallMethod)
      	(gdb_PyErr_NewException, gdb_PySys_GetObject, gdb_PySys_SetPath):
      	New functions.
      	(GDB_PYSYS_SETPATH_CHAR, PyObject_CallMethod, PyErr_NewException)
      	(PySys_GetObject, PySys_SetPath): New macros.
      4d759979
  9. 14 Feb, 2017 2 commits
    • Tim Wiederhake's avatar
      python: Implement btrace Python bindings for record history. · 75c0bdf4
      Tim Wiederhake authored
      
      
      This patch implements the gdb.Record Python object methods and fields for
      record target btrace.  Also, implement a stub for record target full.
      Signed-off-by: default avatarTim Wiederhake <tim.wiederhake@intel.com>
      
      gdb/ChangeLog:
      
      	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-record-btrace.o,
      	py-record-full.o.
      	(SUBDIR_PYTHON_SRCS): Add py-record-btrace.c, py-record-full.c.
      	* python/py-record-btrace.c, python/py-record-btrace.h,
      	python/py-record-full.c, python/py-record-full.h: New file.
      	* python/py-record.c: Add include for py-record-btrace.h and
      	py-record-full.h.
      	(recpy_method, recpy_format, recpy_goto, recpy_replay_position,
      	recpy_instruction_history, recpy_function_call_history, recpy_begin,
      	recpy_end): Use functions from py-record-btrace.c and py-record-full.c.
      	* python/python-internal.h (PyInt_FromSsize_t, PyInt_AsSsize_t):
      	New definition.
      	(gdbpy_initialize_btrace): New export.
      	* python/python.c (_initialize_python): Add gdbpy_initialize_btrace.
      
      Change-Id: I8bd893672ffc7e619cc1386767897249e125973a
      75c0bdf4
    • Tim Wiederhake's avatar
      python: Create Python bindings for record history. · 4726b2d8
      Tim Wiederhake authored
      
      
      This patch adds three new functions to the gdb module in Python:
      	- start_recording
      	- stop_recording
      	- current_recording
      start_recording and current_recording return an object of the new type
      gdb.Record, which can be used to access the recorded data.
      Signed-off-by: default avatarTim Wiederhake <tim.wiederhake@intel.com>
      
      gdb/ChangeLog
      
      	* Makefile.in (SUBDIR_PYTHON_OBS): Add python/py-record.o.
      	(SUBDIR_PYTHON_SRCS): Add python/py-record.c.
      	* python/py-record.c: New file.
      	* python/python-internal.h (gdbpy_start_recording,
      	gdbpy_current_recording, gdpy_stop_recording,
      	gdbpy_initialize_record): New export.
      	* python/python.c (_initialize_python): Add gdbpy_initialize_record.
      	(python_GdbMethods): Add gdbpy_start_recording,
      	gdbpy_current_recording and gdbpy_stop_recording.
      
      Change-Id: I772aa9aa068621443f10a330b11dc7dc9a63face
      4726b2d8
  10. 21 Jan, 2017 1 commit
    • Simon Marchi's avatar
      Fix python-interactive with Python 3.6 · 6f8b0407
      Simon Marchi authored
      New in v2:
      
       - Define PyMem_RawMalloc as PyMem_Malloc for Python < 3.4 and use
         PyMem_RawMalloc in the code.
      
      Since Python 3.4, the callback installed in PyOS_ReadlineFunctionPointer
      should return a value allocated with PyMem_RawMalloc instead of
      PyMem_Malloc.  The reason is that PyMem_Malloc must be called with the
      Python Global Interpreter Lock (GIL) held, which is not the case in the
      context where this function is called.  PyMem_RawMalloc was introduced
      for cases like this.
      
      In Python 3.6, it looks like they added an assert to verify that
      PyMem_Malloc was not called without the GIL.  The consequence is that
      typing anything in the python-interactive mode of gdb crashes the
      process.  The same behavior was observed with the official package on
      Arch Linux as well as with a manual Python build on Ubuntu 14.04.
      
      This is what is shown with a debug build of Python 3.6 (the error with a
      non-debug build is far less clear):
      
        (gdb) pi
        >>> print(1)
        Fatal Python error: Python memory allocator called without holding the GIL
      
        Current thread 0x00007f1459af8780 (most recent call first):
        [1]    21326 abort      ./gdb
      
      and the backtrace:
      
        #0  0x00007ffff618bc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
        #1  0x00007ffff618f028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
        #2  0x00007ffff6b104d6 in Py_FatalError (msg=msg@entry=0x7ffff6ba15b8 "Python memory allocator called without holding the GIL") at Python/pylifecycle.c:1457
        #3  0x00007ffff6a37a68 in _PyMem_DebugCheckGIL () at Objects/obmalloc.c:1972
        #4  0x00007ffff6a3804e in _PyMem_DebugFree (ctx=0x7ffff6e65290 <_PyMem_Debug+48>, ptr=0x24f8830) at Objects/obmalloc.c:1994
        #5  0x00007ffff6a38e1d in PyMem_Free (ptr=<optimized out>) at Objects/obmalloc.c:442
        #6  0x00007ffff6b866c6 in _PyFaulthandler_Fini () at ./Modules/faulthandler.c:1369
        #7  0x00007ffff6b104bd in Py_FatalError (msg=msg@entry=0x7ffff6ba15b8 "Python memory allocator called without holding the GIL") at Python/pylifecycle.c:1431
        #8  0x00007ffff6a37a68 in _PyMem_DebugCheckGIL () at Objects/obmalloc.c:1972
        #9  0x00007ffff6a37aa3 in _PyMem_DebugMalloc (ctx=0x7ffff6e65290 <_PyMem_Debug+48>, nbytes=5) at Objects/obmalloc.c:1980
        #10 0x00007ffff6a38d91 in PyMem_Malloc (size=<optimized out>) at Objects/obmalloc.c:418
        #11 0x000000000064dbe2 in gdbpy_readline_wrapper (sys_stdin=0x7ffff6514640 <_IO_2_1_stdin_>, sys_stdout=0x7ffff6514400 <_IO_2_1_stdout_>, prompt=0x7ffff4d4f7d0 ">>> ")
          at /home/emaisin/src/binutils-gdb/gdb/python/py-gdb-readline.c:75
      
      The documentation is very clear about it [1] and it was also mentioned
      in the "What's New In Python 3.4" page [2].
      
      [1] https://docs.python.org/3/c-api/veryhigh.html#c.PyOS_ReadlineFunctionPointer
      [2] https://docs.python.org/3/whatsnew/3.4.html#changes-in-the-c-api
      
      gdb/ChangeLog:
      
      	* python/python-internal.h (PyMem_RawMalloc): Define for
      	Python < 3.4.
      	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use
      	PyMem_RawMalloc instead of PyMem_Malloc.
      6f8b0407
  11. 11 Jan, 2017 5 commits
    • Tom Tromey's avatar
      Remove make_cleanup_py_decref and make_cleanup_py_xdecref · 8dbcee67
      Tom Tromey authored
      make_cleanup_py_decref and make_cleanup_py_xdecref are now unused, so
      this patch removes themm.  Future Python changes should use gdbpy_ref
      instead.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* python/python-internal.h (make_cleanup_py_decref)
      	(make_cleanup_py_xdecref): Don't declare.
      	* python/py-utils.c (py_decref, make_cleanup_py_decref)
      	(py_xdecref, make_cleanup_py_xdecref): Remove.
      8dbcee67
    • Tom Tromey's avatar
      Remove ensure_python_env · 17a22718
      Tom Tromey authored
      All of gdb has been converted away from ensure_python_env and
      varobj_ensure_python_env now; so remove them.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* python/python.c (ensure_python_env, restore_python_env):
      	Remove.
      	* python/python-internal.h (ensure_python_env): Don't declare.
      	* varobj.h (varobj_ensure_python_env): Don't declare.
      	* varobj.c (varobj_ensure_python_env): Remove.
      17a22718
    • Tom Tromey's avatar
      Change type of encoding argument to gdbpy_extract_lazy_string · 1eba6383
      Tom Tromey authored
      This changes gdbpy_extract_lazy_string's "encoding" argument to be a
      unique_xmalloc_ptr.  I chose this rather than std::string because it
      can sometimes be NULL.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* python/py-prettyprint.c (print_string_repr, print_children):
      	Update.
      	* python/py-lazy-string.c (gdbpy_extract_lazy_string): Change type
      	of "encoding".
      	* varobj.c (varobj_value_get_print_value): Update.
      	* python/python-internal.h (gdbpy_extract_lazy_string): Update.
      1eba6383
    • Tom Tromey's avatar
      Introduce gdbpy_enter_varobj and use it · 6cd67bea
      Tom Tromey authored
      This introduces gdbpy_enter_varobj, a subclass of gdbpy_enter; then
      changes one function in py-varobj.c to use it.  gdbpy_enter_varobj
      takes a varobj as an argument, similar to varobj_ensure_python_env.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* varobj.c (gdbpy_enter_varobj): New constructor.
      	* python/python-internal.h (gdbpy_enter_varobj): New class.
      	* python/py-varobj.c (py_varobj_get_iterator): Use
      	gdbpy_enter_varobj.
      6cd67bea
    • Tom Tromey's avatar
      Introduce gdbpy_enter · 4ecee2c4
      Tom Tromey authored
      This introduces gdbpy_enter, a class that can be used to acquire and
      release the Python GIL, and also set other Python-related globals used
      by gdb.  ensure_python_env is rewritten in terms of this new class.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* python/python.c (gdbpy_enter): New constructor.
      	(~gdbpy_enter): New destructor.
      	(restore_python_env, ensure_python_env): Rewrite.
      	* python/python-internal.h (gdbpy_enter): New class.
      4ecee2c4
  12. 01 Jan, 2017 1 commit
    • Joel Brobecker's avatar
      update copyright year range in GDB files · 61baf725
      Joel Brobecker authored
      This applies the second part of GDB's End of Year Procedure, which
      updates the copyright year range in all of GDB's files.
      
      gdb/ChangeLog:
      
              Update copyright year range in all GDB files.
      61baf725
  13. 11 Nov, 2016 1 commit
    • Yao Qi's avatar
      Remove apply_val_pretty_printer parameter valaddr · 668e1674
      Yao Qi authored
      This patch removes the parameter valaddr of
      extension_language_ops::apply_val_pretty_printer and remove const from
      "struct value *val".  valaddr can be got in each extension language's
      implementation of apply_val_pretty_printer.
      
      gdb:
      
      2016-11-11  Yao Qi  <yao.qi@linaro.org>
      
      	* cp-valprint.c (cp_print_value): Remove local base_valaddr.
      	* extension-priv.h (struct extension_language_ops)
      	<apply_val_pretty_printer>: Remove the second parameter.
      	Remove const from "struct value *".  Callers updated.
      	* extension.c (apply_ext_lang_val_pretty_printer): Update
      	comments.  Remove parameter valaddr.  Remove const from
      	"struct value *".
      	* extension.h (apply_ext_lang_val_pretty_printer): Update
      	declaration.
      	* guile/guile-internal.h (gdbscm_apply_val_pretty_printer):
      	Update declaration.
      	* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
      	Remove parameter valaddr.  Remove const from "struct value *".
      	* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer):
      	Likewise.
      	* python/python-internal.h (gdbpy_apply_val_pretty_printer):
      	Update declaration.
      668e1674
  14. 10 Nov, 2016 1 commit
    • Tom Tromey's avatar
      Use unique_xmalloc_ptr in Python code · 9b972014
      Tom Tromey authored
      This changes some utility functions in the Python code to return
      unique_xmalloc_ptr, and then fixes up the callers.
      
      I chose unique_xmalloc_ptr rather than std::string because at a few
      call points the xmalloc'd string is released and ownership transferred
      elsewhere.
      
      This patch found a few existing memory leaks.  For example,
      py-unwind.c called gdbpy_obj_to_string but never freed the result.
      
      Built and regression tested on the buildbot.
      
      2016-11-09  Tom Tromey  <tom@tromey.com>
      
      	* varobj.h (varobj_get_display_hint): Change return type.
      	* varobj.c (varobj_get_display_hint): Return unique_xmalloc_ptr.
      	(varobj_value_get_print_value): Update.
      	* python/python.c (gdbpy_before_prompt_hook, gdbpy_print_stack)
      	(gdbpy_apply_type_printers): Update.
      	* python/python-internal.h (unicode_to_target_string)
      	(python_string_to_target_string, python_string_to_host_string)
      	(gdbpy_obj_to_string, gdbpy_exception_to_string)
      	(gdbpy_get_display_hint): Change return types.
      	* python/py-varobj.c (py_varobj_iter_next): Update.
      	* python/py-value.c (valpy_getitem, convert_value_from_python):
      	Update.
      	* python/py-utils.c (unicode_to_encoded_string)
      	(unicode_to_target_string, python_string_to_target_string)
      	(python_string_to_host_string, gdbpy_obj_to_string)
      	(gdbpy_exception_to_string): Return unique_xmalloc_ptr.
      	* python/py-unwind.c (pyuw_parse_register_id): Update.
      	* python/py-type.c (typy_getitem): Update.
      	* python/py-prettyprint.c (gdbpy_get_display_hint)
      	(print_stack_unless_memory_error, print_children)
      	(gdbpy_apply_val_pretty_printer): Update.
      	* python/py-param.c (set_parameter_value): Update.
      	(get_doc_string, call_doc_function): Return unique_xmalloc_ptr.
      	(get_set_value, get_show_value, compute_enum_values, parmpy_init):
      	Update.
      	* python/py-infthread.c (thpy_set_name): Update.
      	* python/py-function.c (fnpy_call, fnpy_init): Update.
      	* python/py-framefilter.c (extract_sym): Change "name" to
      	unique_xmalloc_ptr.
      	(enumerate_args, enumerate_locals): Update.
      	(py_print_frame): Use unique_xmalloc_ptr.
      	* python/py-frame.c (frapy_read_var): Update.  Remove cleanup.
      	* python/py-cmd.c (cmdpy_function, cmdpy_completer, cmdpy_init):
      	Update.
      	* python/py-breakpoint.c (bppy_set_condition): Use
      	unique_xmalloc_ptr.
      	(bppy_init): Likewise.  Remove cleanup.
      	(local_setattro): Update.
      	* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_list_children)
      	(varobj_update_one): Update.
      9b972014
  15. 25 Jun, 2016 1 commit
    • David Taylor's avatar
      Support structure offsets that are 512K or larger. · 6b850546
      David Taylor authored
      GDB computes structure byte offsets using a 32 bit integer.  And,
      first it computes the offset in bits and then converts to bytes.  The
      result is that any offset that if 512K bytes or larger overflows.
      This patch changes GDB to use LONGEST for such calculations.
      
      	PR gdb/17520 Structure offset wrong when 1/4 GB or greater.
      	* c-lang.h: Change all parameters, variables, and struct or union
      	members used as struct or union fie3ld offsets from int to
      	LONGEST.
      	* c-valprint.c: Likewise.
      	* cp-abi.c: Likewise.
      	* cp-abi.h: Likewise.
      	* cp-valprint.c: Likewise.
      	* d-valprint.c: Likewise.
      	* dwarf2loc.c: Likewise.
      	* eval.c: Likewise.
      	* extension-priv.h: Likewise.
      	* extension.c: Likewise.
      	* extension.h: Likewise.
      	* findvar.c: Likewise.
      	* gdbtypes.h: Likewise.
      	* gnu-v2-abi.c: Likewise.
      	* gnu-v3-abi.c: Likewise.
      	* go-valprint.c: Likewise.
      	* guile/guile-internal.h: Likewise.
      	* guile/scm-pretty-print.c: Likewise.
      	* jv-valprint.c Likewise.
      	* opencl-lang.c: Likewise.
      	* p-lang.h: Likewise.
      	* python/py-prettyprint.c: Likewise.
      	* python/python-internal.h: Likewise.
      	* spu-tdep.c: Likewise.
      	* typeprint.c: Likewise.
      	* valarith.c: Likewise.
      	* valops.c: Likewise.
      	* valprint.c: Likewise.
      	* valprint.h: Likewise.
      	* value.c: Likewise.
      	* value.h: Likewise.
      	* p-valprint.c: Likewise.
      	* c-typeprint.c (c_type_print_base): When printing offset, use
      	plongest, not %d.
      	* gdbtypes.c (recursive_dump_type): Ditto.
      6b850546
  16. 24 Jun, 2016 1 commit
    • Tom Tromey's avatar
      Make gdbpy_parameter static · 0c72ed4c
      Tom Tromey authored
      While working on the next patch in this series, I noticed that
      gdbpy_parameter did not need to be exported.  This makes it "static".
      
      2016-06-23  Tom Tromey  <tom@tromey.com>
      
      	* python/python.c (gdbpy_parameter): Now static.
      	* python/python-internal.h (gdbpy_parameter): Don't declare.
      0c72ed4c
  17. 30 Mar, 2016 1 commit
    • Doug Evans's avatar
      python/py-utils.c (host_string_to_python_string): New function. · 4ae6cc19
      Doug Evans authored
      gdb/ChangeLog:
      
      	* python/py-utils.c (host_string_to_python_string): New function.
      	* python/python-internal.h (host_string_to_python_string): Declare it.
      	* python/py-*.c (*): Update all calls to
      	PyString_Decode (str, strlen (str), host_charset (), NULL);
      	to use host_string_to_python_string instead.
      4ae6cc19
  18. 01 Jan, 2016 1 commit
  19. 24 Jun, 2015 1 commit
    • Gary Benson's avatar
      Remove redundant include directives. · dc06243f
      Gary Benson authored
      stdint.h was added to common-defs.h some months ago and should
      no longer be included directly by any file.
      
      gdb_assert.h was added to common-defs.h nearly a year ago, but
      three includes have crept in since then.
      
      This commit removes all such redundant include directives.
      
      gdb/ChangeLog:
      
      	* common/buffer.c (stdint.h): Do not include.
      	* common/print-utils.c (stdint.h): Likewise.
      	* compile/compile-c-symbols.c (gdb_assert.h): Likewise.
      	* compile/compile-c-types.c (gdb_assert.h): Likewise.
      	* ft32-tdep.c (gdb_assert.h): Likewise.
      	* guile/scm-utils.c (stdint.h): Likewise.
      	* i386-linux-tdep.c (stdint.h): Likewise.
      	* i386-tdep.c (stdint.h): Likewise.
      	* nat/linux-btrace.c (stdint.h): Likewise.
      	* nat/linux-btrace.h (stdint.h): Likewise.
      	* nat/linux-ptrace.c (stdint.h): Likewise.
      	* nat/mips-linux-watch.h (stdint.h): Likewise.
      	* ppc-linux-nat.c (stdint.h): Likewise.
      	* python/python-internal.h (stdint.h): Likewise.
      	* stub-termcap.c (stdlib.h): Likewise.
      	* target/target.h (stdint.h): Likewise.
      	* xtensa-linux-nat.c (stdint.h): Likewise.
      
      gdb/gdbserver/ChangeLog:
      
      	* linux-i386-ipa.c (stdint.h): Do not include.
      	* lynx-i386-low.c (stdint.h): Likewise.
      	* lynx-ppc-low.c (stdint.h): Likewise.
      	* mem-break.c (stdint.h): Likewise.
      	* thread-db.c (stdint.h): Likewise.
      	* tracepoint.c (stdint.h): Likewise.
      	* win32-low.c (stdint.h): Likewise.
      dc06243f
  20. 29 Apr, 2015 2 commits
    • Doug Evans's avatar
      PR python/18285 · 2ce1cdbf
      Doug Evans authored
      gdb/ChangeLog:
      
      	PR python/18285
      	* NEWS: Document new gdb.XMethodWorker.get_result_type method.
      	* eval.c (evaluate_subexp_standard) <OP_FUNCALL>: Handle
      	EVAL_AVOID_SIDE_EFFECTS for xmethods.
      	* extension-priv.h (struct extension_language_ops)
      	<get_xmethod_result_type>: New member.
      	* extension.c (get_xmethod_result_type): New function.
      	* extension.h (get_xmethod_result_type): Declare.
      	* python/py-xmethods.c (get_result_type_method_name): New static
      	global.
      	(py_get_result_type_method_name): Ditto.
      	(gdbpy_get_xmethod_result_type): New function.
      	(gdbpy_initialize_xmethods): Initialize py_get_result_type_method_name.
      	* python/python-internal.h (gdbpy_get_xmethod_result_type): Declare.
      	* python/python.c (python_extension_ops): Add
      	gdbpy_get_xmethod_result_type.
      	* python/lib/gdb/xmethod.py (XMethodWorker): Add get_result_type.
      	* valarith.c (value_x_binop): Handle EVAL_AVOID_SIDE_EFFECTS for
      	xmethods.
      	(value_x_unop): Ditto.
      	* value.c (result_type_of_xmethod): New function.
      	* value.h (result_type_of_xmethod): Declare.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-xmethods.exp: Add ptype tests.
      	* gdb.python/py-xmethods.py (E_method_char_worker): Add
      	get_result_type method.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Xmethod API) <gdb.XMethodWorker.get_result_type>:
      	Document.
      	(Writing an Xmethod): Add get_result_type to example.
      2ce1cdbf
    • Doug Evans's avatar
      PR python/18089 · 69b4374a
      Doug Evans authored
      gdb/ChangeLog:
      
      	PR python/18089
      	* python/py-prettyprint.c (print_children): Verify result of children
      	iterator.  Provide better error message.
      	* python/python-internal..h (gdbpy_print_python_errors_p): Declare.
      	* python/python.c (gdbpy_print_python_errors_p): New function.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-bad-printers.c: New file.
      	* gdb.python/py-bad-printers.py: New file.
      	* gdb.python/py-bad-printers.exp: New file.
      69b4374a
  21. 01 Apr, 2015 1 commit
    • Sasha Smundak's avatar
      Add support for writing unwinders in Python. · d11916aa
      Sasha Smundak authored
      gdb/ChangeLog:
      
      	* Makefile.in (SUBDIR_PYTHON_OBJS): Add py-unwind.o.
      	(SUBDIR_PYTHON_SRCS): Add py-unwind.c.
      	(py-unwind.o): New recipe.
      	* NEWS: mention Python frame unwinding.
      	* data-directory/Makefile.in (PYTHON_FILE_LIST): Add
      	gdb/unwinder.py and gdb/command/unwinder.py
      	* python/lib/gdb/__init__.py (packages): Add frame_unwinders
      	list.
      	(execute_unwinders): New function.
      	* python/lib/gdb/command/unwinders.py: New file.
      	* python/lib/gdb/unwinder.py: New file.
      	* python/py-objfile.c (objfile_object): Add frame_unwinders field.
      	(objfpy_dealloc): Decrement frame_unwinders reference count.
      	(objfpy_initialize): Create frame_unwinders list.
      	(objfpy_get_frame_unwinders): New function.
      	(objfpy_set_frame_unwinders): Ditto.
      	(objfile_getset): Add frame_unwinders attribute to Objfile.
      	* python/py-progspace.c (pspace_object): Add frame_unwinders field.
      	(pspy_dealloc): Decrement frame_unwinders reference count.
      	(pspy_initialize): Create frame_unwinders list.
      	(pspy_get_frame_unwinders): New function.
      	(pspy_set_frame_unwinders): Ditto.
      	(pspy_getset): Add frame_unwinders attribute to gdb.Progspace.
      	* python/py-unwind.c: New file.
      	* python/python-internal.h (pspy_get_name_unwinders): New prototype.
      	(objpy_get_frame_unwinders): New prototype.
      	(gdbpy_initialize_unwind): New prototype.
      	* python/python.c (gdbpy_apply_type_printers): Call
      	gdbpy_initialize_unwind.
      
      gdb/doc/ChangeLog:
      
      	* doc/python.texi (Writing a Frame Unwinder in Python): Add
      	section.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-unwind-maint.c: New file.
      	* gdb.python/py-unwind-maint.exp: New test.
      	* gdb.python/py-unwind-maint.py: New file.
      	* gdb.python/py-unwind.c: New file.
      	* gdb.python/py-unwind.exp: New test.
      	* gdb.python/py-unwind.py: New test.
      d11916aa
  22. 27 Feb, 2015 1 commit
    • Pedro Alves's avatar
      python/python-internal.h: enum ‘ext_lang_rc’ not defined · e992c591
      Pedro Alves authored
      Fixes this in C++ mode:
      
        src/gdb/python/python-internal.h: At global scope:
        src/gdb/python/python-internal.h:313:13: error: use of enum ‘ext_lang_rc’ without previous declaration
         extern enum ext_lang_rc gdbpy_apply_val_pretty_printer
      	       ^
        src/gdb/python/python-internal.h:320:41: error: invalid type in declaration before ‘;’ token
            const struct language_defn *language);
      					   ^
      
      gdb/ChangeLog:
      2015-02-27  Pedro Alves  <palves@redhat.com>
      
      	* python/python-internal.h: Include "extension-priv.h".
      e992c591
  23. 04 Feb, 2015 1 commit
    • Jan Kratochvil's avatar
      Fix Python 3 build error on 32-bit hosts · 881d5d5d
      Jan Kratochvil authored
      on Fedora Rawhide (==22) i686 using --with-python=/usr/bin/python3 one gets:
      
      ./python/py-value.c:1696:3: error: initialization from incompatible pointer type [-Werror]
         valpy_hash,            /*tp_hash*/
         ^
      ./python/py-value.c:1696:3: error: (near initialization for ‘value_object_type.tp_hash’) [-Werror]
      cc1: all warnings being treated as errors
      Makefile:2628: recipe for target 'py-value.o' failed
      
      This is because in Python 2 tp_hash was:
      	typedef long (*hashfunc)(PyObject *);
      while in Python 3 tp_hash is:
      	typedef Py_hash_t (*hashfunc)(PyObject *);
      
      Py_hash_t is int for 32-bit hosts and long for 64-bit hosts.  While on 32-bit
      hosts sizeof(long)==sizeof(int) still the hashfunc type is formally
      incompatible.  As this patch should have no compiled code change it is not
      really necessary for gdb-7.9, it would fix there just this non-fatal
      compilation warning:
      	./python/py-value.c:1696:3: warning: initialization from incompatible pointer type
      	   valpy_hash,            /*tp_hash*/
      	   ^
      	./python/py-value.c:1696:3: warning: (near initialization for ‘value_object_type.tp_hash’)
      
      gdb/ChangeLog
      2015-02-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	* python/python-internal.h (Py_hash_t): Define it for Python <3.2.
      	* python/py-value.c (valpy_fetch_lazy): Use it.  Remove cast to the
      	return type.
      881d5d5d
  24. 01 Jan, 2015 1 commit
  25. 12 Dec, 2014 1 commit
    • Doug Evans's avatar
      New python function gdb.lookup_objfile. · 6dddd6a5
      Doug Evans authored
      gdb/ChangeLog:
      
      	* NEWS: Mention gdb.lookup_objfile.
      	* python/python.c (GdbMethods): Add lookup_objfile.
      	* python/python-internal.h (gdbpy_lookup_objfile): Declare.
      	* python/py-objfile.c: #include "symtab.h".
      	(objfpy_build_id_ok, objfpy_build_id_matches): New functions.
      	(objfpy_lookup_objfile_by_name): New function.
      	(objfpy_lookup_objfile_by_build_id): New function.
      	(gdbpy_lookup_objfile): New function.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Objfiles In Python): Document gdb.lookup_objfile.
      
      gdb/testsuite/ChangeLog:
      
      	* lib/gdb-python.exp (get_python_valueof): New function.
      	* gdb.python/py-objfile.exp: Add tests for gdb.lookup_objfile.
      6dddd6a5
  26. 02 Dec, 2014 3 commits
    • Nick Bull's avatar
      New python events: inferior call, register/memory changed. · 162078c8
      Nick Bull authored
      gdb/ChangeLog:
      
      	* NEWS: Mention new Python events.
      	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
      	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
      	(py-infevents.o): New rule.
      	* doc/observer.texi (inferior_call_pre, inferior_call_post)
      	(memory_changed, register_changed): New observers.
      	* infcall.c (call_function_by_hand): Notify observer before and
      	after inferior call.
      	* python/py-event.h (inferior_call_kind): New enum.
      	(emit_inferior_call_event): New prototype.
      	(emit_register_changed_event): New prototype.
      	(emit_memory_changed_event): New prototype.
      	* python/py-events.h (events_object): New registries
      	inferior_call, memory_changed and register_changed.
      	* python/py-evts.c (gdbpy_initialize_py_events): Add the
      	inferior_call, memory_changed and register_changed registries.
      	* python/py-infevents.c: New.
      	* python/py-inferior.c (python_on_inferior_call_pre)
      	(python_on_inferior_call_post, python_on_register_change)
      	(python_on_memory_change): New functions.
      	(gdbpy_initialize_inferior): Attach python handler to new
      	observers.
      	* python/py-infthread.c(gdbpy_create_ptid_object): New.
      	(thpy_get_ptid) Use gdbpy_create_ptid_object.
      	* python/python-internal.h:
      	(gdbpy_create_ptid_object)
      	(gdbpy_initialize_inferior_call_pre_event)
      	(gdbpy_initialize_inferior_call_post_event)
      	(gdbpy_initialize_register_changed_event)
      	(gdbpy_initialize_memory_changed_event): New prototypes.
      	* python/python.c (_initialize_python): Initialize new events.
      	* valops.c (value_assign): Notify register_changed observer.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Events In Python): Document new events
      	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
      	and RegisterChangedEvent.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-events.py (inferior_call_handler): New.
      	(register_changed_handler, memory_changed_handler): New.
      	(test_events.invoke): Register new handlers.
      	* gdb.python/py-events.exp: Add tests for inferior call,
      	memory_changed and register_changed events.
      162078c8
    • Doug Evans's avatar
    • Doug Evans's avatar
      New python events: infcall, register/memory changed. · dc6c8717
      Doug Evans authored
      gdb/ChangeLog:
      
      	* NEWS: Mention new Python events.
      	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
      	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
      	(py-infevents.o): New rule.
      	* doc/observer.texi (inferior_call_pre, inferior_call_post)
      	(memory_changed, register_changed): New observers.
      	* infcall.c (call_function_by_hand): Notify observer before and
      	after inferior call.
      	* python/py-event.h (inferior_call_kind): New enum.
      	(emit_inferior_call_event): New prototype.
      	(emit_register_changed_event): New prototype.
      	(emit_memory_changed_event): New prototype.
      	* python/py-events.h (events_object): New registries
      	inferior_call, memory_changed and register_changed.
      	* python/py-evts.c (gdbpy_initialize_py_events): Add the
      	inferior_call, memory_changed and register_changed registries.
      	* python/py-infevents.c: New.
      	* python/py-inferior.c (python_on_inferior_call_pre)
      	(python_on_inferior_call_post, python_on_register_change)
      	(python_on_memory_change): New functions.
      	(gdbpy_initialize_inferior): Attach python handler to new
      	observers.
      	* python/py-infthread.c(gdbpy_create_ptid_object): New.
      	(thpy_get_ptid) Use gdbpy_create_ptid_object.
      	* python/python-internal.h:
      	(gdbpy_create_ptid_object)
      	(gdbpy_initialize_inferior_call_pre_event)
      	(gdbpy_initialize_inferior_call_post_event)
      	(gdbpy_initialize_register_changed_event)
      	(gdbpy_initialize_memory_changed_event): New prototypes.
      	* python/python.c (_initialize_python): Initialize new events.
      	* valops.c (value_assign): Notify register_changed observer.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Events In Python): Document new events
      	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
      	and RegisterChangedEvent.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-events.py (inferior_call_handler): New.
      	(register_changed_handler, memory_changed_handler): New.
      	(test_events.invoke): Register new handlers.
      	* gdb.python/py-events.exp: Add tests for inferior call,
      	memory_changed and register_changed events.
      dc6c8717
  27. 17 Oct, 2014 1 commit
    • Doug Evans's avatar
      New python event "clear_objfiles". · 4ffbba72
      Doug Evans authored
      If one is watching new_objfile events in python, it helps to know
      when the list of objfiles is cleared.  This patch adds a new
      clear_objfiles event to support this.
      
      This patch is all just cut-n-paste-n-tweak derived from
      the new_objfiles event.
      
      gdb/ChangeLog:
      
      	* NEWS: Mention new event gdb.clear_objfiles.
      	* python/py-event.h (emit_clear_objfiles_event): Clear
      	* python/py-events.h (events_object): New member clear_objfiles.
      	* python/py-evts.c (gdbpy_initialize_py_events): Add clear_objfiles
      	event.
      	* python/py-inferior.c (python_new_objfile): If objfile is NULL,
      	emit clear_objfiles event.
      	* python/py-newobjfileevent.c (create_clear_objfiles_event_object): New
      	function.
      	(emit_clear_objfiles_event): New function.
      	(clear_objfiles): New event.
      	* python/python-internal.h (gdbpy_initialize_clear_objfiles_event):
      	Declare.
      	* python/python.c (_initialize_python): Call
      	gdbpy_initialize_clear_objfiles_event.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Events In Python): Document clear_objfiles event.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-events.exp: Update expected output for clear_objfiles
      	event.
      	* gdb.python/py-events.py: Add clear_objfiles event.
      4ffbba72
  28. 08 Oct, 2014 1 commit
    • Gary Benson's avatar
      Remove spurious exceptions.h inclusions · c765fdb9
      Gary Benson authored
      defs.h includes utils.h, and utils.h includes exceptions.h.  All GDB
      .c files include defs.h as their first line, so no file other than
      utils.h needs to include exceptions.h.  This commit removes all such
      inclusions.
      
      gdb/ChangeLog:
      
      	* ada-lang.c: Do not include exceptions.h.
      	* ada-valprint.c: Likewise.
      	* amd64-tdep.c: Likewise.
      	* auto-load.c: Likewise.
      	* block.c: Likewise.
      	* break-catch-throw.c: Likewise.
      	* breakpoint.c: Likewise.
      	* btrace.c: Likewise.
      	* c-lang.c: Likewise.
      	* cli/cli-cmds.c: Likewise.
      	* cli/cli-interp.c: Likewise.
      	* cli/cli-script.c: Likewise.
      	* completer.c: Likewise.
      	* corefile.c: Likewise.
      	* corelow.c: Likewise.
      	* cp-abi.c: Likewise.
      	* cp-support.c: Likewise.
      	* cp-valprint.c: Likewise.
      	* darwin-nat.c: Likewise.
      	* dwarf2-frame-tailcall.c: Likewise.
      	* dwarf2-frame.c: Likewise.
      	* dwarf2loc.c: Likewise.
      	* dwarf2read.c: Likewise.
      	* eval.c: Likewise.
      	* event-loop.c: Likewise.
      	* event-top.c: Likewise.
      	* f-valprint.c: Likewise.
      	* frame-unwind.c: Likewise.
      	* frame.c: Likewise.
      	* gdbtypes.c: Likewise.
      	* gnu-v2-abi.c: Likewise.
      	* gnu-v3-abi.c: Likewise.
      	* guile/scm-auto-load.c: Likewise.
      	* guile/scm-breakpoint.c: Likewise.
      	* guile/scm-cmd.c: Likewise.
      	* guile/scm-frame.c: Likewise.
      	* guile/scm-lazy-string.c: Likewise.
      	* guile/scm-param.c: Likewise.
      	* guile/scm-symbol.c: Likewise.
      	* guile/scm-type.c: Likewise.
      	* hppa-hpux-tdep.c: Likewise.
      	* i386-tdep.c: Likewise.
      	* inf-loop.c: Likewise.
      	* infcall.c: Likewise.
      	* infcmd.c: Likewise.
      	* infrun.c: Likewise.
      	* interps.c: Likewise.
      	* interps.h: Likewise.
      	* jit.c: Likewise.
      	* linespec.c: Likewise.
      	* linux-nat.c: Likewise.
      	* linux-thread-db.c: Likewise.
      	* m32r-rom.c: Likewise.
      	* main.c: Likewise.
      	* memory-map.c: Likewise.
      	* mi/mi-cmd-break.c: Likewise.
      	* mi/mi-cmd-stack.c: Likewise.
      	* mi/mi-interp.c: Likewise.
      	* mi/mi-main.c: Likewise.
      	* monitor.c: Likewise.
      	* nto-procfs.c: Likewise.
      	* objc-lang.c: Likewise.
      	* p-valprint.c: Likewise.
      	* parse.c: Likewise.
      	* ppc-linux-tdep.c: Likewise.
      	* printcmd.c: Likewise.
      	* probe.c: Likewise.
      	* python/py-auto-load.c: Likewise.
      	* python/py-breakpoint.c: Likewise.
      	* python/py-cmd.c: Likewise.
      	* python/py-finishbreakpoint.c: Likewise.
      	* python/py-frame.c: Likewise.
      	* python/py-framefilter.c: Likewise.
      	* python/py-function.c: Likewise.
      	* python/py-gdb-readline.c: Likewise.
      	* python/py-inferior.c: Likewise.
      	* python/py-infthread.c: Likewise.
      	* python/py-lazy-string.c: Likewise.
      	* python/py-linetable.c: Likewise.
      	* python/py-param.c: Likewise.
      	* python/py-prettyprint.c: Likewise.
      	* python/py-symbol.c: Likewise.
      	* python/py-type.c: Likewise.
      	* python/py-value.c: Likewise.
      	* python/python-internal.h: Likewise.
      	* python/python.c: Likewise.
      	* record-btrace.c: Likewise.
      	* record-full.c: Likewise.
      	* regcache.c: Likewise.
      	* remote-fileio.c: Likewise.
      	* remote-mips.c: Likewise.
      	* remote.c: Likewise.
      	* rs6000-aix-tdep.c: Likewise.
      	* rs6000-nat.c: Likewise.
      	* skip.c: Likewise.
      	* solib-darwin.c: Likewise.
      	* solib-dsbt.c: Likewise.
      	* solib-frv.c: Likewise.
      	* solib-ia64-hpux.c: Likewise.
      	* solib-spu.c: Likewise.
      	* solib-svr4.c: Likewise.
      	* solib.c: Likewise.
      	* spu-tdep.c: Likewise.
      	* stack.c: Likewise.
      	* stap-probe.c: Likewise.
      	* symfile-mem.c: Likewise.
      	* symmisc.c: Likewise.
      	* target.c: Likewise.
      	* thread.c: Likewise.
      	* top.c: Likewise.
      	* tracepoint.c: Likewise.
      	* tui/tui-interp.c: Likewise.
      	* typeprint.c: Likewise.
      	* utils.c: Likewise.
      	* valarith.c: Likewise.
      	* valops.c: Likewise.
      	* valprint.c: Likewise.
      	* value.c: Likewise.
      	* varobj.c: Likewise.
      	* windows-nat.c: Likewise.
      	* xml-support.c: Likewise.
      c765fdb9
  29. 07 Aug, 2014 1 commit
    • Gary Benson's avatar
      Move stdio.h to common-defs.h · d02f550d
      Gary Benson authored
      This commit moves the inclusion of stdio.h to common-defs.h and
      removes all other inclusions.
      
      gdb/
      2014-08-07  Gary Benson  <gbenson@redhat.com>
      
      	* common/common-defs.h: Include stdio.h.
      	* defs.h: Do not include stdio.h.
      	* ada-lang.c: Likewise.
      	* common/buffer.c: Likewise.
      	* common/common-utils.c: Likewise.
      	* cp-name-parser.y: Likewise.
      	* gnu-nat.c: Likewise.
      	* go32-nat.c: Likewise.
      	* i386gnu-nat.c: Likewise.
      	* proc-api.c: Likewise.
      	* proc-events.c: Likewise.
      	* proc-flags.c: Likewise.
      	* proc-why.c: Likewise.
      	* python/python-internal.h: Likewise.
      	* target-memory.c: Likewise.
      	* tui/tui-io.c: Likewise.
      	* tui/tui.c: Likewise.
      
      gdb/gdbserver/
      2014-08-07  Gary Benson  <gbenson@redhat.com>
      
      	* server.h: Do not include stdio.h.
      	* linux-low.c: Likewise.
      	* remote-utils.c: Likewise.
      	* spu-low.c: Likewise.
      	* utils.c: Likewise.
      	* wincecompat.c: Likewise.
      d02f550d