Commit Graph

89614 Commits

Author SHA1 Message Date
Tim Wiederhake 0a0faf9fc6 Add documentation for new record Python bindings.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:

	* NEWS: Add record Python bindings entry.

gdb/doc/ChangeLog:

	* python.texi (Recordings In Python): New section.

Change-Id: Ibacb5930085bff36b0003fde30db9a8178cb280b
2017-02-14 10:57:56 +01:00
Tim Wiederhake 714aa61c16 python: Add tests for record Python bindings
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/testsuite/ChangeLog:

        * gdb.python/py-record-btrace.c, gdb.python/py-record-btrace.exp,
	gdb.python/py-record-full.c, gdb.python/py-record-full.exp: New file.

Change-Id: Icd919b4e1d5642f5cbc097a6aede1416eba402e5
2017-02-14 10:57:56 +01:00
Tim Wiederhake 75c0bdf484 python: Implement btrace Python bindings for record history.
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: Tim 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
2017-02-14 10:57:56 +01:00
Tim Wiederhake 4726b2d82c python: Create Python bindings for record history.
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: Tim 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
2017-02-14 10:57:56 +01:00
Tim Wiederhake b158a20f26 Add method to query current recording method to target_ops.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog

	* record-btrace.c (record_btrace_record_method): New function.
	(init_record_btrace_ops): Initialize to_record_method.
	* record-full.c (record_full_record_method): New function.
	(init_record_full_ops, init_record_full_core_ops): Add
	record_full_record_method.
	* record.h (enum record_method): New enum.
	* target-debug.h (target_debug_print_enum_record_method: New define.
	* target-delegates.c: Regenerate.
	* target.c (target_record_method): New function.
	* target.h: Include record.h.
	(struct target_ops) <to_record_method>: New field.
	(target_record_method): New export.

Change-Id: I05daa70e4e08a19901e848c731bb7d60cd87cc5a
2017-02-14 10:57:56 +01:00
Tim Wiederhake 45b196c590 Add record_start and record_stop functions.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog

	* record.h (record_start, record_stop): New export.
	* record.c (record_start, record_stop): New function.

Change-Id: If235d4bde8ec61dab6dbd23e087430e66d2e91a7
2017-02-14 10:57:56 +01:00
Tim Wiederhake fdd2bd920b btrace: Use binary search to find instruction.
Currently, btrace_find_insn_by_number will iterate over all function call
segments to find the one that contains the needed instruction.  This linear
search is too slow for the upcoming Python bindings that will use this
function to access instructions.  This patch introduces a vector in struct
btrace_thread_info that holds pointers to all recorded function segments and
allows to use binary search.

The proper solution is to turn the underlying tree into a vector of objects
and use indices for access.  This requires more work.  A patch set is
currently being worked on and will be published later.

Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:
	* btrace.c (btrace_fetch): Copy function call segments pointer
	into a vector.
	(btrace_clear): Clear the vector.
	(btrace_find_insn_by_number): Use binary search to find the correct
	function call segment.
	* btrace.h (brace_fun_p): New typedef.
	(struct btrace_thread_info) <functions>: New field.

Change-Id: I8a7f67e80bfe4ff62c4192f74a2153a70bf2a035
2017-02-14 10:57:56 +01:00
Tim Wiederhake 508352a9bf btrace: Export btrace_decode_error function.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:

	* record-btrace.c (btrace_ui_out_decode_error): Move most of it ...
	* btrace.c (btrace_decode_error): ... here.  New function.
	* btrace.h (btrace_decode_error): New export.

Change-Id: I2b4b43a55dbfd9f526a540d2ad52a6708f31feba
2017-02-14 10:57:56 +01:00
Tim Wiederhake 69090ceead btrace: Count gaps as one instruction explicitly.
This gives all instructions, including gaps, a unique number.  Add a function
to retrieve the error code if a btrace instruction iterator points to an
invalid instruction.

Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:

	* btrace.c (ftrace_call_num_insn, btrace_insn_get_error): New function.
	(ftrace_new_function, btrace_insn_number, btrace_insn_cmp,
	btrace_find_insn_by_number): Remove special case for gaps.
	* btrace.h (btrace_insn_get_error): New export.
	(btrace_insn_number, btrace_find_insn_by_number): Adjust comment.
	* record-btrace.c (btrace_insn_history): Print number for gaps.
	(record_btrace_info, record_btrace_goto): Handle gaps.

Change-Id: I8eb0e48a95f4278522fea74ea13526bfe6898ecc
2017-02-14 10:57:56 +01:00
Markus Metzger 4c2c7ac69d btrace: preserve call stack on function switch
On 64-bit FC25, the _dl_runtime_resolve function uses a conditional branch to
'call' a particular variant optimized for that system:

    (gdb) disas _dl_runtime_resolve_avx_opt
    Dump of assembler code for function _dl_runtime_resolve_avx_opt:
       0x00007ffff7deeb60 <+0>: push   %rax
       0x00007ffff7deeb61 <+1>: push   %rcx
       0x00007ffff7deeb62 <+2>: push   %rdx
       0x00007ffff7deeb63 <+3>: mov    $0x1,%ecx
       0x00007ffff7deeb68 <+8>: xgetbv
       0x00007ffff7deeb6b <+11>: mov    %eax,%r11d
       0x00007ffff7deeb6e <+14>: pop    %rdx
       0x00007ffff7deeb6f <+15>: pop    %rcx
       0x00007ffff7deeb70 <+16>: pop    %rax
       0x00007ffff7deeb71 <+17>: and    $0x4,%r11d
       0x00007ffff7deeb75 <+21>: bnd je 0x7ffff7def4a0 <_dl_runtime_resolve_sse_vex>
    End of assembler dump.

When computing the function-level trace, btrace treats this as a switch from
_dl_runtime_resolve_avx_opt to _dl_runtime_resolve_sse_vex.  We know that we
switched functions but we can't really say in which caller/callee relationship
those two functions are.

In addition to preserving the indentaion level, also preserve the caller
information.  This is a heuristic since we don't really know.  But at least in
this case, this seems to be the right thing to do.

This fixes a fail in gdb.btrace/rn-dl-bind.exp on 64-bit FC25.

gdb/
	* btrace.c (ftrace_new_switch): Preserve up link and flags.
2017-02-14 10:15:27 +01:00
GDB Administrator 61697d017e Automatic date update in version.in 2017-02-14 00:00:30 +00:00
Palmer Dabbelt 10ddfe62f8 Don't use "_gp" on RISC-V, use "_global_pointer$" instead
"_gp" could conflict with ABI-complient code.  While it's probably OK
because MIPS uses this name, we figured it'd be good to clean this up
before a release with RISC-V in it.

ld/ChangeLog:

2017-02-13  Palmer Dabbelt  <palmer@dabbelt.com>

        * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Change
        _gp to __global_pointer$.

bfd/ChangeLog:

2017-02-13  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (riscv_global_pointer_value): Change _gp to
        __global_pointer$.
2017-02-13 09:53:54 -08:00
Nick Clifton d11135f552 Fix invalid memory access in the BFD library's DWARF parser.
PR binutils/21151
	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Check for an invalid
	unit length field.
2017-02-13 17:51:27 +00:00
Thomas Preud'homme 3c6452ae8d [ARM] Allow immediate without prefix in unified syntax for VCMP
2017-02-13  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	gas/
	* config/tc-arm.c (parse_ifimm_zero): Make prefix optional in unified
	syntax.
	* testsuite/gas/arm/vcmp-noprefix-imm.d: New file.
	* testsuite/gas/arm/vcmp-noprefix-imm.s: New file.
2017-02-13 17:47:21 +00:00
Nick Clifton c12214021d Fix illegal memory access bug in nm when run on a corrupt binary.
PR binutils/21150
	* nm.c (file_symbol): Add test of string length before testing
	string characters.
2017-02-13 17:23:10 +00:00
Nick Clifton 1835f746a7 Extend previous patch to cover uncompress_section_contents returning FALSE to other callers.
PR binutils/21135
	(dump_section_as_bytes, load_specific_debug_section): Likewise.
2017-02-13 15:19:48 +00:00
Nick Clifton f055032e4e Fix invalid read of section contents whilst processing a corrupt binary.
PR binutils/21135
	* readelf.c (dump_section_as_bytes): Handle the case where
	uncompress_section_contents returns false.
2017-02-13 15:04:37 +00:00
Nick Clifton ebdf1ebfa5 Fix invalid memory access attempting to read the compression header of a too-small compressed section.
PR binutils/21149
	* readelf.c (get_compression_header): Add size parameter.  Check
	size against sizeof compression header before attempting to
	extract the header.
	(process_section_headers): Pass size to get_compression_header.
	(dump_section_as_strings): Likewise.
	(dump_section_as_bytes): Likewise.
	(load_specific_debug_section): Likewise.
2017-02-13 14:52:48 +00:00
Nick Clifton 4aeb00ad3c Fix check for buffer overflow when processing version information.
PR binutils/21148
	* readelf.c (process_version_sections): Include size of auxillary
	version information when checking for buffer overflow.
2017-02-13 14:35:24 +00:00
Nick Clifton 0ee3043f58 Fix access violation when reporting sections that could not be dumped.
PR binutils/21147
	* readelf.c (process_section_contents): Fix off by one error
	reporting un-dumped sections.
2017-02-13 14:17:07 +00:00
Nick Clifton f84ce13b67 Fix read-after-free error in readelf when processing multiple, relocated sections in an MSP430 binary.
PR binutils/21139
	* readelf.c (target_specific_reloc_handling): Add num_syms
	parameter.  Check for symbol table overflow before accessing
	symbol value.  If reloc pointer is NULL, discard all saved state.
	(apply_relocations): Pass num_syms to target_specific_reloc_handling.
	Call target_specific_reloc_handling with a NULL reloc pointer
	after processing all of the relocs.
2017-02-13 14:03:22 +00:00
Luis Machado 5cf30ebf64 Improve load command's help text
This fairly obvious patch adds usage text to the load command's help text.

Originally it did not have usage and mentioned things like FILE and OFFSET
without explaining how those should be passed in the command.

gdb/ChangeLog:

2017-02-13  Luis Machado  <lgustavo@codesourcery.com>

	* symfile (_initialize_symfile): Add usage text to the load command's
	help text.

gdb/doc/ChangeLog:

2017-02-13  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.texinfo (Target Commands): Document the optional offset
	argument for the load command.
2017-02-13 07:29:30 -06:00
Luis Machado bf5f525c89 Fix gdb.linespec/explicit.exp
This patch addresses timeout failures i noticed while testing aarch64-elf.

FAIL: gdb.linespec/explicit.exp: complete unique function name (timeout)
FAIL: gdb.linespec/explicit.exp: complete non-unique function name (timeout)
FAIL: gdb.linespec/explicit.exp: complete non-existant function name (timeout)
FAIL: gdb.linespec/explicit.exp: complete unique file name (timeout)
FAIL: gdb.linespec/explicit.exp: complete non-unique file name (timeout)

The timeouts were caused by an attempt to match a bell character (x07) that
doesn't show up on my particular test setup.

The bell character is output whenever one tries to complete a pattern and there
are multiple possible matches. When there is only one possible match, GDB will
complete the input pattern without outputting the bell character.

The reason for the discrepancy in this test's behavior is due to the use of
"main" for a unique name test.

On glibc-based systems, GDB may notice the "main_arena" symbol, which is
a data global part of glibc's malloc implementation. Therefore a bell character
will be output because we have a couple possible completion matches.

GDB should not be outputting such a data symbol as a possible match, but this
problem may/will be addressed in a future change and is besides the point of
this particular change.

On systems that are not based on glibc, GDB will not see any other possible
matches for completing "main", so there will be no bell characters.

The use of main is a bit fragile though, so the patch adds a new local function
with a name that has a greater chance of being unique and adjusts the test to
iuse it.

I've also added the regular expression switch (-re) to all the
gdb_test_multiple calls that were missing it. Hopefully this will reduce the
chances of someone wasting time trying to match a regular expression (a much
more common use case) when, in reality, the pattern is supposed to be matched
literally.

gdb/testsuite/ChangeLog

2017-02-13  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.linespec/explicit.c (my_unique_function_name): New function.
	(main): Call my_unique_function_name.
	* gdb.linespec/explicit.exp: Use my_unique_function_name to test
	completion of patterns with a single match.
	Add missing -re switches to gdb_test_multiple calls.
2017-02-13 07:16:34 -06:00
Luis Machado 13a66184d0 Make gdb.arch/i386-biarch-core.exp more robust
This test attempts to load a x86 core file no matter what target
architectures the tested GDB supports. If GDB doesn't know how to handle
a i386 target, it is very likely the core file will not be recognized.

In this case we should still attempt to load a core file to make sure GDB
doesn't crash or throws an internal error.  But we should not proceed to
try to read memory unconditionally.

This patch makes the test check for proper i386 arch support in GDB and bails
out if i386 is not supported and the core file format is not recognized.

This addresses the spurious aarch64-elf failures i'm seeing for this test.

gdb/testsuite/ChangeLog:

2017-02-13  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.arch/i386-biarch-core.exp: Check for i386 arch support and
	return if core file is not recognized.
2017-02-13 07:13:54 -06:00
Nick Clifton 03f7786e2f Fix readelf writing to illegal addresses whilst processing corrupt input files containing symbol-difference relocations.
PR binutils/21137
	* readelf.c (target_specific_reloc_handling): Add end parameter.
	Check for buffer overflow before writing relocated values.
	(apply_relocations): Pass end to target_specific_reloc_handling.
2017-02-13 13:08:32 +00:00
Mike Frysinger 13a590ca65 sim: use ARRAY_SIZE instead of ad-hoc sizeof calculations 2017-02-13 01:26:21 -05:00
GDB Administrator b1499fc214 Automatic date update in version.in 2017-02-13 00:00:29 +00:00
GDB Administrator 61351dd701 Automatic date update in version.in 2017-02-12 00:00:23 +00:00
Alan Modra 54064fdb79 Fix use after free in cgen instruction lookup
* cgen-opc.c (cgen_lookup_insn): Delete buf and base_insn temps.
	Use insn_bytes_value and insn_int_value directly instead.  Don't
	free allocated memory until function exit.
2017-02-11 17:40:41 +10:30
GDB Administrator 09ec4d3122 Automatic date update in version.in 2017-02-11 00:00:30 +00:00
Simon Marchi 26a06916b6 Do not send queries on secondary UIs
This is a follow-up to

  https://sourceware.org/ml/gdb-patches/2017-02/msg00261.html

This patch restricts queries to the main UI, which allows to avoid two
different problems.

The first one is that GDB is issuing queries on secondary MI channels
for which a TTY is allocated.  The second one is that GDB is not able to
handle queries on two (CLI) UIs simultaneously.  Restricting queries to
the main UI allows to bypass these two problems.

More details on how/why these two problems happen:

1. Queries on secondary MI UI

  The current criterion to decide if we should query the user is whether
  the input stream is a TTY.  The original way to start GDB in MI mode
  from a front-end was to create a subprocess with pipes to its
  stdin/stdout.  In this case, the input was considered non-interactive
  and queries were auto-answered.  Now that front-ends can create the MI
  channel as a separate UI connected to a dedicated TTY, GDB now
  considers this input stream as interactive and sends queries to it.
  By restricting queries to the main UI, we make sure we never query on
  the secondary MI UI.

2. Simultaneous queries

  As Pedro stated it, when you have two queries on two different CLI UIs
  at the same time, you end up with the following pseudo stack:

  #0 gdb_readline_wrapper
  #1 defaulted_query                 // for UI #2
  #2 handle_command
  #3 execute_command ("handle SIGTRAP" ....
  #4 stdin_event_handler             // input on UI #2
  #5 gdb_do_one_event
  #7 gdb_readline_wrapper
  #8 defaulted_query                 // for UI #1
  #9 handle_command
  #10 execute_command ("handle SIGINT" ....
  #11 stdin_event_handler            // input on UI #1
  #12 gdb_do_one_event
  #13 gdb_readline_wrapper

  trying to answer the query on UI #1 will therefore answer for UI #2.

  By restricting the queries to the main UI, we ensure that there will
  never be more than one pending query, since you can't have two queries
  on a UI at the same time.

I added a snippet to gdb.base/new-ui.exp to verify that we get a query
on the main UI, but that we don't on the secondary one (or, more
precisely, that it gets auto-answered).

