Commit Graph

39739 Commits

Author SHA1 Message Date
Pedro Alves e5f25bc5d6 Fix "list ambiguous_variable"
The "list" command allows specifying the name of variables as
argument, not just functions, so that users can type "list
a_global_variable".

That support is a broken when it comes to ambiguous locations though.

If there's more than one such global variable in the program, e.g.,
static globals in different compilation units, GDB ends up listing the
source of the first variable it finds, only.

linespec.c does find both symbol and minsym locations for all the
globals.  The problem is that it ends up merging all the resulting
sals into one, because they all have address, zero.  I.e., all sals
end up with sal.pc == 0, so maybe_add_address returns false for all
but the first.

The zero addresses appear because:

- in the minsyms case, linespec.c:minsym_found incorrectly treats all
  minsyms as if they were function/text symbols.  In list mode we can
  end up with data symbols there, and we shouldn't be using
  find_pc_sect_line on data symbols.

- in the debug symbols case, symbol_to_sal misses recording an address
  (sal.pc) for non-block, non-label symbols.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

	* linespec.c (minsym_found): Handle non-text minsyms.
	(symbol_to_sal): Record a sal.pc for non-block, non-label symbols.

gdb/testsuite/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

	* gdb.base/list-ambiguous.exp (test_list_ambiguous_function):
	Rename to ...
	(test_list_ambiguous_symbol): ... this and add a symbol name
	parameter.  Adjust.
	(test_list_ambiguous_function): Reimplement on top of
	test_list_ambiguous_symbol and also test listing ambiguous
	variables.
	* gdb.base/list-ambiguous0.c (ambiguous): Rename to ...
	(ambiguous_fun): ... this.
	(ambiguous_var): New.
	* gdb.base/list-ambiguous1.c (ambiguous): Rename to ...
	(ambiguous_fun): ... this.
	(ambiguous_var): New.
2017-09-20 16:12:54 +01:00
Walfred Tedeschi 1b7fa39ed9 [OBV] amd64-features-makefile: add missing backslash.
In an old commit the backslash of was missing in the rule for creating the
i386-avx-mpx-avx512-pku.dat file.  No need to regenerate the files, this
was done by another commit from Yao.

2017-09-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* features/Makefile (i386-avx-mpx-avx512-pku.dat): Add backslash.
2017-09-20 15:01:40 +02:00
Walfred Tedeschi 37dd082596 add ChangeLog from previous commit 2017-09-20 14:47:04 +02:00
Walfred Tedeschi 6470a84860 gdb - avx512: tests were failing due to missing memory aligment.
Test was running on a fault during code execution.  Analysis have shown
that the wrong instruction had been used.  An instruction that takes
not alligned memory is more appropriated for the task.

ChangeLog:

2017-09-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testesuite/ChangeLog:
	* gdb.arch/i386-avx512.c (move_zmm_data_to_reg): Use
	vmovups instead vmovaps.
	(move_zmm_data_to_memory): Use vmovups instead vmovaps.

Change-Id: I4a95560861ef1792ed6ce86578fdd726162863f1
2017-09-20 13:42:21 +02:00
John Baldwin 4e5a4f5850 Add a 'starti' command.
This works like 'start' but it stops at the first instruction rather
than the first line in main().  This is useful if one wants to single
step through runtime linker startup.

While here, introduce a RUN_ARGS_HELP macro for shared help text
between run, start, and starti.  This includes expanding the help for
start and starti to include details from run's help text.

gdb/ChangeLog:

	* NEWS (Changes since GDB 8.0): Add starti.
	* infcmd.c (enum run_break): New.
	(run_command_1): Queue pending event for RUN_STOP_AT_FIRST_INSN
	case.
	(run_command): Use enum run_how.
	(start_command): Likewise.
	(starti_command): New function.
	(RUN_ARGS_HELP): New macro.
	(_initialize_infcmd): Use RUN_ARGS_HELP for run and start
	commands.  Add starti command.

gdb/doc/ChangeLog:

	* gdb.texinfo (Starting your Program): Add description of
	starti command.  Mention starti command as an alternative for
	debugging the elaboration phase.

gdb/testsuite/ChangeLog:

	* gdb.base/starti.c: New file.
	* gdb.base/starti.exp: New file.
	* lib/gdb.exp (gdb_starti_cmd): New procedure.
2017-09-19 12:15:35 -07:00
Yao Qi aa70c9f195 Remove one explicit rule for monitor.o
gdb/monitor.c was removed by 40e0b27 (Delete the remaining ROM monitor
targets).

gdb:

2017-09-19  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (monitor.o): Remove the rule.
2017-09-19 10:18:57 +01:00
Yao Qi d654162044 Use DISABLE_COPY_AND_ASSIGN
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.
2017-09-19 10:10:03 +01:00
Simon Marchi 0615127c58 dwarf2expr: Remove unused abort_expression label in execute_stack_op
The label abort_expression is unused, so remove it.

gdb/ChangeLog:

	* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Remove
	label abort_expression.
2017-09-18 13:09:20 +02:00
Simon Marchi 04fd3ba9b6 Refactor handle_qxfer_libraries and friends to use std::string
Using std::string in handle_qxfer_libraries and friends allow to
simplify the code.  We don't have to manually free the buffer, and we
don't have to pre-compute the required space.

gdb/gdbserver/ChangeLog:

	* server.c (accumulate_file_name_length): Remove.
	(emit_dll_description): Adjust to std::string change.
	(handle_qxfer_libraries): Use std::string to hold document.
2017-09-16 14:22:11 +02:00
Simon Marchi 5e1875543d Make xml_escape_text return an std::string
This is a simple replacement, it allows removing some manual free'ing in
the callers.

gdb/ChangeLog:

	* common/buffer.c (buffer_xml_printf): Adjust.
	* common/xml-utils.c (xml_escape_text): Change return type to
	std::string, update code accordingly.
	* common/xml-utils.h (xml_escape_text): Change return type to
	std::string.
	* rs6000-aix-tdep.c (rs6000_aix_shared_library_to_xml): Adjust.
	* windows-tdep.c (windows_xfer_shared_library): Adjust.
	* unittests/xml-utils-selftests.c (test_xml_escape_text):
	Adjust.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_qxfer_libraries_svr4): Adjust to change of
	return type of xml_escape_text.
	* server.c (emit_dll_description): Likewise.
2017-09-16 14:19:31 +02:00
Simon Marchi c3d7b541fa Add unit test for xml_escape_text
The following patch modifies xml_escape_text, so I took the opportunity
to write a unit test for it.

gdb/ChangeLog:

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add new source file.
	(SUBDIR_UNITTESTS_OBS): Add new object file.
	* unittests/xml-utils-selftests.c: New file.
2017-09-16 14:16:28 +02:00
Simon Marchi 1526853e34 Add selftests run filtering
With the growing number of selftests, I think it would be useful to be
able to run only a subset of the tests.  This patch associates a name to
each registered selftest.  It then allows doing something like:

  (gdb) maintenance selftest aarch64
  Running self-tests.
  Running selftest aarch64-analyze-prologue.
  Running selftest aarch64-process-record.
  Ran 2 unit tests, 0 failed

or with gdbserver:

  ./gdbserver --selftest=aarch64

In both cases, only the tests that contain "aarch64" in their name are
ran.  To help validate that the tests you want to run were actually ran,
it also prints a message with the test name before running each test.

Right now, all the arch-dependent tests are registered as a single test
of the selftests.  To be able to filter those too, I made them
"first-class citizen" selftests.  The selftest type is an interface,
with different implementations for "simple selftests" and "arch
selftests".  The run_tests function simply iterates on that an invokes
operator() on each test.

I changed the tests data structure from a vector to a map, because

  - it allows iterating in a stable (alphabetical) order
  - it allows to easily verify if a test with a given name has been
    registered, to avoid duplicates

There's also a new command "maintenance info selftests" that lists the
registered selftests.

gdb/ChangeLog:

	* common/selftest.h (selftest): New struct/interface.
	(register_test): Add name parameter, add new overload.
	(run_tests): Add filter parameter.
	(for_each_selftest_ftype): New typedef.
	(for_each_selftest): New declaration.
	* common/selftest.c (tests): Change type to
	map<string, unique_ptr<selftest>>.
	(simple_selftest): New struct.
	(register_test): New function.
	(register_test): Add name parameter and use it.
	(run_tests): Add filter parameter and use it.  Add prints.
	Adjust to vector -> map change.
	* aarch64-tdep.c (_initialize_aarch64_tdep): Add names when
	registering selftests.
	* arm-tdep.c (_initialize_arm_tdep): Likewise.
	* disasm-selftests.c (_initialize_disasm_selftests): Likewise.
	* dwarf2-frame.c (_initialize_dwarf2_frame): Likewise.
	* dwarf2loc.c (_initialize_dwarf2loc): Likewise.
	* findvar.c (_initialize_findvar): Likewise.
	* gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise.
	* maint.c (maintenance_selftest): Update call to run_tests.
	(maintenance_info_selftests): New function.
	(_initialize_maint_cmds): Register "maintenance info selftests"
	command.  Update "maintenance selftest" doc.
	* regcache.c (_initialize_regcache): Add names when registering
	selftests.
	* rust-exp.y (_initialize_rust_exp): Likewise.
	* selftest-arch.c (gdbarch_selftest): New struct.
	(gdbarch_tests): Remove.
	(register_test_foreach_arch): Add name parameter.  Call
	register_test.
	(tests_with_arch): Remove, move most content to
	gdbarch_selftest::operator().
	(_initialize_selftests_foreach_arch): Remove.
	* selftest-arch.h (register_test_foreach_arch): Add name
	parameter.
	(run_tests_with_arch): New declaration.
	* utils-selftests.c (_initialize_utils_selftests): Add names
	when registering selftests.
	* utils.c (_initialize_utils): Likewise.
	* unittests/array-view-selftests.c
	(_initialize_array_view_selftests): Likewise.
	* unittests/environ-selftests.c (_initialize_environ_selftests):
	Likewise.
	* unittests/function-view-selftests.c
	(_initialize_function_view_selftests): Likewise.
	* unittests/offset-type-selftests.c
	(_initialize_offset_type_selftests): Likewise.
	* unittests/optional-selftests.c
	(_initialize_optional_selftests): Likewise.
	* unittests/scoped_restore-selftests.c
	(_initialize_scoped_restore_selftests): Likewise.
	* NEWS: Document "maintenance selftest" and "maint info
	selftests".

gdb/gdbserver/ChangeLog:

	* server.c (captured_main): Accept argument for --selftest.
	Update run_tests call.
	* linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names
	when registering selftests.

gdb/doc/ChangeLog:

	* gdb.texinfo (Maintenance Commands): Document filter parameter
	of "maint selftest".  Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
Simon Marchi 5846367a24 mi_load_progress: Restore current_uiout using a scoped_restore
Simply use a scoped_restore instead of manually saving and restoring
current_uiout.

gdb/ChangeLog:

	* mi/mi-main.c (mi_load_progress): Restore current_uiout using a
	scoped_restore.
2017-09-16 13:45:56 +02:00
Simon Marchi bd77e8ff27 mi_load_progress: Use unique_ptr to manage ui_out lifetime
In mi_load_progress, we xfree a ui_out object.  Because ui_out is not
trivially destructible, it should be freed with delete.  This patch
makes use of a unique_ptr to do it.

gdb/ChangeLog:

	* mi/mi-main.c (mi_load_progress): Make uiout variable
	a unique_ptr.

diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 0ee2605..0359dc1
100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2325,7 +2325,6
@@ mi_load_progress (const char *section_name, static char
*previous_sect_name = NULL; int new_section; struct ui_out *saved_uiout;
-  struct ui_out *uiout; struct mi_interp *mi = (struct mi_interp *)
   current_interpreter ();

   /* This function is called through deprecated_show_load_progress
@@ -2333,17 +2332,19 @@ mi_load_progress (const char *section_name,
      of this function.  */
   saved_uiout = current_uiout;

+  std::unique_ptr<ui_out> uiout;
+
   if (current_interp_named_p (INTERP_MI)
       || current_interp_named_p (INTERP_MI2))
-    current_uiout = mi_out_new (2);
+    uiout.reset (mi_out_new (2));
   else if (current_interp_named_p (INTERP_MI1))
-    current_uiout = mi_out_new (1);
+    uiout.reset (mi_out_new (1));
   else if (current_interp_named_p (INTERP_MI3))
-    current_uiout = mi_out_new (3);
+    uiout.reset (mi_out_new (3));
   else
     return;

-  uiout = current_uiout;
+  current_uiout = uiout.get ();

   new_section = (previous_sect_name ?
 		 strcmp (previous_sect_name, section_name) : 1);
@@ -2356,12 +2357,12 @@ mi_load_progress (const char *section_name,
 	fputs_unfiltered (current_token, mi->raw_stdout);
       fputs_unfiltered ("+download", mi->raw_stdout);
       {
-	ui_out_emit_tuple tuple_emitter (uiout, NULL);
+	ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
 	uiout->field_string ("section", section_name);
 	uiout->field_int ("section-size", total_section);
 	uiout->field_int ("total-size", grand_total);
       }
-      mi_out_put (uiout, mi->raw_stdout);
+      mi_out_put (uiout.get (), mi->raw_stdout);
       fputs_unfiltered ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
     }
@@ -2374,19 +2375,18 @@ mi_load_progress (const char *section_name,
 	fputs_unfiltered (current_token, mi->raw_stdout);
       fputs_unfiltered ("+download", mi->raw_stdout);
       {
-	ui_out_emit_tuple tuple_emitter (uiout, NULL);
+	ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
 	uiout->field_string ("section", section_name);
 	uiout->field_int ("section-sent", sent_so_far);
 	uiout->field_int ("section-size", total_section);
 	uiout->field_int ("total-sent", total_sent);
 	uiout->field_int ("total-size", grand_total);
       }
-      mi_out_put (uiout, mi->raw_stdout);
+      mi_out_put (uiout.get (), mi->raw_stdout);
       fputs_unfiltered ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
     }

-  xfree (uiout);
   current_uiout = saved_uiout;
 }
2017-09-16 13:45:55 +02:00
Sergio Durigan Junior c4dfafabc5 Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)
This is a followup patch to the build breakage fix on AArch64.  While
doing the fix, I found it better to convert tdesc->reg_defs (on
gdbserver/tdesc.h) from using VEC to using std::vector.  This makes
the code easier to read and maintain, and also is one more step
towards the C++fication.

Regtested on BuildBot.

2017-09-16  Sergio Durigan Junior  <sergiodj@redhat.com>

	* regcache.c (get_thread_regcache): Update code to use "std::vector"
	instead of "VEC" for "target_desc.reg_defs".
	(regcache_cpy): Likewise.
	(registers_to_string): Likewise.
	(registers_from_string): Likewise.
	(find_regno): Likewise.
	(supply_regblock): Likewise.
	(regcache_raw_read_unsigned): Likewise.
	* tdesc.c (init_target_desc): Likewise.
	(tdesc_create_reg): Likewise.
	* tdesc.h: Remove declaration of "tdesc_reg_p".  Include <vector>.
	(struct target_desc) <reg_defs>: Convert to "std::vector".
	(target_desc): Do not initialize "reg_defs".
	(~target_desc): Update code to use "std::vector" instead of "VEC"
	for "target_desc.reg_defs".
	(operator==): Likewise.
2017-09-15 23:51:33 -04:00
Pedro Alves 26a67918a5 Sync libiberty/ & include/ with GCC
Note this brings in the interface files for libcc1/G++ as well, which
we will be needing in GDB soon anyway.  That commit renamed a method
in the C interface and that required a small update to GDB's compile/
code, which I've included that in this patch to keep the tree
building.

