Commit Graph

35935 Commits

Author SHA1 Message Date
Pedro Alves 68c14faada target.h: Include infrun.h
Fixes:

  src/gdb/target.h:753:10: error: use of enum ‘exec_direction_kind’ without previous declaration

in C++ mode.  We can't forward declare enums.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* target.h: Include "infrun.h".
2015-02-27 17:28:49 +00:00
Pedro Alves 749bab0110 proc-service, extern "C"
libthread_db.so calls symbols in the client (GDB), through the
proc-service interface.  These routines must have extern "C" linkage
so their symbol names are not mangled when GDB is built as a C++
program.  On the GDBserver side, we were missing fallback declarations for
all these symbols.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.

gdb/gdbserver/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
	[!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare.
	[!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread)
	ps_ptwrite, ps_lgetregs, ps_lsetregs, ps_lgetfpregs)
	(ps_lsetfpregs, ps_getpid)
	(ps_get_thread_area, ps_pglobal_lookup, ps_pstop, ps_pcontinue)
	(ps_lstop, ps_lcontinue, ps_lgetxregsize, ps_lgetxregs)
	(ps_lsetxregs, ps_plog): Declare.
2015-02-27 17:28:11 +00:00
Pedro Alves 3c14e5a39b Make functions and variables exported by the IPA be extern "C"
Functions and variables that are exported by the IPA DSO (that
GDBserver needs to look up) should have "C" mangling, thus be declared
with extern "C".

Function and variable declarations need the extern "C" marker, but
variable definitions can't be marked extern, so the patch splits
IP_AGENT_EXPORT into three.

Building in C++ mode revealed that a few variables were missing
IP_AGENT_EXPORT, thus the IPA has been broken when stripped, even in C
mode...  So this ends being a bug fix as well.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* common/agent.h (IPA_SYM_EXPORTED_NAME): New.
	(IPA_SYM): Use it.
	* common/common-defs.h (EXTERN_C_PUSH, EXTERN_C_POP): New macros.

gdb/gdbserver/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* linux-amd64-ipa.c (gdb_agent_get_raw_reg): Use
	IP_AGENT_EXPORT_FUNC.
	* linux-i386-ipa.c (gdb_agent_get_raw_reg): Use
	IP_AGENT_EXPORT_FUNC.
	* tracepoint.c (ATTR_USED, ATTR_NOINLINE, ATTR_CONSTRUCTOR)
	(IP_AGENT_EXPORT): Delete.
	(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
	(gdb_trampoline_buffer, gdb_trampoline_buffer_end)
	(gdb_trampoline_buffer_error, collecting, gdb_collect)
	(stop_tracing, flush_trace_buffer, about_to_request_buffer_space)
	(trace_buffer_is_full, stopping_tracepoint, expr_eval_result)
	(error_tracepoint, tracepoints, tracing, trace_buffer_ctrl)
	(trace_buffer_ctrl_curr, trace_buffer_lo, trace_buffer_hi)
	(traceframe_read_count, traceframe_write_count)
	(traceframes_created, trace_state_variables, get_raw_reg)
	(get_trace_state_variable_value, set_trace_state_variable_value)
	(ust_loaded, helper_thread_id, cmd_buf): Use
	IPA_SYM_EXPORTED_NAME.
	(stop_tracing, flush_trace_buffer): Use IP_AGENT_EXPORT_FUNC.
	(tracepoints) Use IP_AGENT_EXPORT_VAR.
	(stopping_tracepoint, trace_buffer_is_full, expr_eval_result): Use
	IP_AGENT_EXPORT_VAR and wrap in EXTERN_C_PUSH/EXTERN_C_POP.
	(last_tracepoint): Move into !IN_PROCESS_AGENT block.
	(error_tracepoint): Use IP_AGENT_EXPORT_VAR and wrap in
	EXTERN_C_PUSH/EXTERN_C_POP.
	(trace_state_variables): Use IP_AGENT_EXPORT_VAR.
	(trace_buffer_lo, trace_buffer_hi): Use IP_AGENT_EXPORT_VAR and
	wrap in EXTERN_C_PUSH/EXTERN_C_POP.
	(trace_buffer_ctrl, trace_buffer_ctrl_curr)
	(traceframe_write_count, traceframe_read_count)
	(traceframes_created, tracing): Use IP_AGENT_EXPORT_VAR.
	(about_to_request_buffer_space, get_trace_state_variable_value)
	(set_trace_state_variable_value): Use IP_AGENT_EXPORT_FUNC.
	(collecting): Use IP_AGENT_EXPORT_VAR and wrap in
	EXTERN_C_PUSH/EXTERN_C_POP.
	(gdb_collect): Use IP_AGENT_EXPORT_FUNC.
	(ust_loaded, cmd_buf): Use IP_AGENT_EXPORT_VAR.
	(helper_thread_id, gdb_agent_capability): Use IP_AGENT_EXPORT_VAR
	and wrap in EXTERN_C_PUSH/EXTERN_C_POP.
	(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
	(gdb_trampoline_buffer, gdb_trampoline_buffer_end)
	(gdb_trampoline_buffer_error): Use IP_AGENT_EXPORT_VAR.
	* tracepoint.h (ATTR_USED, ATTR_NOINLINE, EXPORTED_SYMBOL):
	Define.
	(IP_AGENT_EXPORT_FUNC, IP_AGENT_EXPORT_VAR)
	(IP_AGENT_EXPORT_VAR_DECL): Define.
	(tracing): Declare.
	(gdb_agent_get_raw_reg): Declare.
2015-02-27 17:27:29 +00:00
Pedro Alves 56000a9801 Add extern "C" to declarations of C symbols
These symbols are defined in C code, so in C++ mode we need to use
extern "C" to declare them.  As extern "C" can't be used inside a
function's scope, we move the declarations to the global scope at the
same time.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* cli-out.c (_rl_erase_entire_line): Move declaration out of
	cli_mld_erase_entire_line, and make it extern "C".
	* common/common-defs.h (EXTERN_C): New.
	* completer.c (_rl_completion_prefix_display_length)
	(_rl_print_completions_horizontally, QSFUNC): Move declarations
	out of gdb_display_match_list_1.
	(_rl_qsort_string_compare): Move declaration out of
	gdb_display_match_list_1, and make it extern "C".
	* defs.h (re_comp): Use EXTERN_C.
	* maint.c (_mcleanup): Move declaration out of mcleanup_wrapper,
	and make it extern "C".
	(monstartup): Move declaration out of maintenance_set_profile_cmd,
	and make it extern "C".
	(main): Move declaration out of maintenance_set_profile_cmd.
	* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason_string): Use
	EXTERN_C.
2015-02-27 17:26:16 +00:00
Pedro Alves bcabf4207e Make array object extern
Compiling python.c in C++ mode, we get:

  ...src/gdb/python/python.c: At global scope:
  ...src/gdb/python/python.c:106:31: error: storage size of ‘GdbMethods’ isn’t known
   static PyMethodDef GdbMethods[];
				 ^

Fix it by making the affected array objects extern.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* python/python.c (GdbMethods): Rename to ...
	(python_GdbMethods): ... this and make extern.
	(GdbModuleDef): Rename to ...
	(python_GdbModuleDef): ... this and make extern.
2015-02-27 17:25:45 +00:00
Pedro Alves 928dbe0756 record-btrace.c: Remove redefinitions
The set_record_btrace_cmdlist and show_record_btrace_cmdlist objects
are declared twice in the file, seemingly a simply copy/paste
oversight.  In C, the first time counts as forward declaration, but in
C++, they are all definitions.  That results in:

 src/gdb/record-btrace.c:80:33: error: redefinition of ‘cmd_list_element* set_record_btrace_cmdlist’
 src/gdb/record-btrace.c:61:33: error: ‘cmd_list_element* set_record_btrace_cmdlist’ previously declared here
 src/gdb/record-btrace.c:81:33: error: redefinition of ‘cmd_list_element* show_record_btrace_cmdlist’
 src/gdb/record-btrace.c:62:33: error: ‘cmd_list_element* show_record_btrace_cmdlist’ previously declared here

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* record-btrace.c (set_record_btrace_cmdlist)
	(show_record_btrace_cmdlist): Remove redefinitions.
 ---

 gdb/record-btrace.c |    4 ----
 1 file changed, 4 deletions(-)
2015-02-27 17:25:23 +00:00
Tom Tromey 52059ffd69 Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place.  However, in C++, such a nested structure is given a name that
is nested inside the structure.  This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.

gdb/ChangeLog:
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* dwarf2-frame.c (enum cfa_how_kind, struct
	dwarf2_frame_state_reg_info): Move out of struct
	dwarf2_frame_state.
	* dwarf2read.c (struct tu_stats): Move out of struct
	dwarf2_per_objfile.
	(struct file_entry): Move out of struct line_header.
	(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
	typedef_field_list): Move out of struct field_info.
	* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
	Move out of struct dynamic_prop.
	(union type_owner, union field_location, struct field, struct
	range_bounds, union type_specific): Move out of struct main_type.
	(struct fn_fieldlist, struct fn_field, struct typedef_field)
	(VOFFSET_STATIC): Move out of struct cplus_struct_type.
	(struct call_site_target, union call_site_parameter_u, struct
	call_site_parameter): Move out of struct call_site.
	* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
	m32c_prologue.
	(enum srcdest_kind): Move out of struct srcdest.
	* main.c (enum cmdarg_kind): Move out of struct cmdarg.
	* prologue-value.h (enum prologue_value_kind): Move out of struct
	prologue_value.
	* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
	gdbarch_tdep.
	* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
	out of struct field_info.
	* symfile.h (struct other_sections): Move out of struct
	section_addr_info.
	* symtab.c (struct symbol_cache_slot): Move out struct
	block_symbol_cache.
	* target-descriptions.c (enum tdesc_type_kind): Move out of
	typedef struct tdesc_type.
	* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
	struct tui_line_or_address.
	* value.c (enum internalvar_kind, union internalvar_data): Move
	out of struct internalvar.
	* xtensa-tdep.h (struct ctype_cache): Move out of struct
	gdbarch_tdep.
2015-02-27 17:19:15 +00:00
Pedro Alves fe978cb071 C++ keyword cleanliness, mostly auto-generated
This patch renames symbols that happen to have names which are
reserved keywords in C++.

Most of this was generated with Tromey's cxx-conversion.el script.
Some places where later hand massaged a bit, to fix formatting, etc.
And this was rebased several times meanwhile, along with re-running
the script, so re-running the script from scratch probably does not
result in the exact same output.  I don't think that matters anyway.

gdb/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.

gdb/gdbserver/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.
2015-02-27 16:33:07 +00:00
Pedro Alves 3bc3d82a00 Add --enable-build-with-cxx configure switch
This new option, disabled by default for now, allows specifying
whether to build GDB, GDBserver, and friends with a C++ (98/03)
compiler.

The name of the switch should be familiar to those who followed GCC's
own C++ conversion process.

. Adding -fpermissive to COMPILER in C++ mode (see the new
build-with-cxx.m4 file) makes errors like these be warnings instead:

  gdb/infrun.c:6597:1: error:   initializing argument 1 of ‘void sig_print_info(gdb_signal)’ [-fpermissive]
   sig_print_info (enum gdb_signal oursig)
   ^
  gdb/infrun.c: In function ‘void do_restore_infcall_suspend_state_cleanup(void*)’:
  gdb/infrun.c:7164:39: error: invalid conversion from ‘void*’ to ‘infcall_suspend_state*’ [-fpermissive]
     restore_infcall_suspend_state (state);
				 ^

so that the compiler carries on compiling the file.  -Werror still
catches the warnings, so nothing is lost, only our lifes are made
easier by concentrating on getting other more important things out of
the way first.

There's no way to quiet those warnings.  Until they're all fixed, when
building in C++ mode, -Werror is disabled by default.

. Adding -Wno-narrowing suppresses thousands of instances of this warning:

  gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
  gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of ‘-1l’ from ‘LONGEST {aka long int}’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
  gdb/arm-linux-tdep.c:450:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing]

We can defer handling those until we target C++11.


. Adding -Wno-sign-compare suppresses thousands of instances of this warning:

  gdb/linux-record.c:1763:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
	 if (tmpulongest == tdep->fcntl_F_GETLK64)
				  ^


. Adding -Wno-write-strings suppresses thousands of instances of this warning:

  gdb/mi/mi-cmd-var.c: In function ‘void mi_cmd_var_show_attributes(char*, char**, int)’:
  gdb/mi/mi-cmd-var.c:514:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       attstr = "editable";
	      ^
  gdb/mi/mi-cmd-var.c:516:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       attstr = "noneditable";
	      ^