gdb/ChangeLog:

	* utils.c (defaulted_query): Don't query on secondary UIs.

gdb/testsuite/ChangeLog:

	* gdb.base/new-ui.exp (do_test): Test queries behavior on main
	and extra UIs.
2017-02-10 16:29:50 -05:00
Simon Marchi b761ca9e3d new-ui.exp: Use proc_with_prefix
gdb/testsuite/ChangeLog:

	* gdb.base/new-ui.exp (do_test, do_test_invalid_args): Use
	proc_with_prefix.
2017-02-10 16:29:45 -05:00
Tom Tromey 0b145e37a2 Remove unused variable in rust-lang.c
I found another unused "cleanup" local variable, this time in
rust-lang.c.  This patch removes it.  Committing as obvious.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_get_disr_info): Remove unused variable.
2017-02-10 13:09:23 -07:00
Tom Tromey b964bee0f0 Fix Python test to use lowercase command
While testing this series I saw some errors from the Python test
suite.  There were a couple of tests using "P" as a command; this
changes them to "p".

gdb/testsuite/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* gdb.python/py-xmethods.exp: Use "p" command, not "P".
2017-02-10 12:24:35 -07:00
Tom Tromey 2d8365c48f Remove unnecessary local variables
I found an unused local variables in a couple of places in the Python
code; this removes them.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* python/py-value.c (valpy_richcompare_throw): Remove unnecessary
	"cleanup" local.
	* python/py-type.c (typy_legacy_template_argument): Remove
	unnecessary "cleanup" local.