include/ChangeLog:
2017-09-15  Pedro Alves  <palves@redhat.com>

	* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.

	2017-09-12  Jiong Wang  <jiong.wang@arm.com>

	* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
	* dwarf2.h (DW_CFA_DUP): New define.

	2017-08-21  Richard Biener  <rguenther@suse.de>

	* simple-object.h (simple_object_copy_lto_debug_sections): New
	function.

	2017-05-18  Martin Liska  <mliska@suse.cz>

	* ansidecl.h: Define CONSTEXPR macro.

	2017-05-24  Nathan Sidwell  <nathan@acm.org>

	* libiberty.h (ASTRDUP): Adjust cast to avoid warning.

	2017-01-30  Alexandre Oliva <aoliva@redhat.com>

	Introduce C++ support in libcc1.
	* gcc-c-fe.def (int_type_v0): Rename from...
	(int_type): ... this.  Introduce new version.
	(float_type_v0): Rename from...
	(float_type): ... this.  Introduce new version.
	(char_type): New.
	* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
	(gcc_type_array): Move...
	* gcc-interface.h: ... here.
	* gcc-cp-fe.def: New.
	* gcc-cp-interface.h: New.

	2016-04-29  Oleg Endo  <olegendo@gcc.gnu.org>

	* longlong.h (umul_ppmm): Remove SHMEDIA checks.
	(__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations.

	2017-09-15  Yao Qi  <yao.qi@linaro.org>
	    Pedro Alves  <palves@redhat.com>

	* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.

	2017-09-12  Jiong Wang  <jiong.wang@arm.com>

	* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
	* dwarf2.h (DW_CFA_DUP): New define.

	2017-08-21  Richard Biener  <rguenther@suse.de>

	* simple-object.h (simple_object_copy_lto_debug_sections): New
	function.

	2017-05-18  Martin Liska  <mliska@suse.cz>

	* ansidecl.h: Define CONSTEXPR macro.

	2017-05-24  Nathan Sidwell  <nathan@acm.org>

	* libiberty.h (ASTRDUP): Adjust cast to avoid warning.

	2017-01-30  Alexandre Oliva <aoliva@redhat.com>

	Introduce C++ support in libcc1.
	* gcc-c-fe.def (int_type_v0): Rename from...
	(int_type): ... this.  Introduce new version.
	(float_type_v0): Rename from...
	(float_type): ... this.  Introduce new version.
	(char_type): New.
	* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
	(gcc_type_array): Move...
	* gcc-interface.h: ... here.
	* gcc-cp-fe.def: New.
	* gcc-cp-interface.h: New.

	2016-04-29  Oleg Endo  <olegendo@gcc.gnu.org>

	* longlong.h (umul_ppmm): Remove SHMEDIA checks.
	(__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations.

libiberty/ChangeLog:
2017-09-15  Nathan Sidwell  <nathan@acm.org>

	PR demangler/82195
	* cp-demangle.c (d_name): Add 'toplevel' parm.  Pass to	...
	(d_local_name): ... here.  Parse trailing function args on nested
	local_name.
	(d_encoding, d_special_name, d_class_enum_type): Adjust d_name calls.
	* testsuite/demangle-expected: Add tests.

2017-09-15  Richard Biener  <rguenther@suse.de>

	PR lto/81968
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Iterate marking dependent sections necessary.

2017-09-15  Nathan Sidwell  <nathan@acm.org>

	* cp-demangle.c (is_fnqual_component_type): Reimplement using
	FNQUAL_COMPONENT_CASE.
	(d_encoding): Hold bare_function_type in local var.
	(d_local_name): Build name in both cases and build result once.
	Collapse switch-if to single conditional.
	(d_local_name):

	* testsuite/demangle-expected: Realign blank lines with tests.

2017-09-12  Jiong Wang  <jiong.wang@arm.com>

	* dwarfnames.c (DW_CFA_DUP): New define.

gdb/ChangeLog:
2017-09-15  Pedro Alves  <palves@redhat.com>

	* compile/compile-c-types.c (convert_enum, convert_int)
	(convert_float): Adjust to refer to int_type_v0 and float_type_v0.
2017-09-15 17:40:33 +01:00
Simon Marchi 124aceb46d gdbserver: Remove thread_to_gdb_id
As explained in the previous patch, the gdb_id concept is no longer
relevant.  The function thread_to_gdb_id is trivial, it returns the
thread's ptid.  Remove it and replace its usage with ptid_of.

The changes in nto-low.c and lynx-low.c are fairly straightforward, but
I was not able to build test them.

gdb/gdbserver/ChangeLog:

	* inferiors.h (thread_to_gdb_id): Remove.
	* inferiors.c (thread_to_gdb_id): Remove.
	* server.c (handle_qxfer_threads_worker, handle_query): Adjust.
	* lynx-low.c (lynx_resume, lynx_wait_1, lynx_fetch_registers,
	lynx_store_registers, lynx_read_memory, lynx_write_memory):
	Likewise.
	* nto-low.c (nto_fetch_registers, nto_store_registers,
	nto_stopped_by_watchpoint, nto_stopped_data_address): Likewise.
2017-09-15 18:02:51 +02:00
Simon Marchi 96cde54f0a gdbserver: Remove gdb_id_to_thread_id
From what I understand, this function is not doing anything useful as of
today.

Here's the result of my archeological research:

- The field thread_info::gdb_id was added in

  a06660f7  Use LWP IDs for thread IDs in gdbserver

  There was problem when using a 32-bits gdb with a 64-bits gdbserver.
  For some reason that I don't fully understand, the thread ids
  exchanged between gdb and gdbserver could overflow a 32 bits data
  type.  My guess is that they were the thread address (e.g. the
  0x7ffff7f20b40 in "Thread 0x7ffff7f20b40 (LWP 1058)" today).  This
  patch changed that so gdb/gdbserver would talk in terms of the OS
  assigned numerical id (as shown in ps).  It therefore added a way to
  convert between this gdb_id (the numerical id) and the thread id (the
  address).

- 95954743cb  Implement the multiprocess extensions, and add linux
              multiprocess supportNon-stop mode support.

  This patch made gdbserver deal with threads using their numerical ids
  and not the address-like id.  Starting from there, the gdb_id <->
  thread id conversion was not needed anymore, since the remote protocol
  and gdbserver were using the same kind of ids again.  The gdb_id field
  in the thread_info structure was also unused starting there.

- d50171e4  Teach linux gdbserver to step-over-breakpoints.

  This patch moved the thread_info structure around, and got rid of the
  gdb_id field (which was unused).

Looking at the implementation of gdb_id_to_thread_id, it is not doing
anything useful.  It is looking up a thread by ptid using
find_thread_ptid, which basically loops over all threads looking at
their entry.id field.  If a thread with that ptid is found, it returns
its entry.id field.  So it will always return the same thing as it input
(with the exception of if no thread exist with that ptid, then it will
return null_ptid).

gdb/gdbserver/ChangeLog:

	* inferiors.h (gdb_id_to_thread_id): Remove.
	* inferiors.c (gdb_id_to_thread_id): Remove.
	* server.c (process_serial_event): Adjust to gdb_id_to_thread_id
	removal.  Move pid declaration closer to where it's used.
2017-09-15 18:02:51 +02:00
Simon Marchi e8ca139ed0 gdbserver: Move detach code to its own function
The code required to handle the 'D' packet is non trivial, so move it
out to its own function.

The moved out code is identical, except for the call to strtol and some
breaks that became returns.

Tested manually, and by running gdb.base/*detach*.exp with
native-gdbserver and native-extended-gdbserver.

gdb/gdbserver/ChangeLog:

	* server.c (handle_detach): New function.
	(process_serial_event): Move code out, call handle_detach.
2017-09-15 17:59:37 +02:00
Simon Marchi f8a4e11920 Deduplicate require_running macros and move them up
I find it very confusing to define the require_running in the middle of
the file, and re-define it to something else later in the middle of the
same file.  I think it would be better if those macros had different
names so that we know exactly what they do.

gdb/gdbserver/ChangeLog:

	* server.c (require_running): Rename to ...
	(require_running_or_return): ... this ...
	(require_running_or_break): ... and this.
	(handle_query, process_serial_event): Adjust.
2017-09-15 17:59:36 +02:00
Simon Marchi 0eb0a40713 linux-low: Remove unused variables
gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_set_resume_request): Remove unused
	variables.
2017-09-15 16:41:35 +02:00
Simon Marchi 3f8a780428 dwarf2read: Replace copy_string usages with savestring
copy_string does the exact same thing as savestring, so replace the
usages of the former with the latter.

gdb/ChangeLog:

	* dwarf2read.c (copy_string): Remove.
	(parse_macro_definition): Replace copy_string with savestring.
2017-09-15 16:41:34 +02:00
Simon Marchi 785922a559 gdbserver: Remove duplicate functions to find any thread of process
We have about 6 functions/callbacks to find_inferior meant to find a
thread that belongs to a given pid.  Remove all but
find_any_thread_of_pid and replace their uses with
find_any_thread_of_pid.

gdb/gdbserver/ChangeLog:

	* server.c (first_thread_of): Remove.
	(process_serial_event): Replace usage of first_thread_of with
	find_any_thread_of_pid.
	* tracepoint.c (same_process_p): Remove.
	(gdb_agent_about_to_close): Replace usage of same_process_p with
	find_any_thread_of_pid.
	* linux-x86-low.c (same_process_callback): Remove.
	(x86_arch_setup_process_callback): Replace usage of
	same_process_callback with find_any_thread_of_pid.
	* thread-db.c (any_thread_of): Remove.
	(switch_to_process): Replace usage of any_thread_of with
	find_any_thread_of_pid.
	* inferiors.c (thread_pid_matches_callback): Remove.
	(find_thread_process): Adjust to use find_any_thread_of_pid.
2017-09-15 14:53:20 +02:00
Yao Qi 8d20070632 Fix x86 build failures
Christophe Lyon told me that GDB build failed on i386-linux with
--enable-64-bit-bfd=yes, so I audit the gdb/configure.tgt again.  I
find that i386-darwin has the same issue too.  Additionally, GDB
for solaris target fails to build too.  This patch fixes all of them.

gdb:

2017-09-15  Yao Qi  <yao.qi@linaro.org>

	* configure.tgt (i[34567]86-*-darwin*): Append amd64.o to
	gdb_target_obs.
	(i[34567]86-*-solaris2.1[0-9]* | x86_64-*-solaris2.1[0-9]*):
	Likewise.
	(i[34567]86-*-linux*): Likewise.
2017-09-15 13:05:39 +01:00
Simon Marchi d185219da3 Make dwarf_expr_context::stack an std::vector
Replace the manually managed array with a vector.  It is mostly
straightforward, except maybe one thing in execute_stack_op, in the
handling of DW_OP_fbreg.  When the code stumbles on that opcode while
evaluating an expression, it needs to evaluate a subexpression to find
where the fb reg has been saved.  Rather than creating a new context, it
reuses the current context.  It saves the size of the stack before and
restores the stack to that size after.

I think we can do a little bit better by saving the current stack
locally and installing a new empty stack.  This way, if the
subexpression is malformed and underflows, we'll get an exception.
Before, it would have overwritten the top elements of the top-level
expression.  The evaluation of the top-level expression would have then
resumed with the same stack size, but possibly some corrupted elements.

gdb/ChangeLog:

	* dwarf2expr.h (dwarf_stack_value): Add constructor.
	(dwarf_expr_context) <~dwarf_expr_context>: Define as default.
	<stack>: Change type to std::vector.
	<stack_len, stack_allocated>: Remove.
	<grow_stack>: Remove.
	* dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust.
	(dwarf_expr_context::~dwarf_expr_context): Remove.
	(dwarf_expr_context::grow_stack): Remove.
	(dwarf_expr_context::push): Adjust.
	(dwarf_expr_context::pop): Adjust.
	(dwarf_expr_context::fetch): Adjust.
	(dwarf_expr_context::fetch_in_stack_memory): Adjust.
	(dwarf_expr_context::stack_empty_p): Adjust.
	(dwarf_expr_context::execute_stack_op): Adjust.
2017-09-14 22:36:57 +02:00
Pedro Alves 26e53f3eac gdb.base/nodebug.exp: Rename called functions
I'm seeing these failures on my system:

  FAIL: gdb.base/nodebug.exp: p (double) mult (2.0, 3.0)
  FAIL: gdb.base/nodebug.exp: p ((double (*) (double, double)) mult)(2.0f, 3.0f)
  FAIL: gdb.base/nodebug.exp: p ((double (*) (double, double)) mult)(2, 3)

The problem is simply that GDB is finding a symbol named "mult" from
glibc's debug info:

  (gdb) ptype mult
  type = enum expression_operator {var, num, lnot, mult, divide, module, plus, minus, less_than, greater_than, less_or_equal, greater_or_equal, equal, not_equal, land, lor,  qmop}

  (gdb) info types expression_operator
  All types matching regular expression "expression_operator":

  File plural-exp.h:
  enum expression_operator;

Fix this by unloading symbols from shared libraries.

gdb/testsuite/ChangeLog:
2017-09-14  Pedro Alves  <palves@redhat.com>

	* gdb.base/nodebug.exp (nodebug_runto): New procedure.
	(top level): Use it instead of runto.
2017-09-14 18:32:00 +01:00
Simon Marchi eccd80d694 Make dwarf_expr_context::stack_empty_p return a bool
gdb/ChangeLog:

	* dwarf2expr.h (dwarf_expr_context) <stack_empty_p>: Change
	return type to bool.
	* dwarf2expr.c (dwarf_expr_context::stack_empty_p): Likewise.
2017-09-14 16:54:37 +02:00
Simon Marchi 690098826e Make dwarf_stack_value::in_stack_memory a bool
Replace int with bool, because that's what it is.

gdb/ChangeLog:

	* dwarf2expr.h (dwarf_expr_piece) <v.mem.in_stack_memory>:
	Change type to bool.
	(dwarf_stack_value) <in_stack_memory>: Likewise.
	(dwarf_expr_context) <push_address>: Change parameter type to
	bool.
	<fetch_in_stack_memory>: Change return type to bool.
	<push>: Change parameter type to bool.
	* dwarf2expr.c (dwarf_expr_context::push): Change parameter type
	to bool.
	(dwarf_expr_context::push_address): Likewise.
	(dwarf_expr_context::fetch_in_stack_memory): Change return type
	to bool.
	(dwarf_expr_context::execute_stack_op): Adjust.
	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Adjust.
2017-09-14 16:14:35 +02:00
Simon Marchi 1e46716193 Make dwarf_expr_piece::pieces an std::vector
Change the manually managed array dwarf_expr_piece::piece with an
std::vector.  After passing the pieces array to allocate_piece_closure,
dwarf2_evaluate_loc_desc_full doesn't need that data anymore.  We can
therefore move the content of the vector to avoid copying it.

Reg-tested on the buildbot.

gdb/ChangeLog:

	* dwarf2expr.h (struct dwarf_expr_piece): Move up.
	(struct dwarf_expr_context) <n_pieces>: Remove.
	<pieces>: Change type to std::vector.
	* dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust.
	(dwarf_expr_context::~dwarf_expr_context): Don't manually free
	pieces.
	(dwarf_expr_context::add_piece): Adjust.
	* dwarf2loc.c (struct piece_closure): Initialize fields.
	<n_pieces>: Remove.
	<pieces>: Change type to std::vector.
	(allocate_piece_closure): Adjust, change parameter to
	std::vector rvalue and std::move it to piece_closure.
	(rw_pieced_value): Adjust.
	(check_pieced_synthetic_pointer): Adjust.
	(indirect_synthetic_pointer): Adjust.
	(coerce_pieced_ref): Adjust.
	(free_pieced_value_closure):  Adjust.  Use delete to free
	piece_closure.
	(dwarf2_evaluate_loc_desc_full): Adjust.  std::move ctx.pieces
	to allocate_piece_closure.
	(dwarf2_loc_desc_get_symbol_read_needs): Adjust.
2017-09-14 15:57:01 +02:00
Simon Marchi 0782db848b probe: Replace VEC(probe_ops_cp) with std::vector
This patch replaces the usage of VEC to store pointers to probe_ops with
an std::vector.  The sole usage of that vector type is one global
variable that holds the ops for the various kinds of probes, so this is
pretty straightforward (no allocation/deallocation issues).

gdb/ChangeLog:

	* probe.h (probe_ops_cp): Remove typedef.
	(DEF_VEC_P (probe_ops_cp)): Remove.
	(all_probe_ops): Change type to std::vector.
	* probe.c (info_probes_for_ops): Adjust to vector change.
	(probe_linespec_to_ops): Likewise.
	(all_probe_ops): Change type to std::vector.
	(_initialize_probe): Adjust to vector change.
	* dtrace-probe.c (_initialize_dtrace_probe): Likewise.
	* elfread.c (elf_get_probes): Likewise.
	* stap-probe.c (_initialize_stap_probe): Likewise.
2017-09-12 14:15:23 +02:00
Simon Marchi 1eac6bea98 Make collect_probes return an std::vector
Change collect_probes so it returns an std::vector<bound_probe> instead
of a VEC(bound_probe_s).  This allows removing some cleanups.  It also
seems like enable_probes_command and disable_probes_command were not
freeing that vector.

The comparison function compare_probes needs to be updated to return a
bool indicating whether the first parameter is "less than" the second
parameter.

I defined two constructors to bound_probe.  The default constructor is
needed, for example, so the instance in struct bp_location can be
constructed without parameters.  The constructor with parameters is
useful so we can use emplace_back and pass the values directly.

The s390 builder on the buildbot shows a weird failure that I can't
explain:

../../binutils-gdb/gdb/elfread.c: In function void probe_key_free(bfd*, void*):
../../binutils-gdb/gdb/elfread.c:1346:8: error: types may not be defined in a for-range-declaration [-Werror]
   for (struct probe *probe : *probes)
        ^~~~~~

I guess it's a bug with that specific version< of the compiler, since no
other gcc gives me that error.  It is using:

  g++ (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)

Any idea about this problem?

gdb/ChangeLog:

	* probe.h (struct bound_probe): Define constructors.
	* probe.c (bound_probe_s): Remove typedef.
	(DEF_VEC_O (bound_probe_s)): Remove VEC.
	(collect_probes): Change return type to std::vector, remove
	cleanup.
	(compare_probes): Return bool, change parameter type.  Change
	semantic to "less than".
	(gen_ui_out_table_header_info): Change parameter to std::vector
	and update.
	(exists_probe_with_pops): Likewise.
	(info_probes_for_ops): Update to std::vector change.
	(enable_probes_command): Likewise.
	(disable_probes_command): Likewise.
2017-09-12 13:55:32 +02:00
Simon Marchi aaa63a3190 Make probe_ops::get_probes fill an std::vector
This patch changes one usage of VEC to std::vector.  It is a relatively
straightforward 1:1 change.  The implementations of
sym_probe_fns::sym_get_probes return a borrowed reference to their probe
vectors, meaning that the caller should not free it.  In the new code, I
made them return a const reference to the vector.

This patch and the following one were tested by the buildbot.  I didn't
see any failures that looked related to this one.

gdb/ChangeLog:

	* probe.h (struct probe_ops) <get_probes>: Change parameter from
	vec to std::vector.
	* probe.c (parse_probes_in_pspace): Update.
	(find_probes_in_objfile): Update.
	(find_probe_by_pc): Update.
	(collect_probes): Update.
	(probe_any_get_probes): Update.
	* symfile.h (struct sym_probe_fns) <sym_get_probes> Change
	return type to reference to std::vector.
	* dtrace-probe.c (dtrace_process_dof_probe): Change parameter to
	std::vector and update.
	(dtrace_process_dof): Likewise.
	(dtrace_get_probes): Likewise.
	* elfread.c (elf_get_probes): Change return type to std::vector,
	store an std::vector in bfd_data.
	(probe_key_free): Update to std::vector.
	* stap-probe.c (handle_stap_probe): Change parameter to
	std::vector and update.
	(stap_get_probes): Likewise.
	* symfile-debug.c (debug_sym_get_probes): Change return type to
	std::vector and update.
2017-09-12 13:37:00 +02:00
Tom Tromey cb85b21ba1 Remove make_show_memory_breakpoints_cleanup
This removes make_show_memory_breakpoints_cleanup, replacing it with
make_scoped_restore_show_memory_breakpoints and updating all callers.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (program_breakpoint_here_p): Update.
	* target.c (make_scoped_restore_show_memory_breakpoints): Rename
	from make_show_memory_breakpoints_cleanup.  Return a
	scoped_restore_tmpl<int>.
	(restore_show_memory_breakpoints): Remove.
	* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Update.
	* mem-break.c (memory_validate_breakpoint): Update.
	* ia64-tdep.c (ia64_memory_insert_breakpoint): Update.
	(ia64_memory_remove_breakpoint): Update.
	(ia64_breakpoint_from_pc): Update.
	* target.h (make_scoped_restore_show_memory_breakpoints): Rename
	from make_show_memory_breakpoints_cleanup.
2017-09-11 16:15:14 -06:00
Tom Tromey 8fbc99ef16 Use std::string in d-namespace.c
This removes some cleanups from d-namespace.c by replacing manual
string management with std::string.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* d-namespace.c (d_lookup_symbol): Use std::string.
	(find_symbol_in_baseclass): Likewise.
2017-09-11 16:15:13 -06:00
Tom Tromey 50feb4bd43 Use std::string in ctf_start
This changes ctf_start to use std::string, allowing for some cleanup
removal.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* ctf.c (ctf_start): Use std::string.
2017-09-11 16:15:12 -06:00
Tom Tromey c6dc63a162 Remove cleanups from find_frame_funname
This changes find_frame_funname to return a unique_xmalloc_ptr and
then fixes up the callers.  This removes several cleanups.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* ada-lang.c (is_known_support_routine): Update.
	(ada_unhandled_exception_name_addr_from_raise): Update.
	* guile/scm-frame.c (gdbscm_frame_name): Update.
	* python/py-frame.c (frapy_name): Update.
	(frapy_function): Update.
	* stack.h (find_frame_funname): Update.
	* stack.c (find_frame_funname): Return unique_xmalloc_ptr.
	(print_frame): Update.
2017-09-11 16:15:11 -06:00
Tom Tromey d6b9b80f94 Remove cleanups from findcmd.c
This removes cleanups from findcmd.c, replacing manual buffer
management with a gdb::byte_vector.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* findcmd.c (put_bits): Take a gdb::byte_vector.
	(parse_find_args): Return gdb::byte_vector.  "args" now const.
	Remove "pattern_bufp" and "pattern_lenp" parameters.  Remove
	cleanups.
	(find_command): Update.
2017-09-11 16:15:10 -06:00
Tom Tromey a9921622de Replace clear_hook_in_cleanup with scoped_restore_hook_in
This removes clear_hook_in_cleanup in favor of a scoped_restore-like
class.  scoped_restore itself can't be used because hook_in is a
bitfield.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* cli/cli-script.c (class scoped_restore_hook_in): New.
	(clear_hook_in_cleanup): Remove.
	(execute_cmd_pre_hook, execute_cmd_post_hook): Use
	scoped_restore_hook_in.
2017-09-11 16:15:09 -06:00
Tom Tromey be0d7abb5e Replace interp_set_temp with scoped_restore_interp
This removes interp_set_temp and an associated cleanup, in favor of a
new RAII class, scoped_restore_interp.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* cli/cli-script.c (restore_interp): Remove.
	(read_command_lines): Use scoped_restore_interp.
	* interps.c (scoped_restore_interp::set_temp): Rename from
	interp_set_temp.
	* interps.h (class scoped_restore_interp): New.
	(interp_set_temp): Remove.
2017-09-11 16:15:08 -06:00
Tom Tromey 00f675ff65 Change setup_breakpoint_reporting to return a scoped_restore
This changes setup_breakpoint_reporting to return a scoped_restore,
allowing for some cleanup removal.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
	(mi_cmd_catch_exception, mi_catch_load_unload): Update.
	* mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a
	scoped_restore.
	(mi_cmd_break_insert_1): Update.
	* mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a
	scoped_restore.
2017-09-11 16:15:07 -06:00
Tom Tromey cb791d5948 Make extract_arg return a std::string
Change extract_arg to return a std::string and fix up all the users.
I think string is mildly better than unique_xmalloc_ptr<char>, when
possible, because it provides a more robust API.

I changed the error messages emitted from find_location_by_number to
avoid either writing to a string or an extra allocation; this can be
changed but I thought that the new message was not any less clear.
You can see an example in the testsuite patch.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* demangle.c (demangle_command): Update.
	* breakpoint.c (disable_command): Update.
	(enable_command): Update.
	(find_location_by_number): Make "number" const.  Use
	get_number_trailer.
	* cli/cli-utils.c (extract_arg): Return std::string.
	* probe.c (parse_probe_linespec): Update.  Change types.
	(collect_probes): Take string arguments.
	(parse_probe_linespec): Likewise.
	(info_probes_for_ops): Update.
	(enable_probes_command): Update.
	(disable_probes_command): Update.
	* break-catch-sig.c (catch_signal_split_args): Update.
	* mi/mi-parse.c (mi_parse): Update.

testsuite/ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* gdb.base/ena-dis-br.exp (test_ena_dis_br): Update test.
2017-09-11 15:46:14 -06:00
Tom Tromey 2039bd9f0c Constify language_enum
Change language_enum to take a const argument.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* language.h (language_enum): Make argument const.
	* language.c (language_enum): Make argument const.
2017-09-11 15:46:13 -06:00
Tom Tromey f1735a53a6 Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.

This makes future const fixes simpler by reducing the number of lines
that must be changed.  I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design.  Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.

This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* common/common-utils.h (skip_to_space): Remove macro, redeclare
	as function.
	(skip_to_space): Rename from skip_to_space_const.
	* common/common-utils.c (skip_to_space): New function.
	(skip_to_space): Rename from skip_to_space_const.
	* cli/cli-utils.h (get_number): Rename from get_number_const.
	(extract_arg): Rename from extract_arg_const.
	* cli/cli-utils.c (get_number): Rename from get_number_const.
	(extract_arg): Rename from extract_arg_const.
	(number_or_range_parser::get_number): Use ::get_number.
	* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
	break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
	cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
	completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
	linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
	minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
	python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
	stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 15:46:12 -06:00
Tom Tromey 7d221d749c Make it simpler to add events to Python
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.
2017-09-11 14:15:22 -06:00
Tom Tromey 35c61a1dd5 Small event ownership clean up in Python layer
It seems cleaner to me for functions like create_thread_event_object,
which pass object ownership to their callers, to directly return a
gdb_ref<>.  This way the ownership transfer is part of the API.  This
patch makes this change.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* python/py-threadevent.c (create_thread_event_object): Return
	gdbpy_ref.
	* python/py-stopevent.h (create_stop_event_object)
	(create_breakpoint_event_object, create_signal_event_object):
	Update.
	* python/py-stopevent.c (create_stop_event_object): Return
	gdbpy_ref.
	(emit_stop_event): Update.
	* python/py-signalevent.c (create_signal_event_object): Return
	gdbpy_ref.
	* python/py-infevents.c (create_inferior_call_event_object):
	Update.
	* python/py-event.h (create_event_object)
	(create_thread_event_object): Update.
	* python/py-event.c (create_event_object): Return gdbpy_ref.
	* python/py-continueevent.c: Return gdbpy_ref.
	* python/py-bpevent.c (create_breakpoint_event_object): Return
	gdbpy_ref.
2017-09-11 14:15:21 -06:00
Tom Tromey 7c96f8c1da Add new_inferior, inferior_deleted, and new_thread events
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.
2017-09-11 14:15:20 -06:00
Sergio Durigan Junior a059f00c85 Fix build breakage on GNU/Linux AArch64, take 2
The last commit unfortunately was not enough to fix the build breakage
on AArch64.  I made a mistake and did not test it alone on BuildBot,
but along with another patch that was responsible for fixing the
breakage.

The failure is:

  In file included from /usr/include/string.h:640:0,
		   from build-gnulib-gdbserver/import/string.h:41,
		   from ../../../binutils-gdb/gdb/gdbserver/../common/common-defs.h:56,
		   from ../../../binutils-gdb/gdb/gdbserver/server.h:22,
		   from ../../../binutils-gdb/gdb/gdbserver/regcache.c:19:
  In function ‘void* memset(void*, int, size_t)’,
      inlined from ‘regcache* init_register_cache(regcache*, const target_desc*, unsigned char*)’ at ../../../binutils-gdb/gdb/gdbserver/regcache.c:150:50:
  /usr/include/aarch64-linux-gnu/bits/string3.h:81:32: error: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
	 __warn_memset_zero_len ();
				  ^
  In function ‘void* memset(void*, int, size_t)’,
      inlined from ‘regcache* get_thread_regcache(thread_info*, int)’ at ../../../binutils-gdb/gdb/gdbserver/regcache.c:57:60:
  /usr/include/aarch64-linux-gnu/bits/string3.h:81:32: error: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
	 __warn_memset_zero_len ();

This is likely due to a GCC bug, because for some reason the compiler
assumes that the third argument to the memset:

  memset (regcache->register_status, REG_UNAVAILABLE,
	  VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));

is always zero, which is not always true.

Anyway, the simple fix for this is to guard the memset calls with:

  if (!VEC_empty (tdesc_reg_p, regcache->tdesc->reg_defs))

This time, I made sure to regtest only this patch on BuildBot, and it
finally solved the breakage.

gdb/gdbserver/ChangeLog:
2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>

	* regcache.c (get_thread_regcache): Guard calls to "memset"
          with "!VEC_empty".
2017-09-10 18:12:14 -04:00
Sergio Durigan Junior cc397f3a23 Fix build breakage on GNU/Linux AArch64
This patch fixes the build breakage that has been happening on AArch64
since September 5th.  The breakage was introduced by the following
commit:

  author        Yao Qi <yao.qi@linaro.org>
          Tue, 5 Sep 2017 04:54:52 -0400 (09:54 +0100)
  committer     Yao Qi <yao.qi@linaro.org>
          Tue, 5 Sep 2017 04:54:52 -0400 (09:54 +0100)
  commit        f7000548a2

  Use VEC for target_desc.reg_defs

The build log for this commit can be seen here:

  <https://gdb-build.sergiodj.net/builders/Ubuntu-AArch64-native-gdbserver-m64/builds/2696/steps/compile%20gdb/logs/stdio>

And the underlying problem is that the code is not calling the new
function "allocate_target_description" to allocate the "struct
target_desc" using "new" instead of XNEW, which end up not properly
initializing the fields of the structure.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>

	* linux-low.c (handle_extended_wait): Use
	"allocate_target_description" instead of "XNEW".
	* linux-x86-low.c (initialize_low_arch): Likewise.
2017-09-10 12:33:28 -04:00
Andrew Burgess 72542b8ee6 gdb: Remove check for gdb_stderr == NULL
Recent changes made gdb_stderr a macro:

  #define gdb_stderr (*current_ui_gdb_stderr_ptr ())

and current_ui_gdb_stderr_ptr return this:

   &current_ui->m_gdb_stderr

The problem is that this is undefined if current_ui is NULL, which can
happen early on during gdb start up.

If we run into an error during early gdb start up then we write the
error message to gdb_stderr.  However, if we are too early during the
start up then current_ui is NULL, and using the gdb_stderr macro
triggers undefined behaviour.

We try to avoid this using a check 'gdb_stderr == NULL' which was fine
before the recent changes, but now, still triggers undefined behaviour.

A better check is instead 'current_ui == NULL' which is what I use in
this patch.

Triggering this failure is pretty hard, most of the really early errors
are only triggered if pretty basic things are not as expected, for
example, if the default signal handlers are not as expected.  Seeing one
of these errors trigger usually means that someone working on gdb has
made an incorrect change.  Still, the errors are present in gdb, and
should we ever trigger one it would be nice if gdb didn't crash.

For testing this change I've been applying this patch which adds an
unconditional error into a function called early during gdb start up.
Later in the same function is a real error call which, in some
circumstances could be triggered:

  ## START ##
  diff --git a/gdb/common/signals-state-save-restore.c b/gdb/common/signals-state-save-restore.c
  index d11a9ae006c..d75ba70f894 100644
  --- a/gdb/common/signals-state-save-restore.c
  +++ b/gdb/common/signals-state-save-restore.c
  @@ -37,6 +37,9 @@ static sigset_t original_signal_mask;
   void
   save_original_signals_state (void)
   {
  +
  +  internal_error (__FILE__, __LINE__, "example error");
  +
   #ifdef HAVE_SIGACTION
     int i;
     int res;
  ## END ##

gdb/ChangeLog:

	* utils.c (abort_with_message): Don't compare gdb_stderr to NULL,
	check current_ui instead.
	(internal_vproblem): Likewise.
2017-09-10 09:49:34 +01:00
Simon Marchi 0d64823e51 Remove unnecessary calls to is_mi_like_p in print_thread_info_1
There are two calls to uiout->is_mi_like_p in the else branch of a
if (uiout->is_mi_like_p ()), we already know they will return false.

A bit lower, there are two if (!uiout->is_mi_like_p ()) that we can
merge.

gdb/ChangeLog:

	* thread.c (print_thread_info_1): Remove unnecessary calls to
	uiout->is_mi_like_p.
2017-09-09 22:51:58 +02:00
Tom Tromey eb1e02fd05 Use std::vector in add_using_directive
This changes add_using_directive to accept a std::vector and then
changes the callers.  This allows removing a cleanup.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* namespace.h (add_using_directive): Update.
	* namespace.c (add_using_directive): Change type of excludes to
	std::vector.
	* dwarf2read.c (read_import_statement): Use std::vector.
	(read_namespace): Update.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
2017-09-09 14:10:51 -06:00
Tom Tromey 0fc21fd8cf Use gdb::def_vector in create_sals_line_offset
This changes create_sals_line_offset to use gdb::def_vector, removing
some cleanups.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* linespec.c (create_sals_line_offset): Use gdb::def_vector.
2017-09-09 14:10:50 -06:00
Tom Tromey 49663d051c Use gdb::byte_vector in pascal_object_print_value
This changes pascal_object_print_value to use a gdb::byte_vector.
This removes a cleanup.  This change also points out how the previous
code had a possible use-after-free bug.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* p-valprint.c (pascal_object_print_value): Use gdb::byte_vector.
2017-09-09 14:10:49 -06:00
Tom Tromey 0b868b60c9 Use gdb::def_vector in func_command
This changes func_command to use gdb::def_vector, removing a cleanup.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* stack.c (func_command): Use gdb::def_vector.
2017-09-09 14:10:48 -06:00
Tom Tromey c0470d489b Use ui_out_emit_list and ui_out_emit_tuple with gdb::optional
This changes a few spots to use ui_out_emit_list and/or
ui_out_emit_tuple with gdb::optional, to preserve existing behavior.
This allows for the removal of a few more cleanups.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* mi/mi-cmd-var.c (mi_cmd_var_list_children): Use gdb::optional,
	ui_out_emit_list, ui_out_emit_tuple.
	(mi_cmd_var_update): Likewise.
2017-09-09 13:46:09 -06:00
Tom Tromey ca5909c7de Remove make_cleanup_ui_out_redirect_pop
This patch introduces ui_out_redirect_pop.  All uses of
make_cleanup_ui_out_redirect_pop are replaced with this new class.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* mi/mi-interp.c (mi_user_selected_context_changed): Use
	ui_out_redirect_pop.
	* guile/scm-ports.c (ioscm_with_output_to_port_worker): Use
	ui_out_redirect_pop.
	* utils.c (do_ui_out_redirect_pop)
	(make_cleanup_ui_out_redirect_pop): Remove.
	* top.c (execute_command_to_string): Use ui_out_redirect_pop.
	* utils.h (make_cleanup_ui_out_redirect_pop): Remove.
	* ui-out.h (ui_out_redirect_pop): New class.
2017-09-09 13:46:08 -06:00
Tom Tromey e6a2252ac3 Use ui_out_emit_list in more places
This changes various spots to use ui_out_emit_list, removing some
cleanups.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* mi/mi-main.c (output_cores): Use ui_out_emit_list.
	(list_available_thread_groups, mi_cmd_list_thread_groups)
	(mi_cmd_data_list_changed_registers, mi_cmd_data_read_memory)
	(mi_cmd_data_read_memory_bytes, mi_cmd_trace_frame_collected):
	Likewise.
2017-09-09 13:46:07 -06:00
Tom Tromey 393702cd59 Use ui_out_emit_tuple in disasm.c
This changes one spot in disasm.c to use ui_out_emit_tuple.  This
patch required a large reindentation, so I've separated it out.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Use
	ui_out_emit_tuple.
2017-09-09 13:46:06 -06:00
Tom Tromey 76f9c9cfd4 Use ui_out_emit_tuple in more places
This changes more places to use ui_out_emit_tuple, removing cleanups.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* target.c (flash_erase_command): Use ui_out_emit_tuple.
	* stack.c (print_frame): Use ui_out_emit_tuple.
	* spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple.
	(info_spu_mailbox_command, info_spu_dma_command)
	(info_spu_proxydma_command): Likewise.
	* mi/mi-main.c (mi_cmd_trace_frame_collected): Use
	ui_out_emit_tuple, gdb::byte_vector, bin2hex.
	* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use
	ui_out_emit_tuple.
	* breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple.
2017-09-09 13:46:05 -06:00
Tom Tromey dc9fe180a4 Remove make_cleanup_ui_out_table_begin_end
This changes the few remaining uses of
make_cleanup_ui_out_table_begin_end to use ui_out_emit_table instead,
and then removes the cleanup.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* ui-out.h (make_cleanup_ui_out_table_begin_end): Remove.
	(class ui_out_emit_table): Update comment.
	* ui-out.c (do_cleanup_table_end)
	(make_cleanup_ui_out_table_begin_end): Remove.
	* spu-tdep.c (info_spu_mailbox_list): Use ui_out_emit_table.
	(info_spu_dma_cmdlist): Likewise.
	* probe.c (info_probes_for_ops): Use ui_out_emit_table.
	* darwin-nat-info.c (darwin_debug_regions_recurse): Use
	ui_out_emit_table.
2017-09-09 13:46:04 -06:00
Tom Tromey f8cc3da6e4 Use ui_out_emit_table and ui_out_emit_list in print_thread_info_1
This changes print_thread_info_1 to use ui_out_emit_table and
ui_out_emit_list.  Which one is used depends on whether the ui-out is
mi-like; so the emitters are wrapped in gdb::optional.

ChangeLog
2017-09-09  Tom Tromey  <tom@tromey.com>

	* thread.c (print_thread_info_1): Use ui_out_emit_table,
	ui_out_emit_list, gdb::optional.
2017-09-09 13:46:04 -06:00
John Baldwin 481695ed5f Remove unnecessary function prototypes.
These prototypes were required when compiling GDB as C but are not
required for C++.

gdb/ChangeLog:

	* aarch64-linux-nat.c: Remove _initialize_aarch64_linux_nat
	prototype.
	* aarch64-linux-tdep.c: Remove _initialize_aarch64_linux_tdep
	prototype.
	* aarch64-newlib-tdep.c: Remove _initialize_aarch64_newlib_tdep
	prototype.
	* aarch64-tdep.c: Remove _initialize_aarch64_tdep prototype.
	* ada-exp.y: Remove _initialize_ada_exp prototype.
	* ada-lang.c: Remove _initialize_ada_language prototype.
	* ada-tasks.c: Remove _initialize_tasks prototype.
	* addrmap.c: Remove _initialize_addrmap prototype.
	* agent.c: Remove _initialize_agent prototype.
	* aix-thread.c: Remove _initialize_aix_thread prototype.
	* alpha-bsd-nat.c: Remove _initialize_alphabsd_nat prototype.
	* alpha-linux-nat.c: Remove _initialize_alpha_linux_nat prototype.
	* alpha-linux-tdep.c: Remove _initialize_alpha_linux_tdep
	prototype.
	* alpha-nbsd-tdep.c: Remove _initialize_alphanbsd_tdep prototype.
	* alpha-obsd-tdep.c: Remove _initialize_alphaobsd_tdep prototype.
	* alpha-tdep.c: Remove _initialize_alpha_tdep prototype.
	* amd64-darwin-tdep.c: Remove _initialize_amd64_darwin_tdep
	prototype.
	* amd64-dicos-tdep.c: Remove _initialize_amd64_dicos_tdep
	prototype.
	* amd64-fbsd-nat.c: Remove _initialize_amd64fbsd_nat prototype.
	* amd64-fbsd-tdep.c: Remove _initialize_amd64fbsd_tdep prototype.
	* amd64-linux-nat.c: Remove _initialize_amd64_linux_nat prototype.
	* amd64-linux-tdep.c: Remove _initialize_amd64_linux_tdep
	prototype.
	* amd64-nbsd-nat.c: Remove _initialize_amd64nbsd_nat prototype.
	* amd64-nbsd-tdep.c: Remove _initialize_amd64nbsd_tdep prototype.
	* amd64-obsd-nat.c: Remove _initialize_amd64obsd_nat prototype.
	* amd64-obsd-tdep.c: Remove _initialize_amd64obsd_tdep prototype.
	* amd64-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
	* amd64-tdep.c: Remove _initialize_amd64_tdep prototype.
	* amd64-windows-nat.c: Remove _initialize_amd64_windows_nat
	prototype.
	* amd64-windows-tdep.c: Remove _initialize_amd64_windows_tdep
	prototype.
	* annotate.c: Remove _initialize_annotate prototype.
	* arc-newlib-tdep.c: Remove _initialize_arc_newlib_tdep prototype.
	* arc-tdep.c: Remove _initialize_arc_tdep prototype.
	* arch-utils.c: Remove _initialize_gdbarch_utils prototype.
	* arm-linux-nat.c: Remove _initialize_arm_linux_nat prototype.
	* arm-linux-tdep.c: Remove _initialize_arm_linux_tdep prototype.
	* arm-nbsd-tdep.c: Remove _initialize_arm_netbsd_tdep prototype.
	* arm-obsd-tdep.c: Remove _initialize_armobsd_tdep prototype.
	* arm-symbian-tdep.c: Remove _initialize_arm_symbian_tdep
	prototype.
	* arm-tdep.c: Remove _initialize_arm_tdep prototype.
	* arm-wince-tdep.c: Remove _initialize_arm_wince_tdep prototype.
	* auto-load.c: Remove _initialize_auto_load prototype.
	* auxv.c: Remove _initialize_auxv prototype.
	* avr-tdep.c: Remove _initialize_avr_tdep prototype.
	* ax-gdb.c: Remove _initialize_ax_gdb prototype.
	* bfin-linux-tdep.c: Remove _initialize_bfin_linux_tdep prototype.
	* bfin-tdep.c: Remove _initialize_bfin_tdep prototype.
	* break-catch-sig.c: Remove _initialize_break_catch_sig prototype.
	* break-catch-syscall.c: Remove _initialize_break_catch_syscall
	prototype.
	* break-catch-throw.c: Remove _initialize_break_catch_throw
	prototype.
	* breakpoint.c: Remove _initialize_breakpoint prototype.
	* bsd-uthread.c: Remove _initialize_bsd_uthread prototype.
	* btrace.c: Remove _initialize_btrace prototype.
	* charset.c: Remove _initialize_charset prototype.
	* cli/cli-cmds.c: Remove _initialize_cli_cmds prototype.
	* cli/cli-dump.c: Remove _initialize_cli_dump prototype.
	* cli/cli-interp.c: Remove _initialize_cli_interp prototype.
	* cli/cli-logging.c: Remove _initialize_cli_logging prototype.
	* cli/cli-script.c: Remove _initialize_cli_script prototype.
	* coff-pe-read.c: Remove _initialize_coff_pe_read prototype.
	* coffread.c: Remove _initialize_coffread prototype.
	* compile/compile.c: Remove _initialize_compile prototype.
	* complaints.c: Remove _initialize_complaints prototype.
	* completer.c: Remove _initialize_completer prototype.
	* copying.awk: Remove _initialize_copying prototype.
	* copying.c: Regenerate.
	* core-regset.c: Remove _initialize_core_regset prototype.
	* corefile.c: Remove _initialize_core prototype.
	* corelow.c: Remove _initialize_corelow prototype.
	* cp-abi.c: Remove _initialize_cp_abi prototype.
	* cp-namespace.c: Remove _initialize_cp_namespace prototype.
	* cp-support.c: Remove _initialize_cp_support prototype.
	* cp-valprint.c: Remove _initialize_cp_valprint prototype.
	* cris-linux-tdep.c: Remove _initialize_cris_linux_tdep prototype.
	* cris-tdep.c: Remove _initialize_cris_tdep prototype.
	* ctf.c: Remove _initialize_ctf prototype.
	* d-lang.c: Remove _initialize_d_language prototype.
	* darwin-nat-info.c: Remove _initialize_darwin_info_commands
	prototype.
	* darwin-nat.c: Remove _initialize_darwin_inferior prototype.
	* dbxread.c: Remove _initialize_dbxread prototype.
	* dcache.c: Remove _initialize_dcache prototype.
	* demangle.c: Remove _initialize_demangler prototype.
	* disasm-selftests.c: Remove _initialize_disasm_selftests
	prototype.
	* disasm.c: Remove _initialize_disasm prototype.
	* dtrace-probe.c: Remove _initialize_dtrace_probe prototype.
	* dummy-frame.c: Remove _initialize_dummy_frame prototype.
	* dwarf2-frame-tailcall.c: Remove _initialize_tailcall_frame
	prototype.
	* dwarf2-frame.c: Remove _initialize_dwarf2_frame prototype.
	* dwarf2expr.c: Remove _initialize_dwarf2expr prototype.
	* dwarf2loc.c: Remove _initialize_dwarf2loc prototype.
	* dwarf2read.c: Remove _initialize_dwarf2_read prototype.
	* elfread.c: Remove _initialize_elfread prototype.
	* exec.c: Remove _initialize_exec prototype.
	* extension.c: Remove _initialize_extension prototype.
	* f-lang.c: Remove _initialize_f_language prototype.
	* f-valprint.c: Remove _initialize_f_valprint prototype.
	* fbsd-nat.c: Remove _initialize_fbsd_nat prototype.
	* fbsd-tdep.c: Remove _initialize_fbsd_tdep prototype.
	* filesystem.c: Remove _initialize_filesystem prototype.
	* findcmd.c: Remove _initialize_mem_search prototype.
	* fork-child.c: Remove _initialize_fork_child prototype.
	* frame-base.c: Remove _initialize_frame_base prototype.
	* frame-unwind.c: Remove _initialize_frame_unwind prototype.
	* frame.c: Remove _initialize_frame prototype.
	* frv-linux-tdep.c: Remove _initialize_frv_linux_tdep prototype.
	* frv-tdep.c: Remove _initialize_frv_tdep prototype.
	* ft32-tdep.c: Remove _initialize_ft32_tdep prototype.
	* gcore.c: Remove _initialize_gcore prototype.
	* gdb_bfd.c: Remove _initialize_gdb_bfd prototype.
	* gdbarch.c: Regenerate.
	* gdbarch.sh: Remove _initialize_gdbarch prototype.
	* gdbtypes.c: Remove _initialize_gdbtypes prototype.
	* gnu-nat.c: Remove _initialize_gnu_nat prototype.
	* gnu-v2-abi.c: Remove _initialize_gnu_v2_abi prototype.
	* gnu-v3-abi.c: Remove _initialize_gnu_v3_abi prototype.
	* go-lang.c: Remove _initialize_go_language prototype.
	* go32-nat.c: Remove _initialize_go32_nat prototype.
	* guile/guile.c: Remove _initialize_guile prototype.
	* h8300-tdep.c: Remove _initialize_h8300_tdep prototype.
	* hppa-linux-nat.c: Remove _initialize_hppa_linux_nat prototype.
	* hppa-linux-tdep.c: Remove _initialize_hppa_linux_tdep prototype.
	* hppa-nbsd-nat.c: Remove _initialize_hppanbsd_nat prototype.
	* hppa-nbsd-tdep.c: Remove _initialize_hppanbsd_tdep prototype.
	* hppa-obsd-nat.c: Remove _initialize_hppaobsd_nat prototype.
	* hppa-obsd-tdep.c: Remove _initialize_hppaobsd_tdep prototype.
	* hppa-tdep.c: Remove _initialize_hppa_tdep prototype.
	* i386-bsd-nat.c: Remove _initialize_i386bsd_nat prototype.
	* i386-cygwin-tdep.c: Remove _initialize_i386_cygwin_tdep
	prototype.
	* i386-darwin-tdep.c: Remove _initialize_i386_darwin_tdep
	prototype.
	* i386-dicos-tdep.c: Remove _initialize_i386_dicos_tdep prototype.
	* i386-fbsd-nat.c: Remove _initialize_i386fbsd_nat prototype.
	* i386-fbsd-tdep.c: Remove _initialize_i386fbsd_tdep prototype.
	* i386-gnu-nat.c: Remove _initialize_i386gnu_nat prototype.
	* i386-gnu-tdep.c: Remove _initialize_i386gnu_tdep prototype.
	* i386-linux-nat.c: Remove _initialize_i386_linux_nat prototype.
	* i386-linux-tdep.c: Remove _initialize_i386_linux_tdep prototype.
	* i386-nbsd-nat.c: Remove _initialize_i386nbsd_nat prototype.
	* i386-nbsd-tdep.c: Remove _initialize_i386nbsd_tdep prototype.
	* i386-nto-tdep.c: Remove _initialize_i386nto_tdep prototype.
	* i386-obsd-nat.c: Remove _initialize_i386obsd_nat prototype.
	* i386-obsd-tdep.c: Remove _initialize_i386obsd_tdep prototype.
	* i386-sol2-nat.c: Remove _initialize_amd64_sol2_nat prototype.
	* i386-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
	* i386-tdep.c: Remove _initialize_i386_tdep prototype.
	* i386-windows-nat.c: Remove _initialize_i386_windows_nat
	prototype.
	* ia64-libunwind-tdep.c: Remove _initialize_libunwind_frame
	prototype.
	* ia64-linux-nat.c: Remove _initialize_ia64_linux_nat prototype.
	* ia64-linux-tdep.c: Remove _initialize_ia64_linux_tdep prototype.
	* ia64-tdep.c: Remove _initialize_ia64_tdep prototype.
	* ia64-vms-tdep.c: Remove _initialize_ia64_vms_tdep prototype.
	* infcall.c: Remove _initialize_infcall prototype.
	* infcmd.c: Remove _initialize_infcmd prototype.
	* inferior.c: Remove _initialize_inferiors prototype.
	* inflow.c: Remove _initialize_inflow prototype.
	* infrun.c: Remove _initialize_infrun prototype.
	* interps.c: Remove _initialize_interpreter prototype.
	* iq2000-tdep.c: Remove _initialize_iq2000_tdep prototype.
	* jit.c: Remove _initialize_jit prototype.
	* language.c: Remove _initialize_language prototype.
	* linux-fork.c: Remove _initialize_linux_fork prototype.
	* linux-nat.c: Remove _initialize_linux_nat prototype.
	* linux-tdep.c: Remove _initialize_linux_tdep prototype.
	* linux-thread-db.c: Remove _initialize_thread_db prototype.
	* lm32-tdep.c: Remove _initialize_lm32_tdep prototype.
	* m2-lang.c: Remove _initialize_m2_language prototype.
	* m32c-tdep.c: Remove _initialize_m32c_tdep prototype.
	* m32r-linux-nat.c: Remove _initialize_m32r_linux_nat prototype.
	* m32r-linux-tdep.c: Remove _initialize_m32r_linux_tdep prototype.
	* m32r-tdep.c: Remove _initialize_m32r_tdep prototype.
	* m68hc11-tdep.c: Remove _initialize_m68hc11_tdep prototype.
	* m68k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
	* m68k-bsd-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
	* m68k-linux-nat.c: Remove _initialize_m68k_linux_tdep prototype.
	* m68k-linux-tdep.c: Remove _initialize_m68k_linux_tdep prototype.
	* m68k-tdep.c: Remove _initialize_m68k_tdep prototype.
	* m88k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
	* m88k-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
	* machoread.c: Remove _initialize_machoread prototype.
	* macrocmd.c: Remove _initialize_macrocmd prototype.
	* macroscope.c: Remove _initialize_macroscope prototype.
	* maint.c: Remove _initialize_maint_cmds prototype.
	* mdebugread.c: Remove _initialize_mdebugread prototype.
	* memattr.c: Remove _initialize_mem prototype.
	* mep-tdep.c: Remove _initialize_mep_tdep prototype.
	* mi/mi-cmd-env.c: Remove _initialize_mi_cmd_env prototype.
	* mi/mi-cmds.c: Remove _initialize_mi_cmds prototype.
	* mi/mi-interp.c: Remove _initialize_mi_interp prototype.
	* mi/mi-main.c: Remove _initialize_mi_main prototype.
	* microblaze-linux-tdep.c: Remove
	_initialize_microblaze_linux_tdep prototype.
	* microblaze-tdep.c: Remove _initialize_microblaze_tdep prototype.
	* mips-fbsd-nat.c: Remove _initialize_mips_fbsd_nat prototype.
	* mips-fbsd-tdep.c: Remove _initialize_mips_fbsd_tdep prototype.
	* mips-linux-nat.c: Remove _initialize_mips_linux_nat prototype.
	* mips-linux-tdep.c: Remove _initialize_mips_linux_tdep prototype.
	* mips-nbsd-nat.c: Remove _initialize_mipsnbsd_nat prototype.
	* mips-nbsd-tdep.c: Remove _initialize_mipsnbsd_tdep prototype.
	* mips-sde-tdep.c: Remove _initialize_mips_sde_tdep prototype.
	* mips-tdep.c: Remove _initialize_mips_tdep prototype.
	* mips64-obsd-nat.c: Remove _initialize_mips64obsd_nat prototype.
	* mips64-obsd-tdep.c: Remove _initialize_mips64obsd_tdep
	prototype.
	* mipsread.c: Remove _initialize_mipsread prototype.
	* mn10300-linux-tdep.c: Remove _initialize_mn10300_linux_tdep
	prototype.
	* mn10300-tdep.c: Remove _initialize_mn10300_tdep prototype.
	* moxie-tdep.c: Remove _initialize_moxie_tdep prototype.
	* msp430-tdep.c: Remove _initialize_msp430_tdep prototype.
	* mt-tdep.c: Remove _initialize_mt_tdep prototype.
	* nds32-tdep.c: Remove _initialize_nds32_tdep prototype.
	* nios2-linux-tdep.c: Remove _initialize_nios2_linux_tdep
	prototype.
	* nios2-tdep.c: Remove _initialize_nios2_tdep prototype.
	* nto-procfs.c: Remove _initialize_procfs prototype.
	* nto-tdep.c: Remove _initialize_nto_tdep prototype.
	* objc-lang.c: Remove _initialize_objc_language prototype.
	* objfiles.c: Remove _initialize_objfiles prototype.
	* observer.c: Remove observer_test_first_notification_function,
	observer_test_second_notification_function,
	observer_test_third_notification_function, and
	_initialize_observer prototypes.
	* opencl-lang.c: Remove _initialize_opencl_language prototypes.
	* osabi.c: Remove _initialize_gdb_osabi prototype.
	* osdata.c: Remove _initialize_osdata prototype.
	* p-valprint.c: Remove _initialize_pascal_valprint prototype.
	* parse.c: Remove _initialize_parse prototype.
	* ppc-fbsd-nat.c: Remove _initialize_ppcfbsd_nat prototype.
	* ppc-fbsd-tdep.c: Remove _initialize_ppcfbsd_tdep prototype.
	* ppc-linux-nat.c: Remove _initialize_ppc_linux_nat prototype.
	* ppc-linux-tdep.c: Remove _initialize_ppc_linux_tdep prototype.
	* ppc-nbsd-nat.c: Remove _initialize_ppcnbsd_nat prototype.
	* ppc-nbsd-tdep.c: Remove _initialize_ppcnbsd_tdep prototype.
	* ppc-obsd-nat.c: Remove _initialize_ppcobsd_nat prototype.
	* ppc-obsd-tdep.c: Remove _initialize_ppcobsd_tdep prototype.
	* printcmd.c: Remove _initialize_printcmd prototype.
	* probe.c: Remove _initialize_probe prototype.
	* proc-api.c: Remove _initialize_proc_api prototype.
	* proc-events.c: Remove _initialize_proc_events prototype.
	* proc-service.c: Remove _initialize_proc_service prototype.
	* procfs.c: Remove _initialize_procfs prototype.
	* psymtab.c: Remove _initialize_psymtab prototype.
	* python/python.c: Remove _initialize_python prototype.
	* ravenscar-thread.c: Remove _initialize_ravenscar prototype.
	* record-btrace.c: Remove _initialize_record_btrace prototype.
	* record-full.c: Remove _initialize_record_full prototype.
	* record.c: Remove _initialize_record prototype.
	* regcache.c: Remove _initialize_regcache prototype.
	* reggroups.c: Remove _initialize_reggroup prototype.
	* remote-notif.c: Remove _initialize_notif prototype.
	* remote-sim.c: Remove _initialize_remote_sim prototype.
	* remote.c: Remove _initialize_remote prototype.
	* reverse.c: Remove _initialize_reverse prototype.
	* rl78-tdep.c: Remove _initialize_rl78_tdep prototype.
	* rs6000-aix-tdep.c: Remove _initialize_rs6000_aix_tdep prototype.
	* rs6000-lynx178-tdep.c: Remove _initialize_rs6000_lynx178_tdep
	prototype.
	* rs6000-nat.c: Remove _initialize_rs6000_nat prototype.
	* rs6000-tdep.c: Remove _initialize_rs6000_tdep prototype.
	* rust-exp.y: Remove _initialize_rust_exp prototype.
	* rx-tdep.c: Remove _initialize_rx_tdep prototype.
	* s390-linux-nat.c: Remove _initialize_s390_nat prototype.
	* s390-linux-tdep.c: Remove _initialize_s390_tdep prototype.
	* score-tdep.c: Remove _initialize_score_tdep prototype.
	* selftest-arch.c: Remove _initialize_selftests_foreach_arch
	prototype.
	* ser-go32.c: Remove _initialize_ser_dos prototype.
	* ser-mingw.c: Remove _initialize_ser_windows prototype.
	* ser-pipe.c: Remove _initialize_ser_pipe prototype.
	* ser-tcp.c: Remove _initialize_ser_tcp prototype.
	* ser-unix.c: Remove _initialize_ser_hardwire prototype.
	* serial.c: Remove _initialize_serial prototype.
	* sh-linux-tdep.c: Remove _initialize_sh_linux_tdep prototype.
	* sh-nbsd-nat.c: Remove _initialize_shnbsd_nat prototype.
	* sh-nbsd-tdep.c: Remove _initialize_shnbsd_tdep prototype.
	* sh-tdep.c: Remove _initialize_sh_tdep prototype.
	* skip.c: Remove _initialize_step_skip prototype.
	* sol-thread.c: Remove _initialize_sol_thread prototype.
	* solib-aix.c: Remove _initialize_solib_aix prototype.
	* solib-darwin.c: Remove _initialize_darwin_solib prototype.
	* solib-dsbt.c: Remove _initialize_dsbt_solib prototype.
	* solib-frv.c: Remove _initialize_frv_solib prototype.
	* solib-spu.c: Remove _initialize_spu_solib prototype.
	* solib-svr4.c: Remove _initialize_svr4_solib prototype.
	* solib-target.c: Remove _initialize_solib_target prototype.
	* solib.c: Remove _initialize_solib prototype.
	* source.c: Remove _initialize_source prototype.
	* sparc-linux-nat.c: Remove _initialize_sparc_linux_nat prototype.
	* sparc-linux-tdep.c: Remove _initialize_sparc_linux_tdep
	prototype.
	* sparc-nat.c: Remove _initialize_sparc_nat prototype.
	* sparc-nbsd-nat.c: Remove _initialize_sparcnbsd_nat prototype.
	* sparc-nbsd-tdep.c: Remove _initialize_sparcnbsd_tdep prototype.
	* sparc-obsd-tdep.c: Remove _initialize_sparc32obsd_tdep
	prototype.
	* sparc-sol2-nat.c: Remove _initialize_sparc_sol2_nat prototype.
	* sparc-sol2-tdep.c: Remove _initialize_sparc_sol2_tdep prototype.
	* sparc-tdep.c: Remove _initialize_sparc_tdep prototype.
	* sparc64-fbsd-nat.c: Remove _initialize_sparc64fbsd_nat
	prototype.
	* sparc64-fbsd-tdep.c: Remove _initialize_sparc64fbsd_tdep
	prototype.
	* sparc64-linux-nat.c: Remove _initialize_sparc64_linux_nat
	prototype.
	* sparc64-linux-tdep.c: Remove _initialize_sparc64_linux_tdep
	prototype.
	* sparc64-nat.c: Remove _initialize_sparc64_nat prototype.
	* sparc64-nbsd-nat.c: Remove _initialize_sparc64nbsd_nat
	prototype.
	* sparc64-nbsd-tdep.c: Remove _initialize_sparc64nbsd_tdep
	prototype.
	* sparc64-obsd-nat.c: Remove _initialize_sparc64obsd_nat
	prototype.
	* sparc64-obsd-tdep.c: Remove _initialize_sparc64obsd_tdep
	prototype.
	* sparc64-sol2-tdep.c: Remove _initialize_sparc64_sol2_tdep
	prototype.
	* spu-linux-nat.c: Remove _initialize_spu_nat prototype.
	* spu-multiarch.c: Remove _initialize_spu_multiarch prototype.
	* spu-tdep.c: Remove _initialize_spu_tdep prototype.
	* stabsread.c: Remove _initialize_stabsread prototype.
	* stack.c: Remove _initialize_stack prototype.
	* stap-probe.c: Remove _initialize_stap_probe prototype.
	* std-regs.c: Remove _initialize_frame_reg prototype.
	* symfile-debug.c: Remove _initialize_symfile_debug prototype.
	* symfile-mem.c: Remove _initialize_symfile_mem prototype.
	* symfile.c: Remove _initialize_symfile prototype.
	* symmisc.c: Remove _initialize_symmisc prototype.
	* symtab.c: Remove _initialize_symtab prototype.
	* target-dcache.c: Remove _initialize_target_dcache prototype.
	* target-descriptions.c: Remove _initialize_target_descriptions
	prototype.
	* thread.c: Remove _initialize_thread prototype.
	* tic6x-linux-tdep.c: Remove _initialize_tic6x_linux_tdep
	prototype.
	* tic6x-tdep.c: Remove _initialize_tic6x_tdep prototype.
	* tilegx-linux-nat.c: Remove _initialize_tile_linux_nat prototype.
	* tilegx-linux-tdep.c: Remove _initialize_tilegx_linux_tdep
	prototype.
	* tilegx-tdep.c: Remove _initialize_tilegx_tdep prototype.
	* tracefile-tfile.c: Remove _initialize_tracefile_tfile prototype.
	* tracefile.c: Remove _initialize_tracefile prototype.
	* tracepoint.c: Remove _initialize_tracepoint prototype.
	* tui/tui-hooks.c: Remove _initialize_tui_hooks prototype.
	* tui/tui-interp.c: Remove _initialize_tui_interp prototype.
	* tui/tui-layout.c: Remove _initialize_tui_layout prototype.
	* tui/tui-regs.c: Remove _initialize_tui_regs prototype.
	* tui/tui-stack.c: Remove _initialize_tui_stack prototype.
	* tui/tui-win.c: Remove _initialize_tui_win prototype.
	* tui/tui.c: Remove _initialize_tui prototype.
	* typeprint.c: Remove _initialize_typeprint prototype.
	* user-regs.c: Remove _initialize_user_regs prototype.
	* utils.c: Remove _initialize_utils prototype.
	* v850-tdep.c: Remove _initialize_v850_tdep prototype.
	* valarith.c: Remove _initialize_valarith prototype.
	* valops.c: Remove _initialize_valops prototype.
	* valprint.c: Remove _initialize_valprint prototype.
	* value.c: Remove _initialize_values prototype.
	* varobj.c: Remove _initialize_varobj prototype.
	* vax-bsd-nat.c: Remove _initialize_vaxbsd_nat prototype.
	* vax-nbsd-tdep.c: Remove _initialize_vaxnbsd_tdep prototype.
	* vax-tdep.c: Remove _initialize_vax_tdep prototype.
	* windows-nat.c: Remove _initialize_windows_nat,
	_initialize_check_for_gdb_ini, and _initialize_loadable
	prototypes.
	* windows-tdep.c: Remove _initialize_windows_tdep prototype.
	* xcoffread.c: Remove _initialize_xcoffread prototype.
	* xml-support.c: Remove _initialize_xml_support prototype.
	* xstormy16-tdep.c: Remove _initialize_xstormy16_tdep prototype.
	* xtensa-linux-nat.c: Remove _initialize_xtensa_linux_nat
	prototype.
	* xtensa-linux-tdep.c: Remove _initialize_xtensa_linux_tdep
	prototype.
	* xtensa-tdep.c: Remove _initialize_xtensa_tdep prototype.
2017-09-09 11:02:37 -07:00
Keith Seitz a611b5cb00 Remove unused field field_info.fnfields
Since at least 7.3 the "fnfields" field in struct field_info has been
unused.  This patch simply removes it.

gdb/ChangeLog:

	* dwarf2read.c (struct field_info) <fnfields>: Remove unused
	field.
2017-09-08 16:47:13 -07:00
Christoph Weinmann 469412dd9c Remove C/C++ relevant code in Fortran specific file.
Remove code relevant for printing C/C++ Integer values in a
Fortran specific file to unify printing of Fortran values.
This does not change the output.
2017-09-08 15:11:47 +02:00
Bernhard Heckel e0f86435f8 fortran: Testsuite, fix typos in vla-value. 2017-09-08 15:11:47 +02:00
Bernhard Heckel 9e9af4be9f Fortran: Testsuite, fix differences in type naming. 2017-09-08 15:11:47 +02:00
Frank Penczek a5ad232b3e Fix indentation for printing Fortran types with pointers
Printing the prefix "PTR TO -> (" resp. "REF TO ->(" ignored the active
indentation level.  This caused inconsistent appearance of user-defined
Fortran types containing pointers.  Fix by using "fprintfi_filtered" with the
current indentation level for outputting the prefix string.  Add test case
ptr-indentation.

Example using 'ptype' on object of type:
  type TypeWithPointer
    integer i
    integer, pointer:: p
  end type TypeWithPointer

Before:
  type = Type typewithpointer
      integer(kind=4) :: i
  PTR TO -> ( integer(kind=4) :: p)
  End Type typewithpointer

After:
  type = Type typewithpointer
      integer(kind=4) :: i
      PTR TO -> ( integer(kind=4) :: p)
  End Type typewithpointer
2017-09-08 15:11:47 +02:00
Joel Brobecker e50142270b Document the GDB 8.0.1 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 8.0.1 released.
2017-09-07 07:53:34 -07:00
Joel Brobecker 63c99141de remove QStartupWithShell entry from NEWS::Changes in GDB 7.11
This entry was added twice within the same commit, back in Dec 2017
by the following change:

    commit aefd8b33d9
    Date:   Thu Dec 22 22:14:02 2016 -0500
    Subject: Implement proper "startup-with-shell" support on gdbserver

I think the second entry is just a rebase/merge oversight, and it wasn't
meant to be added there, particularly since the 7.11 branch was no longer
active at that time anymore.

This patch just removes the entry.

gdb/ChangeLog:

	* NEWS (Changes in GDB 7.11): Remove entry for QStartupWithShell.
2017-09-07 07:24:33 -07:00
Tom Tromey 69c1e056df Change funcall_chain to be a std::vector
This simplifies the handling of funcall_chain, by changing it to be a
std::vector<int> and then fixing the users.  This allows the removal
of a cleanup.

It would be even cleaner to replace this with better logic in the
parsers; but a baby step seemed ok.

gdb/ChangeLog
2017-09-05  Tom Tromey  <tom@tromey.com>

	* parse.c (funcall_chain): Now a std::vector.
	(start_arglist, end_arglist): Simplify.
	(free_funcalls): Remove.
	(parse_exp_in_context_1): Remove cleanup.
2017-09-06 15:49:32 -06:00
Tom Tromey fef704bfec Remove last cleanups from go-exp.y
This removes the last remaining cleanups from go-exp.y.

2017-09-05  Tom Tromey  <tom@tromey.com>

	* go-exp.y (go_parse): Don't create a cleanup.
2017-09-06 15:49:31 -06:00
Tom Tromey 5613c5857a Remove last cleanups from d-exp.y
This removes the last remaining cleanups from d-exp.y.

2017-09-05  Tom Tromey  <tom@tromey.com>

	* d-exp.y (PrimaryExpression): Use std::string.
	(d_parse): Don't create a cleanup.
2017-09-06 15:49:31 -06:00
Tom Tromey eae49211e1 Remove make_cleanup_clear_parser_state
This removes make_cleanup_clear_parser_state in favor of
scoped_restore.

2017-09-05  Tom Tromey  <tom@tromey.com>

	* utils.c (do_clear_parser_state): Remove.
	(make_cleanup_clear_parser_state): Remove.
	* p-exp.y (pascal_parse): Use scoped_restore.
	* m2-exp.y (m2_parse): Use scoped_restore.
	* f-exp.y (f_parse): Use scoped_restore.
	* d-exp.y (d_parse): Use scoped_restore.
	* c-exp.y (c_parse): Use scoped_restore.
	* ada-exp.y (ada_parse): Use scoped_restore.
	* utils.h (make_cleanup_clear_parser_state): Remove.
2017-09-06 15:49:30 -06:00
Keith Seitz 73b9be8b53 Introduce dw2_linkage_name and dw2_linkage_name_attr.
The DWARF reader is littered with the following idiom to read a linkage name
from the debug info:

  mangled = dwarf2_string_attr (die, DW_AT_linkage_name, cu);
  if (mangled == NULL)
    mangled = dwarf2_string_attr (die, DW_AT_MIPS_linkage_name, cu);

This patch introduces functions to simplify this to:

  mangled = dw2_linkage_name (die, cu);

or

  attr = dw2_linkage_name_attr (die, cu);

gdb/ChangeLog:

	* dwarf2read.c (dw2_linkage_name_attr): New function.
	(dw2_linkage_name): New function.
	(dwarf2_compute_name, dwarf2_physname, read_call_site_scope)
	(guess_full_die_structure_name, dwarf2_name): Use dw2_linkage_name.
	(anonymous_struct_prefix, dwarf2_name): Use dw2_linkage_name_attr.
2017-09-06 12:50:52 -07:00
Tom Tromey 5aec60eb2f Cast char constant to int in sizeof.exp
PR gdb/22010 concerns a regression I introduced with the scalar
printing changes.  The bug is that this code in sizeof.exp:

    set signof_byte [get_integer_valueof "'\\377'" -1]

can incorrectly compute sizeof_byte.  One underlying problem here is
that gdb's C parser doesn't treat a char constant as an int (this is
PR 19973).

However, it seems good to have an immediate fix for the regression.
The simplest is to cast to an int here.

testsuite/ChangeLog
2017-09-05  Tom Tromey  <tom@tromey.com>

	PR gdb/22010:
	* gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
2017-09-06 11:11:03 -06:00
Kamil Rytarowski a102602bc5 Correct shell compatibility issue detected with pkgsrc.
String comparison of in a POSIX bourne shell must be done
with '=', not '=='. For example the NetBSD sh(1) does not
support it.

gdb/ChangeLog
2017-09-06  Kamil Rytarowski  <n54@gmx.com>

	* config/djgpp/djconfig.sh: Correct shell portability issue.
2017-09-06 18:52:08 +02:00
Thomas Preud'homme 8f8f815255 Fix calls in gdb.arch/thumb2-it.exp
Tests in gdb.arch/thumb2-it.exp call functions defined in assembly
without type debugging information. Since
7022349d5c ("Stop assuming no-debug-info
functions return int") this triggers an error which leads to many tests
to FAIL. This patch cast the call to indicate the return type of the
functions when calling them.

2017-09-06  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gdb/testsuite/
	* gdb.arch/thumb2-it.exp: Cast call to assembly defined function.
2017-09-06 17:54:26 +01:00
Kamil Rytarowski 28ad437d7a Define HAVE_NATIVE_GCORE_HOST on NetBSD
NetBSD ships with gcore(1) againg since the version 2.0.
This tool is functional and actively maintained.

gdb/ChangeLog
2017-09-06  Kamil Rytarowski  <n54@gmx.com>

	* configure.nat: Define HAVE_NATIVE_GCORE_HOST on NetBSD.
2017-09-06 18:40:29 +02:00
John Baldwin 351787dd4c Add native target for FreeBSD/aarch64.
gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add mips-fbsd-nat.c.
	* NEWS: Mention new FreeBSD/mips native configuration.
	* configure.host: Add aarch64*-*-freebsd*.
	* configure.nat: Likewise.
	* aarch64-fbsd-nat.c: New file.
2017-09-06 09:42:08 -07:00
John Baldwin c0f84956d0 Add FreeBSD/aarch64 architecture.
Support for collecting and supplying general purpose and floating point
register sets is provided along with signal frame unwinding.

gdb/ChangeLog:

	* Makefile.in (ALL_64_TARGET_OBS): Add aarch64-fbsd-tdep.o.
	(ALLDEPFILES): Add aarch64-fbsd-tdep.c.
	* NEWS: Mention new FreeBSD/aarch64 target.
	* configure.tgt: Add aarch64*-*-freebsd*.
	* aarch64-fbsd-tdep.c: New file.
	* aarch64-fbsd-tdep.h: New file.
2017-09-06 09:40:47 -07:00
Kamil Rytarowski 7610297ab5 Add myself as a write-after-approval GDB maintainer.
gdb/ChangeLog:
2017-09-06  Kamil Rytarowski  <n54@gmx.com>

	* MAINTAINERS (Write After Approval): Add Kamil Rytarowski.
2017-09-06 18:01:18 +02:00
Jan Kratochvil fbd1b77155 Fix accessing TLS variables with no debug info
Since 2273f0ac95 ("change minsyms not to be relocated at
read-time"), printing TLS symbols of objfiles with a non-zero base
address, without debug info, fails.

E.g., with:

 $ mv /usr/lib/debug /usr/lib/debug-x

to get debug info out of the way, we get:

 $ echo 'int main(){}' | gcc -pthread -x c -
 $ ./gdb -q -ex start -ex 'p (int) errno' ./a.out
 Cannot access memory at address 0xffffef7c0698

instead of the expected:

 $1 = 0

The regression is not visible with glibc debuginfo installed.

The problem is that we compute the address of TLS minsyms incorrectly.

To trigger the problem, it is important that the variable is in an
objfile with a non-zero base address.  While glibc is a shared library
for 'errno', it's easier for the testcase to use PIE instead of a
shlib.  For TLS variables in PT_EXEC the regression obviously does not
happen.

gdb/ChangeLog
2017-09-06  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* parse.c (find_minsym_type_and_address): Don't relocate addresses
	of TLS symbols.

gdb/testsuite/ChangeLog
2017-09-06  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.threads/tls-nodebug-pie.c: New file.
	* gdb.threads/tls-nodebug-pie.exp: New file.
2017-09-06 12:32:46 +01:00
Philippe Waroquiers 5ca79eae06 Fix leak of auto_obstack objfile_per_bfd_storage->storage_obstack;
commit 23732b1e32
  Author: Pedro Alves <palves@redhat.com>
  Date:   Tue Jun 27 16:22:08 2017 +0100
changed objfile_per_bfd_storage->storage_obstack
from  'struct obstack storage_obstack;'
to    'auto_obstack storage_obstack;'
So the obstack is auto allocated when the  objfile_per_bfd_storage ctor is
manually called by get_objfile_bfd_data).
However, the ctor call was still followed by a manual call to
      obstack_init (&storage->storage_obstack);

This results in a bunch of leaks detected by valgrind, such as:
==24665== 4,064 bytes in 1 blocks are definitely lost in loss record 11,469 of 11,590
==24665==    at 0x4C27BF5: malloc (vg_replace_malloc.c:299)
==24665==    by 0x5437B7: xmalloc (common-utils.c:44)
==24665==    by 0x77CAA7: _obstack_begin_worker (obstack.c:141)
==24665==    by 0x60168F: auto_obstack (gdb_obstack.h:70)
==24665==    by 0x60168F: get_objfile_bfd_data(objfile*, bfd*) (objfiles.h:188)
==24665==    by 0x601DB6: allocate_objfile(bfd*, char const*, enum_flags<objfile_flag>) (objfiles.c:423)
==24665==    by 0x647753: symbol_file_add_with_addrs(bfd*, char const*, enum_flags<symfile_add_flag>, section_addr_info*, enum_flags<objfile_flag>, objfile*) (symfile.c:1158)
==24665==    by 0x647C7B: symbol_file_add_separate(bfd*, char const*, enum_flags<symfile_add_flag>, objfile*) (symfile.c:1252)
==24665==    by 0x4C7D79: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1270)
==24665==    by 0x647CB4: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:861)
==24665==    by 0x647809: syms_from_objfile_1 (symfile.c:1062)

-> remove the manual call to obstack_init.
Reg-tested on Debian 8/amd64, tests results are the same before/after the patch.
valgrind still show some leaks, but less.

gdb/ChangeLog
2017-09-05  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* objfiles.c (get_objfile_bfd_data): Remove useless obstack_init
	call.
2017-09-05 20:51:23 +02:00
Tom Tromey 5eb5f85062 Don't use -fdiagnostics-color=never for rustc
I noticed that the gdb.rust tests fail because the test suite passes
-fdiagnostics-color=never to rustc.  This is not a recognized rustc
option, and the test suite already handles passing the appropriate
option to the Rust compiler.

This patch fixes the problem.

testsuite/ChangeLog
2017-09-05  Tom Tromey  <tom@tromey.com>

	* lib/gdb.exp (gdb_compile): Don't use universal_compile_options
	for rust.
2017-09-05 12:08:03 -06:00
Simon Marchi ae780a21f2 Test different follow-exec-mode settings in gdb.multi/multi-arch-exec.exp
Using follow-exec-mode "new" takes a different code path than "same", so
it's interesting to test this path in combination with a change in
architecture of the inferior.  This test fails if you remove the
previous patch.

gdb/testsuite/ChangeLog:

	* gdb.multi/multi-arch-exec.exp: Test with different
	"follow-exec-mode" settings.
	(do_test): New procedure.
2017-09-05 17:42:04 +02:00
Simon Marchi bf93d7ba99 Add thread after updating gdbarch when exec'ing
As mentioned in the previous patch, we should avoid doing register reads
after a process does an exec and before we've updated that inferior's
gdbarch.  Otherwise, we may interpret the registers using the wrong
architecture.  When a process does an exec with "follow-exec-mode new",
a new inferior is added by follow_exec.  The gdbarch of that new
inferior is at first set to some default value, probably specific to the
gdb build (I get "i386" here), which may not be the right one.  It is
updated later by the call to target_find_description.  Before that
point, if we try to read the inferior's registers, we may not interpret
them correctly.  This has been exposed by a failure in
gdb.base/foll-exec-mode.exp after the previous patch, with:

  Remote 'g' packet reply is too long (expected 312 bytes, got 816 bytes)

The call to "add_thread" done just after adding the inferior is
problematic, because it ends up reading the registers (because the ptid
is re-used, we end up doing a switch_to_thread to it, which tries to
update stop_pc).  The registers returned by gdbserver are the x86-64
ones, while we try to interpret them using the "i386" gdbarch.

Postponing the call to add_thread to until the target
description/gdbarch has been updated seems to fix the issue.

As to why this issue was uncovered by the previous patch: what I think
happened before that patch is that since we were updating stop_pc before
switching to the new inferior, we were filling the regcache associated
to the ptid (this worked fine as long as the architectures of the
previous and new process images were the same).  The call to
switch_to_thread then worked, because the register read hit the
regcache.  Now, it triggers a register read, while the gdbarch is not
set correctly, leading to the "reply is too long" error.  If this is
right, it sounds wrong that we delete and re-add a thread with the same
ptid, and are able to access the registers from the deleted thread.
When we delete a thread, should we clear the regcache associated to that
ptid, so that the new thread starts with a fresh/empty regcache?

gdb/ChangeLog:

	* infrun.c (follow_exec): Call add_thread after
	target_find_description.
2017-09-05 17:41:03 +02:00
Simon Marchi 1bb7c05977 Read stop_pc after updating the gdbarch when exec'ing
When an inferior execs and changes architecture (e.g. 64 bits to 32
bits), the gdbarch associated to the inferior is updated by the
follow_exec call in handle_inferior_event_1.  We should avoid doing any
register read before that point, because the registers sent by the
remote side will be those of the new architecture, but we would
interpret them using the old architecture.  We do just that by setting
stop_pc during this window, which obviously requires reading the
registers.  This results in gdb.multi/multi-arch-exec.exp failing, GDB
outputting the following error:

  Truncated register 50 in remote 'g' packet

This patch fixes that by postponing the setting of stop_pc to after
we've updated the inferior gdbarch.

This bug was hiding another problem, and as such introduces some
failures in gdb.base/foll-exec-mode.exp.  The following patch takes care
of that.

gdb/ChangeLog:

	* infrun.c (handle_inferior_event_1): When exec'ing, read
	stop_pc after follow_exec.
2017-09-05 17:41:03 +02:00
Simon Marchi fc80982757 Improve "'g' reply is is to long" error message
... by adding the expected size, and the received size.  I found this
useful when debugging gdbarch/remote issues, since it gives a hint of
what gdb expects and what the remote sent.

gdb/ChangeLog:

	* remote.c (process_g_packet): Update error message.
2017-09-05 17:41:03 +02:00
Yao Qi d2fcdd8546 Add i386.o to gdb_target_obs for x86_64-* targets
This patch fixes the build failure caused by 22916b0
(Convert the rest x86 target descriptions).

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.tgt (gdb_target_obs): Add i386.o for x86_64-*
	targets.
2017-09-05 14:46:47 +01:00
Pedro Alves e69570ee18 eval.c:evaluate_subexp_standard: Factor out function call handling
While working on the no-debug-info debugging improvements, I found
evaluate_subexp_standard's function call code unnecessarily long and
hard to navigate and debug.  The use of goto doesn't help either.

This commit tries to improve things by factoring out the
function-call-related code to separate helper functions.

gdb/ChangeLog:
2017-09-05  Pedro Alves  <palves@redhat.com>

	* eval.c (eval_call, evaluate_funcall): New functions, factored
	out from ...
	(evaluate_subexp_standard): ... this.
2017-09-05 12:13:57 +01:00
Yao Qi 22916b0786 Convert the rest x86 target descriptions
This patch changes the rest of x86 target descriptions in GDB and
GDBserver.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* amd64-tdep.c (amd64_target_description): Create target
	descriptions.
	(_initialize_amd64_tdep): Don't call functions
	initialize_tdesc_amd64_*.  Add self tests.
	* arch/amd64.c (amd64_create_target_description): Add parameter
	is_linux.  Call set_tdesc_osabi if is_linux is true.
	* arch/amd64.h (amd64_create_target_description): Update the
	declaration.
	* arch/i386.c (i386_create_target_description): Add parameter
	is_linux.  Call set_tdesc_osabi if is_linux is true.
	* arch/i386.h (i386_create_target_description): Update
	declaration.
	* configure.tgt: Add i386.o to gdb_target_obs.
	* features/Makefile (XMLTOC): Remove i386/*.xml.
	* features/i386/amd64-avx-avx512.c: Remove.
	* features/i386/amd64-avx-mpx-avx512-pku.c: Remove.
	* features/i386/amd64-avx-mpx.c: Remove.
	* features/i386/amd64-avx.c: Remove.
	* features/i386/amd64-mpx.c: Remove.
	* features/i386/amd64.c: Remove.
	* features/i386/i386-avx-avx512.c: Remove.
	* features/i386/i386-avx-mpx-avx512-pku.c: Remove.
	* features/i386/i386-avx-mpx.c: Remove.
	* features/i386/i386-avx.c: Remove.
	* features/i386/i386-mmx.c: Remove.
	* features/i386/i386-mpx.c: Remove.
	* features/i386/i386.c: Remove.
	* i386-tdep.c: Don't include features/i386/i386*.c., include
	target-descriptions.h and arch/i386.h.
	(i386_target_description): Create target descriptions.
	(i386_gdbarch_init): Don't call initialize_tdesc_i386_*
	functions.  Do self tests.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.srv (srv_i386_regobj): Remove.
	(srv_amd64_regobj): Remove.
	(srv_regobj): Set it to "" for x86 non-linux targets.
	* linux-x86-tdesc.c (i386_linux_read_description):
	* lynx-i386-low.c: Include x86-xstate.h and arch/i386.h.
	(init_registers_i386): Remove the declaration.
	(tdesc_i386): Remove the declaration.
	(lynx_i386_arch_setup): Call i386_create_target_description.
	* nto-x86-low.c: Likewise.
	* win32-i386-low.c [__x86_64__]: include arch/amd64.h.
	[!__x86_64__]: include arch/i386.h.
	(i386_arch_setup) [__x86_64__]: Call amd64_create_target_description.
2017-09-05 09:54:54 +01:00
Yao Qi 0854b7b187 Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.c
gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* features/Makefile (XMLTOC): Remove i386/amd64XXX-linux.xml.
	* features/i386/amd64-avx-avx512-linux.c: Removed.
	* features/i386/amd64-avx-linux.c: Removed.
	* features/i386/amd64-avx-mpx-avx512-pku-linux.c: Removed.
	* features/i386/amd64-avx-mpx-linux.c: Removed.
	* features/i386/amd64-linux.c: Removed.
	* features/i386/amd64-mpx-linux.c: Removed.
	* features/i386/x32-avx-avx512-linux.c: Removed.
	* features/i386/x32-avx-linux.c: Removed.
	* features/i386/x32-linux.c: Removed.
2017-09-05 09:54:54 +01:00
Yao Qi 38602d55e0 [GDBserver] Shorten srv_amd64_linux_xmlfiles
GDBserver now is able to generate target descriptions from features, so
don't need to remember these target description files.

Note that it should be i386/amd64-avx-avx512-linux.xml instead of
i386/amd64-avx-avx512.xml in $srv_amd64_linux_xmlfiles.  This patch
removes it anyway.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.srv (srv_amd64_linux_xmlfiles): Remove
	i386/amd64-XXX-linux from it.
2017-09-05 09:54:54 +01:00
Yao Qi 44b886ff15 [GDBserver] Use pre-generated amd64-linux tdesc as test
Now, all these amd64-linux pre-generated tdesc can be used as test, so
don't need to build them if $development is false.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.srv: Empty srv_amd64_linux_regobj if $development is
	false.
	(ipa_amd64_linux_regobj): Remove.
	(ipa_x32_linux_regobj): Remove.
2017-09-05 09:54:54 +01:00
Yao Qi b4570e4b30 Convert amd64-linux target descriptions
This patch changes amd64-linux target descriptions so that they can be
dynamically generated in both GDB and GDBserver.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (arch-amd64.o): New rule.
	* configure.srv: Append arch-amd64.o.
	* linux-amd64-ipa.c: Include common/x86-xstate.h.
	(get_ipa_tdesc): Call amd64_linux_read_description.
	(initialize_low_tracepoint): Don't call init_registers_x32_XXX
	and init_registers_amd64_XXX.
	* linux-x86-low.c (x86_linux_read_description): Call
	amd64_linux_read_description.
	(x86_get_ipa_tdesc_idx): Call amd64_get_ipa_tdesc_idx.
	(initialize_low_arch): Don't call init_registers_x32_XXX and
	init_registers_amd64_XXX.
	* linux-x86-tdesc-selftest.c: Declare init_registers_amd64_XXX
	and tdesc_amd64_XXX.
	[__x86_64__] (amd64_tdesc_test): New function.
	(initialize_low_tdesc) [__x86_64__]: Call init_registers_x32_XXX
	and init_registers_amd64_XXX.
	* linux-x86-tdesc.c: Include arch/amd64.h.
	(xcr0_to_tdesc_idx): New function.
	(i386_linux_read_description): New function.
	(amd64_get_ipa_tdesc_idx): New function.
	* linux-x86-tdesc.h (amd64_get_ipa_tdesc_idx): Declare.
	(amd64_get_ipa_tdesc): Declare.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-tdep.c: Include arch/amd64.h.  Don't include
	features/i386/*.c.
	(amd64_linux_read_description): Call
	amd64_create_target_description.
	* arch/amd64.c: New file.
	* arch/amd64.h: New file.
	* configure.tgt (x86_64-*-linux*): Append amd64.o.
	* Makefile.in (ALL_64_TARGET_OBS): Append amd64.o.
2017-09-05 09:54:54 +01:00
Yao Qi 6c73f67f9c Lazily and dynamically create amd64-linux target descriptions
This patch starts to use the generate c feature files to dynamically
create amd64-linux target descriptions.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-tdep.c: Don't include amd64-XXX-linux and
	x32-XXX-linux.c.  Include 64bit-XX.c and x32-XX.c.
	(amd64_linux_read_description): Create target descriptions.
	(_initialize_amd64_linux_tdep): Don't call initialize_tdesc_XXX
	functions.  Add unit tests.
	* features/Makefile (FEATURE_XMLFILES): Append 64bit-XXX.xml and
	x32-core.xml.
	* features/i386/64bit-avx.c: Generated.
	* features/i386/64bit-avx512.c: Generated.
	* features/i386/64bit-core.c: Generated.
	* features/i386/64bit-linux.c: Generated.
	* features/i386/64bit-mpx.c: Generated.
	* features/i386/64bit-pkeys.c: Generated.
	* features/i386/64bit-segments.c: Generated.
	* features/i386/64bit-sse.c: Generated.
	* features/i386/x32-core.c: Generated.
	* target-descriptions.c (maint_print_c_tdesc_cmd): Print feature
	c files for amd64-linux and x32-linux.
2017-09-05 09:54:54 +01:00
Yao Qi 9d3d478be5 Centralize amd64-linux target descriptions
This patch adds a new function amd64_linux_read_description, which
creates amd64-linux target descriptions according to its two
arguments, xcr0 and is_x32.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-tdep.c (amd64_linux_read_description): New
	function.
	(amd64_linux_core_read_description): Call
	amd64_linux_read_description.
	(amd64_linux_init_abi): Likewise.
	(amd64_x32_linux_init_abi): Likewise.
	* amd64-linux-tdep.h (amd64_linux_read_description): Declare.
	* x86-linux-nat.c (x86_linux_read_description): Call
	amd64_linux_read_description.
2017-09-05 09:54:53 +01:00
Yao Qi b9f1d50ffc Update comments in amd64_linux_core_read_description
gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-tdep.c (amd64_linux_core_read_description): Update
	comments.
2017-09-05 09:54:53 +01:00
Yao Qi d1f28ea24a [GDBserver] Shorten srv_i386_linux_xmlfiles
GDBserver now is able to generate target descriptions from features, so
don't need to remember these target description files.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.srv (srv_i386_linux_xmlfiles): Remove
	i386/i386-XXX-linux.xml from it.
2017-09-05 09:54:53 +01:00
Yao Qi 25a93583f3 [GDBserver] Use pre-generated tdesc as test
Now, these *-generate.c files are only used in GDBserver for unit test.
If $development is false (in release), these *-generate.c files won't be
used at all.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.srv: Set srv_i386_linux_regobj empty if $development
	is false.
	* linux-i386-ipa.c (initialize_low_tracepoint): Don't call
	initialize_low_tdesc.
	* linux-x86-low.c (initialize_low_arch): Wrap initialize_low_tdesc
	with #if initialize_low_tdesc.
	* linux-x86-tdesc-selftest.c: New file.
	* linux-x86-tdesc.c: Move code to linux-x86-tdesc-selftest.c.
2017-09-05 09:54:53 +01:00
Yao Qi 188c9e6dcb Remove features/i386/i386-*linux.c
Now, features/i386/i386-XXX-linux.c are not used, remove them.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* features/Makefile (XMLTOC): Remove i386/i386-XX-linux.xml.
	* features/i386/i386-avx-avx512-linux.c: Remove.
	* features/i386/i386-avx-linux.c: Remove.
	* features/i386/i386-avx-mpx-avx512-pku-linux.c: Remove.
	* features/i386/i386-avx-mpx-linux.c: Remove.
	* features/i386/i386-linux.c: Remove.
	* features/i386/i386-mmx-linux.c: Remove.
	* features/i386/i386-mpx-linux.c: Remove.
2017-09-05 09:54:53 +01:00
Yao Qi 5f035c0716 Share i386-linux target description between GDB and GDBserver
The code on creating i386-linux target descriptions are quite similar
between GDB and GDBserver, so this patch moves them into a shared file
arch/i386.c.  I didn't name it as i386-linux.c, because I want to reuse it
to create other i386 non-linux target descriptions later.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (ALL_TARGET_OBS): Add i386.o.
	(SFILES): Add arch/i386.c.
	(HFILES_NO_SRCDIR): Add arch/i386.h.
	* arch/i386.c: New file.
	* arch/i386.h: New file.
	* arch/tdesc.h (allocate_target_description): Declare.
	(set_tdesc_architecture): Declare.
	(set_tdesc_osabi): Declare.
	* configure.tgt (i[34567]86-*-linux*): Add i386.o.
	* i386-linux-tdep.c: Don't include ../features/i386/32bit-XXX.c.
	include arch/i386.h.
	(i386_linux_read_description): Remove code and call
	i386_create_target_description.
	(set_tdesc_architecture): New function.
	(set_tdesc_osabi): New function.
	* target-descriptions.h (allocate_target_description): Remove.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (arch-i386.o): New rule.
	* configure.srv (i[34567]86-*-linux*): Add arch-i386.o.
	(x86_64-*-linux*): Likewise.
	* linux-x86-tdesc.c: Don't include ../features/i386/32bit-XXX.c,
	include arch/i386.h.
	(i386_linux_read_description): Remove code and call
	i386_create_target_description.
	* tdesc.c (allocate_target_description): New function.
	* tdesc.h (set_tdesc_architecture): Remove declaration.
	(set_tdesc_osabi): Likewise.
2017-09-05 09:54:53 +01:00
Yao Qi 0abe8a8992 Dynamically composite xml in reply to GDB
GDBserver still uses pre-generated target descriptions in order to
reply to GDB's query on target description (see xml-builtin-generated.c
in GDBserver build directory).  This patch teaches GDBserver to
create XML contents according to the target descriptions rather than
using pre-generated ones.

First, change target feature c files to pass the feature xml file
name to tdesc_create_feature, so that target description in GDBserver
can record them, and create XML contents from these features in
buffer, like

  ...
  <xi:include href="$FEATURE1_XML_NAME"/>
  <xi:include href="$FEATURE2_XML_NAME"/>
  ...

and send this buffer back to GDB.

Note that this patch reuses target_desc.xmltarget a little bit, which is
to hold the XML contents dynamically generated in tdesc_get_features_xml.
However, it is not xfree'ed in ~target_desc, because we can't tell it is
from xstrdup or a literal string.  Since we don't delete target_desc,
there is no memory leak yet.  After we change all target descriptions to
the new style, target_desc.xmltarget is from xstrdup, then, we can safely
xfree it in ~target_desc.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* arch/tdesc.h (tdesc_create_feature): Add an argument xml.
	* target-descriptions.c (tdesc_create_feature): Likewise, and
	adjust code.
	* features/i386/32bit-avx.c: Re-generated.
	* features/i386/32bit-avx512.c: Re-generated.
	* features/i386/32bit-core.c: Re-generated.
	* features/i386/32bit-linux.c: Re-generated.
	* features/i386/32bit-mpx.c: Re-generated.
	* features/i386/32bit-pkeys.c: Re-generated.
	* features/i386/32bit-sse.c: Re-generated.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* linux-x86-tdesc.c: Don't include <inttypes.h>.
	(i386_linux_read_description) [!IN_PROCESS_AGENT]: Call
	set_tdesc_architecture and set_tdesc_osabi.  Remove code setting
	.xmltarget.
	* server.c (get_features_xml): Call tdesc_get_features_xml.
	* tdesc.c (set_tdesc_architecture): New function.
	(set_tdesc_osabi): New function.
	(tdesc_get_features_xml): New function.
	(tdesc_create_feature): Add an argument.
	* tdesc.h (struct target_desc) <features>: New field.
	<arch, osabi>: New field.
	(~target_desc): xfree features, arch, and osabi.
	(target_desc::oerator==): Don't compare .xmltarget.
	[!IN_PROCESS_AGENT] (set_tdesc_architecture): Declare.
	(set_tdesc_osabi): Likewise.
	(tdesc_get_features_xml): Likewise.
2017-09-05 09:54:53 +01:00
Yao Qi 0a188386c0 [GDBserver] unit test to i386_tdesc
This patch adds a unit test in GDBserver to test dynamically created
target descriptions equal these pre-generated ones.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* linux-x86-tdesc.c: Include selftest.h.
	(i386_tdesc_test): New function.
	(initialize_low_tdesc): Call selftests::register_test.
	* tdesc.h: Include regdef.h.
	(target_desc): Override operator == and !=.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* regformats/regdef.h (struct reg): Override operator == and !=.
2017-09-05 09:54:53 +01:00
Yao Qi f49ff00066 [GDBserver] Centralize tdesc for i386-linux
tdesc_i386_XXX_linux is used in many places in linux-x86-low.c and this
patch adds a new function i386_linux_read_description to return the right
tdesc according to xcr0.  i386_linux_read_description is quite similar to
the counterpart in GDB, and the following patch will share the duplicated
code, so this patch adds arch/tdesc.h includes the declarations of various
tdesc apis which are used by the shared code.  The generated c feature
files can include arch/tdesc.h only.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* configure.srv (srv_tgtobj): Append linux-x86-tdesc.o.
	(ipa_obj): Likewise.
	* linux-i386-ipa.c: Include common/x86-xstate.h
	(get_ipa_tdesc): Call i386_linux_read_description.
	(initialize_low_tracepoint): Don't call  init_registers_XXX
	functions, call initialize_low_tdesc instead.
	* linux-x86-low.c (x86_linux_read_description): Call
	i386_linux_read_description.
	(initialize_low_arch): Don't call init_registers_i386_XXX
	functions, call initialize_low_tdesc.
	* linux-x86-tdesc.c: New file.
	* linux-x86-tdesc.h (x86_linux_tdesc): New X86_TDESC_LAST.
	(i386_get_ipa_tdesc_idx): Declare.
	(i386_get_ipa_tdesc): Declare.
	(initialize_low_tdesc): Declare.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* arch/tdesc.h: New file.
	* regformats/regdat.sh: Generate code using tdesc_create_reg.
	* target-descriptions.c: Update comments.
	* target-descriptions.h: Include "arch/tdesc.h".  Remove the
	declarations.
	* features/i386/32bit-avx.c: Re-generated.
	* features/i386/32bit-avx512.c: Re-generated.
	* features/i386/32bit-core.c: Re-generated.
	* features/i386/32bit-linux.c: Re-generated.
	* features/i386/32bit-mpx.c: Re-generated.
	* features/i386/32bit-pkeys.c: Re-generated.
	* features/i386/32bit-sse.c: Re-generated.
2017-09-05 09:54:53 +01:00
Yao Qi 2b68ef2f11 Return X86_TDESC_MMX in x86_get_ipa_tdesc_idx
gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* linux-x86-low.c (x86_get_ipa_tdesc_idx): Use X86_TDESC_MMX
	instead of 0.
2017-09-05 09:54:52 +01:00
Yao Qi f7000548a2 Use VEC for target_desc.reg_defs
Nowadays, target_desc.reg_defs is a pointer points to a pre-generated
array, which is not flexible.  This patch changes it from an array
to a VEC so that GDBserver can create target descriptions dynamically
later.  Instead of using pre-generated array, the -generated.c calls
VEC_safe_push to add each register to vector.

Since target_desc.reg_defs is used in IPA, we need to build common/vec.c
for IPA too.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (IPA_OBJS): Add vec-ipa.o
	* regcache.c (get_thread_regcache): Use VEC_length.
	(init_register_cache): Likewise.
	(regcache_cpy): Likewise.
	(registers_to_string): Iterate reg_defs via VEC_iterate.
	(find_regno): Likewise.
	(find_register_by_number): Use VEC_index.
	(register_size): Call find_register_by_number.
	(register_data): Call find_register_by_number.
	(supply_regblock): Use VEC_length.
	(regcache_raw_read_unsigned): Likewise.
	* tdesc.c (init_target_desc): Iterate reg_defs via
	VEC_iterate.
	(default_description): Update initializer.
	(copy_target_description): Don't update field num_registers.
	* tdesc.h (struct target_desc) <reg_defs>: Change it to VEC.
	<num_registers>: Remove.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* regformats/regdat.sh: Update generated code.
2017-09-05 09:54:52 +01:00
Yao Qi c9a5e2a5b2 Adjust code generated by regformats/regdat.sh
regformats/regdat.sh generate some *-generated.c files when GDBserver
is built.  Each .c file has some static variables, which are only used
within function init_registers_XXX, like this,

static struct reg regs_i386_linux[] = {
  { "eax", 0, 32 },
  { "ecx", 32, 32 },
  ...
};

static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 };
static const char *xmltarget_i386_linux = "i386-linux.xml";

void
init_registers_i386_linux (void)
{
  ...
}

This patch moves these static variables' definitions to function
init_registers_XXX, so the generated files look like this,

void
init_registers_i386_linux (void)
{
  static struct target_desc tdesc_i386_linux_s;
  struct target_desc *result = &tdesc_i386_linux_s;
static struct reg regs_i386_linux[] = {
  ...
};

static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 };
static const char *xmltarget_i386_linux = "i386-linux.xml";

  ...
}

We want GDBserver create target descriptions dynamically in each
init_registers_XXXX functions, so this patch moves all the related code
into function init_registers_XXXX, so that the following patch can easily
change function init_registers_XXXX to create target description
dynamically, rather than using current pre-generated array.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* regformats/regdat.sh: Adjust code order.
2017-09-05 09:54:52 +01:00
Simon Marchi d6b687ac7a expprint: Fix format string warning
My compiler (gcc 5.4.0, clang 3.8) gives this warning:

/home/emaisin/src/binutils-gdb/gdb/expprint.c: In lambda function:
/home/emaisin/src/binutils-gdb/gdb/expprint.c:1055:35: error: format not a string literal and no format arguments [-Werror=format-security]
      fprintf_filtered (stream, mod);
                                   ^

Fix it by not using the passed string as the format string.

gdb/ChangeLog:

	* expprint.c (dump_subexp_body_standard): Use constant format
	string in fprintf_filtered call.
2017-09-05 09:01:13 +02:00
John Baldwin a379bfd00e Enable support for x86 debug registers on NetBSD.
NetBSD recently added PT_GETDBREGS and PT_SETDBREGS ptrace operations
that match the existing ones supported by x86-bsd-nat.c.  NetBSD's
headers do not provide the DBREG_DRX helper macro, so define a local
version in x86-bsd-nat.c.  In addition, add the x86-nat.o and x86-dregs.o
object files to the native NetBSD x86 build targets.

gdb/ChangeLog:

	* configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and
	NetBSD/i386.
	* x86-bsd-nat.c [!DBREG_DRX && __NetBSD__]: Define DBREG_DRX.
2017-09-04 19:34:48 -07:00
John Baldwin f7efc967ba Make <sys/user.h> include in bsd-kvm.c conditional on HAVE_SYS_USER_H.
NetBSD has recently removed <sys/user.h>.

gdb/ChangeLog:

	* bsd-kvm.c: Make <sys/user.h> conditional on HAVE_SYS_USER_H.
2017-09-04 19:34:48 -07:00
John Baldwin c49fbc6c79 Define _KMEMUSER before including BSD kernel headers.
Recent versions of NetBSD hide certain kernel structures needed by the
KVM target from userland unless this macro is defined.

gdb/ChangeLog:

	* bsd-kvm.o: Define _KMEMUSER.
	* configure.ac: Define _KMEMUSER when checking for "struct lwp".
	* configure: Regenerate.
2017-09-04 19:34:48 -07:00
John Baldwin 26562e73d8 Include "x86-xstate.h" for X86_XSTATE_* constants.
gdb/ChangeLog:

	* amd64-fbsd-nat.c: Add include of "x86-xstate.h".
	* i386-fbsd-nat.c: Likewise.
2017-09-04 19:31:33 -07:00
John Baldwin 31cf148787 Explicitly include <array> for std::array<>.
gdb/ChangeLog:

	* unittests/array-view-selftests.c: Add include of <array>.
2017-09-04 15:58:38 -07:00
John Baldwin 5b9f8a7c6e Catch up to recent changes to call_function_by_hand().
gdb/ChangeLog:

	* spu-tdep.c (flush_ea_cache): Add missing argument to
	call_function_by_hand.
2017-09-04 15:57:02 -07:00
Pedro Alves d69cf9b207 Document "no debug info debugging" improvements
Here's the documentation bits for all the improvements done in
previous commits.

Note that the original "weak alias functions" paragraph ends up
disappearing, because this patch, which I'm considering kind of part
of this series, makes the alias case Just Work:
  https://sourceware.org/ml/gdb-patches/2017-07/msg00018.html

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* NEWS (Safer support for debugging with no debug info): New.

gdb/doc/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Variables) <Program Variables>: Document inspecting
	no-debug-info variables.
	(Symbols) <Examining the Symbol Table>: Document inspecting
	no-debug-info types.
	(Calling) <Calling functions with no debug info>: New subsection,
	documenting calling no-debug-info functions.
	(Non-debug DLL Symbols) <Working with Minimal Symbols>: Update.
2017-09-04 20:21:16 +01:00
Pedro Alves 3693fdb3c8 Make "p S::method() const::static_var" work too
Trying to print a function local static variable of a const-qualified
method still doesn't work after the previous fixes:

  (gdb) p 'S::method() const'::static_var
  $1 = {i1 = 1, i2 = 2, i3 = 3}
  (gdb) p S::method() const::static_var
  No symbol "static_var" in specified context.

The reason is that the expression parser/evaluator loses the "const",
and the above unquoted case is just like trying to print a variable of
the non-const overload, if it exists, even.  As if the above unquoted
case had been written as:

  (gdb) p S::method()::static_var
  No symbol "static_var" in specified context.

We can see the problem without static vars in the picture.  With:

 struct S
 {
    void method ();
    void method () const;
 };

Compare:

  (gdb) print 'S::method(void) const'
  $1 = {void (const S * const)} 0x400606 <S::method() const>
  (gdb) print S::method(void) const
  $2 = {void (S * const)} 0x4005d8 <S::method()>   # wrong method!

That's what we need to fix.  If we fix that, the function local static
case starts working.

The grammar production for function/method types is this one:

  exp:       exp '(' parameter_typelist ')' const_or_volatile

This results in a TYPE_INSTANCE expression evaluator operator.  For
the example above, we get something like this ("set debug expression 1"):

...
            0  TYPE_INSTANCE         1 TypeInstance: Type @0x560fda958be0 (void)
            5    OP_SCOPE              Type @0x560fdaa544d8 (S) Field name: `method'
...

While evaluating TYPE_INSTANCE, we end up in
value_struct_elt_for_reference, trying to find the method named
"method" that has the prototype recorded in TYPE_INSTANCE.  In this
case, TYPE_INSTANCE says that we're looking for a method that has
"(void)" as parameters (that's what "1 TypeInstance: Type
@0x560fda958be0 (void)" above means.  The trouble is that nowhere in
this mechanism do we communicate to value_struct_elt_for_reference
that we're looking for the _const_ overload.
value_struct_elt_for_reference only compared parameters, and the
non-const "method()" overload has matching parameters, so it's
considered the right match...

Conveniently, the "const_or_volatile" production in the grammar
already records "const" and "volatile" info in the type stack.  The
type stack is not used in this code path, but we can borrow the
information.  The patch converts the info in the type stack to an
"instance flags" enum, and adds that as another element in
TYPE_INSTANCE operators.  This type instance flags is then applied to
the temporary type that is passed to value_struct_elt_for_reference
for matching.

The other side of the problem is that methods in the debug info aren't
marked const/volatile, so with that in place, the matching never finds
const/volatile-qualified methods.

The problem is that in the DWARF, there's no indication at all whether
a method is const/volatile qualified...  For example (c++filt applied
to the linkage name for convenience):

   <2><d3>: Abbrev Number: 6 (DW_TAG_subprogram)
      <d4>   DW_AT_external    : 1
      <d4>   DW_AT_name        : (indirect string, offset: 0x3df): method
      <d8>   DW_AT_decl_file   : 1
      <d9>   DW_AT_decl_line   : 58
      <da>   DW_AT_linkage_name: (indirect string, offset: 0x5b2): S::method() const
      <de>   DW_AT_declaration : 1
      <de>   DW_AT_object_pointer: <0xe6>
      <e2>   DW_AT_sibling     : <0xec>

I see the same with both GCC and Clang.  The patch works around this
by extracting the cv qualification from the "const" and "volatile" in
the demangled name.  This will need further tweaking for "&" and
"const &" overloads, but we don't support them in the parser yet,
anyway.

The TYPE_CONST changes were necessary otherwise the comparisons in valops.c:

  if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j))
    continue;

would fail, because when both TYPE_CONST() TYPE_FN_FIELD_CONST() were
true, their values were different.

BTW, I'm recording the const/volatile-ness of methods in the
TYPE_FN_FIELD info because #1 - I'm not sure it's kosher to change the
method's type directly (vs having to call make_cv_type to create a new
type), and #2 it's what stabsread.c does:

...
	    case 'A':		/* Normal functions.  */
	      new_sublist->fn_field.is_const = 0;
	      new_sublist->fn_field.is_volatile = 0;
	      (*pp)++;
	      break;
	    case 'B':		/* `const' member functions.  */
	      new_sublist->fn_field.is_const = 1;
	      new_sublist->fn_field.is_volatile = 0;
...

After all this, this finally all works:

  print S::method(void) const
  $1 = {void (const S * const)} 0x400606 <S::method() const>
  (gdb) p S::method() const::static_var
  $2 = {i1 = 1, i2 = 2, i3 = 3}

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* c-exp.y (function_method, function_method_void): Add current
	instance flags to TYPE_INSTANCE.
	* dwarf2read.c (check_modifier): New.
	(compute_delayed_physnames): Assert that only C++ adds delayed
	physnames.  Mark fn_fields as const/volatile depending on
	physname.
	* eval.c (make_params): New type_instance_flags parameter.  Use
	it as the new type's instance flags.
	(evaluate_subexp_standard) <TYPE_INSTANCE>: Extract the instance
	flags element and pass it to make_params.
	* expprint.c (print_subexp_standard) <TYPE_INSTANCE>: Handle
	instance flags element.
	(dump_subexp_body_standard) <TYPE_INSTANCE>: Likewise.
	* gdbtypes.h: Include "enum-flags.h".
	(type_instance_flags): New enum-flags type.
	(TYPE_CONST, TYPE_VOLATILE, TYPE_RESTRICT, TYPE_ATOMIC)
	(TYPE_CODE_SPACE, TYPE_DATA_SPACE): Return boolean.
	* parse.c (operator_length_standard) <TYPE_INSTANCE>: Adjust.
	(follow_type_instance_flags): New function.
	(operator_check_standard) <TYPE_INSTANCE>: Adjust.
	* parser-defs.h (follow_type_instance_flags): Declare.
	* valops.c (value_struct_elt_for_reference): const/volatile must
	match too.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/func-static.c (S::method const, S::method volatile)
	(S::method volatile const): New methods.
	(c_s, v_s, cv_s): New instances.
	(main): Call method() on them.
	* gdb.base/func-static.exp (syntax_re, cannot_resolve_re): New variables.
	(cannot_resolve): New procedure.
	(cxx_scopes_list): Test cv methods.  Add print-scope-quote and
	print-quote-unquoted columns.
	(do_test): Test printing each scope too.
2017-09-04 20:21:16 +01:00
Pedro Alves e68cb8e001 Handle "p 'S::method()::static_var'" (quoted) in symbol lookup
While the previous commit made "p method()::static_var" (no
single-quotes) Just Work, if users (or frontends) try wrapping the
expression with quotes, they'll get:

  (gdb) p 'S::method()::static_var'
  'S::method()::static_var' has unknown type; cast it to its declared type

even if we _do_ have debug info for that variable.  That's better than
the bogus/confusing value what GDB would print before the
stop-assuming-int patch:

  (gdb) p 'S::method()::static_var'
  $1 = 1

but I think it'd still be nice to make this case Just Work too.

In this case, due to the quoting, the C/C++ parser (c-exp.y)
interprets the whole expression/string as a single symbol name, and we
end up calling lookup_symbol on that name.  There's no debug symbol
with that fully-qualified name, but since the compiler gives the
static variable a mangled linkage name exactly like the above, it
appears in the mininal symbols:

  $ nm -A local-static | c++filt | grep static_var
  local-static:0000000000601040 d S::method()::static_var

... and that's what GDB happens to find/print.  This only happens in
C++, note, since for C the compiler uses different linkage names:

  local-static-c:0000000000601040 d static_var.1848

So while (in C++, not C) function local static variables are given a
mangled name that demangles to the same syntax that GDB
documents/expects as the way to access function local statics, there's
no global symbol in the debug info with that name at all.  The debug
info for a static local variable for a non-inline function looks like
this:

 <1><2a1>: Abbrev Number: 19 (DW_TAG_subprogram)
 ...
 <2><2f7>: Abbrev Number: 20 (DW_TAG_variable)
    <2f8>   DW_AT_name        : (indirect string, offset: 0x4e9): static_var
    <2fc>   DW_AT_decl_file   : 1
    <2fd>   DW_AT_decl_line   : 64
    <2fe>   DW_AT_type        : <0x25>
    <302>   DW_AT_location    : 9 byte block: 3 40 10 60 0 0 0 0 0      (DW_OP_addr: 601040)

and for an inline function, it looks like this (linkage name run
through c++filt for convenience):

 <2><21b>: Abbrev Number: 16 (DW_TAG_variable)
    <21c>   DW_AT_name        : (indirect string, offset: 0x21a): static_var
    <220>   DW_AT_decl_file   : 1
    <221>   DW_AT_decl_line   : 48
    <222>   DW_AT_linkage_name: (indirect string, offset: 0x200): S::inline_method()::static_var
    <226>   DW_AT_type        : <0x25>
    <22a>   DW_AT_external    : 1
    <22a>   DW_AT_location    : 9 byte block: 3 a0 10 60 0 0 0 0 0      (DW_OP_addr: 6010a0)

(The inline case makes the variable external so that the linker can
merge the different inlined copies.  It seems like GCC never outputs
the linkage name for non-extern globals.)

When we read the DWARF, we record the static_var variable as a regular
variable of the containing function's block.  This makes stopping in
the function and printing the variable as usual.  The variable just so
happens to have a memory address as location.

So one way to make "p 'S::method()::static_var'" work would be to
record _two_ copies of the symbols for these variables.  One in the
function's scope/block, with "static_var" as name, as we currently do,
and another in the static or global blocks (depending on whether the
symbol is external), with a fully-qualified name.  I wrote a prototype
patch for that, and it works.  For the non-inline case above, since
the debug info doesn't point to the linkage same, that patch built the
physname of the static local variable as the concat of the physname of
the containing function, plus "::", plus the variable's name.  We
could make that approach work for C too, though it kind of feels
awkward to record fake symbol names like that in C.

The other approach I tried is to change the C++ symbol lookup routines
instead.  This is the approach this commit takes.  We can already
lookup up symbol in namespaces and classes, so this feels like a good
fit, and was easy enough.  The advantage is that this doesn't require
recording extra symbols.

The test in gdb.cp/m-static.exp that exposed the need for this is
removed, since the same functionality is now covered by
gdb.cp/local-static.exp.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* cp-namespace.c (cp_search_static_and_baseclasses): Handle
	function/method scopes; lookup the nested name as a function local
	static variable.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/local-static.exp: Also test with
	class::method::variable wholly quoted.
	* gdb.cp/m-static.exp (class::method::variable): Remove test.
2017-09-04 20:21:16 +01:00
Pedro Alves 858be34c5a Handle "p S::method()::static_var" in the C++ parser
This commit makes "print S::method()::static_var" actually find the
debug symbol for static_var.  Currently, you get:

  (gdb) print S::method()::static_var
  A syntax error in expression, near `'.

Quoting the whole string would seemingly work before the previous
patch that made GDB stop assuming int for no-debug-info variables:

  (gdb) p 'S::method()::static_var'
  $1 = 1

... except that's incorrect output, because:

  (gdb) ptype 'S::method()::static_var'
  type = <data variable, no debug info>

The way to make it work correctly currently is by quoting the
function/method part, like this:

  (gdb) print 'S::method()'::static_var
  $1 = {i1 = 1, i2 = 2, i3 = 3}
  (gdb) ptype 'S::method()'::static_var
  type = struct aggregate {
      int i1;
      int i2;
      int i3;
  }

At least after the "stop assuming int" patch, this is what we
now get:

  (gdb) p 'S::method()::static_var'
  'S::method()::static_var' has unknown type; cast it to its declared type
  (gdb) p (struct aggregate) 'S::method()::static_var'
  $1 = {i1 = 1, i2 = 2, i3 = 3}

However, IMO, users shouldn't really have to care about any of this.
GDB should Just Work, without quoting, IMO.

So here's a patch that implements support for that in the C++ parser.
With this patch, you now get:

  (gdb) p S::method()::S_M_s_var_aggregate
  $1 = {i1 = 1, i2 = 2, i3 = 3}
  (gdb) ptype S::method()::S_M_s_var_aggregate
  type = struct aggregate {
      int i1;
      int i2;
      int i3;
  }

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	(%type <voidval>): Add function_method.
	* c-exp.y (exp): New production for calls with no arguments.
	(function_method, function_method_void_or_typelist): New
	productions.
	(exp): New production for "method()::static_var".
	* eval.c (evaluate_subexp_standard): Handle OP_FUNC_STATIC_VAR.
	* expprint.c (print_subexp_standard, dump_subexp_body_standard):
	Handle OP_FUNC_STATIC_VAR.
	* parse.c (operator_length_standard):
	Handle OP_FUNC_STATIC_VAR.
	* std-operator.def (OP_FUNC_STATIC_VAR): New.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/local-static.c: New.
	* gdb.base/local-static.cc: New.
	* gdb.base/local-static.exp:  New.
2017-09-04 20:21:15 +01:00
Pedro Alves dd5901a6a5 Eliminate UNOP_MEMVAL_TLS
Since minsym references now go via OP_VAR_MSYM_VALUE, UNOP_MEMVAL_TLS
is no longer used anywhere.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* eval.c (evaluate_subexp_standard): Remove UNOP_MEMVAL_TLS
	handling.
	* expprint.c (print_subexp_standard, dump_subexp_body_standard):
	Ditto.
	* parse.c (operator_length_standard, operator_check_standard):
	Ditto.
	* std-operator.def (UNOP_MEMVAL_TLS): Delete.
2017-09-04 20:21:15 +01:00
Pedro Alves 46a4882b3c Stop assuming no-debug-info variables have type int
An earlier commit made GDB no longer assume no-debug-info functions
return int.  This commit gives the same treatment to variables.

Currently, you can end misled by GDB over output like this:

  (gdb) p var
  $1 = -1
  (gdb) p /x var
  $2 = 0xffffffff

until you realize that GDB is assuming that the variable is an "int",
because:

  (gdb) ptype var
  type = <data variable, no debug info>

You may try to fix it by casting, but that doesn't really help:

  (gdb) p /x (unsigned long long) var
  $3 = 0xffffffffffffffff            # incorrect
         ^^

That's incorrect output, because the variable was defined like this:

  uint64_t var = 0x7fffffffffffffff;
                   ^^

What happened is that with the cast, GDB did an int -> 'unsigned long
long' conversion instead of reinterpreting the variable as the cast-to
type.  To get at the variable properly you have to reinterpret the
variable's address manually instead, with either:

  (gdb) p /x *(unsigned long long *) &var
  $4 = 0x7fffffffffffffff
  (gdb) p /x {unsigned long long} &var
  $5 = 0x7fffffffffffffff

After this commit GDB does it for you.  This is what you'll get
instead:

  (gdb) p var
  'var' has unknown type; cast it to its declared type
  (gdb) p /x (unsigned long long) var
  $1 = 0x7fffffffffffffff

As in the functions patch, the "compile" machinery doesn't currently
have the cast-to type handy, so it continues assuming no-debug
variables have int type, though now at least it warns.

The change to gdb.cp/m-static.exp deserves an explanation:

 - gdb_test "print 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
 + gdb_test "print (int) 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \

That's printing the "sintvar" function local static of the
"gnu_obj_1::method()" method.

The problem with that test is that that "'S::method()::static_var'"
syntax doesn't really work in C++ as you'd expect.  The way to make it
work correctly currently is to quote the method part, not the whole
expression, like:

  (gdb) print 'gnu_obj_1::method()'::sintvar

If you wrap the whole expression in quotes, like in m-static.exp, what
really happens is that the parser considers the whole string as a
symbol name, but there's no debug symbol with that name.  However,
local statics have linkage and are given a mangled name that demangles
to the same string as the full expression, so that's what GDB prints.
After this commit, and without the cast, the print in m-static.exp
would error out saying that the variable has unknown type:

  (gdb) p 'gnu_obj_1::method()::sintvar'
  'gnu_obj_1::method()::sintvar' has unknown type; cast it to its declared type

TBC, if currently (even before this series) you try to print any
function local static variable of type other than int, you'll get
bogus results.  You can see that with m-static.cc as is, even.
Printing the "svar" local, which is a boolean (1 byte) still prints as
"int" (4 bytes):

  (gdb) p 'gnu_obj_1::method()::svar'
  $1 = 1
  (gdb) ptype 'gnu_obj_1::method()::svar'
  type = <data variable, no debug info>

This probably prints some random bogus value on big endian machines.

If 'svar' was of some aggregate type (etc.) we'd still print it as
int, so the problem would have been more obvious...  After this
commit, you'll get instead:

  (gdb) p 'gnu_obj_1::method()::svar'
  'gnu_obj_1::method()::svar' has unknown type; cast it to its declared type

... so at least GDB is no longer misleading.  Making GDB find the real
local static debug symbol is the subject of the following patches.  In
the end, it'll all "Just Work".

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* ax-gdb.c: Include "typeprint.h".
	(gen_expr_for_cast): New function.
	(gen_expr) <OP_CAST, OP_CAST_TYPE>: Use it.
	<OP_VAR_VALUE, OP_MSYM_VAR_VALUE>: Error out if the variable's
	type is unknown.
	* dwarf2read.c (new_symbol_full): Fallback to int instead of
	nodebug_data_symbol.
	* eval.c: Include "typeprint.h".
	(evaluate_subexp_standard) <OP_VAR_VALUE, OP_VAR_MSYM_VALUE>:
	Error out if symbol has unknown type.
	<UNOP_CAST, UNOP_CAST_TYPE>: Common bits factored out to
	evaluate_subexp_for_cast.
	(evaluate_subexp_for_address, evaluate_subexp_for_sizeof): Handle
	OP_VAR_MSYM_VALUE.
	(evaluate_subexp_for_cast): New function.
	* gdbtypes.c (init_nodebug_var_type): New function.
	(objfile_type): Use it to initialize types of variables with no
	debug info.
	* typeprint.c (error_unknown_type): New.
	* typeprint.h (error_unknown_type): New declaration.
	* compile/compile-c-types.c (convert_type_basic): Handle
	TYPE_CODE_ERROR; warn and fallback to int for variables with
	unknown type.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.asm/asm-source.exp: Add casts to int.
	* gdb.base/nodebug.c (dataglobal8, dataglobal32_1, dataglobal32_2)
	(dataglobal64_1, dataglobal64_2): New globals.
	* gdb.base/nodebug.exp: Test different expressions involving the
	new globals, with print, whatis and ptype.  Add casts to int.
	* gdb.base/solib-display.exp: Add casts to int.
	* gdb.compile/compile-ifunc.exp: Expect warning.  Add cast to int.
	* gdb.cp/m-static.exp: Add cast to int.
	* gdb.dwarf2/dw2-skip-prologue.exp: Add cast to int.
	* gdb.threads/tls-nodebug.exp: Check that gdb errors out printing
	tls variable with no debug info without a cast.  Test with a cast
	to int too.
	* gdb.trace/entry-values.exp: Add casts.
2017-09-04 20:21:15 +01:00
Pedro Alves fe13dfecbf evaluate_subexp_standard: Factor out OP_VAR_VALUE handling.
A following patch will want to call the new evaluate_var_value
function in another spot.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* eval.c (evaluate_var_value): New function, factored out from ...
	(evaluate_subexp_standard): ... here.
2017-09-04 20:21:14 +01:00
Pedro Alves d008ee2156 evaluate_subexp_standard: Remove useless assignments
gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* eval.c (evaluate_subexp_standard) <UNOP_COMPLEMENT, UNOP_ADDR>:
	Remove useless assignments to 'op'.
2017-09-04 20:21:14 +01:00
Pedro Alves 827d0c517e evaluate_subexp_standard: Eliminate one goto
A following patch will want to factor out a bit of
evaluate_subexp_standard, and it'd be handy to reuse the code under the
"nosideret:" label there too.  This commits moves it to a separate
function as preparation for that.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* eval.c (eval_skip_value): New function.
	(evaluate_subexp_standard): Use it.
2017-09-04 20:21:14 +01:00
Pedro Alves 2c5a2be190 Make ptype/whatis print function name of functions with no debug info too
The patch to make GDB stop assuming functions return int left GDB with
an inconsistency.  While with normal expression evaluation the
"unknown return type" error shows the name of the function that misses
debug info:

  (gdb) p getenv ("PATH")
  'getenv' has unknown return type; cast the call to its declared return type
   ^^^^^^

which is handy in more complicated expressions, "ptype" does not:

  (gdb) ptype getenv ("PATH")
  function has unknown return type; cast the call to its declared return type
  ^^^^^^^^

This commit builds on the new OP_VAR_MSYM_VALUE to fix it, by making
OP_FUNCALL extract the function name from the symbol stored in
OP_VAR_VALUE/OP_VAR_MSYM_VALUE.  We now get the same error in "print"
vs "ptype":

  (gdb) ptype getenv()
  'getenv' has unknown return type; cast the call to its declared return type
  (gdb) p getenv()
  'getenv' has unknown return type; cast the call to its declared return type

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* eval.c (evaluate_subexp_standard): <OP_FUNCALL>: Extract
	function name from symbol/minsym and pass it to
	error_call_unknown_return_type.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/nodebug.exp: Test that ptype's error about functions
	with unknown return type includes the function name too.
2017-09-04 20:21:14 +01:00
Pedro Alves 74ea4be48e Introduce OP_VAR_MSYM_VALUE
The previous patch left GDB with an inconsistency.  While with normal
expression evaluation the "unknown return type" error shows the name
of the function that misses debug info:

  (gdb) p getenv ("PATH")
  'getenv' has unknown return type; cast the call to its declared return type
   ^^^^^^

which can by handy in more complicated expressions, "ptype" does not:

  (gdb) ptype getenv ("PATH")
  function has unknown return type; cast the call to its declared return type
  ^^^^^^^^

This commit is a step toward fixing it.

The problem is that while evaluating the expression above, we have no
reference to the minimal symbol where we could extract the name from.
This is because the resulting expression tree has no reference to the
minsym at all.  During parsing, the type and address of the minsym are
extracted and an UNOP_MEMVAL / UNOP_MEMVAL_TLS operator is generated
(see write_exp_elt_msym).  With "set debug expression", here's what
you see:

            0  OP_FUNCALL            Number of args: 0
            3    UNOP_MEMVAL           Type @0x565334a51930 (<text variable, no debug info>)
            6      OP_LONG               Type @0x565334a51c60 (__CORE_ADDR), value 140737345035648 (0x7ffff7751d80)

The "print" case finds the function name, because
call_function_by_hand looks up the function by address again.
However, for "ptype", we don't reach that code, because obviously we
don't really call the function.

Unlike minsym references, references to variables with debug info have
a pointer to the variable's symbol in the expression tree, with
OP_VAR_VALUE:

  (gdb) ptype main()
  ...
            0  OP_FUNCALL            Number of args: 0
            3    OP_VAR_VALUE          Block @0x0, symbol @0x559bbbd9b358 (main(int, char**))
  ...

so I don't see why do minsyms need to be different.  So to prepare for
fixing the missing function name issue, this commit adds a new
OP_VAR_MSYM_VALUE operator that mimics OP_VAR_VALUE, except that it's
for minsyms instead of debug symbols.  For infcalls, we now get
expressions like these:

            0  OP_FUNCALL            Number of args: 0
            3    OP_VAR_MSYM_VALUE     Objfile @0x1e41bf0, msymbol @0x7fffe599b000 (getenv)

In the following patch, we'll make OP_FUNCALL extract the function
name from the symbol stored in OP_VAR_VALUE/OP_VAR_MSYM_VALUE.

OP_VAR_MSYM_VALUE will be used more in a later patch in the series
too.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (resolve_subexp): Handle OP_VAR_MSYM_VALUE.
	* ax-gdb.c (gen_msym_var_ref): New function.
	(gen_expr): Handle OP_VAR_MSYM_VALUE.
	* eval.c (evaluate_var_msym_value): New function.
	* eval.c (evaluate_subexp_standard): Handle OP_VAR_MSYM_VALUE.
	<OP_FUNCALL>: Extract function name from symbol/minsym and pass it
	to call_function_by_hand.
	* expprint.c (print_subexp_standard, dump_subexp_body_standard):
	Handle OP_VAR_MSYM_VALUE.
	(union exp_element) <msymbol>: New field.
	* minsyms.h (struct type): Forward declare.
	(find_minsym_type_and_address): Declare.
	* parse.c (write_exp_elt_msym): New function.
	(write_exp_msymbol): Delete, refactored as ...
	(find_minsym_type_and_address): ... this new function.
	(write_exp_msymbol): Reimplement using OP_VAR_MSYM_VALUE.
	(operator_length_standard, operator_check_standard): Handle
	OP_VAR_MSYM_VALUE.
	* std-operator.def (OP_VAR_MSYM_VALUE): New.
2017-09-04 20:21:13 +01:00
Pedro Alves 7022349d5c Stop assuming no-debug-info functions return int
The fact that GDB defaults to assuming that functions return int, when
it has no debug info for the function has been a recurring source of
user confusion.  Recently this came up on the errno pretty printer
discussions.  Shortly after, it came up again on IRC, with someone
wondering why does getenv() in GDB return a negative int:

  (gdb) p getenv("PATH")
  $1 = -6185

This question (with s/getenv/random-other-C-runtime-function) is a FAQ
on IRC.

The reason for the above is:

 (gdb) p getenv
 $2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv>
 (gdb) ptype getenv
 type = int ()

... which means that GDB truncated the 64-bit pointer that is actually
returned from getent to 32-bit, and then sign-extended it:

 (gdb) p /x -6185
 $6 = 0xffffe7d7

The workaround is to cast the function to the right type, like:

 (gdb) p ((char *(*) (const char *)) getenv) ("PATH")
 $3 = 0x7fffffffe7d7 "/usr/local/bin:/"...

IMO, we should do better than this.

I see the "assume-int" issue the same way I see printing bogus values
for optimized-out variables instead of "<optimized out>" -- I'd much
rather that the debugger tells me "I don't know" and tells me how to
fix it than showing me bogus misleading results, making me go around
tilting at windmills.

If GDB prints a signed integer when you're expecting a pointer or
aggregate, you at least have some sense that something is off, but
consider the case of the function actually returning a 64-bit integer.
For example, compile this without debug info:

 unsigned long long
 function ()
 {
   return 0x7fffffffffffffff;
 }

Currently, with pristine GDB, you get:

 (gdb) p function ()
 $1 = -1                      # incorrect
 (gdb) p /x function ()
 $2 = 0xffffffff              # incorrect

maybe after spending a few hours debugging you suspect something is
wrong with that -1, and do:

 (gdb) ptype function
 type = int ()

and maybe, just maybe, you realize that the function actually returns
unsigned long long.  And you try to fix it with:

(gdb) p /x (unsigned long long) function ()
 $3 = 0xffffffffffffffff      # incorrect

... which still produces the wrong result, because GDB simply applied
int to unsigned long long conversion.  Meaning, it sign-extended the
integer that it extracted from the return of the function, to 64-bits.

and then maybe, after asking around on IRC, you realize you have to
cast the function to a pointer of the right type, and call that.  It
won't be easy, but after a few missteps, you'll get to it:

.....  (gdb) p /x ((unsigned long long(*) ()) function) ()
 $666 = 0x7fffffffffffffff             # finally! :-)


So to improve on the user experience, this patch does the following
(interrelated) things:

 - makes no-debug-info functions no longer default to "int" as return
   type.  Instead, they're left with NULL/"<unknown return type>"
   return type.

    (gdb) ptype getenv
    type = <unknown return type> ()

 - makes calling a function with unknown return type an error.

    (gdb) p getenv ("PATH")
    'getenv' has unknown return type; cast the call to its declared return type

 - and then to make it easier to call the function, makes it possible
   to _only_ cast the return of the function to the right type,
   instead of having to cast the function to a function pointer:

    (gdb) p (char *) getenv ("PATH")                      # now Just Works
    $3 = 0x7fffffffe7d7 "/usr/local/bin:/"...

    (gdb) p ((char *(*) (const char *)) getenv) ("PATH")  # continues working
    $4 = 0x7fffffffe7d7 "/usr/local/bin:/"...

   I.e., it makes GDB default the function's return type to the type
   of the cast, and the function's parameters to the type of the
   arguments passed down.

After this patch, here's what you'll get for the "unsigned long long"
example above:

 (gdb) p function ()
 'function' has unknown return type; cast the call to its declared return type
 (gdb) p /x (unsigned long long) function ()
 $4 = 0x7fffffffffffffff     # correct!

Note that while with "print" GDB shows the name of the function that
has the problem:

  (gdb) p getenv ("PATH")
  'getenv' has unknown return type; cast the call to its declared return type

which can by handy in more complicated expressions, "ptype" does not:

  (gdb) ptype getenv ("PATH")
  function has unknown return type; cast the call to its declared return type

This will be fixed in the next patch.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle
	TYPE_GNU_IFUNC specially here.  Throw error if return type is
	unknown.
	* ada-typeprint.c (print_func_type): Handle functions with unknown
	return type.
	* c-typeprint.c (c_type_print_base): Handle functions and methods
	with unknown return type.
	* compile/compile-c-symbols.c (convert_symbol_bmsym)
	<mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol.
	* compile/compile-c-types.c: Include "objfiles.h".
	(convert_func): For functions with unknown return type, warn and
	default to int.
	* compile/compile-object-run.c (compile_object_run): Adjust call
	to call_function_by_hand_dummy.
	* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to
	call_function_by_hand.
	* eval.c (evaluate_subexp_standard): Adjust calls to
	call_function_by_hand.  Handle functions and methods with unknown
	return type.  Pass expect_type to call_function_by_hand.
	* f-typeprint.c (f_type_print_base): Handle functions with unknown
	return type.
	* gcore.c (call_target_sbrk): Adjust call to
	call_function_by_hand.
	* gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL
	return type instead of int.  Make nodebug_text_gnu_ifunc_symbol be
	an integer address type instead of nodebug.
	* guile/scm-value.c (gdbscm_value_call): Adjust call to
	call_function_by_hand.
	* infcall.c (error_call_unknown_return_type): New function.
	(call_function_by_hand): New "default_return_type" parameter.
	Pass it down.
	(call_function_by_hand_dummy): New "default_return_type"
	parameter.  Use it instead of defaulting to int.  If there's no
	default and the return type is unknown, throw an error.  If
	there's a default return type, and the called function has no
	debug info, then assume the function is prototyped.
	* infcall.h (call_function_by_hand, call_function_by_hand_dummy):
	New "default_return_type" parameter.
	(error_call_unknown_return_type): New declaration.
	* linux-fork.c (call_lseek): Cast return type of lseek.
	(inferior_call_waitpid, checkpoint_command): Adjust calls to
	call_function_by_hand.
	* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust
	calls to call_function_by_hand.
	* m2-typeprint.c (m2_procedure): Handle functions with unknown
	return type.
	* objc-lang.c (lookup_objc_class, lookup_child_selector)
	(value_nsstring, print_object_command): Adjust calls to
	call_function_by_hand.
	* p-typeprint.c (pascal_type_print_varspec_prefix): Handle
	functions with unknown return type.
	(pascal_type_print_func_varspec_suffix): New function.
	(pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC,
	TYPE_CODE_METHOD>: Use it.
	* python/py-value.c (valpy_call): Adjust call to
	call_function_by_hand.
	* rust-lang.c (rust_evaluate_funcall): Adjust call to
	call_function_by_hand.
	* valarith.c (value_x_binop, value_x_unop): Adjust calls to
	call_function_by_hand.
	* valops.c (value_allocate_space_in_inferior): Adjust call to
	call_function_by_hand.
	* typeprint.c (type_print_unknown_return_type): New function.
	* typeprint.h (type_print_unknown_return_type): New declaration.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
	return type of munmap in infcall.
	* gdb.base/break-probes.exp: Cast return type of foo in infcall.
	* gdb.base/checkpoint.exp: Simplify using for loop.  Cast return
	type of ftell in infcall.
	* gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
	type of getpid in infcall.
	* gdb.base/infcall-exec.exp: Cast return type of execlp in
	infcall.
	* gdb.base/info-os.exp: Cast return type of getpid in infcall.
	Bail on failure to extract the pid.
	* gdb.base/nodebug.c: #include <stdint.h>.
	(multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
	New functions.
	* gdb.base/nodebug.exp (test_call_promotion): New procedure.
	Change expected output of print/whatis/ptype with functions with
	no debug info.  Test all supported languages.  Call
	test_call_promotion.
	* gdb.compile/compile.exp: Adjust expected output to expect
	warning.
	* gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 20:21:13 +01:00
Pedro Alves 54990598c4 Fix calling prototyped functions via function pointers
Calling a prototyped function via a function pointer with the right
prototype doesn't work correctly, if the called function requires
argument coercion...  Like, e.g., with:

  float mult (float f1, float f2) { return f1 * f2; }

  (gdb) p mult (2, 3.5)
  $1 = 7
  (gdb) p ((float (*) (float, float)) mult) (2, 3.5)
  $2 = 0

both calls should have returned the same, of course.  The problem is
that GDB misses marking the type of the function pointer target as
prototyped...

Without the fix, the new test fails like this:

 (gdb) p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)
 $30 = 0
 (gdb) FAIL: gdb.base/callfuncs.exp: p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdbtypes.c (lookup_function_type_with_arguments): Mark function
	types with more than one parameter as prototyped.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/callfuncs.exp (do_function_calls): New parameter
	"prototypes".  Test calling float functions via prototyped and
	unprototyped function pointers.
	(perform_all_tests): New parameter "prototypes".  Pass it down.
	(top level): Pass down "prototypes" parameter to
	perform_all_tests.
2017-09-04 20:21:13 +01:00
Simon Marchi 34d16ea2a1 gdb.base/commands.exp: Test loop_break and loop_continue in nested loops
This patch improves the loop_break and loop_continue tests to verify
that they work as expected when multiple loops are nested (they affect
the inner loop).

gdb/testsuite/ChangeLog:

	* gdb.base/commands.exp (loop_break_test, loop_continue_test):
	Test with nested loops.
2017-09-04 21:19:17 +02:00
Pedro Alves 9a24775b97 Introduce gdb_disassembly_flags
For some reason I ended up staring at some of the "int flags" in
btrace-related code, and I got confused because I had no clue what the
flags where supposed to indicate.

Fix that by using enum_flags, so that:
  #1 - it's clear from the type what the flags are about, and
  #2 - the compiler can catch mismatching mistakes

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* cli/cli-cmds.c (print_disassembly, disassemble_current_function)
	(disassemble_command): Use gdb_disassembly_flags instead of bare
	int.
	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn)
	(dump_insns, do_mixed_source_and_assembly_deprecated)
	(do_mixed_source_and_assembly, do_assembly_only, gdb_disassembly):
	Use gdb_disassembly_flags instead of bare int.
	* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED, DISASSEMBLY_RAW_INSN)
	(DISASSEMBLY_OMIT_FNAME, DISASSEMBLY_FILENAME)
	(DISASSEMBLY_OMIT_PC, DISASSEMBLY_SOURCE)
	(DISASSEMBLY_SPECULATIVE): No longer macros.  Instead they're...
	(enum gdb_disassembly_flag): ... values of this new enumeration.
	(gdb_disassembly_flags): Define.
	(gdb_disassembly)
	(gdb_pretty_print_disassembler::pretty_print_insn): Use it.
	* mi/mi-cmd-disas.c (mi_cmd_disassemble): Use
	gdb_disassembly_flags instead of bare int.
	* record-btrace.c (btrace_insn_history)
	(record_btrace_insn_history, record_btrace_insn_history_range)
	(record_btrace_insn_history_from): Use gdb_disassembly_flags
	instead of bare int.
	* record.c (get_insn_history_modifiers, cmd_record_insn_history):
	Use gdb_disassembly_flags instead of bare int.
	* target-debug.h (target_debug_print_gdb_disassembly_flags):
	Define.
	* target-delegates.c: Regenerate.
	* target.c (target_insn_history, target_insn_history_from)
	(target_insn_history_range): Use gdb_disassembly_flags instead of
	bare int.
	* target.h: Include "disasm.h".
	(struct target_ops) <to_insn_history, to_insn_history_from,
	to_insn_history_range>: Use gdb_disassembly_flags instead of bare
	int.
	(target_insn_history, target_insn_history_from)
	(target_insn_history_range): Use gdb_disassembly_flags instead of
	bare int.
2017-09-04 18:23:22 +01:00
Simon Marchi 9521ecda68 Add tests for loop_break and loop_continue commands
I grepped the testsuite for loop_break and loop_continue and didn't find
anything, so I wrote some simple tests for those.

gdb/testsuite/ChangeLog:

	* gdb.base/commands.exp: Call the new procedures.
	(loop_break_test, loop_continue_test): New procedures.
2017-09-04 19:15:59 +02:00
Simon Marchi 80a65e9b8f Error out immediatly when using if command without args in command list
When using "if" (or while) without args directly on gdb's command line,
you get this:

  (gdb) if
  if/while commands require arguments

When doing the same when entering a command list, you only get an error
when the command is executed, when parse_exp_in_context_1 fails to
evaluate the expression.

  (gdb) define foo
  Type commands for definition of "foo".
  End with a line saying just "end".
  >if
   >end
  >end
  (gdb) foo
  Argument required (expression to compute).

I think it would make more sense to error out when inputting the command
list directly:

  (gdb) define foo
  Type commands for definition of "foo".
  End with a line saying just "end".
  >if
  if/while commands require arguments.

The only required change is to check whether args is an empty string in
build_command_line.

gdb/ChangeLog:

	* cli/cli-script.c (build_command_line): For if/while commands,
	check whether args is empty.

gdb/testsuite/ChangeLog:

	* gdb.base/commands.exp: Call new procedure.
	(define_if_without_arg_test): New procedure.
2017-09-04 19:13:48 +02:00
Simon Marchi 6b66338c70 Move command lines types/declarations to cli-script.h
I think it would make more sense if the types and function declarations
related to command lines were in cli-script.h rather than defs.h, since
the related function definitions are in cli-script.c.

I had to add a few includes here and there.  I also had to rename the
"lines" parameter of command_lines_deleter::operator(), because ncurses
has a "#define lines ..." that was interfering when cli-script.h is
included by some TUI source files that also include ncurses header files.

gdb/ChangeLog:

	* cli/cli-script.h (enum misc_command_type): Move from defs.h.
	(enum command_control_type): Likewise.
	(struct command_line): Likewise.
	(free_command_lines): Likewise.
	(struct command_lines_deleter): Likewise.
	(command_line_up): Likewise.
	(read_command_lines): Likewise.
	(read_command_lines_1): Likewise.
	* defs.h (enum misc_command_type): Move to cli/cli-script.h.
	(enum command_control_type): Likewise.
	(struct command_line): Likewise.
	(free_command_lines): Likewise.
	(struct command_lines_deleter): Likewise.
	(command_line_up): Likewise.
	(read_command_lines): Likewise.
	(read_command_lines_1): Likewise.
	* breakpoint.h: Include cli/cli-script.h.
	* extension-priv.h: Likewise.
	* gdbcmd.h: Likewise.
2017-09-04 19:09:12 +02:00
Simon Marchi 50a421ac3a gdbserver Makefile: don't delete intermediary files
If you "make" from scratch in gdbserver/, you'll notice that make
deletes the files it considers as intermediary at the end:

  $ make clean && make
  ...
  rm i386-mmx-linux-generated.c x32-avx-avx512-linux-generated.c ...

Then, if you type make again, make will rebuild these files and rebuild
gdbserver.  To avoid this, we can add the .SECONDARY special target.  If
it has no pre-requisites, all intermediary files will be kept.

gdb/gdbserver/ChangeLog:

	* Makefile.in (.SECONDARY): Define target.
2017-09-04 19:02:56 +02:00
Pedro Alves 51abb42130 Kill init_sal
Instead, make symtab_and_line initialize its members itself.  Many
symtab_and_line declarations are moved to where the object is
initialized at the same time both for clarity and to avoid double
initialization.  A few functions, like e.g., find_frame_sal are
adjusted to return the sal using normal function return instead of an
output parameter likewise to avoid having to default-construct a sal
and then immediately have the object overwritten.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (is_known_support_routine): Move sal declaration to
	where it is initialized.
	* breakpoint.c (create_internal_breakpoint, init_catchpoint)
	(parse_breakpoint_sals, decode_static_tracepoint_spec)
	(clear_command, update_static_tracepoint): Remove init_sal
	references.  Move declarations closer to initializations.
	* cli/cli-cmds.c (list_command): Move sal declarations closer to
	initializations.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Remove init_sal
	references.  Move sal declarations closer to initializations.
	* frame.c (find_frame_sal): Return a symtab_and_line via function
	return instead of output parameter.  Remove init_sal references.
	* frame.h (find_frame_sal): Return a symtab_and_line via function
	return instead of output parameter.
	* guile/scm-frame.c (gdbscm_frame_sal): Adjust.
	* guile/scm-symtab.c (stscm_make_sal_smob): Use in-place new
	instead of memset.
	(gdbscm_find_pc_line): Remove init_sal reference.
	* infcall.c (call_function_by_hand_dummy): Remove init_sal
	references.  Move declarations closer to initializations.
	* infcmd.c (set_step_frame): Update.  Move declarations closer to
	initializations.
	(finish_backward): Remove init_sal references.  Move declarations
	closer to initializations.
	* infrun.c (process_event_stop_test, handle_step_into_function)
	(insert_hp_step_resume_breakpoint_at_frame)
	(insert_step_resume_breakpoint_at_caller): Likewise.
	* linespec.c (create_sals_line_offset, decode_digits_ordinary)
	(symbol_to_sal): Likewise.
	* probe.c (parse_probes_in_pspace): Remove init_sal reference.
	* python/py-frame.c (frapy_find_sal): Move sal declaration closer
	to its initialization.
	* reverse.c (save_bookmark_command): Use new/delete.  Remove
	init_sal references.  Move declarations closer to initializations.
	* source.c (get_current_source_symtab_and_line): Remove brace
	initialization.
	(set_current_source_symtab_and_line): Now takes the sal by const
	reference.  Remove brace initialization.
	(line_info): Remove init_sal reference.
	* source.h (set_current_source_symtab_and_line): Now takes a
	symtab_and_line via const reference.
	* stack.c (set_current_sal_from_frame): Adjust.
	(print_frame_info): Adjust.
	(get_last_displayed_sal): Return the sal via function return
	instead of via output parameter.  Simplify.
	(frame_info): Adjust.
	* stack.h (get_last_displayed_sal): Return the sal via function
	return instead of via output parameter.
	* symtab.c (init_sal): Delete.
	(find_pc_sect_line): Remove init_sal references.  Move
	declarations closer to initializations.
	(find_function_start_sal): Remove init_sal references.  Move
	declarations closer to initializations.
	* symtab.h (struct symtab_and_line): In-class initialize all
	fields.
	* tracepoint.c (set_traceframe_context)
	(print_one_static_tracepoint_marker): Remove init_sal references.
	Move declarations closer to initializations.
	* tui/tui-disasm.c (tui_show_disassem_and_update_source): Adjust.
	* tui/tui-stack.c (tui_show_frame_info): Adjust.  Move
	declarations closer to initializations.
	* tui/tui-winsource.c (tui_update_source_window_as_is): Remove
	init_sal references.  Adjust.
2017-09-04 17:11:45 +01:00
Pedro Alves 6c5b2ebeac struct symtabs_and_lines -> std::vector<symtab_and_line>
This replaces "struct symtabs_and_lines" with
std::vector<symtab_and_line> in most cases.  This removes a number of
cleanups.

In some cases, the sals objects do not own the sals they point at.
Instead they point at some sal that lives on the stack.  Typically
something like this:

  struct symtab_and_line sal;
  struct symtabs_and_lines sals;

  // fill in sal

  sals.nelts = 1;
  sals.sals = &sal;

  // use sals

Instead of switching those cases to std::vector too, such usages are
replaced by gdb::array_view<symtab_and_line> instead.  This avoids
introducing heap allocations.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* ax-gdb.c (agent_command_1): Use range-for.
	* break-catch-throw.c (re_set_exception_catchpoint): Update.
	* breakpoint.c: Include "common/array-view.h".
	(init_breakpoint_sal, create_breakpoint_sal): Change sals
	parameter from struct symtabs_and_lines to
	array_view<symtab_and_line>.  Adjust.  Use range-for.  Update.
	(breakpoint_sals_to_pc): Change sals parameter from struct
	symtabs_and_lines to std::vector reference.
	(check_fast_tracepoint_sals): Change sals parameter from struct
	symtabs_and_lines to std::array_view.  Use range-for.
	(decode_static_tracepoint_spec): Return a std::vector instead of
	symtabs_and_lines.  Update.
	(create_breakpoint): Update.
	(break_range_command, until_break_command, clear_command): Update.
	(base_breakpoint_decode_location, bkpt_decode_location)
	(bkpt_probe_create_sals_from_location)
	(bkpt_probe_decode_location, tracepoint_decode_location)
	(tracepoint_probe_decode_location)
	(strace_marker_create_sals_from_location): Return a std::vector
	instead of symtabs_and_lines.
	(strace_marker_create_breakpoints_sal): Update.
	(strace_marker_decode_location): Return a std::vector instead of
	symtabs_and_lines.  Update.
	(update_breakpoint_locations): Change struct symtabs_and_lines
	parameters to gdb::array_view.  Adjust.
	(location_to_sals): Return a std::vector instead of
	symtabs_and_lines.  Update.
	(breakpoint_re_set_default): Use std::vector instead of struct
	symtabs_and_lines.
	(decode_location_default): Return a std::vector instead of
	symtabs_and_lines.  Update.
	* breakpoint.h: Include "common/array-view.h".
	(struct breakpoint_ops) <decode_location>: Now returns a
	std::vector instead of returning a symtabs_and_lines via output
	parameter.
	(update_breakpoint_locations): Change sals parameters to use
	gdb::array_view.
	* cli/cli-cmds.c (edit_command, list_command): Update to use
	std::vector and gdb::array_view.
	(ambiguous_line_spec): Adjust to use gdb::array_view and
	range-for.
	(compare_symtabs): Rename to ...
	(cmp_symtabs): ... this.  Change parameters to symtab_and_line
	const reference and adjust.
	(filter_sals): Rewrite using std::vector and standard algorithms.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Simplify.
	(jump_command): Update to use std::vector.
	* linespec.c (struct linespec_state) <canonical_names>: Update
	comment.
	(add_sal_to_sals_basic): Delete.
	(add_sal_to_sals, filter_results, convert_results_to_lsals)
	(decode_line_2, create_sals_line_offset)
	(convert_address_location_to_sals, convert_linespec_to_sals)
	(convert_explicit_location_to_sals, parse_linespec)
	(event_location_to_sals, decode_line_full, decode_line_1)
	(decode_line_with_current_source)
	(decode_line_with_last_displayed, decode_objc)
	(decode_digits_list_mode, decode_digits_ordinary, minsym_found)
	(linespec_result::~linespec_result): Adjust to use std::vector
	instead of symtabs_and_lines.
	* linespec.h (linespec_sals::sals): Now a std::vector.
	(struct linespec_result): Use std::vector, bool, and in-class
	initialization.
	(decode_line_1, decode_line_with_current_source)
	(decode_line_with_last_displayed): Return std::vector.
	* macrocmd.c (info_macros_command): Use std::vector.
	* mi/mi-main.c (mi_cmd_trace_find): Use std::vector.
	* probe.c (parse_probes_in_pspace, parse_probes): Adjust to use
	std::vector.
	* probe.h (parse_probes): Return a std::vector.
	* python/python.c (gdbpy_decode_line): Use std::vector and
	gdb::array_view.
	* source.c (select_source_symtab, line_info): Use std::vector.
	* stack.c (func_command): Use std::vector.
	* symtab.h (struct symtabs_and_lines): Delete.
	* tracepoint.c (tfind_line_command, scope_info): Use std::vector.
2017-09-04 17:11:15 +01:00
Pedro Alves 7c44b49cb6 Introduce gdb::array_view
An array_view is an abstraction that provides a non-owning view over a
sequence of contiguous objects.

A way to put it is that array_view is to std::vector (and std::array
and built-in arrays with rank==1) like std::string_view is to
std::string.

The main intent of array_view is to use it as function input parameter
type, making it possible to pass in any sequence of contiguous
objects, irrespective of whether the objects live on the stack or heap
and what actual container owns them.  Implicit construction from the
element type is supported too, making it easy to call functions that
expect an array of elements when you only have one element (usually on
the stack).  For example:

 struct A { .... };
 void function (gdb::array_view<A> as);

 std::vector<A> std_vec = ...;
 std::array<A, N> std_array = ...;
 A array[] = {...};
 A elem;

 function (std_vec);
 function (std_array);
 function (array);
 function (elem);

Views can be either mutable or const.  A const view is simply created
by specifying a const T as array_view template parameter, in which
case operator[] of non-const array_view objects ends up returning
const references.  (Making the array_view itself const is analogous to
making a pointer itself be const.  I.e., disables re-seating the
view/pointer.)  Normally functions will pass around array_views by
value.

Uses of gdb::array_view (other than the ones in the unit tests) will
be added in a follow up patch.

gdb/ChangeLog
2017-09-04  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/array-view-selftests.c.
	(SUBDIR_UNITTESTS_OBS): Add array-view-selftests.o.
	* common/array-view.h: New file.
	* unittests/array-view-selftests.c: New file.
2017-09-04 17:10:12 +01:00
Pedro Alves e439fa140a Clarify "list" output when specified lines are ambiguous
Currently, with "list LINESPEC1,LINESPEC2", if one of the linespecs is
ambiguous, i.e., if it expands to multiple locations, you get this
seemingly odd output:

 (gdb) list foo,bar
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

Since "foo" above expands to multiple locations, the specified range
is indeterminate, and GDB is trying to be helpful by showing you what
was ambiguous.  It looks confusing to me, though.  I think it'd be
much more user friendly if GDB actually told you that, like this:

 (gdb) list foo,bar
 Specified first line 'foo' is ambiguous:
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

 (gdb) list bar,foo
 Specified last line 'foo' is ambiguous:
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

Note, I'm using "first" and "last" in the output because that's what
the manual uses:

 ~~~
 list first,last

     Print lines from first to last. [...]
 ~~~

Tested on x86-64 GNU/Linux.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* cli/cli-cmds.c (edit_command): Pass message to
	ambiguous_line_spec.
	(list_command): Pass message to ambiguous_line_spec.  Say
	"first"/"last" instead of "start" and "end" to be consistent with
	the manual.
	(ambiguous_line_spec): Add 'format' and vararg parameters.  Use
	them to print formatted message.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/list-ambiguous.exp: New file.
	* gdb.base/list-ambiguous0.c: New file.
	* gdb.base/list-ambiguous1.c: New file.
	* gdb.base/list.exp (test_list_range): Adjust expected output.
2017-09-04 16:49:29 +01:00
Pedro Alves 7525b645df Fix build breakage when libipt is available
Fix build regression introduced by 0860c437cb ("btrace: Store
btrace_insn in an std::vector"):

  src/gdb/btrace.c: In function ‘void ftrace_add_pt(btrace_thread_info*, pt_insn_decoder*, int*, std::vector<unsigned int>&)’:
  src/gdb/btrace.c:1329:38: error: invalid initialization of reference of type ‘const btrace_insn&’ from expression of type ‘btrace_insn*’
      ftrace_update_insns (bfun, &btinsn);
					^
  src/gdb/btrace.c:648:1: note: in passing argument 2 of ‘void ftrace_update_insns(btrace_function*, const btrace_insn&)’
   ftrace_update_insns (struct btrace_function *bfun, const btrace_insn &insn)
   ^

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* btrace.c (ftrace_add_pt): Pass btrace_insn to
	ftrace_update_insns by reference instead of pointer.
2017-09-04 16:01:17 +01:00
Yao Qi badc002020 Let i386_target_description return tdesc_i386_mmx
This patch remove the usage of tdesc_i386_mmx in i386-go32-tdep.c, and use
i386_target_description to get it instead.

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* i386-go32-tdep.c: Include x86-xstate.h.
	(i386_go32_init_abi): Call i386_target_description.
	* i386-tdep.c (i386_target_description): Return tdesc_i386_mmx
	if xcr0 is X86_XSTATE_X87_MASK.
	* i386-tdep.h (tdesc_i386): Remove the declaration.
	(tdesc_i386_mmx): Likewise.
2017-09-04 11:33:56 +01:00
Yao Qi d78bdb54ac Return X86_XSTATE_SSE_MASK instead of 0 in i386fbsd_core_read_xcr0
i386fbsd_core_read_xcr0 reads the value of xcr0 from the corefile.  If
it fails, returns 0.  This makes its caller {i386,amd64}_target_description
has to handle this special value.  IMO, i386fbsd_core_read_xcr0 should
return the default xcr0 in case of error.

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* i386-fbsd-tdep.c (i386fbsd_core_read_xcr0): Return
	X86_XSTATE_SSE_MASK instead of 0.
2017-09-04 11:33:56 +01:00
Yao Qi ca1fa5eef2 Use i386_target_description to get tdesc_i386
GDB can call function i386_target_description to get the right target
description rather than tdesc_i386

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* amd64-fbsd-nat.c (amd64fbsd_read_description): Call
	i386_target_description.
	* i386-fbsd-nat.c (i386fbsd_read_description): Call
	i386_target_description.
	* i386-tdep.c (i386_gdbarch_init): Likewise.
2017-09-04 11:33:56 +01:00
Yao Qi 2434b0199d Use amd64_target_description to get tdesc_amd64
This patch changes amd64-*-tdep.c files to use function
amd64_target_description to get the right target description rather than
use the variable tdesd_amd64.

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* amd64-darwin-tdep.c: Include "x86-xstate.h".
	(x86_darwin_init_abi_64): Call amd64_target_description.
	* amd64-dicos-tdep.c: Likewise.
	* amd64-fbsd-nat.c: Likewise.
	* amd64-fbsd-tdep.c: Likewise.
	* amd64-nbsd-tdep.c: Likewise.
	* amd64-obsd-tdep.c: Likewise.
	* amd64-sol2-tdep.c: Likewise.
	* amd64-windows-tdep.c: Likewise.
	* amd64-tdep.h (tdesc_amd64): Remove the declaration.
2017-09-04 11:33:56 +01:00
Simon Marchi 0860c437cb btrace: Store btrace_insn in an std::vector
Because it contains a non-POD type field (flags), the type btrace_insn
should be new'ed/delete'd.  Replace the VEC (btrace_insn_s) in
btrace_function with an std::vector.

gdb/ChangeLog:

	* btrace.h (btrace_insn_s, DEF_VEC_O (btrace_insn_s)): Remove.
	(btrace_function) <insn>: Change type to use std::vector.
	* btrace.c (ftrace_debug, ftrace_call_num_insn,
	ftrace_find_call, ftrace_new_gap, ftrace_update_function,
	ftrace_update_insns, ftrace_compute_global_level_offset,
	btrace_stitch_bts, btrace_clear, btrace_insn_get,
	btrace_insn_end, btrace_insn_next, btrace_insn_prev): Adjust to
	change to std::vector.
	(ftrace_update_insns): Adjust to change to std::vector, change
	type of INSN parameter.
	(btrace_compute_ftrace_bts): Adjust call to ftrace_update_insns.
	* record-btrace.c (btrace_call_history_insn_range,
	btrace_compute_src_line_range,
	record_btrace_frame_prev_register): Adjust to change to
	std::vector.
	* python/py-record-btrace.c (recpy_bt_func_instructions): Adjust
	to change to std::vector.
2017-09-04 10:46:36 +02:00
Tom Tromey 0638b7f902 Use std::string in reopen_exec_file
This changes reopen_exec_file to use a std::string, removing a
cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* corefile.c (reopen_exec_file): Use std::string.
2017-09-03 13:03:11 -06:00
Tom Tromey 8f84fb0ee8 Use std::string and unique_xmalloc_ptr in compile/ code
Change various things in the compile/ code to use std::string or
unique_xmalloc_ptr as appropriate.  This allows the removal of some
cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* compile/compile.c (compile_register_name_mangled): Return
	std::string.
	* compile/compile-loc2c.c (pushf_register_address): Update.
	(pushf_register): Update.
	* compile/compile-c-types.c (convert_array): Update.
	* compile/compile-c-symbols.c (generate_vla_size): Update.
	(error_symbol_once): Use a gdb::unique_xmalloc_ptr.
	(symbol_substitution_name): Return a gdb::unique_xmalloc_ptr.
	(convert_one_symbol): Update.
	(generate_c_for_for_one_variable): Update.
	* compile/compile-c-support.c (c_get_range_decl_name): Return a
	std::string.
	(generate_register_struct): Update.
	* compile/compile-internal.h (c_get_range_decl_name): Return a
	std::string.
	(compile_register_name_mangled): Return std::string.
2017-09-03 13:03:10 -06:00
Tom Tromey 18e9961f02 Return std::string from perror_string
Change perror_string to return a std::string, removing a cleanup in
the process.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* utils.c (perror_string): Return a std::string.
	(throw_perror_with_name, perror_warning_with_name): Update.
2017-09-03 13:03:09 -06:00
Tom Tromey 453437863c Use std::string and unique_xmalloc_ptr in demangle_command
Change demangle_command to use std::string and unique_xmalloc_ptr,
removing some cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* demangle.c (demangle_command): Use std::string,
	unique_xmalloc_ptr.
2017-09-03 13:03:08 -06:00
Tom Tromey b57af50345 Use std::string in do_set_command
Change do_set_command to use std::string, removing a cleanup and some
manual resizing code.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* cli/cli-setshow.c (do_set_command): Use std::string.
2017-09-03 13:03:07 -06:00
Tom Tromey 6eecf35f97 Use unique_xmalloc_ptr in cd_command
Change cd_command to use unique_xmalloc_ptr, removing a cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* cli/cli-cmds.c (cd_command): Use gdb::unique_xmalloc_ptr.
2017-09-03 13:03:06 -06:00