For now, it's best to hide these warnings from view until we're
'-fpermissive'-clean, and can thus start building with -Werror.
The C compiler has always managed to build working GDBs with these
issues in the code, so a C++ compiler should too.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMPILER): New, get it from autoconf.
	(COMPILE.pre, CC_LD): Use COMPILER.
	(CXX): Get from autoconf instead.
	(CXX_FOR_TARGET): Default to g++ instead of gcc.
	* acinclude.m4: Include build-with-cxx.m4.
	* build-with-cxx.m4: New file.
	* configure.ac: Call AC_PROG_CXX and GDB_AC_BUILD_WITH_CXX.
	Disable -Werror by default if building in C++ mode.
	(build_warnings): Add -Wno-sign-compare, -Wno-write-strings and
	-Wno-narrowing in C++ mode.  Only enable -Wpointer-sign in C mode.
	Run supported-warning-flags tests with the C++ compiler.
	Save/restore CXXFLAGS too.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMPILER): New, get it from autoconf.
	(CXX): Get from autoconf instead.
	(COMPILE.pre): Use COMPILER.
	(CC-LD): Rename to ...
	(CC_LD): ... this.  Use COMPILER.
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT), $(IPA_LIB)): Adjust.
	(CXX_FOR_TARGET): Default to g++ instead of gcc.
	* acinclude.m4: Include build-with-cxx.m4.
	* configure.ac: Call AC_PROG_CXX and GDB_AC_BUILD_WITH_CXX.
	Disable -Werror by default if building in C++ mode.
	(build_warnings): Add -Wno-sign-compare, -Wno-write-strings and
	-Wno-narrowing in C++ mode. Run supported-warning-flags tests with
	the C++ compiler.  Save/restore CXXFLAGS too.
	* configure: Regenerate.
2015-02-27 16:24:02 +00:00
Pedro Alves 07697489f4 Create libiberty.m4, have GDB and GDBserver use it
Converting GDB to be a C++ program, I stumbled on 'basename' issues,
like:

 src/gdb/../include/ansidecl.h:169:64: error: new declaration ‘char* basename(const char*)’
 /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’

which I believe led to this bit in gold's configure.ac:

 dnl We have to check these in C, not C++, because autoconf generates
 dnl tests which have no type information, and current glibc provides
 dnl multiple declarations of functions like basename when compiling
 dnl with C++.
 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])

These checks IIUC intend to generate all the HAVE_DECL_FOO symbols
that libiberty.h and ansidecl.h check.

GDB is missing these checks currently, which results in the conflict
shown above.

This adds an m4 file that both GDB and GDBserver's configury use to
pull in the autoconf checks that libiberty clients needs done in order
to use these libiberty.h/ansidecl.h.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* libiberty.m4: New file.
	* acinclude.m4: Include libiberty.m4.
	* configure.ac: Call libiberty_INIT.
	* config.in, configure: Regenerate.

gdb/gdbserver/
2015-02-27  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include libiberty.m4.
	* configure.ac: Call libiberty_INIT.
	* config.in, configure: Regenerate.
2015-02-27 15:52:02 +00:00
Pedro Alves 6f98576f29 Add "../lib/unbuffer_output.c" and use it in gdb.base/interrupt.c
In some scenarios, GDB or GDBserver can be spawned with input _not_
connected to a tty, and then tests that rely on stdio fail with
timeouts, because the inferior's stdout and stderr streams end up
fully buffered.

See discussion here:
  https://sourceware.org/ml/gdb-patches/2015-02/msg00809.html

We have a hack in place that works around this for Windows testing,
that forces every test program to link with an .o file that does
(lib/set_unbuffered_mode.c):

 static int __gdb_set_unbuffered_output (void) __attribute__ ((constructor));
 static int
 __gdb_set_unbuffered_output (void)
 {
   setvbuf (stdout, NULL, _IONBF, BUFSIZ);
   setvbuf (stderr, NULL, _IONBF, BUFSIZ);
 }

That's a bit hacky; it ends up done for _all_ tests.

This patch adds a way to do this unbuffering explicitly from the test
code itself, so it is done only when necessary, and for all
targets/hosts.  For starters, it adjusts gdb.base/interrupt.c to use
it.

Tested on x86_64 Fedora 20, native, and against a remote gdbserver
board file that connects to the target with ssh, with and without -t
(create pty).

gdb/testsuite/
2015-02-27  Pedro Alves  <palves@redhat.com>

	* lib/unbuffer_output.c: New file.
	* gdb.base/interrupt.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
2015-02-27 13:54:22 +00:00
Yao Qi eba5ab56cf Don't skip catch-syscall.exp on hppa*-hp-hpux* target
As far as I know, "catch syscall" is supported on hppa*-hp-hpux*, but
the test catch-syscall.exp is skipped on this target by mistake.  This
patch is to fix it.  However, I don't have a hpux machine to test.

gdb/testsuite:

2015-02-27  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/catch-syscall.exp: Don't skip it on hppa*-hp-hpux*
	target.
2015-02-27 13:45:06 +00:00
Andreas Arnez 60abeae4f2 S390: Fix compiler invocation with "compile" command
On 64-bit S390 platforms the "compile" command always failed because
gcc was not invoked correctly.  This patch fixes the compiler
invocation.

gdb/ChangeLog:

	* s390-linux-tdep.c (s390_gcc_target_options): Not just handle
	31-bit targets, but 64-bit targets as well.
	(s390_gnu_triplet_regexp): New function.
	(s390_gdbarch_init): Set the gcc_target_options gdbarch method for
	64-bit targets as well.  Set the gnu_triplet_regexp gdbarch
	method.
2015-02-27 10:47:54 +01:00
Joel Brobecker f44466fb65 Mark latest entry in gdb/ChangeLog as "(tiny patch)". 2015-02-27 09:49:59 +01:00
Jon TURNEY f0666312fd Retrieve segment registers on Windows amd64
For amd64, CONTEXT_FULL does not contain CONTEXT_SEGMENTS, which seems
to be needed to retrieve all the segment registers.  Add it explicitly,
with a little de-cruftification.

The value of the segment registers isn't terribly useful on amd64, but
at least this makes the output of 'info registers' correct.

Before:

    (gdb)  i r cs ss ds es fs gs
    cs             0x33     51
    ss             0x2b     43
    ds             0x0      0
    es             0x0      0
    fs             0x0      0
    gs             0x0      0

After:

    (gdb) i r cs ss ds es fs gs
    cs             0x33     51
    ss             0x2b     43
    ds             0x2b     43
    es             0x2b     43
    fs             0x53     83
    gs             0x2b     43

gdb/ChangeLog

2015-02-27  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* windows-nat.c (CONTEXT_DEBUGGER): Remove.
	(CONTEXT_DEBUGGER_DR): Add CONTEXT_SEGMENTS.  Incorporate flags
	from CONTEXT_DEBUGGER.
2015-02-27 09:46:05 +01:00
Doug Evans 0def5aaad6 Add missing CHECK_TYPEDEF calls to recent vptr_{fieldno,basetype} cleanup.
gdb/ChangeLog:

	* gdbtypes.c (internal_type_vptr_fieldno): Add missing call to
	CHECK_TYPEDEF.
	(set_type_vptr_fieldno): Ditto.
	(internal_type_vptr_basetype, set_type_vptr_basetype): Ditto.
	* gnu-v3-abi.c (gnuv3_dynamic_class): Ditto.

gdb/testsuite/ChangeLog:

	* gdb.cp/class2.cc (Dbase, D): New classes.
	(main): New local delta.
	* gdb.cp/class2.exp: Test printing delta.
	* gdb.cp/classes.cc (DynamicBase2, DynamicBar): New classes.
	(dynbar): New global.
	* gdb.cp/classes.exp (test_ptype_class_objects): Test ptype DynamicBar.
2015-02-26 17:31:29 -08:00
Pedro Alves 9beb7c4e1d gdbserver/Linux: Simplify stepping past program breakpoint a little
.decr_pc_after_break is never higher than .breakpoint_len, so use
.breakpoint_len directly.  Based on idea from Yao here:
https://sourceware.org/ml/gdb-patches/2015-02/msg00689.html

gdb/gdbserver/ChangeLog:
2015-02-26  Pedro Alves  <palves@redhat.com>

	* linux-low.c (linux_wait_1): When incrementing the PC past a
	program breakpoint always use the_low_target.breakpoint_len as
	increment, rather than the maximum between that and
	the_low_target.decr_pc_after_break.
2015-02-26 18:48:46 +00:00
Pedro Alves 77b64a49e2 Add ATTRIBUTE_PRINTF attributes, and fix fallout
Fixes building gdb on x86_64-apple-darwin14 with clang, which produces
a number of warnings from -Wformat-nonliteral.

Ref: https://sourceware.org/ml/gdb/2015-02/msg00047.html

gdb/ChangeLog:
2015-02-26  Pedro Alves  <palves@redhat.com>

	* auto-load.h (file_is_auto_load_safe): Add ATTRIBUTE_PRINTF.
	* complaints.c (vcomplaint): Pass argument FMT directly to
	printf-like functions instead of complaint->fmt.
	* ctf.c (ctf_save_write_metadata): Add ATTRIBUTE_PRINTF.
	* darwin-nat.c (inferior_debug): Add ATTRIBUTE_PRINTF.
	* compile/compile-loc2c.c (pushf, unary, binary): Add
	ATTRIBUTE_PRINTF.
	(do_compile_dwarf_expr_to_c): Pass string literal as format string
	to pushf.
	(BINARY): Pass string literal as format string to 'binary'.
	* compile/compile-object-load.c (link_callbacks_einfo): Add
	ATTRIBUTE_PRINTF.
	* guile/guile-internal.h (gdbscm_printf): Add ATTRIBUTE_PRINTF.
2015-02-26 18:29:12 +00:00
Pedro Alves 532f44ed67 Rename windows-termcap.c -> stub-termcap.c
Preparation for using this on all hosts.

Confirmed that --host=x86_64-w64-mingw32 still builds the stub
termcap.

gdb/ChangeLog:
2015-02-26  Pedro Alves  <palves@redhat.com>

	* windows-termcap.c: Rename to ...
	* stub-termcap.c: ... this.  Adjust header line.
	* Makefile.in (SFILES): Refer to stub-termcap.c instead of
	windows-termcap.c.
	* configure: Regenerate.
	* configure.ac: Refer to stub-termcap.o instead of
	windows-termcap.o.
	* gdb_curses.h: Mention stub-termcap.c instead of
	windows-termcap.c.
2015-02-26 17:13:58 +00:00
Jan Kratochvil 081a1c2ced compile: Fix GNU-IFUNC funcs called from injected code
One could not call IFUNCs (=indirect functions) from the compiled injected
code.  Either it errored with:
	gdb command line:1:1: error: function return type cannot be function

or it just called the IFUNC dispatcher in normal way, returning real function
implementation address instead of the function return value (and thus no
function was called).

gdb/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* compile/compile-c-symbols.c (convert_one_symbol, convert_symbol_bmsym)
	(gcc_symbol_address): Call gnu_ifunc_resolve_addr.

gdb/testsuite/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.compile/compile-ifunc.c: New file.
	* gdb.compile/compile-ifunc.exp: New file.
2015-02-26 17:40:57 +01:00
Antoine Tremblay 2f41223f62 Fix print of value type in a corner case of finish
When doing finish in a function, if gdb fails to return a value, gdb
also fails at printing the value type if this type is a struct.

For example :

(gdb) fin
....
Value returned has type: . Cannot determine contents

This patch fixes this by calling type_to_string to print the type
so that we can support these types.

This patch returns the following example output :

(gdb) fin
....
Value returned has type: struct test. Cannot determine contents

Also, this patch modifies structs.exp to check that we return the
correct type.

gdb/ChangeLog:
	* gdb/infcmd.c (print_return_value): use type_to_string to print type.

gdb/testsuite/ChangeLog:
	* gdb.base/structs.exp: Check for correct struct on finish.
2015-02-26 10:58:00 -05:00
Yao Qi 03eddd80d7 Dwarf assembler: handle one instruction function
On aarch64, we got the following fail:

(gdb) disassemble func
Dump of assembler code for function func:
   0x0000000000400730 <+0>:     ret