2017-02-10 12:24:34 -07:00
Tom Tromey 2bb8f23195 Remove some gotos from Python
This patch slightly refactors a couple of spots in the Python code to
avoid some gotos.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* python/python.c (do_start_initialization): New function, from
	_initialize_python.
	(_initialize_python): Call do_start_initialization.
	* python/py-linetable.c (ltpy_iternext): Use explicit returns, not
	goto.
2017-02-10 12:24:34 -07:00
Tom Tromey 1bdfaf42ac Change one more spot to use gdbpy_ref
This patch changes one more spot in the Python layer to use gdbpy_ref.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* python/py-prettyprint.c (pretty_print_one_value): Use
	gdbpy_ref.
2017-02-10 12:24:33 -07:00
Tom Tromey 88b6faea99 Use gdbpy_ref to simplify some logic
This uses the new gdbpy_ref template to simplify logic in various
parts of the Python layer; for example removing repeated error code or
removing gotos.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref.
	* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use
	gdbpy_ref.
	* python/py-type.c (field_new): Use gdbpy_ref.
	* python/py-symtab.c (symtab_and_line_to_sal_object): Use
	gdbpy_ref.
	* python/py-progspace.c (pspy_new): Use gdbpy_ref.
	(py_free_pspace): Likewise.
	(pspace_to_pspace_object): Likewise.
	* python/py-objfile.c (objfpy_new): Use gdbpy_ref.
	(py_free_objfile): Likewise.
	(objfile_to_objfile_object): Likewise.
	* python/py-inferior.c (delete_thread_object): Use
	gdbpy_ref.
	(infpy_read_memory): Likewise.
	(py_free_inferior): Likewise.
	* python/py-evtregistry.c (create_eventregistry_object): Use
	gdbpy_ref.
	* python/py-event.c (create_event_object): Use gdbpy_ref.
2017-02-10 12:24:32 -07:00
Tom Tromey 7780f18678 Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject.  The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* python/py-ref.h (gdbpy_ref_policy): Now a template.
	(gdbpy_ref): Now a template; allow subclasses of PyObject to be
	used.
	* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
	python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
	python/py-exitedevent.c, python/py-finishbreakpoint.c,
	python/py-framefilter.c, python/py-function.c,
	python/py-inferior.c, python/py-infevents.c,
	python/py-linetable.c, python/py-newobjfileevent.c,
	python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
	python/py-signalevent.c, python/py-stopevent.c,
	python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
	python/py-unwind.c, python/py-utils.c, python/py-value.c,
	python/py-varobj.c, python/py-xmethods.c, python/python.c,
	varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-10 12:24:31 -07:00
Tom Tromey d4b0bb186e Remove some ui_out-related cleanups from Python
This patch introduces a bit of infrastructure -- namely, a minimal
std::optional analogue called gdb::optional, and an RAII template
class that works like make_cleanup_ui_out_tuple_begin_end or
make_cleanup_ui_out_list_begin_end -- and then uses these in the
Python code.  This removes a number of cleanups and generally
simplifies this code.

std::optional is only available in C++17.  Normally I would have had
this code check __cplusplus, but my gcc apparently isn't new enough to
find <optional>, even with -std=c++1z; so, because I could not test
it, the patch does not do this.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

	* ui-out.h (ui_out_emit_type): New class.
	(ui_out_emit_tuple, ui_out_emit_list): New typedefs.
	* python/py-framefilter.c (py_print_single_arg): Use gdb::optional
	and ui_out_emit_tuple.
	(enumerate_locals): Likewise.
	(py_mi_print_variables, py_print_locals, py_print_args): Use
	ui_out_emit_list.
	(py_print_frame): Use gdb::optional, ui_out_emit_tuple,
	ui_out_emit_list.
	* common/gdb_optional.h: New file.