End of assembler dump.^M
(gdb) x/2i func+0^M
   0x400730 <func>:     ret^M
   0x400734 <main>:     stp     x29, x30, [sp,#-16]!^M
(gdb) FAIL: gdb.dwarf2/dw2-ifort-parameter.exp: x/2i func+0

the pattern in proc function_range expects to match <func+0>, however,
GDB doesn't display the offset when it is zero.  This patch is to
adjust the pattern when $func_length is zero.

gdb/testsuite:

2015-02-26  Yao Qi  <yao.qi@linaro.org>

	* lib/dwarf.exp (function_range): Adjust pattern when $func_length
	is zero.
2015-02-26 14:21:19 +00:00
Jan Kratochvil 80c570537e SEGV in ppc64_elf_get_synthetic_symtab reading a separate debug file
The attached patch fixes the SEGV and lets GDB successfully
load all kernel modules installed by default on RHEL 7.

Valgrind on F-21 x86_64 host has shown me more clear what is the problem:

Reading symbols from /home/jkratoch/t/cordic.ko...Reading symbols from
/home/jkratoch/t/cordic.ko.debug...=================================================================
==22763==ERROR: AddressSanitizer: heap-use-after-free on address 0x6120000461c8 at pc 0x150cdbd bp 0x7fffffffc7e0 sp 0x7fffffffc7d0
READ of size 8 at 0x6120000461c8 thread T0
    #0 0x150cdbc in ppc64_elf_get_synthetic_symtab /home/jkratoch/redhat/gdb-test-asan/bfd/elf64-ppc.c:3282
    #1 0x8c5274 in elf_read_minimal_symbols /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1205
    #2 0x8c55e7 in elf_symfile_read /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1268
[...]
0x6120000461c8 is located 264 bytes inside of 288-byte region [0x6120000460c0,0x6120000461e0)
freed by thread T0 here:
    #0 0x7ffff715454f in __interceptor_free (/lib64/libasan.so.1+0x5754f)
    #1 0xde9cde in xfree common/common-utils.c:98
    #2 0x9a04f7 in do_my_cleanups common/cleanups.c:155
    #3 0x9a05d3 in do_cleanups common/cleanups.c:177
    #4 0x8c538a in elf_read_minimal_symbols /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1229
    #5 0x8c55e7 in elf_symfile_read /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1268
[...]
previously allocated by thread T0 here:
    #0 0x7ffff71547c7 in malloc (/lib64/libasan.so.1+0x577c7)
    #1 0xde9b95 in xmalloc common/common-utils.c:41
    #2 0x8c4da2 in elf_read_minimal_symbols /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1147
    #3 0x8c55e7 in elf_symfile_read /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1268
[...]
SUMMARY: AddressSanitizer: heap-use-after-free /home/jkratoch/redhat/gdb-test-asan/bfd/elf64-ppc.c:3282 ppc64_elf_get_synthetic_symtab
[...]
==22763==ABORTING

A similar case a few lines later I have fixed in 2010 by:
        https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=3f1eff0a2c7f0e7078f011f55b8e7f710aae0cc2

My testcase does not always reproduce it but at least a bit:
 * GDB without ppc64 target (even as a secondary one) is reported as "untested"
 * ASAN-built GDB with ppc64 target always crashes (and PASSes with this fix)
 * unpatched non-ASAN-built GDB with ppc64 target crashes from commandline
 * unpatched non-ASAN-built GDB with ppc64 target PASSes from runtest (?)

gdb/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* elfread.c (elf_read_minimal_symbols): Use bfd_alloc for
	bfd_canonicalize_symtab.

gdb/testsuite/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/cordic.ko.bz2: New file.
	* gdb.arch/cordic.ko.debug.bz2: New file.
	* gdb.arch/ppc64-symtab-cordic.exp: New file.
2015-02-26 14:08:01 +01:00
John Baldwin cf424aef0a Rework signal frame probing for FreeBSD/x86
- Use signal frame sniffers that look for the signal trampoline
  instruction sequence to detect most signal frames.

- FreeBSD kernels between 9.2 and 10.1 inclusive do not include the
  signal trampoline code in process core dumps.  To detect signal
  frames for core dumps under these kernels, use the
  kern.proc.sigtramp.<pid> sysctl to fetch the location of the signal
  trampoline in the gdb process and assume that PC values within this
  location are signal frames.  This depends on that location being
  identical for all binaries.

gdb/ChangeLog:
2015-02-25  John Baldwin  <jhb@FreeBSD.org>

	* amd64fbsd-nat.c: Include sys/user.h.
	(_initialize_amd64fbsd_nat): Use the KERN_PROC_SIGTRAMP sysctl
	instead of KERN_PS_STRINGS to locate the signal trampoline.
	* i386fbsd-nat.c: Include sys/user.h.
	(_initialize_i386fbsd_nat): Use the KERN_PROC_SIGTRAMP sysctl
	instead of KERN_PS_STRINGS to locate the signal trampoline.
	* amd64fbsd-tdep.c (amd64fbsd_sigtramp_code): New.
	(amd64fbsd_sigtramp_p): New.
	(amd64fbsd_sigtramp_start_addr, amd64fbsd_sigtramp_end_addr): No
	longer set default values.
	(amd64fbsd_init_abi): Set "sigtramp_p" to "amd64fbsd_sigtramp_p".
	* i386fbsd-tdep.c (i386fbsd_sigtramp_start)
	(i386fbsd_sigtramp_middle, i386fbsd_sigtramp_end)
	(i386fbsd_freebsd4_sigtramp_start)
	(i386fbsd_freebsd4_sigtramp_middle)
	(i386fbsd_freebsd4_sigtramp_end, i386fbsd_osigtramp_start)
	(i386fbsd_osigtramp_middle, i386fbsd_osigtramp_end): New.
	(i386fbsd_sigtramp_p): New.
	(i386fbsd_sigtramp_start_addr, i386fbsd_sigtramp_end_addr): No
	longer set default values.
	(i386fbsd_init_abi): Set "sigtramp_p" to "i386fbsd_sigtramp_p".
2015-02-26 11:10:25 +00:00
John Baldwin c5cb74eeb3 Fix infinite recursion in amd64fbsd_sigcontext_addr
amd64fbsd_sigcontext_addr is using frame_unwind_register_unsigned to
fetch the stack pointer which results in infinite recursion.  This
patch changes it to use get_frame_register to match the
sigcontext_addr methods in the i386-bsd and amd64-linux targets
instead.

gdb/ChangeLog:
2015-02-25  John Baldwin  <jhb@freebsd.org>

	* amd64fbsd-tdep.c (amd64fbsd_sigcontext_addr): Use
	get_frame_register instead of frame_unwind_register_unsigned.
2015-02-26 11:07:57 +00:00
Jan Kratochvil 17487d857c Change // comment in gdb/compile/
Missing ChangeLog in the previous commit:
	bb2b33b939

gdb/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR build/18033
	* compile/compile-c-support.c (c_compute_program): Change // comment.
	* compile/compile-object-load.c (setup_sections): Change // comment.
2015-02-26 11:50:08 +01:00
Jan Kratochvil bb2b33b939 Change // comment in gdb/compile/ 2015-02-26 11:48:18 +01:00
Joel Brobecker 9357a9e66e Remove // comment in gdb/iq2000-tdep.c
gdb/ChangeLog:

	PR build/18033:
	* iq2000-tdep.c (iq2000_frame_cache): Delete C++-style comment.
2015-02-26 10:42:04 +01:00
Yao Qi 21613c12d1 [aarch64] Fix one fail in gdb.xml/tdesc-regs.exp
Hi,
I see the following fail in aarch64-linux-gnu testing...

(gdb) set tdesc file /XXX/gdb/testsuite/gdb.xml/single-reg.xml^M
warning: Architecture rejected target-supplied description^M
(gdb) FAIL: gdb.xml/tdesc-regs.exp: set tdesc file single-reg.xml

core-regs isn't set for aarch64 target, and looks it is an oversight
when aarch64 port was added.

gdb/testsuite:

2015-02-25  Yao Qi  <yao.qi@linaro.org>

	* gdb.xml/tdesc-regs.exp: Set core-regs to aarch64-core.xml for
	aarch64*-*-* target.
2015-02-25 10:39:59 +00:00
Doug Evans b615dd209f Fix typo in earlier entry. 2015-02-23 13:39:45 -08:00
Sergio Durigan Junior 7ee67ee442 PR gdb/18008: Fix typo in documentation
This obvious patch fixes a typo in our documentation
(s/problam/problem).

gdb/doc/ChangeLog:
2015-02-23  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR gdb/18008
	* gdb.texinfo (maint internal-error, maint internal-warning, maint
	demangler-warning): Fix typo ("problam").
2015-02-23 16:15:29 -05:00
Pedro Alves 8090aef2bf gdbserver: redo stepping over breakpoint that was on top of a permanent breakpoint
I'm going to add an alternate mechanism of breakpoint trap
identification to 'check_stopped_by_breakpoint' that does not rely on
checking the instruction at PC.  The mechanism currently used to tell
whether we're stepping over a permanent breakpoint doesn't fit in that
new method.  This patch redoes the whole logic in a different way that
works with both old and new methods, in essence moving the "stepped
permanent breakpoint" detection "one level up".  It makes lower level
check_stopped_by_breakpoint always the adjust the PC, and then has
linux_wait_1 advance the PC past the breakpoint if necessary.  This
ends up being better also because this now handles
non-decr_pc_after_break targets too.  Before, such targets would get
stuck forever reexecuting the breakpoint instruction.

Tested on x86_64 Fedora 20.

gdb/gdbserver/ChangeLog:
2015-02-23  Pedro Alves  <palves@redhat.com>

	* linux-low.c (check_stopped_by_breakpoint): Don't check if the
	thread was doing a step-over; always adjust the PC if
	we stepped over a permanent breakpoint.
	(linux_wait_1): If we stepped over breakpoint that was on top of a
	permanent breakpoint, manually advance the PC past it.
2015-02-23 18:59:38 +00:00
Pedro Alves d8b901edd1 delete_breakpoints: Rewrite using gdb_test_multiple
Because delete_breakpoints uses gdb_expect directly, an internal error
results in slow timeouts instead of quickly bailing out.  This patch
rewrites the procedure to use gdb_test_multiple instead, while
preserving the existing general logic ("delete breakpoints" + "info
breakpoints").

gdb/testsuite/
2015-02-23  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (delete_breakpoints): Rewrite using
	gdb_test_multiple.
2015-02-23 17:35:09 +00:00
Pedro Alves 1f10ba14bc remote.c: simplify parsing stop reasons in T stop replies
We need to be careful with parsing optional stop reasons that start
with an hex character ("awatch", "core"), as GDBs that aren't aware of
them parse them as real numbers.  That's silly of course, given that
there should be a colon after those magic "numbers".  So if strtol on
"abbz:" doesn't return "first invalid char" pointing to the colon, we
know that "abbz" isn't really a register number.  It must be optional
stop info we don't know about.  This adjusts GDB to work that way,
removing the need for the special casing done upfront:

	  /* If this packet is an awatch packet, don't parse the 'a'
	     as a register number.  */
	  if (strncmp (p, "awatch", strlen("awatch")) != 0
	      && strncmp (p, "core", strlen ("core") != 0))

For as long as we care about compatibility with GDB 7.9, we'll need to
continue to be careful about this, so I added a comment.

Tested on x86_64 Fedora 20, native gdbserver.

gdb/ChangeLog:
2015-02-23  Pedro Alves  <palves@redhat.com>

	* remote.c (skip_to_semicolon): New function.
	(remote_parse_stop_reply) <T stop reply>: Use it.  Don't
	special case the stop reasons that look like hex numbers
	upfront.  Instead handle real register numbers after matching
	all the known stop reasons.
2015-02-23 16:45:39 +00:00
Pedro Alves e5b85ead63 gdb.base/info-os.c: Include stdlib.h
Fixes:

 > gdb compile failed, /gdb/testsuite/gdb.base/info-os.c: In function 'main':
 > /gdb/testsuite/gdb.base/info-os.c:65:3: warning: implicit declaration of function 'atexit' [-Wimplicit-function-declaration]
 >    atexit (ipc_cleanup);
 >    ^
 > FAIL: gdb.base/info-os.exp: cannot compile test program

with recent GCCs.

gdb/testsuite/ChangeLog:
2015-02-23  Pedro Alves  <palves@redhat.com>

	* gdb.base/info-os.c: Include stdlib.h.
2015-02-23 14:03:48 +00:00
Pedro Alves bc9540e842 gdbserver: 64-bit kernel / 32-inferior, syscall restarting
$ make check RUNTESTFLAGS="--target_board=native-gdbserver/-m32 clone-thread_db.exp"

gdb.log shows:

  Running target native-gdbserver/-m32
  ...
  clone-thread_db: src/gdb/testsuite/gdb.threads/clone-thread_db.c:57: thread_fn: Assertion `res != -1' failed.
  ...
  (gdb) FAIL: gdb.threads/clone-thread_db.exp: continue to end

That was waitpid returning -1 / EINTR.  We don't see that when testing
with unix/-m32 (native debugging).  Turns out to be that when
debugging a 32-bit inferior, a 64-bit GDBserver is reading/writing
$orig_eax from/to the wrong ptrace register buffer offset.  When
gdbserver is 64-bit, the ptrace register buffer is in 64-bit layout,
so the register is found at "ORIG_EAX * 8", not at "ORIG_EAX * 4".

Fixes these with --target_board=native-gdbserver/-m32 on x86_64 Fedora 20:

    -FAIL: gdb.threads/clone-thread_db.exp: continue to end
    +PASS: gdb.threads/clone-thread_db.exp: continue to end

    -FAIL: gdb.threads/hand-call-in-threads.exp: all dummies popped
    +PASS: gdb.threads/hand-call-in-threads.exp: all dummies popped
     PASS: gdb.threads/hand-call-in-threads.exp: breakpoint on all_threads_running
     PASS: gdb.threads/hand-call-in-threads.exp: breakpoint on hand_call
     PASS: gdb.threads/hand-call-in-threads.exp: disable scheduler locking
    @@ -29339,15 +29331,15 @@ PASS: gdb.threads/hand-call-in-threads.e
     PASS: gdb.threads/hand-call-in-threads.exp: discard hand call, thread 4
     PASS: gdb.threads/hand-call-in-threads.exp: discard hand call, thread 5
     PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 1
    -FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 2
    -FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 3
    -FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 4
    +PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 2
    +PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 3
    +PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 4
     PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 5
     PASS: gdb.threads/hand-call-in-threads.exp: enable scheduler locking
     PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 1
    -FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 2
    -FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 3
    -FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 4
    +PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 2
    +PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 3
    +PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 4
     PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 5
     PASS: gdb.threads/hand-call-in-threads.exp: prepare to discard hand call, thread 1
     PASS: gdb.threads/hand-call-in-threads.exp: prepare to discard hand call, thread 2

gdb/gdbserver/ChangeLog
2015-02-23  Pedro Alves  <palves@redhat.com>

	* linux-x86-low.c (REGSIZE): Define in both 32-bit and 64-bit
	modes.
	(x86_fill_gregset, x86_store_gregset): Use it when handling
	$orig_eax.
2015-02-23 13:03:10 +00:00
Doug Evans 85c3a371b3 testcase for PR symtab/17855
gdb/testsuite/ChangeLog:

	PR symtab/17855
	* gdb.ada/exec_changed.exp: Add second test where symbol lookup cache
	is read after symbols have been re-read.
	* gdb.ada/exec_changed/first.adb (First): New procedure Break_Me.
	* gdb.ada/exec_changed/second.adb (Second): Ditto.
2015-02-22 09:11:55 -08:00
Doug Evans 96553a0cff PR c++/17976, symtab/17821
This patch addresses two issues.

The basic problem is that "(anonymous namespace)" doesn't get entered
into the symbol table because when dwarf2read.c:new_symbol_full is called
the DIE has no name (dwarf2_name returns NULL).

PR 17976: ptype '(anonymous namespace)' should work like any namespace

PR 17821: perf issue looking up (anonymous namespace)

bash$ gdb monster-program
(gdb) mt set per on
(gdb) mt set symbol-cache-size 0
(gdb) break (anonymous namespace)::foo

Before:

Command execution time: 3.266289 (cpu), 6.169030 (wall)
Space used: 811429888 (+12910592 for this command)

After:

Command execution time: 1.264076 (cpu), 4.057408 (wall)
Space used: 798781440 (+0 for this command)

gdb/ChangeLog:

	PR c++/17976, symtab/17821
	* cp-namespace.c (cp_search_static_and_baseclasses): New parameter
	is_in_anonymous.  All callers updated.
	(find_symbol_in_baseclass): Ditto.
	(cp_lookup_nested_symbol_1): Ditto.  Don't search all static blocks
	for symbols in an anonymous namespace.
	* dwarf2read.c (namespace_name): Don't call dwarf2_name, fetch
	DW_AT_name directly.
	(dwarf2_name): Convert missing namespace name to
	CP_ANONYMOUS_NAMESPACE_STR.

gdeb/testsuite/ChangeLog:

	* gdb.cp/anon-ns.exp: Add test for ptype '(anonymous namespace)'.
2015-02-21 21:58:31 -08:00
Jan Kratochvil 97a0c6972e Testsuite patch for: i386: Fix internal error when prstatus in core file is too big
gdb/testsuite/ChangeLog
2015-02-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR corefiles/17808
	* gdb.arch/i386-biarch-core.core.bz2: New file.
	* gdb.arch/i386-biarch-core.exp: New file.
2015-02-21 15:24:20 +01:00
Pedro Alves a47cd6e95a gdb.threads/multi-create-ns-info-thr.exp and native-extended-remote board
The buildbot shows that the new
gdb.threads/multi-create-ns-info-thr.exp test is timing out when
tested with --target=native-extended-remote.  The reason is:

 No breakpoints or watchpoints.
 (gdb) break main
 Breakpoint 1 at 0x10000b00: file ../../../binutils-gdb/gdb/testsuite/gdb.threads/multi-create.c, line 72.
 (gdb) run
 Starting program: /home/gdb-buildbot/fedora-21-ppc64be-1/fedora-ppc64be-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.threads/multi-create-ns-info-thr/multi-cre
 ate-ns-info-thr
 Process /home/gdb-buildbot/fedora-21-ppc64be-1/fedora-ppc64be-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.threads/multi-create-ns-info-thr/multi-create-ns-inf
 o-thr created; pid = 16266
 Unexpected vCont reply in non-stop mode: T0501:00003fffffffd190;40:00000080560fe290;thread:p3f8a.3f8a;core:0;
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) break multi-create.c:45
 Breakpoint 2 at 0x10000994: file ../../../binutils-gdb/gdb/testsuite/gdb.threads/multi-create.c, line 45.
 (gdb) commands
 Type commands for breakpoint(s) 2, one per line.

Non-stop tests don't really work with the
--target_board=native-extended-remote board, because tests toggle
non-stop on after GDB is already connected to gdbserver, while
Currently, non-stop must be enabled before connecting.

This adjusts the test to bail if running to main fails, like all other
non-stop tests.

Note non-stop tests do work with --target_board=native-gdbserver.

gdb/testsuite/ChangeLog:
2015-02-21  Pedro Alves  <palves@redhat.com>

	* gdb.threads/multi-create-ns-info-thr.exp: Return early if
	runto_main fails.
2015-02-21 12:03:23 +00:00
Pedro Alves c5facdc449 Fix gdb.base/solib-corrupted.exp after dtrace probes changes
Commit 6f9b8491 (Adapt `info probes' to support printing probes of
different types.) added a new type column to "info probes".  That
caused a solib-corrupted.exp regression:

 ~~~~~~~~~~~~~~~~~~~~~
 Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/solib-corrupted.exp ...
 FAIL: gdb.base/solib-corrupted.exp: corrupted list

		 === gdb Summary ===

 # of expected passes            2
 # of unexpected failures        1
 ~~~~~~~~~~~~~~~~~~~~~

Tested on x86_64 Fedora 20.

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

	* gdb.base/solib-corrupted.exp: Expect "stap" as first column of
	info probes.
2015-02-20 23:10:53 +00:00
Pedro Alves 2db9a4275c GNU/Linux: Stop using libthread_db/td_ta_thr_iter
TL;DR - GDB can hang if something refreshes the thread list out of the
target while the target is running.  GDB hangs inside td_ta_thr_iter.
The fix is to not use that libthread_db function anymore.

Long version:

Running the testsuite against my all-stop-on-top-of-non-stop series is
still exposing latent non-stop bugs.

I was originally seeing this with the multi-create.exp test, back when
we were still using libthread_db thread event breakpoints.  The
all-stop-on-top-of-non-stop series forces a thread list refresh each
time GDB needs to start stepping over a breakpoint (to pause all
threads).  That test hits the thread event breakpoint often, resulting
in a bunch of step-over operations, thus a bunch of thread list
refreshes while some threads in the target are running.

The commit adds a real non-stop mode test that triggers the issue,
based on multi-create.exp, that does an explicit "info threads" when a
breakpoint is hit.  IOW, it does the same things the as-ns series was
doing when testing multi-create.exp.

The bug is a race, so it unfortunately takes several runs for the test
to trigger it.  In fact, even when setting the test running in a loop,
it sometimes takes several minutes for it to trigger for me.

The race is related to libthread_db's td_ta_thr_iter.  This is
libthread_db's entry point for walking the thread list of the
inferior.

Sometimes, when GDB refreshes the thread list from the target,
libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a
cycle, and get stuck in an infinite loop.

The issue is that when a thread exits, its thread control structure in
glibc is moved from a "used" list to a "cache" list.  These lists are
simply circular linked lists where the "next/prev" pointers are
embedded in the thread control structure itself.  The "next" pointer
of the last element of the list points back to the list's sentinel
"head".  There's only one set of "next/prev" pointers for both lists;
thus a thread can only be in one of the lists at a time, not in both
simultaneously.

So when thread C exits, simplifying, the following happens.  A-C are
threads.  stack_used and stack_cache are the list's heads.

Before:

  stack_used -> A -> B -> C -> (&stack_used)
  stack_cache -> (&stack_cache)

After:

  stack_used -> A -> B -> (&stack_used)
  stack_cache -> C -> (&stack_cache)

td_ta_thr_iter starts by iterating at the list's head's next, and
iterates until it sees a thread whose next pointer points to the
list's head again.  Thus in the before case above, C's next points to
stack_used, indicating end of list.  In the same case, the stack_cache
list is empty.

For each thread being iterated, td_ta_thr_iter reads the whole thread
object out of the inferior.  This includes the thread's "next"
pointer.

In the scenario above, it may happen that td_ta_thr_iter is iterating
thread B and has already read B's thread structure just before thread
C exits and its control structure moves to the cached list.

Now, recall that td_ta_thr_iter is running in the context of GDB, and
there's no locking between GDB and the inferior.  From it's local copy
of B, td_ta_thr_iter believes that the next thread after B is thread
C, so it happilly continues iterating to C, a thread that has already
exited, and is now in the stack cache list.

After iterating C, td_ta_thr_iter finds the stack_cache head, which
because it is not stack_used, td_ta_thr_iter assumes it's just another
thread.  After this, unless the reverse race triggers, GDB gets stuck
in td_ta_thr_iter forever walking the stack_cache list, as no thread
in thatlist has a next pointer that points back to stack_used (the
terminating condition).

Before fully understanding the issue, I tried adding cycle detection
to GDB's td_ta_thr_iter callback.  However, td_ta_thr_iter skips
calling the callback in some cases, which means that it's possible
that the callback isn't called at all, making it impossible for GDB to
break the loop.  I did manage to get GDB stuck in that state more than
once.

Fortunately, we can avoid the issue altogether.  We don't really need
td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE.
We already know how to map and lwp id to a thread id without iterating
(thread_from_lwp), so use that more.

gdb/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (linux_handle_extended_wait): Call
	thread_db_notice_clone whenever a new clone LWP is detected.
	(linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New
	functions.
	* linux-nat.h (thread_db_attach_lwp): Delete declaration.
	(thread_db_notice_clone, linux_stop_and_wait_all_lwps)
	(linux_unstop_all_lwps): Declare.
	* linux-thread-db.c (struct thread_get_info_inout): Delete.
	(thread_get_info_callback): Delete.
	(thread_from_lwp): Use td_thr_get_info and record_thread.
	(thread_db_attach_lwp): Delete.
	(thread_db_notice_clone): New function.
	(try_thread_db_load_1): If /proc is mounted and shows the
	process'es task list, walk over all LWPs and call thread_from_lwp
	instead of relying on td_ta_thr_iter.
	(attach_thread): Don't call check_thread_signals here.  Split the
	tail part of the function (which adds the thread to the core GDB
	thread list) to ...
	(record_thread): ... this function.  Call check_thread_signals
	here.
	(thread_db_wait): Don't call thread_db_find_new_threads_1.  Always
	call thread_from_lwp.
	(thread_db_update_thread_list): Rename to ...
	(thread_db_update_thread_list_org): ... this.
	(thread_db_update_thread_list): New function.
	(thread_db_find_thread_from_tid): Delete.
	(thread_db_get_ada_task_ptid): Simplify.
	* nat/linux-procfs.c: Include <sys/stat.h>.
	(linux_proc_task_list_dir_exists): New function.
	* nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare.

gdb/gdbserver/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

	* thread-db.c: Include "nat/linux-procfs.h".
	(thread_db_init): Skip listing new threads if the kernel supports
	PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible.

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

	* gdb.threads/multi-create-ns-info-thr.exp: New file.
2015-02-20 21:40:31 +00:00
Pedro Alves 3b27ef472d linux-nat.c: fix a few lin_lwp_attach_lwp issues
This function has a few latent bugs that are triggered by a non-stop
mode test that will be added in a subsequent patch.

First, as described in the function's intro comment, the function is
supposed to return 1 if we're already auto attached to the thread, but
haven't processed the PTRACE_EVENT_CLONE event of its parent thread
yet.

Then, we may find that we're trying to attach to a clone child that
hasn't yet stopped for its initial stop, and therefore 'waitpid(...,
WNOHANG)' returns 0.  In that case, we're currently adding the LWP to
the stopped_pids list, which results in linux_handle_extended_wait
skipping the waitpid call on the child, and thus confusing things
later on when the child eventually reports the stop.

Then, the tail end of lin_lwp_attach_lwp always sets the
last_resume_kind of the LWP to resume_stop, which is wrong given that
the user may be doing "info threads" while some threads are running.

And then, the else branch of lin_lwp_attach_lwp always sets the
stopped flag of the LWP.  This branch is reached if the LWP is the
main LWP, which may well be running at this point (to it's wrong to
set its 'stopped' flag).

AFAICS, there's no reason anymore for special-casing the main/leader
LWP here:

- For the "attach" case, linux_nat_attach already adds the main LWP to
the lwp list, and sets its 'stopped' flag.

- For the "run" case, after linux_nat_create_inferior, end up in
linux_nat_wait_1 here:

  /* The first time we get here after starting a new inferior, we may
     not have added it to the LWP list yet - this is the earliest
     moment at which we know its PID.  */
  if (ptid_is_pid (inferior_ptid))
    {
      /* Upgrade the main thread's ptid.  */
      thread_change_ptid (inferior_ptid,
			  ptid_build (ptid_get_pid (inferior_ptid),
				      ptid_get_pid (inferior_ptid), 0));

      lp = add_initial_lwp (inferior_ptid);
      lp->resumed = 1;
    }

... which adds the LWP to the LWP list already, before
lin_lwp_attach_lwp can ever be reached.

gdb/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (lin_lwp_attach_lwp): No longer special case the
	main LWP.  Handle the case of waitpid returning 0 if we're already
	attached to the LWP.  Don't set the LWP's last_resume_kind to
	resume_stop if we already knew about the LWP.
	(linux_nat_filter_event): Add debug logs.
2015-02-20 20:21:59 +00:00
Pedro Alves 1cc28231d2 Garbage collect forward_target_decr_pc_after_break
The definition was removed a year ago, but the declaration managed to
stay behind.

gdb/ChangeLog
2015-02-20  Pedro Alves  <palves@redhat.com>

	* target.h (forward_target_decr_pc_after_break): Delete
	declaration.
2015-02-20 20:11:02 +00:00
Pedro Alves afa8d396f6 fix gdbserver/linux-low'c's pending status handling
Another fix I'm working made schedlock.exp fail with gdbserver
frequently.  Looking deeper, it turns out to be a pre-existing bug.

status_pending_p_callback is filtering out LWPs incorrectly.  The
result is that that sometimes status_pending_p_callback returns a
pending event for an LWP that isn't expected, and then GDBserver gets
very confused.

E.g,. when doing a step-over, linux_wait_for_event is called with a
particular LWP's ptid, meaning events for all other LWPs should be
left pending, but here we see it retuning an event for some other LWP:

 linux_wait_1: [<all threads>]
 step_over_bkpt set [LWP 29577.29577], doing a blocking wait      <--------
 my_waitpid (-1, 0x40000001)
 my_waitpid (-1, 0x80000001): status(57f), 0
 LWFE: waitpid(-1, ...) returned 0, ERRNO-OK
 pc is 0x4007a0
 src/gdb/gdbserver/linux-low.c:2587: A problem internal to GDBserver has been detected.
 linux_wait_1: got event for 29581                                <--------

 Remote connection closed
 (gdb) FAIL: gdb.threads/schedlock.exp: continue to breakpoint: return to loop (initial)
 delete breakpoints

Tested on x86_64 Fedora 20.

gdb/gdbserver/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

	* linux-low.c (status_pending_p_callback): Use ptid_match.
2015-02-20 19:52:51 +00:00
Pedro Alves 60fb7e9efa Fix no-attach-trace.exp with "target remote" / gdbserver
$ make check RUNTESTFLAGS="--target_board=native-gdbserver no-attach-trace.exp"
 ...
 (gdb) trace main
 Tracepoint 1 at 0x400594: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.trace/no-attach-trace.c, line 25.
 (gdb) PASS: gdb.trace/no-attach-trace.exp: set tracepoint on main
 tstart
 You can't do that when your target is `exec'
 (gdb) FAIL: gdb.trace/no-attach-trace.exp: tstart

Even though this target supports tracing, the test restarts GDB and
doesn't do gdb_run_cmd so does not reconnect to the remote target.  So
at that point, GDB only has the "exec" target, which obviously doesn't
do tracing.

The test is about doing "tstart" before running a program, so the fix
is to do gdb_target_supports_trace with whatever target GDB ends up
connected after clean_restart.

Tested on x86_64 Fedora 20, native, native-gdbserver and
native-extended-gdbserver boards.  The test passes with the latter,
and is skipped with the first two.

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

	* gdb.trace/no-attach-trace.exp: Don't run to main.  Do
	clean_restart before gdb_target_supports_trace.
2015-02-20 19:50:36 +00:00
Pedro Alves 5c5019c27c PR18006: internal error if threaded program calls clone(CLONE_VM)
On GNU/Linux, if a pthreaded program has a thread call clone(CLONE_VM)
directly, and then that clone LWP hits a debug event (breakpoint,
etc.) GDB internal errors.  Threaded programs shouldn't really be
calling clone directly, but GDB shouldn't crash either.

The crash looks like this:

 (gdb) break clone_fn
 Breakpoint 2 at 0x4007d8: file clone-thread_db.c, line 35.
 (gdb) r
 ...
 [Thread debugging using libthread_db enabled]
 ...
 src/gdb/linux-nat.c:1030: internal-error: lin_lwp_attach_lwp: Assertion `lwpid > 0' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.

The problem is that 'clone' ends up clearing the parent thread's tid
field in glibc's thread data structure.  For x86_64, the glibc code in
question is here:

  sysdeps/unix/sysv/linux/x86_64/clone.S:

   ...
          testq   $CLONE_THREAD, %rdi
          jne     1f
          testq   $CLONE_VM, %rdi
          movl    $-1, %eax            <----
          jne     2f
          movl    $SYS_ify(getpid), %eax
          syscall
  2:      movl    %eax, %fs:PID
          movl    %eax, %fs:TID        <----
  1:

When GDB refreshes the thread list out of libthread_db, it finds a
thread with LWP with pid -1 (the clone's parent), which naturally
isn't yet on the thread list.  GDB then tries to attach to that bogus
LWP id, which is caught by that assertion.

The fix is to detect the bad PID early.

Tested on x86-64 Fedora 20.  GDBserver doesn't need any fix.

gdb/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

	PR threads/18006
	* linux-thread-db.c (thread_get_info_callback): Return early if
	the thread's lwp id is -1.

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

	PR threads/18006
	* gdb.threads/clone-thread_db.c: New file.
	* gdb.threads/clone-thread_db.exp: New file.
2015-02-20 19:00:21 +00:00
Joel Brobecker f3978e9100 Document the GDB 7.9 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 7.9 released.
2015-02-20 21:20:23 +04:00
Steve Ellcey ffdf88ecd7 2015-02-19 Steve Ellcey <sellcey@imgtec.com>
* dtrace-probe.c (dtrace_process_dof_probe): Initialize arg.expr.
	(dtrace_get_probes) Change type of variable 'dof'.
2015-02-19 14:42:37 -08:00
Antoine Tremblay c9587f8823 Fix non executable stack handling when calling functions in the inferior.
When gdb creates a dummy frame to execute a function in the inferior,
the process may generate a SIGSEGV, SIGTRAP or SIGILL because the stack
is non executable. If the signal handler set in gdb has option print
or stop enabled for these signals gdb handles this correctly.

However, in the case of noprint and nostop the signal is short-circuited
and the inferior process is sent the signal directly. This causes the
inferior to crash because of gdb.

This patch adds a check for SIGSEGV, SIGTRAP or SIGILL so that these
signals are sent to gdb rather than short-circuited in the inferior.
gdb then handles them properly and the inferior process does not
crash.

This patch also fixes the same behavior in gdbserver.

Also added a small testcase to test the issue called catch-gdb-caused-signals.

This applies to Linux only, tested on Linux.

gdb/ChangeLog:
	PR breakpoints/16812
	* linux-nat.c (linux_nat_filter_event): Report SIGTRAP,SIGILL,SIGSEGV.
	* nat/linux-ptrace.c (linux_wstatus_maybe_breakpoint): Add.
	* nat/linux-ptrace.h: Add linux_wstatus_maybe_breakpoint.

gdb/gdbserver/ChangeLog:
	PR breakpoints/16812
	* linux-low.c (wstatus_maybe_breakpoint): Remove.
	(linux_low_filter_event): Update wstatus_maybe_breakpoint name.
	(linux_wait_1): Report SIGTRAP,SIGILL,SIGSEGV.

gdb/testsuite/ChangeLog:
	PR breakpoints/16812
	* gdb.base/catch-gdb-caused-signals.c: New file.
	* gdb.base/catch-gdb-caused-signals.exp: New file.
2015-02-19 11:04:21 -05:00
David Taylor 53cf2ee0d9 [gdb/ax] small "setv" fix and documentation's adjustment.
gdb/doc/agentexpr.texi documents the "setv" opcode as follow:

    @item @code{setv} (0x2d) @var{n}: @result{} @var{v}
    Set trace state variable number @var{n} to the value found on the top
    of the stack.  The stack is unchanged, so that the value is readily
    available if the assignment is part of a larger expression.  The
    handling of @var{n} is as described for @code{getv}.

The @item line is incorrect (and does not match with its
description), so this patch fixes it.

Additionally, in gdb/common/ax.def we find the line:

    DEFOP (setv, 2, 0, 0, 1, 0x2d)

From the comment earlier in the file:

       Each line is of the form:

       DEFOP (name, size, data_size, consumed, produced, opcode)
[...]
       CONSUMED is the number of stack elements consumed.
       PRODUCED is the number of stack elements produced.

which is saying that nothing is consumed and one item is produced.
Both should be 0 or both should be 1.

This patch sets them both to 1, which seems better since if nothing
is on the stack an error will occur.

gdb/ChangeLog:

        * common/ax.def (setv): Fix consumed entry in setv DEFOP.

gdb/doc/ChangeLog:

        * agentexpr.texi (Bytecode Descriptions): Fix summary line for setv.

Tested on x86_64-linux.
2015-02-19 19:04:16 +04:00
Patrick Palka acfe0940a8 Add missing gdb/ChangeLog entry for previous change. 2015-02-18 18:51:14 -05:00
Patrick Palka c4ef48c6b2 Asynchronously resize the TUI
This patch teaches the TUI to resize itself asynchronously instead of
synchronously.  Asynchronously resizing the screen when the underlying
terminal gets resized is the more intuitive behavior and is surprisingly
simple to implement thanks to GDB's async infrastructure.

The implementation is straightforward.  TUI's SIGWINCH handler is just
tweaked to asynchronously invoke a new callback,
tui_async_resize_screen, which is responsible for safely resizing the
screen.  Care must be taken to not to attempt to asynchronously resize
the screen while the TUI is not active.  When the TUI is not active, the
callback will do nothing, but the screen will yet be resized in the next
call to tui_enable() by virtue of win_resized being TRUE.

(So, after the patch there are still two places where the screen gets
resized: one in tui_enable() and the other now in
tui_async_resize_screen() as opposed to being in
tui_handle_resize_during_io().  The one in tui_enable() is still
necessary to handle the case where the terminal gets resized inside the
CLI: in that case, the TUI still needs resizing, but it must wait until
the TUI gets re-enabled.)

gdb/ChangeLog:

	* tui/tui-io.c (tui_handle_resize_during_io): Remove this
	function.
	(tui_putc): Don't call tui_handle_resize_during_io.
	(tui_getc): Likewise.
	(tui_mld_getc): Likewise.
	* tui/tui-win.c: Include event-loop.h and tui/tui-io.h.
	(tui_sigwinch_token): New static variable.
	(tui_initialize_win): Adjust documentation.  Set
	tui_sigwinch_token.
	(tui_async_resize_screen): New asynchronous callback.
	(tui_sigwinch_handler): Adjust documentation.  Asynchronously
	invoke tui_async_resize_screen.
2015-02-18 17:26:06 -05:00
Jose E. Marchesi f6a88844c3 Factorize target program transformations in the GDB_AC_TRANSFORM macro.
This patch introduces a new M4 macro GDB_AC_TRANSFORM to avoid repeating
the common idiom which is the transformation of target program names,
i.e. from gdb to sparc64-linux-gnu-gdb.  It also makes gdb/configure.ac
and gdb/testsuite/configure.ac to use the new macro.

gdb/ChangeLog:

2015-02-18  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* configure: Regenerated.
	* configure.ac: Use GDB_AC_TRANSFORM.
	* Makefile.in (aclocal_m4_deps): Added transform.m4.
	* acinclude.m4: sinclude transform.m4.
	* transform.m4: New file.
	(GDB_AC_TRANSFORM): New macro.

gdb/testsuite/ChangeLog:

2015-02-18  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* configure: Regenerated.
	* configure.ac: Use GDB_AC_TRANSFORM.
	* aclocal.m4: sinclude ../transform.m4.
2015-02-18 13:52:53 +01:00
Jose E. Marchesi b05e3b0dd2 Announce the DTrace USDT probes support in NEWS.
This patch simply adds a small entry to `Changes since GDB 7.8' announcing the
support for dtrace probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* NEWS: Announce the support for DTrace SDT probes.
2015-02-17 16:43:48 +01:00
Jose E. Marchesi 3133f8c11f Documentation for DTrace USDT probes.
This patch modifies the `Static Probe Points' section on the GDB
manual in order to cover the support for DTrace USDT probes, in
addition to SystemTap SDT probes.

gdb/doc/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.texinfo (Static Probe Points): Add cindex `static probe
	point, DTrace'.
	(Static Probe Points): Modified to cover DTrace probes in addition
	to SystemTap probes.  Also modified to cover the `enable probe'
	and `disable probe' commands.
2015-02-17 16:42:15 +01:00
Jose E. Marchesi 497c491bea Simple testsuite for DTrace USDT probes.
This patch adds some simple tests testing the support for DTrace USDT
probes.  The testsuite will be skipped as unsupported in case the user
does not have DTrace installed on her system.  The tests included in the
test suite test breakpointing on DTrace probes, enabling and disabling
probes, printing of probe arguments of several types and also
breakpointing on several probes with the same name.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* lib/dtrace.exp: New file.
	* gdb.base/dtrace-probe.exp: Likewise.
	* gdb.base/dtrace-probe.d: Likewise.
	* gdb.base/dtrace-probe.c: Likewise.
	* lib/pdtrace.in: Likewise.
	* configure.ac: Output variables with the transformed names of
	the strip, readelf, as and nm tools.  AC_SUBST lib/pdtrace.in.
	* configure: Regenerated.
2015-02-17 16:41:16 +01:00
Jose E. Marchesi c3e3045e5c Support for DTrace USDT probes in x86_64 targets.
This patch adds the target-specific code in order to support the
calculation of DTrace probes arguments in x86_64 targets, and also the
enabling and disabling of probes.  This is done by implementing the
`dtrace_*' gdbarch handlers.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* amd64-linux-tdep.c: Include "parser-defs.h" and "user-regs.h".
	(amd64_dtrace_parse_probe_argument): New function.
	(amd64_dtrace_probe_is_enabled): Likewise.
	(amd64_dtrace_enable_probe): Likewise.
	(amd64_dtrace_disable_probe): Likewise.
	(amd64_linux_init_abi): Register the
	`gdbarch_dtrace_probe_argument', `gdbarch_dtrace_enable_probe',
	`gdbarch_dtrace_disable_probe' and
	`gdbarch_dtrace_probe_is_enabled' hooks.
	(amd64_dtrace_disabled_probe_sequence_1): New constant.
	(amd64_dtrace_disabled_probe_sequence_2): Likewise.
	(amd64_dtrace_enable_probe_sequence): Likewise.
	(amd64_dtrace_disable_probe_sequence): Likewise.
2015-02-17 16:04:01 +01:00
Jose E. Marchesi d4777acbc9 New probe type: DTrace USDT probes.
This patch adds a new type of probe to GDB: the DTrace USDT probes.  The new
type is added by providing functions implementing all the entries of the
`probe_ops' structure defined in `probe.h'.  The implementation is
self-contained and does not depend on DTrace source code in any way.

gdb/ChangeLog:

2015-02-7  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* breakpoint.c (BREAK_ARGS_HELP): Help string updated to mention
	the -probe-dtrace new vpossible value for PROBE_MODIFIER.
	* configure.ac (CONFIG_OBS): dtrace-probe.o added if BFD can
	handle ELF files.
	* Makefile.in (SFILES): dtrace-probe.c added.
	* configure: Regenerate.
	* dtrace-probe.c: New file.
	(SHT_SUNW_dof): New constant.
	(dtrace_probe_type): New enum.
	(dtrace_probe_arg): New struct.
	(dtrace_probe_arg_s): New typedef.
	(struct dtrace_probe_enabler): New struct.
	(dtrace_probe_enabler_s): New typedef.
	(dtrace_probe): New struct.
	(dtrace_probe_is_linespec): New function.
	(dtrace_dof_sect_type): New enum.
	(dtrace_dof_dofh_ident): Likewise.
	(dtrace_dof_encoding): Likewise.
	(DTRACE_DOF_ENCODE_LSB): Likewise.
	(DTRACE_DOF_ENCODE_MSB): Likewise.
	(dtrace_dof_hdr): New struct.
	(dtrace_dof_sect): Likewise.
	(dtrace_dof_provider): Likewise.
	(dtrace_dof_probe): Likewise.
	(DOF_UINT): New macro.
	(DTRACE_DOF_PTR): Likewise.
	(DTRACE_DOF_SECT): Likewise.
	(dtrace_process_dof_probe): New function.
	(dtrace_process_dof): Likewise.
	(dtrace_build_arg_exprs): Likewise.
	(dtrace_get_arg): Likewise.
	(dtrace_get_probes): Likewise.
	(dtrace_get_probe_argument_count): Likewise.
	(dtrace_can_evaluate_probe_arguments): Likewise.
	(dtrace_evaluate_probe_argument): Likewise.
	(dtrace_compile_to_ax): Likewise.
	(dtrace_probe_destroy): Likewise.
	(dtrace_gen_info_probes_table_header): Likewise.
	(dtrace_gen_info_probes_table_values): Likewise.
	(dtrace_probe_is_enabled): Likewise.
	(dtrace_probe_ops): New variable.
	(info_probes_dtrace_command): New function.
	(_initialize_dtrace_probe): Likewise.
	(dtrace_type_name): Likewise.
2015-02-17 16:03:22 +01:00
Jose E. Marchesi 8b367e1771 New gdbarch functions: dtrace_parse_probe_argument, dtrace_probe_is_enabled, dtrace_enable_probe, dtrace_disable_probe.
This patch adds several gdbarch functions (along with the corresponding
predicates): `dtrace_parse_probe_argument', `dtrace_probe_is_enabled',
`dtrace_enable_probe' and `dtrace_disable_probe'.  These functions will
be implemented by target-specific code, and called from the DTrace
probes implementation in order to calculate the value of probe
arguments, and manipulate is-enabled probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdbarch.sh (dtrace_parse_probe_argument): New.
	(dtrace_probe_is_enabled): Likewise.
	(dtrace_enable_probe): Likewise.
	(dtrace_disable_probe): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
2015-02-17 15:54:44 +01:00
Jose E. Marchesi 9aca2ff83e New commands `enable probe' and `disable probe'.
This patch adds the above-mentioned commands to the generic probe
abstraction implemented in probe.[ch].  The effects associated to
enabling or disabling a probe depend on the type of probe being
handled, and is triggered by invoking two back-end hooks in
`probe_ops'.

In case some particular probe type does not support the notion of
enabling and/or disabling, the corresponding fields on `probe_ops' can
be initialized to NULL.  This is the case of SystemTap probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* stap-probe.c (stap_probe_ops): Add NULLs in the static
	stap_probe_ops for `enable_probe' and `disable_probe'.
	* probe.c (enable_probes_command): New function.
	(disable_probes_command): Likewise.
	(_initialize_probe): Define the cli commands `enable probe' and
	`disable probe'.
	(parse_probe_linespec): New function.
	(info_probes_for_ops): Use parse_probe_linespec.
	* probe.h (probe_ops): New hooks `enable_probe' and
	`disable_probe'.

gdb/doc/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.texinfo (Static Probe Points): Cover the `enable probe' and
	`disable probe' commands.
2015-02-17 15:51:07 +01:00
Jose E. Marchesi 03e98035a2 Move `compute_probe_arg' and `compile_probe_arg' to probe.c
This patch moves the `compute_probe_arg' and `compile_probe_arg' functions
from stap-probe.c to probe.c.  The rationale is that it is reasonable to
assume that all backends will provide the `$_probe_argN' convenience
variables, and that the user must be placed on the PC of the probe when
requesting that information.  The value and type of the argument can still be
determined by the probe backend via the `pops->evaluate_probe_argument' and
`pops->compile_to_ax' handlers.

Note that a test in gdb.base/stap-probe.exp had to be adjusted because the "No
SystemTap probe at PC" messages are now "No probe at PC".

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* probe.c (compute_probe_arg): Moved from stap-probe.c
	(compile_probe_arg): Likewise.
	(probe_funcs): Likewise.
	* stap-probe.c (compute_probe_arg): Moved to probe.c.
	(compile_probe_arg): Likewise.
	(probe_funcs): Likewise.

gdb/testsuite/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.base/stap-probe.exp (stap_test): Remove "SystemTap" from
	expected message when trying to access $_probe_* convenience
	variables while not on a probe.
2015-02-17 15:50:19 +01:00
Jose E. Marchesi 6f9b84910f Adapt `info probes' to support printing probes of different types.
A "probe type" (backend for the probe abstraction implemented in
probe.[ch]) can extend the information printed by `info probes' by
defining additional columns.  This means that when `info probes' is
used to print all the probes regardless of their types, some of the
columns will be "not applicable" to some of the probes (like, say, the
Semaphore column only makes sense for SystemTap probes).  This patch
makes `info probes' fill these slots with "n/a" marks (currently it
breaks the table) and not include headers for which no actual probe
has been found in the list of defined probes.

This patch also adds support for a new generic column "Type", that
displays the type of each probe.  SystemTap probes identify themselves
as "stap" probes.

gdb/ChangeLog:

2015-02-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* probe.c (print_ui_out_not_applicables): New function.
	(exists_probe_with_pops): Likewise.
	(info_probes_for_ops): Do not include column headers for probe
	types for which no probe has been actually found on any object.
	Also invoke `print_ui_out_not_applicables' in order to match the
	column rows with the header when probes of several types are
	listed.
	Print the "Type" column.
	* probe.h (probe_ops): Added a new probe operation `type_name'.
	* stap-probe.c (stap_probe_ops): Add `stap_type_name'.
	(stap_type_name): New function.
2015-02-17 15:49:12 +01:00
Patrick Palka 69efdff130 Remove superfluous function key_is_command_char()
The function key_is_command_char() is simply a predicate that determines
whether the function tui_dispatch_ctrl_char() will do anything useful.
Since tui_dispatch_ctrl_char() performs the same checks as
key_is_command_char() it is unnecessary to keep key_is_command_char()
around.  This patch removes this useless function and instead
unconditionally calls tui_dispatch_ctrl_char() inside its only caller,
tui_getc().

gdb/ChangeLog:

	* tui/tui-io.c (tui_getc): Don't call key_is_command_char.
	(key_is_command_char): Delete.
2015-02-17 08:06:10 -05:00
Pedro Alves f8e5e23e3d TUI: resize windows to new terminal size before displaying them
If the user:

   #1 - disables the TUI
   #2 - resizes the terminal
   #3 - and then re-enables the TUI

the next wgetch() returns KEY_RESIZE.  This indicates to the ncurses
client that ncurses detected that the terminal has been resized.  We
don't handle KEY_RESIZE anywhere, so it gets passed on to readline
which interprets it as a multibyte character, and then the end result
is that the first key press after enabling the TUI is misinterpreted.

We shouldn't really need to handle KEY_RESIZE (and not all ncurses
implementations have that).  We have our own SIGWINCH handler, and,
when we re-enable the TUI, we explicitly detect terminal resizes and
resize all windows.  The reason ncurses currently does detects a
resize is that something within tui_enable forces a refresh/display of
some window before we get to do the actual resizing.  Setting a break
on ncurses' 'resizeterm' function helps find the culprit(s):

 (top-gdb) bt
 #0  resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462
 #1  0x0000003b42812f3f in _nc_update_screensize (sp=0x2674730) at ../../ncurses/tinfo/lib_setup.c:443
 #2  0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726
 #3  0x0000003b08215539 in wrefresh (win=0x2a7bc00) at ../../ncurses/base/lib_refresh.c:65
 #4  0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60
 #5  0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269
 #6  0x00000000005273a6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:321
 #7  0x00000000005278c7 in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:494
 #8  0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108

That is, tui_enable calls tui_set_key_mode before we've resized all
windows, and that refreshes a window as side effect.

And if we're already debugging something (there's a frame), then we'll
instead show a window from within tui_show_frame_info:

 (top-gdb) bt
 #0  resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462
 #1  0x0000003b42812f3f in _nc_update_screensize (sp=0x202e6c0) at ../../ncurses/tinfo/lib_setup.c:443
 #2  0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726
 #3  0x0000003b08215539 in wrefresh (win=0x2042890) at ../../ncurses/base/lib_refresh.c:65
 #4  0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60
 #5  0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269
 #6  0x0000000000522931 in tui_show_frame_info (fi=0x16b9cc0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:364
 #7  0x00000000005278ba in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:491
 #8  0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108

The fix is to resize windows earlier.

gdb/ChangeLog:
2015-02-17  Pedro Alves  <palves@redhat.com>

	* tui/tui.c (tui_enable): Resize windows before anything
	might show a window.
2015-02-17 10:05:52 +00:00
Maxim Ostapenko 9f2e07213a Fix GDB build fail on Aarch64 when -fno-common is enabled
Current trunk GDB (and gdb-7.8.1 too) fails to build on Aarch64 when
-fno-common is enabled.  It fails during link stage due to multiple
definition of `tdesc_aarch64':

...
[  199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64':
[  199s]
/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11:
multiple definition of `tdesc_aarch64'
[  199s]
aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540:
first defined here
[  199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64':
[  199s]
/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11:
multiple definition of `tdesc_aarch64'
[  199s]
aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540:
first defined here
[  199s] collect2: error: ld returned 1 exit status
[  199s] make[2]: *** [gdb] Error 1
...

This happens because struct target_desc *tdesc_aarch64 is defined in
gdb/features/aarch64.c, which is included by two files
(gdb/aarch64-linux-nat.c and gdb/aarch64-tdep.c).

gdb/Changelog
2015-02-17  Max Ostapenko  <m.ostapenko@partner.samsung.com>

	PR gdb/17984
	* aarch64-linux-nat.c: Don't include features/aarch64.c anymore.
	(aarch64_linux_read_description): Remove initialize_tdesc_aarch64
	call.
	* aarch64-tdep.h (tdesc_aarch64): Declare.
2015-02-17 09:10:49 +00:00
Mark Wielaard 171e6b1cf6 Remove true and false ARI checks now that we use stdbool.h.
gdb/ChangeLog:

	* contrib/ari/gdb_ari.sh: Remove checks for "true" and "false".
2015-02-16 11:08:05 +01:00
Doug Evans d5ff04826e misc cp-namespace.c cleanups
gdb/ChangeLog:

	* cp-namespace.c (cp_basic_lookup_symbol): Rename parameter
	anonymous_namespace to is_in_anonymous for consistency with the rest
	of the file.
	(cp_lookup_bare_symbol): Fix typo in comment.
	(cp_search_static_and_baseclasses): Ditto.
	(search_symbol_list): Use vertical space in comment better.
	(reset_directive_searched): Ditto. Fix typo.
	(cp_lookup_nested_symbol_1): Clarify contents of NESTED_NAME parameter.
2015-02-13 12:03:50 -08:00
Yao Qi 9f04ac5f92 Update Yao Qi's email address in MAINTAINERS
gdb:

	* MAINTAINERS: Update my email address.
2015-02-13 10:23:16 +00:00
Doug Evans 013d031916 completer.c (completion_list_add_name): Fix memory leak.
gdb/ChangeLog:

	* completer.c (completion_list_add_name): Fix memory leak.
2015-02-12 13:32:36 -08:00
David Taylor fa3f8d5ac6 Fix documentation of the QTDV packet
gdb/doc/ChangeLog
2015-02-12  David Taylor  <dtaylor@emc.com>

	* gdb.texinfo (Tracepoint Packets): Document the builtin and name
	fields of the QTDV packet.
2015-02-12 22:38:28 +02:00
Doug Evans 9a7e538ee1 completer.c (complete_line): Remove incorrect comment.
gdb/ChangeLog:

	* completer.c (complete_line): Remove incorrect comment.
2015-02-12 12:20:37 -08:00
Jan Kratochvil 63cc30e93a framefilter quit: New test
It definitely does not test all the RETURN_MASK_ERROR cases.  But it tests at
least two of them.

gdb/testsuite/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.python/py-framefilter.exp (pagination quit - *): New tests.
2015-02-11 14:53:14 +01:00
Jan Kratochvil e1fcd5757b framefilter quit: Use RETURN_MASK_ERROR
Now when the code is exception safe we can let RETURN_QUIT to pass through as
all the installed cleanups with handle that.

gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_single_arg, enumerate_locals)
	(py_print_frame): Use RETURN_MASK_ERROR.
2015-02-11 14:50:09 +01:00
Jan Kratochvil b99bf4e352 framefilter quit: Make it exception safe
gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_frame): Mention RETURN_QUIT in
	function comment.  Wrap all function that can throw in cleanups.
	(gdbpy_apply_frame_filter): Wrap all function that can throw in
	cleanups.
2015-02-11 14:44:00 +01:00
Jan Kratochvil 800eb1cebe framefilter quit: Code cleanup: Avoid gotos
goto error patters are sometimes AFAIK used in C for the cases like:
	int retval=-1;
	if (!(a=malloc())) goto error;
	if (!(b=malloc())) goto error_a;
	if (!(c=malloc())) goto error_b;
	retval=0;
	error_c: free(c);
	error_b: free(b);
	error_a: free(a);
	error: return retval;

But here there is single error label with one do_cleanups() which I do not find
it worth the goto complication.  Without goto one can then furher merge code in
the exit paths in the next patches and ... after all it is all the same, just
without a goto.

gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_frame): Substitute goto error.
	Remove the error label.
2015-02-11 14:40:14 +01:00
Jan Kratochvil 34019068f0 framefilter quit: Code cleanup: Reindentation
Nothing significant but I find code more clear with less deep indentation.

gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_frame): Put conditional code paths
	with goto first, indent the former else codepath left.  Put variable
	'elided' to a new inner block.
2015-02-11 14:37:40 +01:00
Jan Kratochvil 8d4a54e2fb framefilter quit: Obvious whitespacing fixes
gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_frame): Whitespacing fixes.
2015-02-11 14:33:48 +01:00
Pedro Alves 18ad82c163 xcoffread.c: delete 'within_function' definition
Linking GDB as a C++ program, we get:

  src/gdb/buildsym.c:226: multiple definition of `within_function'
  xcoffread.o:src/gdb/xcoffread.c:181: first defined here

gdb/
2015-02-11  Pedro Alves  <palves@redhat.com>

	* xcoffread.c (within_function): Delete.
2015-02-11 11:32:38 +00:00
Tom Tromey e36122e9d7 Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances.  That doesn't
work in C++ though.  C++ treats these as definitions.  So then the
compiler complains about symbol redefinition, like:

 src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
 src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here

The intent of static here is naturally to avoid making these objects
visible outside the compilation unit.  The equivalent in C++ would be
to instead define the objects in the anonymous namespace.  But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.

(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)

gdb/ChangeLog:
2015-02-11  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves <palves@redhat.com>

	* breakpoint.c (base_breakpoint_ops): Delete.
	* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
	* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
	* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
	* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
	* python/py-arch.c (arch_object_type): Make extern.
	* python/py-block.c (block_syms_iterator_object_type): Make extern.
	* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
	* python/py-cmd.c (cmdpy_object_type): Make extern.
	* python/py-continueevent.c (continue_event_object_type)
	* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
	parameter.  Update all callers.
	* python/py-evtregistry.c (eventregistry_object_type): Make extern.
	* python/py-exitedevent.c (exited_event_object_type): Make extern.
	* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
	* python/py-function.c (fnpy_object_type): Make extern.
	* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
	* python/py-infevents.c (call_pre_event_object_type)
	(inferior_call_post_event_object_type).
	(memory_changed_event_object_type): Make extern.
	* python/py-infthread.c (thread_object_type): Make extern.
	* python/py-lazy-string.c (lazy_string_object_type): Make extern.
	* python/py-linetable.c (linetable_entry_object_type)
	(linetable_object_type, ltpy_iterator_object_type): Make extern.
	* python/py-newobjfileevent.c (new_objfile_event_object_type)
	(clear_objfiles_event_object_type): Make extern.
	* python/py-objfile.c (objfile_object_type): Make extern.
	* python/py-param.c (parmpy_object_type): Make extern.
	* python/py-progspace.c (pspace_object_type): Make extern.
	* python/py-signalevent.c (signal_event_object_type): Make extern.
	* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
	* python/py-type.c (type_object_type, field_object_type)
	(type_iterator_object_type): Make extern.
	* python/python.c (python_extension_script_ops)
	(python_extension_ops): Make extern.
	* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
Pedro Alves 0703599a49 Fix adjust_pc_after_break, remove still current thread check
On decr_pc_after_break targets, GDB adjusts the PC incorrectly if a
background single-step stops somewhere where PC-$decr_pc has a
breakpoint, and the thread that finishes the step is not the current
thread, like:

   ADDR1 nop <-- breakpoint here
   ADDR2 jmp PC

IOW, say thread A is stepping ADDR2's line in the background (an
infinite loop), and the user switches focus to thread B.  GDB's
adjust_pc_after_break logic confuses the single-step stop of thread A
for a hit of the breakpoint at ADDR1, and thus adjusts thread A's PC
to point at ADDR1 when it should not, and reports a breakpoint hit,
when thread A did not execute the instruction at ADDR1 at all.