2017-02-10 12:24:31 -07:00
Martin Galvan f67f945cf2 gdb/MAINTAINERS: Update my e-mail address
gdb/ChangeLog:

2017-02-10  Martin Galvan  <martingalvan@sourceware.org>

        * MAINTAINERS (Write After Approval): Update my e-mail address.
2017-02-10 13:50:32 -03:00
Martin Galvan 18da0c51da PR gdb/21122: Fix documentation mistakes for breakpoint commands
Currently, the breakpoint documentation refers to some commands taking breakpoint
"ranges" as arguments. We discussed this with Pedro and concluded that it would
be more accurate to speak in terms of breakpoint "lists", whose elements can optionally
be ranges. I also fixed a couple of minor mistakes in the docs.

gdb/ChangeLog:

	* breakpoint.c (_initialize_breakpoint): Update the help description
	of the 'commands' command to indicate that it takes a list argument.

gdb/doc/ChangeLog:

	* gdb.texinfo (Breakpoints): Reword documentation to speak in terms of
	space-separated breakpoint lists.  Also add a missing @table command
	and @cindex for breakpoint lists.

gdb/testsuite/ChangeLog:

	* gdb.base/help.exp: Update match pattern for testing 'help commands'.
2017-02-10 13:38:54 -03:00
Nicholas Piggin dce75bf984 POWER9 add scv/rfscv instruction support
opcodes/
	* ppc-opc.c (powerpc_opcodes) <scv, rfscv>: New mnemonics.