The test added by this patch exercises exactly that.

I can't find any reason we'd need the "thread to be examined is still
the current thread" condition in adjust_pc_after_break, at least
nowadays; it might have made sense in the past.  Best just remove it,
and rely on currently_stepping().

Here's the test's log of a run with an unpatched GDB:

 35        while (1);
 (gdb) PASS: gdb.threads/step-bg-decr-pc-switch-thread.exp: next over nop
 next&
 (gdb) PASS: gdb.threads/step-bg-decr-pc-switch-thread.exp: next& over inf loop
 thread 1
 [Switching to thread 1 (Thread 0x7ffff7fc2740 (LWP 29027))](running)
 (gdb)
 PASS: gdb.threads/step-bg-decr-pc-switch-thread.exp: switch to main thread
 Breakpoint 2, thread_function (arg=0x0) at ...src/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.c:34
 34        NOP; /* set breakpoint here */
 FAIL: gdb.threads/step-bg-decr-pc-switch-thread.exp: no output while stepping

gdb/ChangeLog:
2015-02-11  Pedro Alves  <pedro@codesourcery.com>

	* infrun.c (adjust_pc_after_break): Don't adjust the PC just
	because the event thread is not the current thread.

gdb/testsuite/ChangeLog:
2015-02-11  Pedro Alves  <pedro@codesourcery.com>

	* gdb.threads/step-bg-decr-pc-switch-thread.c: New file.
	* gdb.threads/step-bg-decr-pc-switch-thread.exp: New file.