gas/
	* testsuite/gas/ppc/power9.d <scv, rfscv>: New tests.
2017-02-10 19:04:26 +10:30
GDB Administrator 53f7e8ea7f Automatic date update in version.in 2017-02-10 00:00:16 +00:00
Simon Marchi 62c14536e4 Remove return in function returning void
gdb/ChangeLog:

	* interps.c (current_interp_set_logging): Remove "return".
2017-02-09 16:24:40 -05:00
Gary Benson ff6fa24786 Fix NULL pointer dereference
This commit fixes a segmentation fault on tab completion when
certain debuginfo is installed:

  https://bugzilla.redhat.com/show_bug.cgi?id=1398387

gdb/ChangeLog:

	* symtab.c (add_symtab_completions): Prevent NULL pointer
	dereference.
2017-02-09 15:37:57 +00:00
GDB Administrator 9d5c5dd77b Automatic date update in version.in 2017-02-09 00:00:27 +00:00
Andrew Burgess d7488716ee ld/arc: Change default linker emulation for nps400
If we are configuring for an arc/linux target, and --with-cpu=nps400 is
used at configure time then change the default linker emulation to the
nps specific version.  All of the alternative linker emulations are
still available using the -mNAME option for ld.

ld/ChangeLog:

	* configure.tgt (arc*-*-linux*): Change the default linker
	emulation based on --with-cpu selection.
	* NEWS: Mention new configuration option.