2015-02-11 09:45:41 +00:00
Doug Evans 7e60a48ee0 lib/gdb.exp (gdb_load): Always return a result.
gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_load): Always return a result.
2015-02-10 22:07:06 -08:00
Doug Evans eaaf76abdc internal_type_self_type: Handle TYPE_SPECIFIC_NONE.
gdb/ChangeLog:

	* gdbtypes.c (internal_type_self_type): If TYPE_SPECIFIC_FIELD hasn't
	been initialized yet, return NULL.
2015-02-10 21:18:59 -08:00
Doug Evans e7d52ed304 Rename new_symfile_objfile, make static.
gdb/ChangeLog:

	* symfile.h (new_symfile_objfile): Delete.
	* symfile.c (finish_new_objfile): Renamed from new_symfile_objfile.
	All callers updated.
2015-02-10 17:01:37 -08:00
Patrick Palka fc6b1256ee Fix a pair of screen-resizing issues in TUI
This patch fixes a pair of TUI issues related to screen resizing:

1. In tui_handle_resize_during_io(), when the TUI screen gets resized,
we fail to update GDB's idea about the height of the output window.

You can see this bug by doing:

  a. Enter TUI mode.
  b. "show height"
  c. Resize the terminal.
  d. "show height"

And observe that despite resizing the terminal, the reported height
remains unchanged.  Note that a similar issue exists in the CLI.