2017-02-08 23:47:43 +00:00
Pedro Alves a474bd8eee Eliminate interp::quiet_p
This commit removes interp::quiet_p / interp_quiet_p /
interp_set_quiet, because AFAICS, it doesn't really do anything.

interp_quiet is only ever checked inside interp_set nowadays:

  if (!first_time && !interp_quiet_p (interp))
    {
      xsnprintf (buffer, sizeof (buffer),
		 "Switching to interpreter \"%.24s\".\n", interp->name);
      current_uiout->text (buffer);
    }

I did a bit of archaelogy, and found that back in 4a8f6654 (2003), it
was also called in another place, to decide whether to print the CLI
prompt.

AFAICS, that condition is always false today, making that if/then
block always dead code.  If we remove that code, then there are no
interp_quiet_p uses left in the tree, so we can remove it all.

There are two paths that lead to interp_set calls:

#1 - When installing the top level interpreter.  In this case,
FIRST_TIME is true.

#2 - In interpreter_exec_cmd.  In this case, the interpreter is always
set quiet before interp_set is called.

Grepping a gdb.log of an x86_64 GNU/Linux run for "Switching to
interpreter" (before this patch) doesn't find any hits.

I suspect the intention of this message was to support something like
a "set interpreter ..." command that would change the interpreter
permanently.  But there's no such command.

Tested on x86_64 Fedora 23.

gdb/ChangeLog:
2017-02-08  Pedro Alves  <palves@redhat.com>

	* interps.c (interp::interp): Remove reference to quiet_p.
	(interp_set): Make static.  Remove dead "Switching to" output
	code.
	(interp_quiet_p, interp_set_quiet): Delete.
	(interpreter_exec_cmd): Don't set the interpreter quiet.
	* interps.h (interp_quiet_p): Make static.
	(class interp) <quiet_p>: Remove field
2017-02-08 18:08:18 +00:00
Jerome Guitton 604c4576fd Command abbreviation in define
When defining a new macro, "command" is not recognized as an alias for
"commands":

 (gdb) define breakmain
 Type commands for definition of "breakmain".
 End with a line saying just "end".
 >break main
 >command
 >echo "IN MAIN\n"
 >end
 (gdb)

There is a special case for while-stepping, where 'ws' and 'stepping' are
recognized explicitely. Instead of adding more special cases, this change
uses cli-decode.

gdb/ChangeLog:
	* cli/cli-decode.c (find_command_name_length): Make it extern.
	* cli/cli-decode.h (find_command_name_length): Declare.
	* cli/cli-script.c (command_name_equals, line_first_arg):
	New functions.
	(process_next_line): Use cli-decode to parse command names.
	(build_command_line): Make args a constant pointer.

gdb/testsuite/ChangeLog:

	* gdb.base/define.exp: Add test for command abbreviations
	in define.
2017-02-08 19:03:25 +01:00