The fix for this is simple: call tui_update_gdb_sizes() after performing
a resize, so that the "height" variable remains consistent with the
height of TUI's output window.

2. In tui_enable(), the call to tui_update_gdb_sizes() may clobber
readline's idea of the actual screen dimensions, and a subsequent
pending resize will use bogus terminal dimensions.

You can see this bug by doing:

  a. Enter TUI mode.
  b. Exit TUI mode.
  c. Resize the terminal.
  d. Enter TUI mode.
  e. Press a key to resize the screen.

And observe that the terminal gets incorrectly resized to the wrong
dimensions.  To fix this issue, we should oppurtunistically resize the
screen in tui_enable().  That way we eliminate the possibility of a
pending resize triggering right after we call tui_update_gdb_sizes().

gdb/ChangeLog:

	* tui/tui-io.c (tui_handle_resize_during_io): Call
	tui_update_gdb_sizes() after resizing the screen.
	* tui/tui.c (tui_enable): Resize the terminal before
	calling tui_update_gdb_sizes().
2015-02-10 19:06:49 -05:00
Patrick Palka d908067812 Fix truncation of TUI command history
If we submit a command while the prompt cursor is somewhere other than
at the end of the command line, the command line gets truncated as the
command window gets shifted one line up.  This happens because we fail
to properly move the cursor to the end of the command line before
transmitting the newline to ncurses.  We need to move the cursor because
when ncurses outputs a newline it truncates any text that appears
past the end of the cursor.

The fix is generic enough to work properly even in multi-line secondary
prompts like the quit prompt.

gdb/ChangeLog:

	* tui/tui-io.c (tui_getc): Move cursor to the end of the command
	line before printing a newline.
2015-02-10 19:06:49 -05:00
Mark Wielaard 9f615e3af0 gdb producer_is_gcc fix bool return value.
gdb/ChangeLog:

	* utils.c (producer_is_gcc): Return true or false.
2015-02-11 00:45:39 +01:00
Mark Wielaard b1ffba5a7f Change producer_is_gcc function return type to bool.
gdb/ChangeLog:

        * utils.h (producer_is_gcc): Change return type to bool. Add major
        argument.
        * utils.c (producer_is_gcc): Likewise.
        (producer_is_gcc_ge_4): Adjust producer_is_gcc call.
        * dwarf2read.c (check_producer): Likewise.
2015-02-10 21:20:38 +01:00
Pedro Alves 01b088bc51 Add "signal SIGTRAP" test
Some local changes I was working on related to SIGTRAP handling
resulted in "signal SIGTRAP" no longer passing the SIGTRAP to the
inferior.

Surprisingly, only annota1.exp catches this.  This commit adds a test
that doesn't rely on annotations, so that at the point annotations are
finaly dropped, we still have this use case covered ...

This is a multi-threaded test to also exercise the case of first
needing to do a step-over before delivering the signal.

Tested on x86_64 Fedora 20, native, remote/extended-remote gdbserver.

gdb/testsuite/
2015-02-10  Pedro Alves  <palves@redhat.com>

	* gdb.threads/signal-sigtrap.c: New file.
	* gdb.threads/signal-sigtrap.exp: New file.
2015-02-10 19:30:55 +00:00
Pedro Alves b052c4fbf5 displaced_step_fixup may access memory from the wrong inferior/thread
displaced_step_fixup takes an thread to work with, as argument.  OTOH,
gdbarch_displaced_step_fixup fixes up the current thread.  The former
calls the latter without making sure the current thread is the one
that was passed in.  If it is not, then gdbarch_displaced_step_fixup
may e.g., try reading from a running thread, which doesn't work on
some targets, or worse, read memory from the wrong inferior and
succeed.

This is mostly a latent problem currently, as non-stop switches the
current thread to the event thread early in fetch_inferior_event.

Tested on x86_64 Fedora 20.

gdb/
2015-02-10  Pedro Alves  <palves@redhat.com>

	* infrun.c (displaced_step_fixup): Switch to the event thread
	before calling gdbarch_displaced_step_fixup.
2015-02-10 19:13:31 +00:00
Antoine Tremblay b05ec7a53f gdbserver: Fix crash when QTinit is handled with no inferior process attached
When gdbserver is called with --multi and attach has not been called yet
and tstart is called on the gdb client, gdbserver would crash.
This patch fixes gdbserver so that it returns E01 to the gdb client.

Also this patch adds a testcase to verify this bug named no-attach-trace.exp

gdb/gdbserver/ChangeLog:
	PR breakpoints/15956
	* tracepoint.c (cmd_qtinit): Add check for current_thread.

gdb/testsuite/ChangeLog:
	* gdb.trace/no-attach-trace.c: New file.
	* gdb.trace/no-attach-trace.exp: New file.
2015-02-10 13:49:41 -05:00
Antoine Tremblay 3ac240d438 Add myself as write-after-approval GDB maintainer
gdb/ChangeLog:
	* MAINTAINERS (Write After Approval): Add Antoine Tremblay.
2015-02-10 13:38:57 -05:00
Simon Marchi c1cc615262 Finish constification of varobj interface
This completes the constification of the struct varobj pointers in the
lang_varobj_ops interface partially done in
b09e2c591f. As suggested by Pedro,
varobj_get_path_expr casts away the const to assign the "mutable" struct
member.

gdb/ChangeLog:

	* ada-varobj.c (ada_name_of_child): Constify parent.
	(ada_path_expr_of_child): Same.
	(ada_value_of_child): Same.
	(ada_type_of_child): Same.
	* c-varobj.c (c_is_path_expr_parent): Same.
	(c_describe_child): Same.
	(c_name_of_child): Same.
	(c_value_of_child): Same.
	(c_type_of_child): Same.
	(cplus_number_of_children): Same.
	(cplus_describe_child): Constify var.
	(cplus_name_of_child): Constify parent.
	(cplus_value_of_child): Same.
	(cplus_type_of_child): Same.
	* jv-varobj.c (java_name_of_child): Same.
	(java_value_of_child): Same.
	(java_type_of_child): Same.
	* varobj.c (value_of_child): Same.
	(varobj_default_is_path_expr_parent): Constify var, parent and return
	value.
	(varobj_get_path_expr): Constify var, modify path_expr through
	mutable_var.
	(install_new_value): Constify parent.
	(value_of_child): Constify parent.
	* varobj.h (struct varobj): Constify parent.
	(struct lang_varobj_ops): Constify name_of_child, value_of_child and
	type_of_child.
	(varobj_get_path_expr): Constify var.
	(varobj_get_path_expr_parent): Constify var and return value.
2015-02-10 12:57:47 -05:00
Luis Machado c1ee941477 Relax ARM prologue unwinder assumption
Modify the ARM prologue unwinder to use the stop_reason hook instead of
returning imprecise frame id's through the arm prologue this_id hook.

gdb/
2015-02-10  Luis Machado  <lgustavo@codesourcery.com>

	* arm-tdep.c (arm_prologue_unwind_stop_reason): New function.
	(arm_prologue_this_id): Move PC and SP limit checks to
	arm_prologue_unwind_stop_reason.
	(arm_prologue_unwind) <stop_reason> : Set to
	arm_prologue_unwind_stop_reason.
2015-02-10 09:46:11 -02:00
Mark Wielaard f7de9aab90 Recognize new DWARF5/GCC5 DW_LANG Fortran 2003 and Fortran 2008 standards.
DWARFv5 defines and GCC5 may output two new DW_LANG constants for the
Fortran 2003 and Fortran 2008 standards. Recognize both as variants of
language_fortran.

gdb/ChangeLog:

	* dwarf2read.c (set_cu_language): Recognize DW_LANG_Fortran03 and
	DW_LANG_Fortran08 as language_fortran.

http://dwarfstd.org/ShowIssue.php?issue=141121.1
2015-02-10 10:15:04 +01:00
Sergio Durigan Junior 0b24eb2de5 PR remote/17946: Fix wrong comparison of pointer against char
We were comparing a pointer against a char on remote.c.  'dcb' filed a
bug to inform us about that.  I pushed the following patch under the
obvious rule.

gdb/ChangeLog:
2015-02-09  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR remote/17946
	* gdb/remote.c (remote_parse_stop_reply): Fix wrong comparison
	of pointer against char.
2015-02-09 19:00:55 -05:00
Mark Wielaard a2c2acaf15 GCC5/DWARFv5 Handle DW_TAG_atomic_type for C11 _Atomic type qualifier.
gdb/ChangeLog

	* c-typeprint.c (cp_type_print_method_args): Handle '_Atomic'.
	(c_type_print_modifier): Likewise.
	* dwarf2read.c (read_tag_atomic_type): New function.
	(read_type_die_1): Handle DW_TAG_atomic_type.
	* gdbtypes.c (make_atomic_type): New function.
	(recursive_dump_type): Handle TYPE_ATOMIC.
	* gdbtypes.h (enum type_flag_values): Renumber.
	(enum type_instance_flag_value): Add TYPE_INSTANCE_FLAG_ATOMIC.
	(TYPE_ATOMIC): New macro.
	(make_atomic_type): Declare.

gdb/testsuite/ChangeLog

	* gdb.dwarf2/atomic.c: New file.
	* gdb.dwarf2/atomic-type.exp: Likewise.

include/ChangeLog

	* dwarf2.def: Add DW_TAG_atomic_type.
2015-02-09 15:09:22 +01:00
Markus Metzger 31fd9caad9 record-btrace: indicate gaps
Indicate gaps in the trace due to decode errors.  Internally, a gap is
represented as a btrace function segment without instructions and with a
non-zero format-specific error code.

Show the gap when traversing the instruction or function call history.
Also indicate gaps in "info record".

It looks like this:

  (gdb) info record
  Active record target: record-btrace
  Recording format: Branch Trace Store.
  Buffer size: 64KB.
  Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182).
  (gdb) record function-call-history /cli
  1	fib	inst 1,9	at src/fib.c:9,14
  2	  fib	inst 10,20	at src/fib.c:6,14
  3	[decode error (1): instruction overflow]
  4	fib	inst 21,28	at src/fib.c:11,14
  5	  fib	inst 29,33	at src/fib.c:6,9
  (gdb) record instruction-history 20,22
  20	   0x000000000040062f <fib+47>:	sub    $0x1,%rax
  [decode error (1): instruction overflow]
  21	   0x0000000000400613 <fib+19>:	add    $0x1,%rax
  22	   0x0000000000400617 <fib+23>:	mov    %rax,0x200a3a(%rip)
  (gdb)

Gaps are ignored during reverse execution and replay.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c (ftrace_find_call): Skip gaps.
	(ftrace_new_function): Initialize level.
	(ftrace_new_call, ftrace_new_tailcall, ftrace_new_return)
	(ftrace_new_switch): Update
	level computation.
	(ftrace_new_gap): New.
	(ftrace_update_function): Create new function after gap.
	(btrace_compute_ftrace_bts): Create gap on error.
	(btrace_stitch_bts): Update parameters.  Clear trace if it
	becomes empty.
	(btrace_stitch_trace): Update parameters.  Update callers.
	(btrace_clear): Reset the number of gaps.
	(btrace_insn_get): Return NULL if the iterator points to a gap.
	(btrace_insn_number): Return zero if the iterator points to a gap.
	(btrace_insn_end): Allow gaps at the end.
	(btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps.
	(btrace_find_insn_by_number): Assert that the found iterator does
	not point to a gap.
	(btrace_call_next, btrace_call_prev): Assert that the last function
	is not a gap.
	* btrace.h (btrace_bts_error): New.
	(btrace_function): Update comment.
	(btrace_function) <insn, insn_offset, number>: Update comment.
	(btrace_function) <errcode>: New.
	(btrace_thread_info) <ngaps>: New.
	(btrace_thread_info) <replay>: Update comment.
	(btrace_insn_get): Update comment.
	* record-btrace.c (btrace_ui_out_decode_error): New.
	(record_btrace_info): Print number of gaps.
	(btrace_insn_history, btrace_call_history): Call
	btrace_ui_out_decode_error for gaps.
	(record_btrace_step_thread, record_btrace_start_replaying): Skip gaps.

testsuite/
	* gdb.btrace/buffer-size.exp: Update "info record" output.
	* gdb.btrace/delta.exp: Update "info record" output.
	* gdb.btrace/enable.exp: Update "info record" output.
	* gdb.btrace/finish.exp: Update "info record" output.
	* gdb.btrace/instruction_history.exp: Update "info record" output.
	* gdb.btrace/next.exp: Update "info record" output.
	* gdb.btrace/nexti.exp: Update "info record" output.
	* gdb.btrace/step.exp: Update "info record" output.
	* gdb.btrace/stepi.exp: Update "info record" output.
	* gdb.btrace/nohist.exp: Update "info record" output.
2015-02-09 09:52:10 +01:00
Markus Metzger afb778a2a8 btrace: identify cpu
Add a struct for identifying a processor and use it in linux-btrace.c when
identifying the processor we're running on.

We will need this feature for the new btrace format.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* common/btrace-common.h (btrace_cpu_vendor, btrace_cpu): New.
	* nat/linux-btrace.c: (btrace_this_cpu): New.
	(cpu_supports_bts): Call btrace_this_cpu.
	(intel_supports_bts): Add cpu parameter.
2015-02-09 09:49:15 +01:00
Markus Metzger 7d5c24b3ae btrace: extend struct btrace_insn
Add the instruction's size as well as a coarse classification to struct
btrace_insn.  Use the information in ftrace_update_function and
ftrace_find_call.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.h (btrace_insn_class): New.
	(btrace_insn) <size, iclass>: New.
	* btrace.c (ftrace_find_call): Update parameters.  Update users.
	Use instruction classification.
	(ftrace_new_return): Update parameters.  Update users.
	(ftrace_update_function): Update parameters.  Update users.  Use
	instruction classification.
	(ftrace_update_insns): Update parameters.  Update users.
	(ftrace_classify_insn): New.
	(btrace_compute_ftrace_bts): Fill in new btrace_insn fields.  Add
	TRY_CATCH around call to gdb_insn_length.
2015-02-09 09:46:49 +01:00