Commit Graph

37433 Commits

Author SHA1 Message Date
Yao Qi 0735fdddbc Fix out of boundary access in pass_in_v
Hi,
I build GDB with -fsanitize=address, and run testsuite.  In
gdb.base/callfuncs.exp, I see the following error,

p t_float_values(0.0,0.0)
=================================================================
==8088==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000cb650 at pc 0x6e195c bp 0x7fff164f9770 sp 0x7fff164f9768
READ of size 16 at 0x6020000cb650 thread T0^
    #0 0x6e195b in regcache_raw_write /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:912
    #1 0x6e1e52 in regcache_cooked_write /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:945
    #2 0x466d69 in pass_in_v /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1101
    #3 0x467512 in pass_in_v_or_stack /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1196
    #4 0x467d7d in aarch64_push_dummy_call /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1335

The code in pass_in_v read contents from V registers (128 bit), but the
data passed through V registers can be less than 128 bit.  In this case,
float is passed.  So writing V registers contents into contents buff
will cause overflow.  In this patch, we add an array reg[V_REGISTER_SIZE],
which is to hold the contents from V registers, and then copy useful
bits to buf.

gdb:

2015-11-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (pass_in_v): Add argument len.  Add local array
	reg.  Callers updated.
2015-11-18 11:49:55 +00:00
Yao Qi 1946c4ccca Fix gdb.threads/multiple-step-overs.exp fails on arm
Hi,
Some tests in gdb.threads/multiple-step-overs.exp fail on arm target
when the displaced stepping on, but they pass when displaced stepping
is off.

 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: step: step
 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: next: next
 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: continue: continue
 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr1: continue to sigusr1_handler

when displaced stepping is on,

Sending packet: $vCont;c#a8...infrun: infrun_async(1)^M <--- [1]
infrun: prepare_to_wait^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   -1.0.0 [Thread 0],^M
infrun:   status->kind = ignore^M
infrun: TARGET_WAITKIND_IGNORE^M
infrun: prepare_to_wait^M
Packet received: T05swbreak:;0b:f8faffbe;0d:409ee7b6;0f:d0880000;thread:p635.636;core:0;^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   1589.1590.0 [Thread 1590],^M
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP^M
infrun: TARGET_WAITKIND_STOPPED^M
infrun: stop_pc = 0x88d0^M
infrun: context switch^M
infrun: Switching context from Thread 1591 to Thread 1590^

GDB resumes the whole process (all threads) rather than the specific
thread for which GDB wants to step over the breakpoint (as shown in [1]).
That is wrong because we resume a single thread and leave others stopped
when doing a normal step over where we temporarily remove the breakpoint,
single-step, reinsert the breakpoint, is that if we let other threads run
in the period while the breakpoint is removed, then these other threads
could miss the breakpoint.  Since with displaced stepping, we don't ever
remove the breakpoint, it should be fine to let other threads run.  However,
there's another reason that we should not let other threads run: that is
the case where some of those threads are also stopped for a breakpoint that
itself needs to be stepped over.  If we just let those threads run, then
they immediately re-trap their breakpoint again.

when displaced stepping is off, GDB behaves correctly, only resumes
the specific thread (as shown in [2]).

Sending packet: $vCont;c:p611.613#b2...infrun: infrun_async(1)^M <-- [2]
infrun: prepare_to_wait^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   -1.0.0 [Thread 0],^M
infrun:   status->kind = ignore^M
infrun: TARGET_WAITKIND_IGNORE^M
infrun: prepare_to_wait^M
Packet received: T05swbreak:;0b:f8faffbe;0d:409e67b6;0f:48880000;thread:p611.613;core:1;^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   1553.1555.0 [Thread 1555],^M
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP^M
infrun: TARGET_WAITKIND_STOPPED^M
infrun: clear_step_over_info^M
infrun: stop_pc = 0x8848

The current logic in GDB on deciding the set of threads to resume is:

  /* Decide the set of threads to ask the target to resume.  */
  if ((step || thread_has_single_step_breakpoints_set (tp))
      && tp->control.trap_expected)
    {
      /* We're allowing a thread to run past a breakpoint it has
	 hit, by single-stepping the thread with the breakpoint
	 removed.  In which case, we need to single-step only this
	 thread, and keep others stopped, as they can miss this
	 breakpoint if allowed to run.  */
      resume_ptid = inferior_ptid;
    }
  else
    resume_ptid = internal_resume_ptid (user_step);

it doesn't handle the case correctly that GDB continue (instead of
single step) the thread for displaced stepping.

I also update the comment below to reflect the code.  I remove the
"with the breakpoint removed" comment, because GDB doesn't remove
breakpoints in displaced stepping, so we don't have to worry that
other threads may miss the breakpoint.

Patch is regression tested on both x86_64-linux and arm-linux.

gdb:

2015-11-17  Yao Qi  <yao.qi@linaro.org>

	* infrun.c (resume): Check control.trap_expected only
	when deciding the set of threads to resume.
2015-11-17 15:40:29 +00:00
Pedro Alves b6b806729d Introduce null_block_symbol
... in the spirit of null_ptid, null_frame_id, etc.

Fixes two instances of:

  /root/binutils-gdb/gdb/cp-namespace.c: In function 'block_symbol cp_lookup_nested_symbol(type*, const char*, const block*, domain_enum)':
  /root/binutils-gdb/gdb/cp-namespace.c:1010: warning: jump to case label
  /root/binutils-gdb/gdb/cp-namespace.c:1008: error:   crosses initialization of 'block_symbol <anonymous>'

Compiler info:

  Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.8/4.2.1/specs
  Target: amd64-unknown-openbsd5.8
  Configured with: OpenBSD/amd64 system compiler
  Thread model: posix
  gcc version 4.2.1 20070719

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

	* cp-namespace.c (cp_lookup_bare_symbol)
	(cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports)
	(cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1)
	(cp_lookup_nested_symbol): Use null_block_symbol.
	* d-namespace.c (d_lookup_symbol, d_lookup_nested_symbol)
	(d_lookup_symbol_imports, d_lookup_symbol_module): Use
	null_block_symbol.
	* symtab.c (null_block_symbol): New global.
	* symtab.h (null_block_symbol): Declare.
2015-11-17 15:30:33 +00:00
Pedro Alves eec461d0a8 [C++] Always use setjmp/longjmp for exceptions
We currently throw exceptions from signal handlers (e.g., for
Quit/ctrl-c).  But throwing C++ exceptions from signal handlers is
undefined.  (That doesn't restore signal masks, like siglongjmp does,
and, because asynchronous signals can arrive at any instruction, we'd
have to build _everything_ with -fasync-unwind-tables to make it
reliable.)  It happens to work on x86_64 GNU/Linux at least, but it's
likely broken on other ports.

Until we stop throwing from signal handlers, use setjmp/longjmp based
exceptions in C++ mode as well.

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

	* common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY)
	(GDB_XCPT_RAW_TRY, GDB_XCPT): Define.
	Replace __cplusplus checks with GDB_XCPT checks throughout.
	* common/common-exceptions.c: Replace __cplusplus checks with
	GDB_XCPT checks throughout.
2015-11-17 15:23:15 +00:00
Pedro Alves 91ee7171d0 MinGW and attribute format(printf/gnu_printf)
Cross building gdbserver for --host=x86_64-w64-mingw32 with gcc 4.8.4
20141219 (Fedora MinGW 4.8.4-1.fc20), I get:

  src/gdb/gdbserver/tracepoint.c: In function 'cmd_qtdp':
  src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=]
	 trace_debug ("Defined %stracepoint %d at 0x%s, "
	 ^
  src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=]
  src/gdb/gdbserver/tracepoint.c:2577:7: error: too many arguments for format [-Werror=format-extra-args]
  src/gdb/gdbserver/tracepoint.c: In function 'stop_tracing':
  src/gdb/gdbserver/tracepoint.c:3447:7: error: unknown conversion type character 'l' in format [-Werror=format=]
	 trace_debug ("Stopping the trace because "
	 ^
  src/gdb/gdbserver/tracepoint.c:3447:7: error: too many arguments for format [-Werror=format-extra-args]
  src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_tracepoint':
  src/gdb/gdbserver/tracepoint.c:4651:3: error: unknown conversion type character 'l' in format [-Werror=format=]
     trace_debug ("Making new traceframe for tracepoint %d at 0x%s, hit %" PRIu64,
     ^
  src/gdb/gdbserver/tracepoint.c:4651:3: error: too many arguments for format [-Werror=format-extra-args]
  src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_step':
  src/gdb/gdbserver/tracepoint.c:4687:3: error: unknown conversion type character 'l' in format [-Werror=format=]
     trace_debug ("Making new step traceframe for "
     ^

trace_debug is a macro that calls:

  static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);

The calls that fail checking use PRIu64, etc., like:

      trace_debug ("Defined %stracepoint %d at 0x%s, "
		   "enabled %d step %" PRIu64 " pass %" PRIu64,
		   tpoint->type == fast_tracepoint ? "fast "
		   : tpoint->type == static_tracepoint ? "static " : "",
		   tpoint->number, paddress (tpoint->address), tpoint->enabled,
		   tpoint->step_count, tpoint->pass_count);

gnulib's stdio/printf module replacements may make %llu, etc. work on
mingw, instead of the MS-specific %I64u, and thus may make PRIu64
expand to %llu.  However, gcc isn't aware of that, because libiberty's
ansidecl.h defines ATTRIBUTE_PRINTF as using attribute format(printf).
But, with that format, gcc checks for MS-style format strings (%I64u).
In order to have gcc expect gnu/standard formats, we need to use
gnu_printf format instead.  Which version to use (printf/gnu_printf)
depends on msvcrt and mingw version, and so gnulib has a
configure-time check, and defines _GL_ATTRIBUTE_FORMAT_PRINTF
accordingly.

Since _GL_ATTRIBUTE_FORMAT_PRINTF is compatible with ATTRIBUTE_PRINTF,
the fix is simply to make use of the former.

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

	* common/common-defs.h (ATTRIBUTE_PRINTF): Redefine in terms of
	_GL_ATTRIBUTE_FORMAT_PRINTF after including ansidecl.h.
2015-11-17 15:22:39 +00:00
Pedro Alves e063da6790 [C++] Define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS for stdint.h
With some toolchains, building in C++ mode stumbles on many instances
of:

 In file included from ../../src/gdb/../include/splay-tree.h:43:0,
                  from ../../src/gdb/dcache.c:26:
 build-gnulib/import/inttypes.h:61:3: error: #error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
  # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
    ^
 make: *** [dcache.o] Error 1

That's:

 #if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX)
 # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
 #endif

I see it when cross building for --host=x86_64-w64-mingw32 using
Fedora 20's g++ (gcc version 4.8.4 20141219 (Fedora MinGW
4.8.4-1.fc20)), Simon reports seeing this on several cross compilers
too.

The issue is that on some hosts that predate C++11, when using C++ one
must define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS to make visible
the definitions of INTMAX_C / INTMAX_MAX etc.

This was a C99 requirement that later C++11 -- the first to define
stdint.h -- removed, and then C11 removed it as well.

https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
says that gnulib's stdint.h fixes this, but because we run gnulib's
configure tests with a C compiler, gnulib determines that mingw's
stdint.h is C99-compliant, and doesn't actually replace it.  Actually,
even though configuring gnulib with a C++ compiler does result in
gnulib replacing stdint.h, the resulting replacement is broken for
mingw, because it defines uintptr_t incorrectly.  I sent a gnulib
patch upstream to fix that, here:

  https://lists.gnu.org/archive/html/bug-gnulib/2015-11/msg00004.html

but then even with that, gnulib still stumbles on other
configured-with-C++-compiler problems.

So for now, until gnulib + C++ is fixed upstream and then gdb's copy
is updated, which may take a while, I think it's best to keep
configuring gnulib in C, and define
__STDC_LIMIT_MACROS/__STDC_CONSTANT_MACROS ourselves, just like C99
intended.

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

	* common/common-defs.h (__STDC_CONSTANT_MACROS)
	(__STDC_LIMIT_MACROS): Define before including stdint.h.
2015-11-17 15:22:16 +00:00
Pedro Alves 95824559df [C++/mingw] Simplify first chance exception handling
Building in C++ errors out with:

../../src/gdb/windows-nat.c: In function 'int get_windows_debug_event(target_ops*, int, target_waitstatus*)':
../../src/gdb/windows-nat.c:1503:13: warning: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
    last_sig = 1;
             ^
../../src/gdb/windows-nat.c:1533:43: warning: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
  windows_resume (ops, minus_one_ptid, 0, 1);
                                           ^
../../src/gdb/windows-nat.c:1228:1: warning:   initializing argument 4 of 'void windows_resume(target_ops*, ptid_t, int, gdb_signal)' [-fpermissive]
 windows_resume (struct target_ops *ops,
 ^

Looking at the code, I can't figure out why we treat first chance
exceptions any different here.

AFAICS, we set last_sig to 1, and then call windows_resume passing
signal==1, so the DBG_EXCEPTION_NOT_HANDLED code path in win32_resume
is taken:

~~~
  if (sig != GDB_SIGNAL_0)
    {
      if (current_event.dwDebugEventCode != EXCEPTION_DEBUG_EVENT)
	{
	  OUTMSG (("Cannot continue with signal %d here.\n", sig));
	}
      else if (sig == last_sig)
	continue_status = DBG_EXCEPTION_NOT_HANDLED;
      else
	OUTMSG (("Can only continue with recieved signal %d.\n", last_sig));
    }
~~~

Fix this by removing this special casing.  gdbserver also goes
straight to continuing with DBG_EXCEPTION_NOT_HANDLED, AFAICS.

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

	* windows-nat.c (handle_exception): Return 0 for first chance
	exceptions.
	(get_windows_debug_event): Adjust.
2015-11-17 15:21:45 +00:00
Pedro Alves ce7715e259 [C++/mingw] gdbserver: gdb/host signal mixup
Building in C++ caught a buglet here:

../../../src/gdb/gdbserver/win32-low.c: In function 'void win32_resume(thread_resume*, size_t)':
../../../src/gdb/gdbserver/win32-low.c:929:11: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
       sig = resume_info[0].sig;
           ^
../../../src/gdb/gdbserver/win32-low.c:934:11: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
       sig = 0;
           ^

Signals in the "struct thread_resume" structure are host signals, not
gdb signals.  The current code happens to work because the only
signals that the Windows port supports have the same number as the gdb
equivalent (see handle_exception for the win32 exception -> gdb signal
mapping).

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

	* win32-low.c (win32_resume): Use gdb_signal_from_host,
	GDB_SIGNAL_0 and gdb_signal_to_string.
2015-11-17 15:21:13 +00:00
Pedro Alves 56db1d676c [C++/mingw] Fix windows-nat.c::xlate
Fixes:

../../src/gdb/windows-nat.c:287:11: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
   {-1, -1}};
           ^

The signal number here doesn't really matter.

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

	* windows-nat.c (xslate): Use GDB_SIGNAL_UNKNOWN instead of -1 as
	signal number for terminator.
2015-11-17 15:20:48 +00:00
Pedro Alves c08790597c [C++/mingw] handle_output_debug_string
Fixes:

 ../../../src/gdb/gdbserver/win32-low.c: In function 'int win32_kill(int)':
 ../../../src/gdb/gdbserver/win32-low.c:823:46: error: invalid conversion from 'int' to 'target_waitkind' [-fpermissive]
     struct target_waitstatus our_status = { 0 };
					       ^

handle_output_debug_string doesn't use the parameter for anything
(it's an output parameter in the gdb version), so just remove it.

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

	* win32-low.c (handle_output_debug_string): Remove parameter.
	(win32_kill): Remove our_status local and adjust call to
	handle_output_debug_string.
	(get_child_debug_event): Adjust call to
	handle_output_debug_string.
2015-11-17 15:20:26 +00:00
Pedro Alves 69e976f8cc [C++/mingw] ser-tcp.c casts
Fixes a few errors like these:

../../src/gdb/ser-tcp.c: In function 'int net_open(serial*, const char*)':
../../src/gdb/ser-tcp.c:286:73: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
     res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len);
                                                                         ^

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

	* ser-tcp.c (net_open) : Cast getsockopt argument to char *
	instead of void *.  Update comment.
	(net_read_prim): Cast recv argument to char * instead of void *.
	(net_write_prim): Cast send argument to char *.  Add comment.
2015-11-17 15:20:03 +00:00
Pedro Alves c3de4d92df [C++/mingw] gdbserver casts
A set of obviously-needed C++ casts.

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

	* win32-i386-low.c (update_debug_registers_callback)
	(win32_get_current_dr): Add cast.
	* win32-low.c (thread_rec, delete_thread_info)
	(continue_one_thread): Add casts.
	(strwinerror): Cast FormatMessage argument to LPTSTR instead of
	LPVOID.
	(win32_create_inferior, suspend_one_thread): Add casts.
2015-11-17 15:19:42 +00:00
Pedro Alves 43499ea30d [C++/mingw] windows-nat.c casts
Fixes a set of errors like:

../../src/gdb/windows-nat.c: In function 'void _initialize_loadable()':
../../src/gdb/windows-nat.c:2778:30: error: invalid conversion from 'void*' to 'BOOL (*)(DWORD) {aka int (*)(long unsigned int)}' [-fpermissive]
       DebugActiveProcessStop = (void *)
                              ^

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

	* windows-nat.c (AdjustTokenPrivileges_ftype)
	(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
	(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
	(GetCurrentConsoleFont_ftype, GetModuleInformation_ftype)
	(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
	(GetConsoleFontSize_ftype): New typedefs.
	(AdjustTokenPrivileges, DebugActiveProcessStop)
	(DebugBreakProcess, DebugSetProcessKillOnExit, EnumProcessModules)
	(GetConsoleFontSize, GetCurrentConsoleFont, GetModuleInformation)
	(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize):
	Adjust.
	(GetModuleFileNameEx_ftype): New typedef.
	(GetModuleFileNameEx): Use it.
	(_initialize_loadable): Define GPA macro and use it.
2015-11-17 15:19:17 +00:00
Pedro Alves 2986367f8e [C++/mingw] gdb-dlfcn.c casts
Fixes:

../../src/gdb/gdb-dlfcn.c: In function 'void* gdb_dlsym(void*, const char*)':
../../src/gdb/gdb-dlfcn.c:105:49: error: invalid conversion from 'void*' to 'HMODULE {aka HINSTANCE__*}' [-fpermissive]
   return (void *) GetProcAddress (handle, symbol);
                                                 ^

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

	* gdb-dlfcn.c (gdb_dlsym, gdb_dlclose) [__MINGW32__]: Add casts to
	HMODULE.
2015-11-17 15:18:58 +00:00
Pedro Alves 0ae1c716a1 [C++/mingw] Misc alloca casts
gdb/ChangeLog:
2015-11-17  Pedro Alves  <palves@redhat.com>

	* exec.c (exec_file_attach, symfile_bfd_open) [__GO32__ || _WIN32
	|| __CYGWIN__]: Add casts.
	* utils.c (gdb_filename_fnmatch): Add cast.
	* windows-nat.c (windows_create_inferior): Add cast.
2015-11-17 15:18:32 +00:00
Pedro Alves cd78b7a167 [C++/mingw] ser-mingw.c casts
2015-11-17  Pedro Alves  <palves@redhat.com>

	* ser-mingw.c (CancelIo_ftype): New typedef.
	(CancelIo): Use CancelIo_ftype.
	(ser_windows_close, ser_windows_wait_handle)
	(ser_windows_read_prim, stop_select_thread)
	(console_select_thread, pipe_select_thread, file_select_thread)
	(ser_console_wait_handle, ser_console_done_wait_handle)
	(ser_console_close, cleanup_pipe_state, pipe_windows_close)
	(pipe_windows_write, pipe_wait_handle, pipe_done_wait_handle)
	(net_windows_socket_check_pending, net_windows_select_thread)
	(net_windows_wait_handle, net_windows_done_wait_handle)
	(net_windows_close): Add casts.
	(_initialize_ser_windows): Cast to CancelIo_ftype* instead of
	void*.
2015-11-17 15:17:44 +00:00
Simon Marchi 0c801b9663 Convert c_string_type to an enum flags type
c_string_type contains values meant to be OR'ed together (even though
some bits are mutually exclusive), so it makes sense to make it an
enum flags type.

gdb/ChangeLog:
2015-11-17  Simon Marchi  <simon.marchi@ericsson.com>

	* c-exp.y (exp): Adjust, change enum c_string_type to
	c_string_type.
	(parse_string_or_char): Likewise.
	* c-lang.c (charset_for_string_type): Likewise.
	(classify_type): Likewise.
	(c_printchar): Likewise.
	(c_printstr): Likewise.
	(evaluate_subexp_c): Likewise.  And change cast to enum
	c_string_type_values.
	* c-lang.h: Include "common/enum_flags.h".
	(enum c_string_type): Rename to...
	(enum c_string_type_values): ...this.
	(c_string_type): Define new enum flags type.
2015-11-17 13:31:29 +00:00
Pedro Alves 8d297bbf60 Type-safe wrapper for enum flags
This patch fixes C++ build errors like this:

/home/pedro/gdb/mygit/cxx-convertion/src/gdb/linux-tdep.c:1126:35: error: invalid conversion from ‘int’ to ‘filterflags’ [-fpermissive]
       | COREFILTER_HUGETLB_PRIVATE);
                                   ^

This is a case of enums used as bit flags.  Unlike "regular" enums,
these values are supposed to be or'ed together.  However, in C++, the
type of "(ENUM1 | ENUM2)" is int, and you then can't assign an int to
an enum variable without a cast.  That means that this:

  enum foo_flags flags = 0;

  if (...)
    flags |= FOO_FLAG1;
  if (...)
    flags |= FOO_FLAG2;

... would have to be written as:

  enum foo_flags flags = (enum foo_flags) 0;

  if (...)
    flags = (enum foo_flags) (flags | FOO_FLAG1);
  if (...)
    flags = (enum foo_flags) (flags | FOO_FLAG2);

which is ... ugly.  Alternatively, we'd have to use an int for the
variable's type, which isn't ideal either.

This patch instead adds an "enum flags" class.  "enum flags" are
exactly the enums where the values are bits that are meant to be ORed
together.

This allows writing code like the below, while with raw enums this
would fail to compile without casts to enum type at the assignments to
'f':

  enum some_flag
  {
     flag_val1 = 1 << 1,
     flag_val2 = 1 << 2,
     flag_val3 = 1 << 3,
     flag_val4 = 1 << 4,
  };
  DEF_ENUM_FLAGS_TYPE(enum some_flag, some_flags)

  some_flags f = flag_val1 | flag_val2;
  f |= flag_val3;

It's also possible to assign literal zero to an enum flags variable
(meaning, no flags), dispensing either adding an awkward explicit "no
value" value to the enumeration or the cast to assignments from 0.
For example:

  some_flags f = 0;
  f |= flag_val3 | flag_val4;

Note that literal integers other than zero do fail to compile:

  some_flags f = 1; // error

C is still supported -- DEF_ENUM_FLAGS_TYPE is just a typedef in that
case.

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

	* btrace.h: Include common/enum-flags.h.
	(btrace_insn_flags): Define.
	(struct btrace_insn) <flags>: Change type.
	(btrace_function_flags): Define.
	(struct btrace_function) <flags>: Change type.
	(btrace_thread_flags): Define.
	(struct btrace_thread_info) <flags>: Change type.
	* c-exp.y (token_flags): Rename to ...
	(token_flag): ... this.
	(token_flags): Define.
	(struct token) <flags>: Change type.
	* common/enum-flags.h: New file.
	* compile/compile-c-types.c (convert_qualified): Change type of
	'quals' local.
	* compile/compile-internal.h: Include "common/enum-flags.h".
	(gcc_qualifiers_flags): Define.
	* completer.c (enum reg_completer_targets): Rename to ...
	(enum reg_completer_target): ... this.
	(reg_completer_targets): Define.
	(reg_or_group_completer_1): Change type of 'targets' parameter.
	* disasm.c (do_mixed_source_and_assembly_deprecated): Change type
	of 'psl_flags' local.
	(do_mixed_source_and_assembly): Change type of 'psl_flags' local.
	* infrun.c: Include "common/enum-flags.h".
	(enum step_over_what): Rename to ...
	(enum step_over_what_flag): ... this.
	(step_over_what): Change type.
	(start_step_over): Change type of 'step_what' local.
	(thread_still_needs_step_over): Now returns a step_over_what.
	Adjust.
	(keep_going_pass_signal): Change type of 'step_what' local.
	* linux-tdep.c: Include "common/enum-flags.h".
	(enum filterflags): Rename to ...
	(enum filter_flag): ... this.
	(filter_flags): Define.
	(dump_mapping_p): Change type of 'filterflags' parameter.
	(linux_find_memory_regions_full): Change type of 'filterflags'
	local.
	(linux_find_memory_regions_full): Pass the address of an unsigned
	int to sscanf instead of the address of an enum.
	* record-btrace.c (btrace_print_lines): Change type of local
	'psl_flags'.
	(btrace_call_history): Replace 'flags' parameter
	with 'int_flags' parameter.  Adjust.
	(record_btrace_call_history, record_btrace_call_history_range)
	(record_btrace_call_history_from): Rename 'flags' parameter to
	'int_flags'.  Use record_print_flags.
	* record.h: Include "common/enum-flags.h".
	(record_print_flags): Define.
	* source.c: Include "common/enum-flags.h".
	(print_source_lines_base, print_source_lines): Change type of
	flags parameter.
	* symtab.h: Include "common/enum-flags.h".
	(enum print_source_lines_flags): Rename to ...
	(enum print_source_lines_flag): ... this.
	(print_source_lines_flags): Define.
	(print_source_lines): Change prototype.
2015-11-17 13:31:29 +00:00
Pedro Alves 9a4073e20b guile disassembly hardcode TARGET_XFER_E_IO
Instead of adding a cast at the memory_error call, as needed for C++,
and have the reader understand the indirection, make it simple and
hardcode the generic memory error at the memory_error call site.

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

	* guile/scm-disasm.c (gdbscm_disasm_read_memory): Return -1 on
	error instead of TARGET_XFER_E_IO.
	(gdbscm_disasm_memory_error): Always pass TARGET_XFER_E_IO to
	memory_error.
2015-11-17 13:31:28 +00:00
Dominik Vogt 340c283058 gdb/testsuite: Fix left shift of negative value.
This patch fixes all occurences of left-shifting negative constants in C cod
which is undefined by the C standard.

gdb/testsuite/ChangeLog:

        * lib/dwarf.exp (_note): Fix left shift of negative value.
        * gdb.trace/trace-condition.exp: Likewise.
2015-11-17 10:56:32 +01:00
Dominik Vogt 66c6502d7a gdb: Fix left shift of negative value.
This patch fixes all occurences of left-shifting negative constants in C cod
which is undefined by the C standard.

gdb/ChangeLog:

        * hppa-tdep.c (hppa_sign_extend, hppa_low_hppa_sign_extend)
        (prologue_inst_adjust_sp, hppa_frame_cache): Fix left shift of negative
        value.
        * dwarf2read.c (read_subrange_type): Likewise.
2015-11-17 10:56:32 +01:00
Yao Qi db3516bbfa Fix stack buffer overflow in aarch64_extract_return_value
Hi,
I build GDB with -fsanitize=address, and run testsuite.  In
gdb.base/callfuncs.exp, I see the following error,

p/c fun1()
=================================================================^M
==9601==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffee858530 at pc 0x6df079 bp 0x7fffee8583a0 sp 0x7fffee858398
WRITE of size 16 at 0x7fffee858530 thread T0
    #0 0x6df078 in regcache_raw_read /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:673
    #1 0x6dfe1e in regcache_cooked_read /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:751
    #2 0x4696a3 in aarch64_extract_return_value /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1708
    #3 0x46ae57 in aarch64_return_value /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1918

We are extracting return value from V registers (128 bit), but only
allocate X_REGISTER_SIZE-byte array, which isn't sufficient.  This
patch changes the array to V_REGISTER_SIZE.

gdb:

2015-11-16  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_extract_return_value):  Change array
	buf's length to V_REGISTER_SIZE.
2015-11-16 15:37:03 +00:00
Yao Qi 8e80f9d1d5 Pass value * instead of bfd_byte * to pass_* functions in aarch64-tdep.c
This patch changes the last argument of functions pass_in_x_or_stack,
pass_in_v_or_stack, pass_on_stack, and pass_in_x to type value *.

gdb:

2015-11-16  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (pass_in_x_or_stack): Change argument type
	from bfd_byte * to value *.  Caller updated.
	(pass_in_x): Likewise.
	(pass_in_v_or_stack): Likewise.
	(pass_on_stack): Likewise.
2015-11-16 14:50:29 +00:00
Yao Qi 0d1993c072 Use value_contents instead of value_contents_writeable
Both aarch64_push_dummy_call and bfin_push_dummy_call only use args[i]
contents but then never write to them, so that we can use
value_contents instead.

gdb:

2015-11-16  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_push_dummy_call): Call value_contents instead
	of value_contents_writeable.
	* bfin-tdep.c (bfin_push_dummy_call): Likewise.
2015-11-16 14:47:50 +00:00
Yao Qi ef9bd0b8d7 Fix bug in arm_push_dummy_call by -fsanitize=address
When I build GDB with -fsanitize=address, and run testsuite,
some gdb.base/*.exp test triggers the ERROR below,

=================================================================
==7646==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000242810 at pc 0x487844 bp 0x7fffe32e84e0 sp 0x7fffe32e84d8
READ of size 4 at 0x603000242810 thread T0
    #0 0x487843 in push_stack_item /home/yao/SourceCode/gnu/gdb/git/gdb/arm-tdep.c:3405
    #1 0x48998a in arm_push_dummy_call /home/yao/SourceCode/gnu/gdb/git/gdb/arm-tdep.c:3960

In that path, GDB passes value on stack, in an INT_REGISTER_SIZE slot,
but the value contents' length can be less than INT_REGISTER_SIZE, so
the contents will be accessed out of the bound.  This patch adds an
array buf[INT_REGISTER_SIZE], and copy val to buf before writing them
to stack.

gdb:

2015-11-16  Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c (arm_push_dummy_call): New array buf.  Store regval
	to buf.  Pass buf instead of val to push_stack_item.
2015-11-16 14:44:19 +00:00
Yao Qi c4312b1985 PR 19051: support of inferior call with gnu vector support on ARM
This patch teaches GDB to support gnu vector in inferior calls.  As a
result, fails in gdb.base/gnu_vector.exp are fixed.  The calling
convention of gnu vector isn't documented in the AAPCS, because it
is the GCC extension.  I checked the gcc/config/arm/arm.c, understand
how GCC pass arguments and return values, and do the same in GDB side.

The patch is tested with both hard float and soft float on arm-linux.

gdb:

2015-11-13  Yao Qi  <yao.qi@linaro.org>

	PR tdep/19051
	* arm-tdep.c (arm_type_align): Return the right alignment
	value for vector.
	(arm_vfp_cprc_sub_candidate): Return true for 64-bit and
	128-bit vector types.
	(arm_return_in_memory): Handel vector type.
2015-11-13 15:11:58 +00:00
Yao Qi b13c8ab2b9 Refactor arm_return_in_memory
Current arm_return_in_memory isn't friendly to adding new things in it.
Moreover, a lot of stuff are about APCS, which is not used nowadays (AAPCS
is being used).  This patch is to refactor arm_return_in_memory, so that
some code can be shared for both APCS and AAPCS at the beginning of
arm_return_in_memory, and then each ABI (APCS and AAPCS) are processed
separately.

gdb:

2015-11-13  Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c (arm_return_in_memory): Rewrite it.
	(arm_return_value): Call arm_return_in_memory for
	TYPE_CODE_COMPLEX.
2015-11-13 15:11:58 +00:00
Yao Qi c1862d0f60 Remove d10v from testsuite
This patch removes the leftover of the d10v stuff in the testsuite
directory. The d10v port was removed in GDB 6.7, but I happen to see
that there are still some leftovers about d10v in testsuite.

gdb/testsuite:

2015-11-13  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/call-sc.exp (test_scalar_returns): Remove the
	comments about d10v.
	(test_scalar_returns): Likewise.
	* gdb.base/d10v.ld: Remove.
	* gdb.base/overlays.exp: Remove the target triplet checking for
	d10v-*-*.
	* gdb.base/structs.exp (test_struct_returns): Remove the
	comments about d10v.
	(test_struct_calls): Likewise.
2015-11-13 15:06:38 +00:00
Yao Qi 77ae9c1933 gdb.base/gnu_vector.exp: Don't test output from the inferior
gdb.base/gnu_vector.c printf the vector and gdb.base/gnu_vector.exp
expects the output by gdb_test_multiple.  Nowadays, the test doesn't
expect the output from inferior_spawn_id, which is wrong.  Even we
change the test to expect from inferior_spawn_id for the inferior
output, it is still possible the inferior exit before tcl/expect gets
the inferior output.  We see this fail on both s390x-linux and
ppc-linux on buildbot,

  FAIL: gdb.base/gnu_vector.exp: verify vector return value (the program exited)

https://sourceware.org/ml/gdb-testers/2015-q4/msg04922.html
https://sourceware.org/ml/gdb-testers/2015-q4/msg04952.html

In order to address these two shortcomings above in gnu_vector.exp,
this patch rewrites the test a little bit.  Get rid of checking the
inferior output, and instead checking them by printing them.  In this
way, the test can also be run on the target without inferior io
(gdb,noinferiorio is set in the board file).

gdb/testsuite:

2015-11-13  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/gnu_vector.exp: Check the return value by "p res".
	* gdb.base/gnu_vector.c: Don't include stdio.h.
	(main): Don't print res and call add_some_intvecs.
2015-11-13 15:03:25 +00:00
Yao Qi df3b6708fe Use gdb_byte * instead of void * in push_stack_item
gdb:

2015-11-12  Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c (push_stack_item): Change contents type to
	const gdb_byte *.
2015-11-12 09:14:20 +00:00
Marcin Kościelnicki 430e004ef7 gdb/testsuite/gdb.trace: Deduplicate set_point assembly.
The assembly code for emitting the proper tracepointable instruction
was duplicated in many places.  Keep it in one place, to reduce work
needed for new targets.

gdb/testsuite/ChangeLog:

	* gdb.trace/change-loc.h: include "trace-common.h", remove SYMBOL
	macro.
	(func5): Removed.
	(func4): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/ftrace-lock.c: include "trace-common.h", remove SYMBOL
	macro.
	(func): Removed.
	(thread_function): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/ftrace.c: include "trace-common.h", remove SYMBOL macro.
	(func): Remove.
	(marker): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/pendshr1.c: include "trace-common.h", remove SYMBOL macro.
	(pendfunc1): Remove.
	(pendfunc): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/pendshr2.c: include "trace-common.h", remove SYMBOL macro.
	(foo): Remove.
	(pendfunc2): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/trace-break.c: include "trace-common.h", remove SYMBOL
	macro.
	(func): Remove.
	(marker): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/trace-common.h: New header.
	* gdb.trace/trace-condition.c: include "trace-common.h", remove SYMBOL
	macro.
	(func): Remove.
	(marker): Use FAST_TRACEPOINT_LABEL.
	* gdb.trace/trace-mt.c: include "trace-common.h", remove SYMBOL macro.
	(func): Remove.
	(thread_function): Use FAST_TRACEPOINT_LABEL.
2015-11-11 21:44:04 +01:00
Simon Marchi 4397c913d5 Replace long int * cast with PTRACE_TYPE_RET *
These casts uses the typedef target type (long int *) instead of the
typedef name.  This was a little mistake in one of the big C++ cast
patches.

gdb/ChangeLog:

	* inf-ptrace.c (inf_ptrace_fetch_register): Change long int *
	cast to PTRACE_TYPE_RET *.
	(inf_ptrace_store_register): Likewise.
2015-11-11 15:16:05 -05:00
Andrew Burgess 5f515954d1 gdb: Make use of 'add_info' to create info sub-commands.
Switch to using 'add_info' function for creating basic info
sub-commands.

gdb/ChangeLog:

	* avr-tdep.c (_initialize_avr_tdep): Switch to 'add_info' for creating
	info sub-commands.
	* gnu-nat.c (add_task_commands): Likewise.
	* macrocmd.c (_initialize_macrocmd): Likewise.
2015-11-11 09:04:05 +00:00
Andrew Burgess f3575e0837 gdb: Use class_info when creating info commands.
The 'add_info' function is used for creating info commands, these
commands should be created as 'class_info' rather than 'no_class'.

gdb/ChangeLog:

	* cli/cli-decode.c (add_info): Switch to class_info.
2015-11-11 09:03:25 +00:00
Marcin Kościelnicki 6e7675a70f gdb/testsuite/gdb.trace: Deduplicate pcreg/spreg/fpreg.
These variables were used in many gdb.trace tests.  Keep them in one place,
to reduce work needed for new targets.

gdb/testsuite/ChangeLog:

	* gdb.trace/backtrace.exp: Use global fpreg/spreg definition, add $
	in front.
	* gdb.trace/change-loc.exp: Use global pcreg definition.
	* gdb.trace/collection.exp: Use global pcreg/fpreg/spreg definition.
	* gdb.trace/entry-values.exp: Use global spreg definition, add $
	in front.
	* gdb.trace/mi-trace-frame-collected.exp: Use global pcreg definition.
	* gdb.trace/pending.exp: Likewise.
	* gdb.trace/report.exp: Use global pcreg/fpreg/spreg definition.
	* gdb.trace/trace-break.exp: Likewise.
	* gdb.trace/trace-condition.exp: Use global pcreg definition, add $
	in front.
	* gdb.trace/unavailable.exp: Use global pcreg/fpreg/spreg definition.
	* gdb.trace/while-dyn.exp: Use global fpreg definition, add $
	in front.
	* lib/trace-support.exp: Define fpreg, spreg, pcreg variables.
2015-11-10 20:05:49 +01:00
Joel Brobecker dddc0e16ef [Ada] GDB crash during "finish" of function with out parameters
Consider a function with the following signature...

   function F (R : out Rec_Type) return Enum_Type;

... where Rec_Type is a simple record:

   type Rec_Type is record
      Cur : Integer;
   end record;

Trying to "finish" from that function causes GDB to SEGV:

    (gdb) fin
    Run till exit from #0  bar.f (r=...) at bar.adb:5
    0x00000000004022fe in foo () at foo.adb:5
    5          I : Enum_Type := F (R);
    [1]    18949 segmentation fault (core dumped)  /[..]/gdb

This is related to the fact that funtion F has a parameter (R)
which is an "out" parameter being passed by copy. For those,
GNAT transforms the return value to be a record with multiple
fields: The first one is called "RETVAL" and contains the return
value shown in the source, and the remaining fields have the same
name as the "out" or "in out" parameters which are passed by copy.
So, in the example above, function F returns a struct that has
one field who name is "r".

Because "RETVAL" starts with "R", GDB thinks it's a wrapper field,
because it looks like the encoding used for  variant records:

   --    member_name ::= {choice} | others_choice
   --    choice ::= simple_choice | range_choice
   --    simple_choice ::= S number
   --    range_choice  ::= R number T number   <<<<<-----  here
   --    number ::= {decimal_digit} [m]
   --    others_choice ::= O (upper case letter O)

See ada_is_wrapper_field:

  return (name != NULL
          && (startswith (name, "PARENT")
              || strcmp (name, "REP") == 0
              || startswith (name, "_parent")
              || name[0] == 'S' || name[0] == 'R' || name[0] == 'O'));

As a result of this, when trying to print the RETURN value,
we think that RETVAL is a wrapper, and thus recurse into
print_field_values...

      if (ada_is_wrapper_field (type, i))
        {
          comma_needed =
            print_field_values (TYPE_FIELD_TYPE (type, i),
                                valaddr,
                                (offset
                                 + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT),
                                stream, recurse, val, options,
                                comma_needed, type, offset, language);

... which is a problem since print_field_values assumes that
the type it is given ("TYPE_FIELD_TYPE (type, i)" here), is also
a record type. However, that's not the case, since RETVAL is
an enum. That eventually leads GDB to a NULL type when trying to
extract fields out of the enum, which then leads to a SEGV when
trying to dereference it.

Ideally, we'd want to be a little more careful in identifying
wrapper fields, by enhancing ada_is_wrapper_field to be a little
more complete in its analysis of the field name before declaring
it a variant record wrapper. However, it's not super easy to do
so, considering that the choices can be combined together when
complex choices are used. Eg:

   -- [...] the choice 1 .. 4 | 7 | -10 would be represented by
   --    R1T4S7S10m

Given that we are working towards getting rid of GNAT encodings,
which means that the above will eventually disappear, we took
the more pragmatic approach is just treating  RETVAL as a special
case.

gdb/ChangeLog:

        * ada-lang.c (ada_is_wrapper_field): Add special handling
        for fields called "RETVAL".

gdb/testsuite/ChangeLog:

        * gdb.ada/fin_fun_out: New testcase.
2015-11-09 09:58:16 -08:00
Yao Qi a5eda10c78 Use ELF_STRING_ARM_unwind in arm-tdep.c
We've already has the definition like this,

 #define ELF_STRING_ARM_unwind           ".ARM.exidx"

so it is better to use the macro rather than the string.

gdb:

2015-11-09  Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c (arm_exidx_new_objfile): Use
	ELF_STRING_ARM_unwind.
2015-11-09 15:56:20 +00:00
Yao Qi c098766357 New function displaced_step_in_progress_thread
This patch adds a new function displaced_step_in_progress_thread,
which returns whether the thread is in progress of displaced
stepping.

gdb:

2015-11-09  Yao Qi  <yao.qi@linaro.org>

	* infrun.c (displaced_step_in_progress_thread): New function.
	(handle_inferior_event_1): Call it.
2015-11-09 14:39:56 +00:00
Kevin Buettner c6f0b406f5 gdb.dwarf2: Don't hardcode certain constants in Dwarf::assemble constructs
Two tests in gdb.dwarf2, data-loc.exp and dynarr-ptr.exp assume that
sizeof(int) is 4.  This patch looks up the integer size and uses this
constant for DW_AT_byte_size, DW_AT_lower_bound, and DW_AT_upper_bound.

I discovered this problem while looking at test results for this
msp430 multilib:

msp430-sim/-msim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either

It fixes the following set of failures:

FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr_tdef.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr_tdef'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr_tdef.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr_tdef'first
FAIL: gdb.dwarf2/data-loc.exp: print foo.three
FAIL: gdb.dwarf2/data-loc.exp: print foo.three(1)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(1)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(4)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(5)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(6)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(4)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(5)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(6)
FAIL: gdb.dwarf2/data-loc.exp: print foo__three
FAIL: gdb.dwarf2/data-loc.exp: print foo__three_tdef
FAIL: gdb.dwarf2/data-loc.exp: print foo__five
FAIL: gdb.dwarf2/data-loc.exp: print foo__five_tdef

As I recall, there are still (other) problems with msp430 multilibs
which don't use -mlarge.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Don't hardcode
	value associated with DW_AT_byte_size.
	* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Don't hardcode
	constants for DW_AT_byte_size, DW_AT_lower_bound, and
	DW_AT_upper_bound.
2015-11-07 11:08:37 -07:00
Kevin Buettner f01dcfd9a7 testsuite: Define and use gdb_target_symbol_prefix_flags_asm.
Some of the source code for the test cases in the GDB testsuite
reside in .S files containing assembly code.  These files typically
define a symbol - such as main - which may, depending on the target,
require a prefix such as underscore.

For example, gdb.dwarf2/dw-compdir-oldgcc.S defines the symbol main:

main:	.globl main

Some targets, such as rx-elf, require main to have an underscore
prefix.  (If it doesn't, a linker error results due to not being able
to find _main required by crt0.o.) So, instead, the above should look
like this for rx-elf and other targets with this same requirement:

_main:	.globl	_main

This patch defines a new tcl proc in lib/gdb named
gdb_target_symbol_prefix_flags_asm.  This proc returns a string
which will - assuming everything else is wired up correctly - cause
-DSYMBOL_PREFIX=_ to be passed on the command line to the compiler.

The test cases are augmented with a macro definition for SYMBOL
as follows:

    #define CONCAT1(a, b) CONCAT2(a, b)
    #define CONCAT2(a, b) a ## b

    #ifdef SYMBOL_PREFIX
    # define SYMBOL(str)     CONCAT1(SYMBOL_PREFIX, str)
    #else
    # define SYMBOL(str)     str
    #endif

Symbols, such as main shown in the example earlier are then wrapped
with SYMBOL like this:

SYMBOL(main):	.globl SYMBOL(main)

The net effect will be to add a prefix for those targets which need
it and add no prefix for those targets which do not.

It should be noted that there was already a proc in lib/gdb.exp
called gdb_target_symbol_prefix_flags.  It still exists, but has
been significantly rewritten.  (There is only one small difference
between the two versions.)

That proc used to explicitly list targets which were known to
require an underscore prefix.  This is no longer done; the recently
added proc, gdb_target_symbol_prefix, is now invoked to dynamically
discover whether or not a prefix is required for that particular
target.

The difference between gdb_target_symbol_prefix_flags_asm
and gdb_target_symbol_prefix_flags is that the former returns
a bare prefix while the latter returns the prefix enclosed in
double quotes.  I.e. assuming that the discovered prefix is
underscore, gdb_target_symbol_prefix_flags_asm returns:

    additional_flags=-DSYMBOL_PREFIX=_

while gdb_target_symbol_prefix_flags returns:

    additional_flags=-DSYMBOL_PREFIX="_"

The double-quoted version is not suitable for using with .S files
containing assembly code; there is no way to strip the double quotes
using C preprocessor constructs.

It would be possible to use the bare (non double quoted) version in
C source code.  However, the supporting macros become more complicated
and therefore more difficult to maintain.

gdb/testsuite/ChangeLog:

	* lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.
	(gdb_target_symbol_prefix_flags): Define in terms of _asm
	version.
	* gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp,
	gdb.dwarf2/dw2-canonicalize-type.exp,
	gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp,
	gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp,
	gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags
	provided by gdb_target_symbol_prefix_flags_asm.
	* gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S,
	testsuite/gdb.dwarf2/dw2-minsym-in-cu.S,
	testsuite/gdb.dwarf2/dw2-unresolved-main.c,
	testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S,
	gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting
	macros where needed).  Use this macro for symbols which require
	the prefix provided by SYMBOL_PREFIX.
2015-11-07 11:03:49 -07:00
Kevin Buettner 2223449a47 gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program.  Some targets use a prefix such as underscore ("_") on
these symbols.  Many of the tests in gdb.dwarf2 do not take this into
account.  As a consequence, these tests fail to build, resulting
either in failures or untested testcases.

Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:

    Dwarf::assemble $asm_file {
        cu {} {
            compile_unit {
                {low_pc main DW_FORM_addr}
                {high_pc main+0x10000 DW_FORM_addr}
            } {
            ...
            }

For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.

For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol.  I.e. the above code is
rewritten (as shown in the patch) as follows:

    Dwarf::assemble $asm_file {
        cu {} {
            compile_unit {
                {low_pc [gdb_target_symbol main] DW_FORM_addr}
                {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
            } {
            ...
            }

I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs.  Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
	New procs.
	* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
	representing expressions, of more than one list element.
	* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
	to prepend linker symbol prefix to f.
	* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
	table_1 and table_2.
	* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
	Likewise, for f and g.
	* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
	for ptr.
	* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
	for main.
	* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
	table_1_ptr and table_2_ptr.
2015-11-05 15:22:51 -07:00
Yao Qi c86a40c6c2 Use aarch64_decode_insn in aarch64_displaced_step_copy_insn
gdb:

2015-11-05  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Call
	aarch64_decode_insn and decode instruction by aarch64_inst.
2015-11-05 09:44:32 +00:00
Yao Qi d9ebcbce29 Use aarch64_decode_insn in aarch64_analyze_prologue
This patch convert aarch64_analyze_prologue to using aarch64_decode_insn
to decode instructions.  After this change, aarch64_analyze_prologue
looks much simple, and some aarch64_decode_* functions are removed
accordingly.

gdb:

2015-11-05  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (extract_signed_bitfield): Remove.
	(decode_masked_match): Remove.
	(aarch64_decode_add_sub_imm): Remove.
	(aarch64_decode_br): Remove.
	(aarch64_decode_eret): Remove.
	(aarch64_decode_movz): Remove.
	(aarch64_decode_orr_shifted_register_x): Remove.
	(aarch64_decode_ret): Remove.
	(aarch64_decode_stp_offset): Remove.
	(aarch64_decode_stur): Remove.
	(aarch64_analyze_prologue): Call aarch64_decode_insn
	and use aarch64_inst to decode instructions.
2015-11-05 09:44:32 +00:00
Yao Qi 93d960127c Combine aarch64_decode_stp_offset_wb and aarch64_decode_stp_offset
This patch combines both aarch64_decode_stp_offset_wb and
aarch64_decode_stp_offset together.

gdb:

2015-11-05  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_decode_stp_offset): New argument
	wback.
	(aarch64_decode_stp_offset_wb): Removed.
	(aarch64_analyze_prologue): Don't use
	aarch64_decode_stp_offset_wb.
2015-11-05 09:44:32 +00:00
Jan Kratochvil 6f2f1a3a70 Fortran: allocate()d memory is uninitialized
allocate (vla1 (5))         ! vla1-not-allocated
  l = allocated(vla1)         ! vla1-allocated     <------------------

Expecting: ^(510-data-evaluate-expression vla1[^M
]+)?(510\^done,value="\(0, 0, 0, 0, 0\)"[^M
]+[(]gdb[)] ^M
[ ]*)
510-data-evaluate-expression vla1^M
510^done,value="(1.82987403e-09, 7.8472714e-44, 1.82987403e-09, 7.8472714e-44, 2.67929926e+20)"^M
(gdb) ^M
FAIL: gdb.mi/mi-vla-fortran.exp: evaluate allocated vla

gcc-4.9.2-6.fc21.x86_64

I think some older gfortran did initialize allocated memory but that is an
unspecified behavior.  I haven't found any initialization mentioned
in Fortran 90 standard (draft) and it is also clearly stated here:
        https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/268786
        Initialization to 0 of allocated arrays (of integers) is an
        implementation issue. i.e. do not rely on it.

Joel Brobecker wrote:
I am wondering if it might be better to just relax instead the regexp to allow
any number rather than just remove the test altogether. The test allows us to
verify that, as soon as we're past the "allocate" call, we no longer say "not
allocated".

gdb/testsuite/ChangeLog
2015-11-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Joel Brobecker  <brobecker@adacore.com>

	* gdb.mi/mi-vla-fortran.exp (evaluate allocated vla): Permit any data.
2015-11-04 15:52:41 +01:00
Marcin Kościelnicki 6df5522640 gdb/s390-linux: Step over MVCLE+JO (and similiar) as a unit.
This is needed to avoid O(n**2) complexity when recording MVCLE and other
partial execution instructions.

gdb/ChangeLog:

	PR/18376
	* gdb/s390-linux-tdep.c (s390_is_partial_instruction): New function.
	(s390_software_single_step): New function.
	(s390_displaced_step_hw_singlestep): New function.
	(s390_gdbarch_init): Fill gdbarch slots with the above.
2015-11-04 15:27:53 +01:00
Marcin Kościelnicki 566c56c911 gdb: Add process record and replay support for s390.
gdb/ChangeLog:

	PR/18376
	* gdb/configure.tgt: Add linux-record.o to s390*-linux.
	* gdb/s390-linux-tdep.c: #include "linux-record.h", "record-full.h"
	(s390_linux_record_tdep): New static global variable.
	(s390x_linux_record_tdep): New static global variable.
	(s390_all_but_pc_registers_record): New function.
	(s390_canonicalize_syscall): New function.
	(s390_linux_syscall_record): New function.
	(s390_linux_record_signal): New function.
	(s390_record_calc_disp_common): New function.
	(s390_record_calc_disp): New function.
	(s390_record_calc_disp_vsce): New function.
	(s390_record_calc_rl): New function.
	(s390_record_gpr_g): New function.
	(s390_record_gpr_h): New function.
	(s390_record_vr): New function.
	(s390_process_record): New function.
	(s390_init_linux_record_tdep): New function.
	(s390_gdbarch_init): Fill record function slots.

gdb/testsuite/ChangeLog:

	* gdb.reverse/s390-mvcle.c: New test.
	* gdb.reverse/s390-mvcle.exp: New file.
	* lib/gdb.exp: Enable reverse tests on s390*-linux.
2015-11-04 15:27:38 +01:00
Marcin Kościelnicki 394816ee10 gdb/record-full: Use xmalloc instead of alloca for temporary memory storage.
On the newly added s390 target, it's possible for a single instruction
to write practically unbounded amount of memory (eg. MVCLE).  This caused
a stack overflow when alloca was used.

gdb/ChangeLog:

	* record-full.c (record_full_exec_insn): Use xmalloc for temporary
	memory storage.
2015-11-04 15:26:59 +01:00
Walfred Tedeschi 14cb1c0b38 Fix non stopping breakpoint on newer compilers.
The breakpoint presented in the return statement was not activated while
compiling the test with gcc 4.9.2.  Added a dummy statement to allow the
breakpoint again.

2015-10-14  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testsuite:

	* i386-mpx-map.c (foo): Add dummy statement to trigger breakpoint.

Change-Id: I5293ca1c7f82a631e1e41cb650c30dd2d09ef3c2
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2015-11-04 11:09:03 +01:00
Walfred Tedeschi 1a2ccd2e32 Changing compiler flags for MPX tests.
Adapts tests to use actual GCC flags, previous used flags were
related to an internal GCC release.

2015-06-18  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testsuite:

	* gdb.arch/i386-mpx-map.exp (comp_flags): Use released GCC flags.
	* gdb.arch/i386-mpx.exp (comp_flags): Use released GCC flags.

Change-Id: Id4c4551693a8df071ed4b71bb5dfb46a526ed5db
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2015-11-04 11:09:02 +01:00
Walfred Tedeschi e00b3c9bc1 Improve error message for MPX bound table examinations.
Error was introduced to fix a build issue caused by a mismatching variable
size.  The error message is changed to explicitly report what goes wrong
and how user might still investigate the issue.

2015-06-18  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* i386-tdep.c (i386_mpx_get_bt_entry) Improves error message.

Change-Id: I6e9c7475eba663f49bd8e720b84ad0265bcb0e92
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2015-11-04 11:09:02 +01:00
Markus Metzger 0c532a2980 btrace: add instruction-history /s and fix documentation
Add support for the /s modifier of the "record instruction-history" command.  It
behaves exactly like /m and prints disassembled instructions in the order in
which they were recorded with interleaved sources.  We accept /s in addition
to /m to align with the "disassemble" command.

The "record instruction-history" modifiers were not documented.  Document
all of them.

gdb/
	* record.c (get_insn_history_modifiers): Set DISASSEMBLY_SOURCE
	instead of DISASSEMBLY_SOURCE_DEPRECATED.  Also accept /s.
	(_initialize_record): Document the /s modifier.
	* NEWS: Announce record instruction-history's new /s modifier.

doc/
	* gdb.texinfo (Process Record and Replay): Document "record
	instruction-history" modifiers.
2015-11-04 09:16:18 +01:00
Markus Metzger f94cc8975c btrace: change record instruction-history /m
The /m modifier interleaves source lines with the disassembly of recorded
instructions.  This calls disasm.c's gdb_disassembly once for each recorded
instruction to be printed.

This doesn't really work because gdb_disassembly may choose not to print
anything in some situations.  And if it does print something, the output
interferes with btrace_insn_history's output around it.

It further results in a separate asm_insns list for each instruction in MI.
Even though there is no MI support for target record, yet, we fix this obvious
issue.

Change record instruction-history /m to use the new gdb_pretty_print_insn
function for printing a single instruction and interleave source lines as
appropriate.

We cannot reuse the new disasm.c do_mixed_source_and_assembly function without
significant changes to it.

gdb/
	* record-btrace.c (struct btrace_line_range): New.
	(btrace_mk_line_range, btrace_line_range_add)
	(btrace_line_range_is_empty, btrace_line_range_contains_range)
	(btrace_find_line_range, btrace_print_lines): New.
	(btrace_insn_history): Add source interleaving algorithm.
2015-11-04 09:14:17 +01:00
Markus Metzger a50a402676 disasm: add struct disasm_insn to describe to-be-disassembled instruction
The "record instruction-history" command prints for each instruction in
addition to the instruction's disassembly:

  - the instruction number in the recorded execution trace
  - a '?' before the instruction if it was executed speculatively

To allow the "record instruction-history" command to use GDB's disassembly
infrastructure, we extend gdb_pretty_print_insn to optionally print those
additional fields and export the function.

Add a new struct disasm_insn to add additional fields describing the
to-be-disassembled instruction.  The additional fields are:

  number            an optional instruction number, zero if omitted.
  is_speculative    a predicate saying whether the instruction was
                    executed speculatively.

If non-zero, the instruction number is printed first.  It will also appear
as a new optional field "insn-number" in MI.  The field will be present if
insn_num is non-zero.

If is_speculative is set, speculative execution will be indicated by a "?"
following the new instruction number field.  Unless the PC is omitted, it
will overwrite the first byte of the PC prefix.  It will appear as a new
optional field "is-speculative" in MI.  The field will contain "?" and will
be present if is_speculative is set.

The speculative execution indication is guarded by a new flag
DISASSEMBLY_SPECULATION.

Replace the PC parameter of gdb_pretty_print_insn with a pointer to the above
struct.  GDB's "disassemble" command does not use the new fields.

gdb/
	* disasm.h (DISASSEMBLY_SPECULATION): New.
	(struct disasm_insn): New.
	(gdb_pretty_print_insn): New.
	* disasm.c (gdb_pretty_print_insn): Replace parameter PC with INSN.
	Update users.  Print instruction number and indicate speculative
	execution, if requested.
2015-11-04 09:12:33 +01:00
Markus Metzger af70908dc4 disasm: split dump_insns
Split disasm.c's dump_insn into two parts:

  - print a single instruction
  - loop over the specified address range

The first part will be refined in subsequent patches so it can be reused.

gdb/
	* disasm.c (dump_insns):  Split into this and ...
	(gdb_pretty_print_insn): ... this.
2015-11-04 09:11:01 +01:00
Simon Marchi 1c215b97f9 xtensa: Add missing statics
This actually fixes the build in C:

/home/simark/src/binutils-gdb/gdb/xtensa-linux-nat.c💯1: error: no previous prototype for ‘supply_gregset_reg’ [-Werror=missing-prototypes]
 supply_gregset_reg (struct regcache *regcache,
 ^
/home/simark/src/binutils-gdb/gdb/xtensa-linux-nat.c:257:1: error: no previous prototype for ‘xtensa_linux_fetch_inferior_registers’ [-Werror=missing-prototypes]
 xtensa_linux_fetch_inferior_registers (struct target_ops *ops,
 ^
/home/simark/src/binutils-gdb/gdb/xtensa-linux-nat.c:272:1: error: no previous prototype for ‘xtensa_linux_store_inferior_registers’ [-Werror=missing-prototypes]
 xtensa_linux_store_inferior_registers (struct target_ops *ops,
 ^
cc1: all warnings being treated as errors

These functions are local to this file, so they should be static.

gdb/ChangeLog:

	* xtensa-linux-nat.c (supply_gregset_reg): Make static.
	(xtensa_linux_fetch_inferior_registers): Likewise.
	(xtensa_linux_store_inferior_registers): Likewise.
2015-11-03 13:33:16 -05:00
Simon Marchi 1996e237bb linux-mips-low.c: Add casts
Fixes a bunch of:

/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c: In function ‘void mips_store_fpregset(regcache*, const void*)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c:809:39: error: invalid conversion from ‘const void*’ to ‘const mips_register*’ [-fpermissive]
   const union mips_register *regset = buf;
                                       ^

gdb/gdbserver/ChangeLog:

	* linux-mips-low.c (mips_fill_gregset): Add cast.
	(mips_store_gregset): Likewise.
	(mips_fill_fpregset): Likewise.
	(mips_store_fpregset): Likewise.
2015-11-03 13:33:15 -05:00
Simon Marchi cbec665beb linux-mips-low.c: Change "private" variable name
Fixes:

/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c:359:48: error: expected ‘,’ or ‘...’ before ‘private’
 mips_add_watchpoint (struct arch_process_info *private, CORE_ADDR addr,
                                                ^

gdb/gdbserver/ChangeLog:

	* linux-mips-low.c (mips_add_watchpoint): Rename private to
	priv.
2015-11-03 13:33:15 -05:00
Simon Marchi eb3e3c67e5 linux-mips-low.c: Fix type of mips_add_watchpoint parameter
Fixes

/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c: In function ‘void mips_add_watchpoint(arch_process_info*, CORE_ADDR, int, int)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c:368:19: error: invalid conversion from ‘int’ to ‘target_hw_bp_type’ [-fpermissive]
   new_watch->type = watch_type;
                   ^

gdb/gdbserver/ChangeLog:

	* linux-mips-low.c (mips_linux_new_thread): Change type of
	watch_type to enum target_hw_bp_type.
2015-11-03 13:33:14 -05:00
Simon Marchi f844cf0ec3 arm-linux-nat.c: Add cast
Fixes:

/home/simark/src/binutils-gdb/gdb/arm-linux-nat.c: In function ‘const target_desc* arm_linux_read_description(target_ops*)’:
/home/simark/src/binutils-gdb/gdb/../include/libiberty.h:711:38: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
 # define alloca(x) __builtin_alloca(x)
                                      ^
/home/simark/src/binutils-gdb/gdb/arm-linux-nat.c:578:13: note: in expansion of macro ‘alloca’
       buf = alloca (VFP_REGS_SIZE);
             ^

gdb/ChangeLog:

	* arm-linux-nat.c (arm_linux_read_description): Add cast.
2015-11-03 13:33:14 -05:00
Simon Marchi 171de4b8fb Change return type of raw_bkpt_type_to_arm_hwbp_type
Fixes:

/home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c: In function ‘int arm_linux_hw_point_initialize(raw_bkpt_type, CORE_ADDR, int, arm_linux_hw_breakpoint*)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c:459:55: error: invalid conversion from ‘int’ to ‘arm_hwbp_type’ [-fpermissive]
   hwbp_type = raw_bkpt_type_to_arm_hwbp_type (raw_type);
                                                       ^

gdb/gdbserver/ChangeLog:

		* linux-arm-low.c (raw_bkpt_type_to_arm_hwbp_type):
		Change return type to arm_hwbp_type.
2015-11-03 13:33:13 -05:00
Simon Marchi 04248ead1f gdbserver arm: Add casts
Trivial casts for C++.

Fixes things like

In file included from /home/simark/src/binutils-gdb/gdb/gdbserver/../common/common-defs.h:39:0,
                 from /home/simark/src/binutils-gdb/gdb/gdbserver/server.h:22,
                 from /home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c:19:
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c: In function ‘int arm_get_hwcap(long unsigned int*)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/../../include/libiberty.h:711:38: error: invalid conversion from ‘void*’ to ‘unsigned char*’ [-fpermissive]
 # define alloca(x) __builtin_alloca(x)
                                      ^
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c:807:25: note: in expansion of macro ‘alloca’
   unsigned char *data = alloca (8);
                         ^

gdb/gdbserver/ChangeLog:

	* linux-aarch32-low.c (arm_fill_gregset): Add cast.
	(arm_store_gregset): Likewise.
	* linux-arm-low.c (arm_get_hwcap): Likewise.
	(arm_read_description): Likewise.
2015-11-03 13:33:13 -05:00
Simon Marchi 04b3479c3f linux-aarch32-low.c: Use NULL_REGSET
Fixes

/home/simark/src/binutils-gdb/gdb/gdbserver/linux-aarch32-low.c:124:1: error: invalid conversion from ‘int’ to ‘regset_type’ [-fpermissive]
 };
 ^

gdb/gdbserver/ChangeLog:

	* linux-aarch32-low.c (aarch32_regsets): Use NULL_REGSET.
2015-11-03 13:33:12 -05:00
Simon Marchi f4b0a6714a target_ops mask_watchpoint: change int to target_hw_bp_type
Fixes:

/home/simark/src/binutils-gdb/gdb/ppc-linux-nat.c: In function ‘int ppc_linux_insert_mask_watchpoint(target_ops*, CORE_ADDR, CORE_ADDR, int)’:
/home/simark/src/binutils-gdb/gdb/ppc-linux-nat.c:1730:40: error: invalid conversion from ‘int’ to ‘target_hw_bp_type’ [-fpermissive]
   p.trigger_type = get_trigger_type (rw);
                                        ^

gdb/ChangeLog:

	* ppc-linux-nat.c (ppc_linux_insert_mask_watchpoint): Change
	type of rw to enum target_hw_bp_type.
	(ppc_linux_remove_mask_watchpoint): Likewise.
	* target.c (target_insert_mask_watchpoint): Likewise.
	(target_remove_mask_watchpoint): Likewise.
	* target.h (target_insert_mask_watchpoint): Likewise.
	(target_remove_mask_watchpoint): Likewise.
	(struct target_ops) <to_insert_mask_watchpoint>: Likewise.
	(struct target_ops) <to_remove_mask_watchpoint>: Likewise.
	* target-delegates.c: Regenerate.
2015-11-03 13:33:12 -05:00
Simon Marchi 653090d321 remote-sim.c: Add casts
Mostly some casts from "generic arg" void* to the actual type.

There are two (enum gdb_signal) casts.  I tried to see if it would have
been better to change the type of sigrc, but it has a double role, as an
enum and as an integer, so I left it as is.

gdb/ChangeLog:

	* remote-sim.c (check_for_duplicate_sim_descriptor): Add casts.
	(get_sim_inferior_data): Likewise.
	(sim_inferior_data_cleanup): Likewise.
	(gdbsim_close_inferior): Likewise.
	(gdbsim_resume_inferior): Likewise.
	(gdbsim_wait): Likewise.
	(simulator_command): Likewise.
	(sim_command_completer): Likewise.
2015-11-03 13:33:11 -05:00
Simon Marchi 2bc84e8a6d linux-ppc-low.c: Add casts
Trivial casts for C++.

gdb/gdbserver/ChangeLog:

	* linux-ppc-low.c (ppc_get_hwcap): Add cast.
	(ppc_fill_vsxregset): Likewise.
	(ppc_store_vsxregset): Likewise.
	(ppc_fill_vrregset): Likewise.
	(ppc_store_vrregset): Likewise.
	(ppc_fill_evrregset): Likewise.
	(ppc_store_evrregset): Likewise.
2015-11-03 13:33:11 -05:00
Simon Marchi e6c5bb0517 linux-ppc-low.c: Remove forward declaration, move ppc_arch_setup lower
g++ doesn't like that we forward-declare a variable that is initialized
later in the file.  It's easy enough to re-order things to fix it.

Fixes

/home/simark/src/binutils-gdb/gdb/gdbserver/linux-ppc-low.c:663:28: error: redefinition of ‘usrregs_info ppc_usrregs_info’
 static struct usrregs_info ppc_usrregs_info =
                            ^
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-ppc-low.c:381:28: note: ‘usrregs_info ppc_usrregs_info’ previously declared here
 static struct usrregs_info ppc_usrregs_info;
                            ^

gdb/gdbserver/ChangeLog:

	* linux-ppc-low.c (ppc_usrregs_info): Remove
	forward-declaration.
	(ppc_arch_setup): Move lower in file.
2015-11-03 13:33:11 -05:00
Marcin Kościelnicki d5f0636bf6 Obvious typo fix in gdb.reverse/readv-reverse.exp
gdb/testsuite/ChangeLog:

	* gdb.reverse/readv-reverse.exp: Obvious typo fixed.
2015-11-03 11:56:19 +01:00
Marcin Kościelnicki 7ad8b86c67 gdb/reverse: Fix continue_to_breakpoint in syscall testcases.
continue_to_breakpoint always continues to the next breakpoint, not to the
one named in parameter.  This rendered the tests effectively useless, since
marker2 was never reached.

gdb/testsuite/ChangeLog:

	* gdb.reverse/fstatat-reverse.exp: Set breakpoint on marker1 after
	reaching marker2.
	* gdb.reverse/getresuid-reverse.exp: Likewise.
	* gdb.reverse/pipe-reverse.exp: Likewise.
	* gdb.reverse/readv-reverse.exp: Likewise.
	* gdb.reverse/recvmsg-reverse.exp: Likewise.
	* gdb.reverse/time-reverse.exp: Likewise.
	* gdb.reverse/waitpid-reverse.exp: Likewise and add KFAILs.
2015-11-03 11:56:18 +01:00
Marcin Kościelnicki b9559b8bc4 Add myself to gdb MAINTAINERS
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Add Marcin Kościelnicki.
2015-11-03 11:28:19 +01:00
Pedro Alves d35ae83384 Don't displaced step when there's a breakpoint in the scratch pad range
Assuming displaced stepping is enabled, and a breakpoint is set in the
memory region of the scratch pad, things break.  One of two cases can
happen:

#1 - The breakpoint wasn't inserted yet (all threads were stopped), so
     after setting up the displaced stepping scratch pad with the
     adjusted copy of the instruction we're trying to single-step, we
     insert the breakpoint, which corrupts the scratch pad, and the
     inferior executes the wrong instruction.  (Example below.)
     This is clearly unacceptable.

#2 - The breakpoint was already inserted, so setting up the displaced
     stepping scratch pad overwrites the breakpoint.  This is OK in
     the sense that we already assume that no thread is going to
     executes the code in the scratch pad range (after initial
     startup) anyway.

This commit addresses both cases by simply punting on displaced
stepping if we have a breakpoint in the scratch pad range.

The #1 case above explains a few regressions exposed by the AS/NS
series on x86:

 Running ./gdb.dwarf2/callframecfa.exp ...
 FAIL: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 1 for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 2 for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 3 for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 4 for call-frame-cfa
 Running ./gdb.dwarf2/typeddwarf.exp ...
 FAIL: gdb.dwarf2/typeddwarf.exp: continue to breakpoint: continue to typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of x at typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of y at typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of z at typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: continue to breakpoint: continue to typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of w at typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of x at typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of y at typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of z at typeddwarf.c:73

Enabling "maint set target-non-stop on" implies displaced stepping
enabled as well, and it's the latter that's to blame here.  We can see
the same failures with "maint set target-non-stop off + set displaced
on".

Diffing (good/bad) gdb.log for callframecfa.exp shows:

 @@ -99,29 +99,29 @@ Breakpoint 2 at 0x80481b0: file q.c, lin
  continue
  Continuing.

 -Breakpoint 2, func (arg=77) at q.c:2
 +Breakpoint 2, func (arg=52301) at q.c:2
  2      in q.c
  (gdb) PASS: gdb.dwarf2/callframecfa.exp: continue to breakpoint: continue to breakpoint for call-frame-cfa
  display arg
 -1: arg = 77
 -(gdb) PASS: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
 +1: arg = 52301
 +(gdb) FAIL: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa

The problem is here, when setting up the func call:

 Breakpoint 1, main (argc=-13345, argv=0x0) at q.c:7
 7       in q.c

 (gdb) disassemble
 Dump of assembler code for function main:
    0x080481bb <+0>:     push   %ebp
    0x080481bc <+1>:     mov    %esp,%ebp
    0x080481be <+3>:     sub    $0x4,%esp
 => 0x080481c1 <+6>:     movl   $0x4d,(%esp)
    0x080481c8 <+13>:    call   0x80481b0 <func>
    0x080481cd <+18>:    leave
    0x080481ce <+19>:    ret
 End of assembler dump.
 (gdb) disassemble /r
 Dump of assembler code for function main:
    0x080481bb <+0>:     55      push   %ebp
    0x080481bc <+1>:     89 e5   mov    %esp,%ebp
    0x080481be <+3>:     83 ec 04        sub    $0x4,%esp
 => 0x080481c1 <+6>:     c7 04 24 4d 00 00 00    movl   $0x4d,(%esp)
    0x080481c8 <+13>:    e8 e3 ff ff ff  call   0x80481b0 <func>
    0x080481cd <+18>:    c9      leave
    0x080481ce <+19>:    c3      ret
 End of assembler dump.

Note the breakpoint at main is set at 0x080481c1.  Right at the
instruction that sets up func's argument.  Executing that instruction
should write 0x4d to the address pointed at by $esp.  However, if we
stepi, the program manages to write 52301/0xcc4d there instead (0xcc
is int3, the x86 breakpoint instruction), because the breakpoint
address is 4 bytes inside the scratch pad location, which is
0x080481bd:

 (gdb) p 0x080481c1 - 0x080481bd
 $1 = 4

IOW, instead of executing:

  "c7 04 24 4d 00 00 00" [ movl $0x4d,(%esp) ]

the inferior executes:

  "c7 04 24 4d cc 00 00" [ movl $0xcc4d,(%esp) ]

gdb/ChangeLog:
2015-10-30  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (breakpoint_in_range_p)
	(breakpoint_location_address_range_overlap): New functions.
	* breakpoint.h (breakpoint_in_range_p): New declaration.
	* infrun.c (displaced_step_prepare_throw): If there's a breakpoint
	in the scratch pad range, don't displaced step.
2015-10-30 16:00:43 +00:00
Yao Qi 4081c0f122 Simplify gdb.threads/wp-replication.exp on counting HW watchpoints
Nowadays, test gdb.threads/wp-replication.exp uses a while loop to
repeatedly insert HW watchpoint, resume and check no error message
coming out, in order to count HW watchpoints  There are some
drawbacks in this way,

 - the loop could be endless.  I think this is use to making trouble
   to S/390, since we had such comment

      # Some targets (like S/390) behave as though supporting
      # unlimited hardware watchpoints.  In this case we just take a
      # safe exit out of the loop.

   I hit this today too because a GDB internal error is triggered
   on "continue" in the loop, and $done is 0 invariantly, so the loop
   can't end.
 - the code counting hardware watchpoint is too complicated.  We can
   use "set breakpoint always-inserted on" to get the result of inserting
   HW watchpoint without resuming the inferior.  In this way,
   watch_count_done and empty_cycle in c file is no longer needed.

In this patch, I change to use "set breakpoint always-inserted on" trick,
and only iterate $NR_THREADS times, to count the HW watchpoint.  In this
way, the loop can't be endless, and GDB doesn't need to resume the inferior.

gdb/testsuite:

2015-10-30  Yao Qi  <yao.qi@linaro.org>

	* gdb.threads/wp-replication.c (watch_count_done): Remove.
	(empty_cycle): Remove.
	(main): Don't call empty_cycle.  Don't use watch_count_done.
	* gdb.threads/wp-replication.exp: Don't set breakpoint on
	empty_cycle.  Rewrite the code counting HW watchpoints.
2015-10-30 15:54:58 +00:00
Marcin Kościelnicki 10268a4c0d gdb/linux-record: Fix struct sizes for x32
While x32 syscall interface is mostly shared with x86_64, some syscalls
are truly 32-bit.  Correct sizes accordingly.

gdb/ChangeLog:

	* amd64-linux-tdep.c (amd64_x32_linux_init_abi): Fix size_msghdr,
	size_stack_t, size_size_t, size_iovec.
2015-10-30 15:52:02 +00:00
Marcin Kościelnicki d9b19c4992 gdb/linux-record: Fix size_termios for x32, amd64, aarch64
60 bytes is the size of glibc's struct termios, the one used by kernel is
36 bytes long.

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_init_abi): Fix size_termios.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Fix size_termios.
	(amd64_x32_linux_init_abi): Fix size_termios.
2015-10-30 15:52:02 +00:00
Marcin Kościelnicki c28ebe255b gdb/linux-record: TASK_COMM_LEN is 16 on ppc too
gdb/ChangeLog:

	* ppc-linux-tdep.c (ppc_init_linux_record_tdep): Fix TASK_COMM_LEN.
2015-10-30 15:52:01 +00:00
Marcin Kościelnicki ff83a547fe gdb/linux-record: Fix old_select syscall handling
We have to use extract_unsigned_integer to read paramaters structure - target
pointers can have different endianness and size.

gdb/ChangeLog:

	* linux-record.c (record_linux_system_call): Fix old_select.
2015-10-30 15:52:01 +00:00
Marcin Kościelnicki d2de23ad39 gdb/linux-record: Fix newfstatat handling
The struct stat pointer is in the third argument, not the second.

gdb/ChangeLog:

	* linux-record.c (record_linux_system_call): Fix newstatat.
2015-10-30 15:52:00 +00:00
Marcin Kościelnicki cb658d218b gdb/linux-record: Fix [gs]etgroups16 syscall
Memory size for getgroups16 needs to be multiplied by entry count, and only
needs recording if the pointer is non-NULL.  setgroups16, on the other hand,
doesn't write to user memory and doesn't need special handling at all.

gdb/ChangeLog:

	* linux-record.c (record_linux_system_call): Fix [gs]etgroups16.
2015-10-30 15:51:59 +00:00
Marcin Kościelnicki b80d067ff0 gdb/linux-record: Support time, waitpid, pipe syscalls
gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_init_abi): Add size_time_t.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Add size_time_t.
	(amd64_x32_linux_init_abi): Add size_time_t.
	* arm-linux-tdep.c (arm_linux_init_abi): Add size_time_t.
	* i386-linux-tdep.c (i386_linux_init_abi): Add size_time_t.
	* linux-record.c (record_linux_system_call): Add time, waitpid, pipe
	handling.
	* linux-record.h (struct linux_record_tdep): Add size_time_t.
	* ppc-linux-tdep.c (ppc_init_linux_record_tdep): Add size_time_t.
2015-10-30 15:51:59 +00:00
Marcin Kościelnicki 933c5a623f gdb/linux-record: Fix msghdr parsing on 64-bit targets
The code failed to account for padding between the int and subsequent
pointer present on 64-bit architectures.

gdb/ChangeLog:

	* linux-record.c (record_linux_msghdr): Fix msg_namelen handling.
2015-10-30 15:51:58 +00:00
Marcin Kościelnicki 72aded8673 gdb/linux-record: Fix readdir and getdents handling
getdents buffer size is given in bytes, not dirent entries (which have
variable size anyway).  We don't need size_dirent and size_dirent64 for
this reason.

readdir, on the other hand, needs size of old_linux_dirent, which is
a somewhat different structure.  Accordingly, rename size_dirent
to size_old_dirent.

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_init_abi): Remove
	size_dirent{,64}, add size_old_dirent.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Remove size_dirent{,64},
	add size_old_dirent.
	(amd64_x32_linux_init_abi): Remove size_dirent{,64}, add
	size_old_dirent.
	* arm-linux-tdep.c (arm_linux_init_abi): Remove size_dirent{,64},
	add size_old_dirent.
	* i386-linux-tdep.c (i386_linux_init_abi): Remove size_dirent{,64},
	add size_old_dirent.
	* linux-record.c (record_linux_system_call): Fix handling of readdir
	and getdents{,64}.
	* linux-record.h (struct linux_record_tdep): Remove size_dirent{,64},
	add size_old_dirent.
	* ppc-linux-tdep.c (ppc_init_linux_record_tdep): Remove
	size_dirent{,64}, add size_old_dirent.
2015-10-30 15:51:58 +00:00
Marcin Kościelnicki 7571f7f297 gdb/linux-record: Fix sizes of sigaction and sigset_t
The values were mistakenly set to size of glibc's sigset_t (128 bytes)
and sigaction (140 or 152 bytes) instead of the kernel ones.  The kernel
has 4 or 8 byte old_sigset_t, 8 byte sigset_t, 16 or 32 byte old_sigaction,
20 or 32 byte sigaction.

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_init_abi): Fix size_sigaction,
	size_sigset_t, size_old_sigaction, size_old_sigset_t.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Fix size_sigaction,
	size_sigset_t, size_old_sigaction, size_old_sigset_t.
	(amd64_x32_linux_init_abi): Fix size_sigaction, size_sigset_t,
	size_old_sigaction, size_old_sigset_t.
	* arm-linux-tdep.c (arm_linux_init_abi): Fix size_sigaction,
	size_old_sigaction, size_old_sigset_t.
	* i386-linux-tdep.c (i386_linux_init_abi): Fix size_sigaction,
	size_old_sigaction, size_old_sigset_t.
	* ppc-linux-tdep.c (ppc_init_linux_record_tdep): Fix size_sigaction,
	size_sigset_t, size_old_sigaction, size_old_sigset_t.
2015-10-30 15:51:57 +00:00
Marcin Kościelnicki d625f9a988 gdb/linux-record: Fix size_[ug]id values
i386 and arm wrongly set them to 2, when it should be 4.  size_[ug]id is used
by getgroups32 etc syscalls, while size_old_[ug]id is used for getgroups16
and friends.

gdb/ChangeLog:

	* arm-linux-tdep.c (arm_linux_init_abi): Fix size_[ug]id.
	* i386-linux-tdep.c (i386_linux_init_abi): Fix size_[ug]id.
2015-10-30 15:51:56 +00:00
Marcin Kościelnicki aefb52a693 gdb/linux-record: Remove size_siginfo
It's a duplicate of size_siginfo_t.

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_init_abi): Remove size_siginfo.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Remove size_siginfo.
	(amd64_x32_linux_init_abi): Remove size_siginfo.
	* arm-linux-tdep.c (arm_linux_init_abi): Remove size_siginfo.
	* i386-linux-tdep.c (i386_linux_init_abi): Remove size_siginfo.
	* linux-record.c (record_linux_system_call): Change size_siginfo
	to size_siginfo_t.
	* linux-record.h (struct linux_record_tdep): Remove size_siginfo.
	* ppc-linux-tdep.c (ppc_init_linux_record_tdep): Remove size_siginfo.
2015-10-30 15:51:56 +00:00
Marcin Kościelnicki 452b4ba5f7 gdb/record: Add testcases for a few syscalls.
gdb/testsuite/ChangeLog:

	* gdb.reverse/fstatat-reverse.c: New test.
	* gdb.reverse/fstatat-reverse.exp: New file.
	* gdb.reverse/getresuid-reverse.c: New test.
	* gdb.reverse/getresuid-reverse.exp: New file.
	* gdb.reverse/pipe-reverse.c: New test.
	* gdb.reverse/pipe-reverse.exp: New file.
	* gdb.reverse/readv-reverse.c: New test.
	* gdb.reverse/readv-reverse.exp: New file.
	* gdb.reverse/recvmsg-reverse.c: New test.
	* gdb.reverse/recvmsg-reverse.exp: New file.
	* gdb.reverse/time-reverse.c: New test.
	* gdb.reverse/time-reverse.exp: New file.
	* gdb.reverse/waitpid-reverse.c: New test.
	* gdb.reverse/waitpid-reverse.exp: New file.
2015-10-30 15:51:55 +00:00
Simon Marchi 7ea45d72f9 gdbserver/proc-service.c: Change CORE_ADDR cast to uintptr_t
Fixes on i386:

../../../binutils-gdb/gdb/gdbserver/proc-service.c: In function ps_pdread:
../../../binutils-gdb/gdb/gdbserver/proc-service.c:83:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
../../../binutils-gdb/gdb/gdbserver/proc-service.c: In function ps_pdwrite:
../../../binutils-gdb/gdb/gdbserver/proc-service.c:93:30: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

I could have kept both casts:

  (CORE_ADDR) (uintptr_t) addr

but it's cleaner this way.  The uintptr_t implicitely gets promoted to a
CORE_ADDR, which is at least as long as uintptr_t.

gdb/gdbserver/ChangeLog:

	* proc-service.c (ps_pdread): Change CORE_ADDR cast to uintptr_t.
	(ps_pdwrite): Likewise.
2015-10-30 11:50:00 -04:00
Henrik Wallin 692916105d gdbserver: Move pointer dereference to after assert checks.
gdb/gdbserver/ChangeLog:

	* linux-arm-low.c (arm_new_thread): Move pointer dereference
	to after assert checks.

Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
2015-10-29 14:28:48 -04:00
Simon Marchi b42945fd28 Add/adjust casts in gdbserver's proc-service
The casts are required because ps_pd{read,write} must respect a fixed
interface.

gdb/gdbserver/ChangeLog:

	* proc-service.c (ps_pdread): Add/adjust casts.
	(ps_pdwrite): Add/adjust casts.
2015-10-29 14:15:08 -04:00
Pedro Alves d2242e347a mdebugread.c: Address class -> address class index
This fixes this error in C++ mode:

 /home/pedro/gdb/mygit/cxx-convertion/src/gdb/mdebugread.c:654:11: error: invalid conversion from ‘int’ to ‘address_class’ [-fpermissive]
   theclass = mdebug_register_index;
	    ^

The "theclass" local is of type enum address_class, however, what it
really holds is an address class index.  Class index values by design
match the address class values up until LOC_FINAL_VALUE, but extend
beyond that, so it's not really right to store an address class index
in an enum address_class.

The fix is really the same making the 'theclass' local be of type int,
but while we're at it, we get rid of the goto, and thus the local
becomes the 'aclass_index' parameter in the new add_data_symbol
function.

gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* mdebugread.c (add_data_symbol): New function, factored out from
	...
	(parse_symbol): ... here.  Delete 'theclass' local.
2015-10-29 17:54:20 +00:00
Simon Marchi cb0a270086 Add a cast in jit_target_read_impl
We could change the signature of the function.  However, it would
require changing gdb_target_read in jit-reader.h, which is an exported
interface.  It's probably better to just add a cast in our code than to
break other people's code.

gdb/ChangeLog:

	* jit.c (jit_target_read_impl): Add cast.
2015-10-29 13:43:02 -04:00
Simon Marchi 15cf126c04 Cast gdb_dlsym return value
gdb/ChangeLog:

	* jit.c (jit_reader_load): Add cast.
2015-10-29 13:43:02 -04:00
Simon Marchi d6f85c8421 gdbserver/server.c: Cast return value of memmem
gdb/gdbserver/ChangeLog:

	* server.c (handle_search_memory_1): Cast return value of
	memmem.
2015-10-29 13:43:02 -04:00
Simon Marchi f98cd05907 Change type of write_qxfer_response parameter
Fixes:

/home/simark/src/binutils-gdb/gdb/gdbserver/server.c: In function ‘int write_qxfer_response(char*, const void*, int, int)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/server.c:398:32: error: invalid conversion from ‘const void*’ to ‘const gdb_byte* {aka const unsigned char*}’ [-fpermissive]
           &out_len, PBUFSIZ - 2) + 1;
                                ^
gdb/gdbserver/ChangeLog:

	* server.c (write_qxfer_response): Change type of data to
	gdb_byte *.
2015-10-29 13:43:01 -04:00
Simon Marchi b40699581c dwarf2read.c: Add cast
There is no enum value representing 0.  It seems like the value of the
name field is irrelevant here.

gdb/ChangeLog:

	* dwarf2read.c (partial_die_full_name): Add cast.
2015-10-29 13:43:01 -04:00
Pedro Alves 7535d5edea Add cast to VEC_iterate
Fixes this in C++:

 ../../src/gdb/break-catch-sig.c: In function ‘int VEC_gdb_signal_type_iterate(const VEC_gdb_signal_type*, unsigned int, gdb_signal_type*)’:
 ../../src/gdb/common/vec.h:576:12: error: invalid conversion from ‘int’ to ‘gdb_signal_type {aka gdb_signal}’ [-fpermissive]
	*ptr = 0;          \
	     ^
 ../../src/gdb/common/vec.h:417:1: note: in expansion of macro ‘DEF_VEC_FUNC_P’
  DEF_VEC_FUNC_P(T)         \
  ^
 ../../src/gdb/break-catch-sig.c:37:1: note: in expansion of macro ‘DEF_VEC_I’
  DEF_VEC_I (gdb_signal_type);
  ^

I actually carried a different fix in the C++ branch that removed this
assignment and then adjusted all callers that depended on it.  The
thinking was that this is for the case where we're returning false,
indicating end of iteration.  But that results in a much larger and
tricker patch; looking back it seems quite pointless.  I looked at the
history of GCC's C++ conversion and saw that they added this same cast
to their version of vec.h, FWIW.  (GCC's vec.h is completely different
nowadays, having been converted to templates meanwhile.)

gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* common/vec.h (DEF_VEC_FUNC_P) [iterate]: Cast 0 to type T.
2015-10-29 17:39:33 +00:00
Pedro Alves fa4c39cb51 guile/: Add enum cast
gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* guile/scm-frame.c (gdbscm_unwind_stop_reason_string): Add cast.
2015-10-29 17:33:27 +00:00
Eli Zaretskii e681cf3fe5 Disable paging when run by Emacs 25.1 and later.
gdb/ChangeLog:

	* utils.c (init_page_info): Disable paging if INSIDE_EMACS is set
	in the environment.
2015-10-29 19:27:31 +02:00
Pedro Alves ebf05345da gnu-v2-abi.c: Add casts
I looked at changing these is_destructor_name/is_constructor_name
interfaces in order to detangle the boolean result from the ctor/dtor
kind return, but then realized that this design goes all the way down
to the libiberty demangler interfaces.  E.g, include/demangle.h:

 ~~~
 /* Return non-zero iff NAME is the mangled form of a constructor name
    in the G++ V3 ABI demangling style.  Specifically, return an `enum
    gnu_v3_ctor_kinds' value indicating what kind of constructor
    it is.  */
 extern enum gnu_v3_ctor_kinds
	 is_gnu_v3_mangled_ctor (const char *name);


 enum gnu_v3_dtor_kinds {
   gnu_v3_deleting_dtor = 1,
   gnu_v3_complete_object_dtor,
   gnu_v3_base_object_dtor,
   /* These are not part of the V3 ABI.  Unified destructors are generated
      as a speed-for-space optimization when the -fdeclone-ctor-dtor option
      is used, and are always internal symbols.  */
   gnu_v3_unified_dtor,
   gnu_v3_object_dtor_group
 };
 ~~~

libiberty/cp-demangle.c:

 ~~~
 enum gnu_v3_ctor_kinds
 is_gnu_v3_mangled_ctor (const char *name)
 {
   enum gnu_v3_ctor_kinds ctor_kind;
   enum gnu_v3_dtor_kinds dtor_kind;

   if (! is_ctor_or_dtor (name, &ctor_kind, &dtor_kind))
     return (enum gnu_v3_ctor_kinds) 0;
   return ctor_kind;
 }
 ~~~

etc.

gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* gnu-v2-abi.c (gnuv2_is_destructor_name)
	(gnuv2_is_constructor_name): Add casts.
2015-10-29 17:23:34 +00:00
Pedro Alves d2412fa5d0 gdbserver/mem-break.c: Add cast
... for C++.

Fixes:

 gdb/gdbserver/mem-break.c:204:28: error: invalid conversion from 'int' to 'bkpt_type' [-fpermissive]

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

	* mem-break.c (Z_packet_to_bkpt_type): Add cast.
2015-10-29 12:56:27 +00:00
Pedro Alves c17414a2a4 gdbserver/tracepoint: Add casts out of tpoint->handle
... as needed for C++.

tpoint->handle is a generic 'void *' handle.

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

	* tracepoint.c (clear_installed_tracepoints): Add casts.
2015-10-29 12:56:27 +00:00
Pedro Alves e053fbc44f gdbserver: enum gdb_signal casts
This is code parsing RSP signal numbers, checking whether the numbers
are indeed valid/known GDB signals, and then converting to host signal
numbers.  I considered adding temporary enum gdb_signal variables
instead, but didn't really like the result.

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

	* server.c (handle_v_cont, process_serial_event): Add enum
	gdb_signal casts to signal parsing code.
2015-10-29 12:56:27 +00:00
Pedro Alves add67df84c gdbserver: btrace enums
Fixes:

 ../../../src/gdb/gdbserver/linux-low.c: In function ‘int linux_low_read_btrace(btrace_target_info*, buffer*, int)’:
 ../../../src/gdb/gdbserver/linux-low.c:6827:48: error: invalid conversion from ‘int’ to ‘btrace_read_type’ [-fpermissive]
    err = linux_read_btrace (&btrace, tinfo, type);
						 ^
 In file included from ../../../src/gdb/gdbserver/linux-low.c:98:0:
 ../../../src/gdb/gdbserver/../nat/linux-btrace.h:116:26: error:   initializing argument 3 of ‘btrace_error linux_read_btrace(btrace_data*, btrace_target_info*, btrace_read_type)’ [-fpermissive]
  extern enum btrace_error linux_read_btrace (struct btrace_data *btrace,
			   ^

The cyclic dependency the comment talks about is no longer relevant:
  https://sourceware.org/ml/gdb-patches/2015-10/msg00643.html

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

	* linux-low.c (linux_low_read_btrace): Change type of 'type'
	parameter.
	* server.c (handle_qxfer_btrace): Change type of 'type'
	local.
	* target.h (struct target_ops) <read_btrace>: Change type of
	'type' parameter.  Update comment.
2015-10-29 12:55:02 +00:00
Pedro Alves 50bc912a20 gdbserver/Linux: Introduce NULL_REGSET
Fixes errors like:

 src/gdb/gdbserver/linux-x86-low.c:477:1: error: invalid conversion from 'int' to 'regset_type' [-fpermissive]

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

	* linux-low.h (NULL_REGSET): Define.
	* linux-aarch64-low.c (aarch64_regsets): Use NULL_REGSET.
	* linux-arm-low.c (arm_regsets): Likewise.
	* linux-crisv32-low.c (cris_regsets): Likewise.
	* linux-m68k-low.c (m68k_regsets): Likewise.
	* linux-mips-low.c (mips_regsets): Likewise.
	* linux-nios2-low.c (nios2_regsets): Likewise.
	* linux-ppc-low.c (ppc_regsets): Likewise.
	* linux-s390-low.c (s390_regsets): Likewise.
	* linux-sh-low.c (sh_regsets): Likewise.
	* linux-sparc-low.c (sparc_regsets): Likewise.
	* linux-tic6x-low.c (tic6x_regsets): Likewise.
	* linux-tile-low.c (tile_regsets): Likewise.
	* linux-x86-low.c (x86_regsets): Likewise.
	* linux-xtensa-low.c (xtensa_regsets): Likewise.
2015-10-29 12:55:02 +00:00
Pedro Alves 44a8b4df1d Add cast to exception_none
Fixes, in C++ mode:

 ../../src/gdb/common/common-exceptions.c:23:69: error: invalid conversion from ‘int’ to ‘return_reason’ [-fpermissive]
  const struct gdb_exception exception_none = { 0, GDB_NO_ERROR, NULL };
								      ^

(I considered adding an enum value for '0', but the code and comments
around return_reason and its uses explain how 0 is special/internal,
so I'm leaving it be.)

gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* common/common-exceptions.c (exception_none): Add cast.
2015-10-29 12:55:01 +00:00
Pedro Alves e3bdafe2ba compile: Rename struct type_map_instance::gcc_type field
Fixes:

  src/gdb/compile/compile-c-types.c:36:12: error: declaration of ‘gcc_type type_map_instance::gcc_type’ [-fpermissive]
     gcc_type gcc_type;
	      ^
  In file included from src/gdb/../include/gcc-c-interface.h:23:0,
		   from src/gdb/compile/compile-internal.h:21,
		   from src/gdb/compile/compile-c-types.c:23:
  src/gdb/../include/gcc-interface.h:32:28: error: changes meaning of ‘gcc_type’ from ‘typedef long long unsigned int gcc_type’ [-fpermissive]
   typedef unsigned long long gcc_type;
			      ^
  src/gdb/compile/compile-c-types.c: In function ‘gcc_type convert_qualified(compile_c_instance*, type*)’:
  src/gdb/compile/compile-c-types.c:310:19: error: invalid conversion from ‘int’ to ‘gcc_qualifiers’ [-fpermissive]
		quals);
		     ^

gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* compile/compile-c-types.c (struct type_map_instance)
	<gcc_type>: Rename to gcc_type_handle.
	(insert_type, convert_type): Adjust.
2015-10-29 12:55:01 +00:00
Pedro Alves 9c6595ab68 Don't assume break/continue inside a TRY block works
In C++, this:

	try
	  {
	    break;
	  }
	catch (..)
	  {}

is invalid.  However, because our TRY/CATCH macros support it in C,
the C++ version of those macros support it too.  To catch such
assumptions, this adds a (disabled) hack that maps TRY/CATCH to raw
C++ try/catch.  Then it goes through all instances that building on
x86_64 GNU/Linux trips on, fixing them.

This isn't strictly necessary yet, but I think it's nicer to try to
keep the tree in a state where it's easier to eliminate the TRY/CATCH
macros.

gdb/ChangeLog:
2015-10-29  Pedro Alves  <palves@redhat.com>

	* dwarf2-frame-tailcall.c (dwarf2_tailcall_sniffer_first): Don't
	assume that "break" breaks out of a TRY/CATCH.
	* python/py-framefilter.c (py_print_single_arg): Don't assume
	"continue" breaks out of a TRY/CATCH.
	* python/py-value.c (valpy_binop_throw): New function, factored
	out from ...
	(valpy_binop): ... this.
	(valpy_richcompare_throw): New function, factored
	out from ...
	(valpy_richcompare): ... this.
	* solib.c (solib_read_symbols): Don't assume "break" breaks out
	of a TRY/CATCH.
	* common/common-exceptions.h [USE_RAW_CXX_TRY]
	<TRY/CATCH/END_CATCH>: Define as 1-1 wrappers around try/catch.
2015-10-29 12:55:01 +00:00
Simon Dardis 93084fcd9b Move encoded as 'or' in binutils.
A patch (http://sourceware.org/ml/binutils/2015-07/msg00376.html)
submitted to binutils will be encoding move as an 'or' instruction over
[d]addu in assembly and various code stubs. This patch for gdb addresses
that change for the mips specific parts of gdb.

gdb/ChangeLog:

	* mips-linux-tdep.c (mips_linux_in_dynsym_stub): Recognise 'or'
	as move along with [d]addu.
2015-10-28 09:54:30 -07:00
Yao Qi 43cdf5aeb8 Pass noaliases_p to aarch64_decode_insn
Nowadays aarch64_decode_insn is a public interface used by both
opcodes and gdb.  However, its behaviour relies on a global variable
no_aliases, which isn't a good practise.  On the other hand, In default,
no_aliases is zero, but in GDB, we do want no alias when decoding
instructions for prologue analysis (patches to be posted), so that we
can handle both instructions "add" and "mov" (an alias of "add") as
"add".  The code in GDB can be simplified.

This patch adds a new argument in aarch64_decode_insn, and pass no_aliases
to it.  In GDB side, always pass 1 to it.

include/opcode:

2015-10-28  Yao Qi  <yao.qi@linaro.org>

	* aarch64.h (aarch64_decode_insn): Update declaration.

opcodes:

2015-10-28  Yao Qi  <yao.qi@linaro.org>

	* aarch64-dis.c	(aarch64_decode_insn): Add one argument
	noaliases_p.  Update comments.  Pass noaliases_p rather than
	no_aliases to aarch64_opcode_decode.
	(print_insn_aarch64_word): Pass no_aliases to
	aarch64_decode_insn.

gdb:

2015-10-28  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_software_single_step): Pass 1 to
	aarch64_decode_insn.
2015-10-28 14:22:57 +00:00
Pedro Alves b80c305316 Make host_address_to_string/gdb_print_host_address cast parameter to 'void *'
Fixes a set of errors like:

 ../../src/gdb/symfile-debug.c: In function ‘int debug_qf_map_symtabs_matching_filename(objfile*, const char*, const char*, int (*)(symtab*, void*), void*)’:
 ../../src/gdb/symfile-debug.c:137:39: error: invalid conversion from ‘int (*)(symtab*, void*)’ to ‘const void*’ [-fpermissive]
	host_address_to_string (callback),
					^

Note this has to work with data and function pointers.  In C++11 we
may perhaps do something a bit safer, but we're not there yet, and I
don't think it really matters.  For now just always do a simple
C-style cast in host_address_to_string itself.  No point in adding a
void * cast to each and every caller.

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

	* common/print-utils.c (host_address_to_string): Rename to ...
	(host_address_to_string_1): ... this.
	* common/print-utils.h (host_address_to_string): Reimplement as
	wrapper around host_address_to_string_1.
	* utils.c (gdb_print_host_address): Rename to ...
	(gdb_print_host_address_1): ... this.
	* utils.h (gdb_print_host_address): Reimplement as wrapper macro
	around	host_address_to_string_1.
2015-10-27 17:33:01 +00:00
Pedro Alves d09f2c3fc1 target_read_memory&co: no longer return target_xfer_status
Years ago, these functions used to return errno/EIO.  Later, through a
series of changes that intended to remove native/remote differences,
they ended up returning a target_xfer_status in disguise.

Unlike target_xfer_partial&co, the point of target_read_memory&co is
to either fully succeed or fail.  On error, they always return
TARGET_XFER_E_IO.  So there's no real point in casting the return of
target_read_memory to a target_xfer_status to pass it to memory_error.
Instead, it results in clearer code to simply decouple
target_read_memory&co's return from target_xfer_status.

This fixes build errors like this in C++ mode:

 ../../src/gdb/corefile.c: In function ‘void read_stack(CORE_ADDR, gdb_byte*, ssize_t)’:
 ../../src/gdb/corefile.c:276:34: error: invalid conversion from ‘int’ to ‘target_xfer_status’ [-fpermissive]
      memory_error (status, memaddr);
				   ^
 ../../src/gdb/corefile.c:216:1: error:   initializing argument 1 of ‘void memory_error(target_xfer_status, CORE_ADDR)’ [-fpermissive]

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

	* alpha-tdep.c (alpha_read_insn): Always pass TARGET_XFER_E_IO to
	memory_error.  Rename local 'status' to 'res'.
	* c-lang.c (c_get_string): Always pass TARGET_XFER_E_IO to
	memory_error.
	* corefile.c (read_stack, read_code, write_memory): Always pass
	TARGET_XFER_E_IO to memory_error.
	* disasm.c (dis_asm_memory_error): Always pass TARGET_XFER_E_IO to
	memory_error.  Rename parameter 'status' to 'err'.
	(dump_insns): Rename local 'status' to 'err'.
	* mips-tdep.c (mips_fetch_instruction): Rename parameter 'statusp'
	to 'errp'.  Rename local 'status' to 'err'.  Always pass
	TARGET_XFER_E_IO to memory_error.
	(mips_breakpoint_from_pc): Rename local 'status' to 'err'.
	* target.c (target_read_memory, target_read_raw_memory)
	(target_read_stack, target_read_code, target_write_memory)
	(target_write_raw_memory): Return -1 on error instead of
	TARGET_XFER_E_IO.
	* valprint.c (val_print_string): Rename local 'errcode' to 'err'.
	Always pass TARGET_XFER_E_IO to memory_error.  Update comment.
2015-10-27 17:25:09 +00:00
Simon Marchi c519209250 guile: Change return value of gdbscm_with_guile for const char *
The documentation of gdbscm_with_guile says that it returns a statically
allocated string (IOW, a const char *).  We can reflect that in its
return value type, and get rid of C++ build errors.

Initially fixes:

/home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c: In function ‘void* gdbscm_disasm_read_memory_worker(void*)’:
/home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c:93:12: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
     return "seek error";

gdb/ChangeLog:

	* guile/guile-internal.h (gdbscm_with_guile): Change return
	types to const char *.
	* guile/scm-safe-call.c (gdbscm_with_guile): Likewise.
	(struct c_data) <func>: Likewise.
	(struct c_data) <result>: Change type to const char *.
	(scscm_eval_scheme_string): Change return type to
	const char *.
	(scscm_source_scheme_script): Likewise.
	(gdbscm_safe_eval_string): Change type of result variable to
	const char * and remove cast.
	(gdbscm_safe_source_script): Likewise.
	* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker):
	Change return type to const char *.
	(gdbscm_disasm_read_memory): Change type of status to
	const char *.
2015-10-27 13:12:12 -04:00
Pedro Alves 79b289e2d8 source.c:openp: save/restore errno
openp's return is documented as:

~~~
   If a file is found, return the descriptor.
   Otherwise, return -1, with errno set for the last name we tried to open.  */
~~~

By inspection, I noticed that there are function calls after the ones
that first set errno, and those may clobber errno.  It's safer to save
errno when see an open fail, and restore it on exit.

Tested on x86_64 Fedora 20.

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

	* source.c (openp): New local 'last_errno'.  Use it to
	save/restore errno.
2015-10-27 16:03:24 +00:00
Pedro Alves 709b551853 psymtab.c: Add casts
... as needed for C++.

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

	* psymtab.c (dump_psymtab_addrmap_1): Add casts.
2015-10-27 15:06:04 +00:00
Simon Marchi e0d13cbd4b ctf.c: Fix int/enum implicit cast
This patch was taken directly from Pedro's branch.

Right now, SET_INT32_FIELD is used to set enum fields.  This works in C,
but not C++.  Therefore, define the new SET_ENUM_FIELD, which casts the
value to the right enum type.

gdb/ChangeLog:

	* ctf.c (SET_ENUM_FIELD): New macro.
	(ctf_read_status): Use it.
	(ctf_read_tp): Use it.
2015-10-27 10:54:21 -04:00
Simon Marchi c6486df5f1 Add scm_t_dynwind_flags casts
There is a handful of calls to

  scm_dynwind_begin (0);

where the parameter is an enum, scm_t_dynwind_flags.  In C++, we have no
choice but to add an explicit cast, since there is no enum value that
represents 0 (no flags set).

gdb/ChangeLog:

	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_stop_x): Add
	scm_t_dynwind_flags casts.
	* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
	* guile/scm-ports.c (gdbscm_open_memory): Likewise.
	* guile/scm-value.c (gdbscm_value_to_string): Likewise.
2015-10-27 09:34:30 -04:00
Simon Marchi 70b8286a97 Introduce ax_raw_byte and use it
This patch was taken directly from Pedro's branch.

ax_simple is used to append an agent expression operator to an agent
expression string.  Therefore, it takes an enum agent_op as input.
There is an instance where it's called to append a raw byte, unrelated
to the enum.  It makes the build fail in C++ mode.

This patch introduces ax_raw_byte for that purpose and uses it.

gdb/ChangeLog:

	* ax.h (ax_raw_byte): New declaration.
	* ax-general.c (ax_raw_byte): New function.
	(ax_simple): Use ax_raw_byte.
	* ax-gdb.c (gen_printf): Likewise.
2015-10-27 09:33:29 -04:00
Simon Marchi a480de357b ada-lang.h: Add cast in GROW_VECT
The assignment requires a cast in C++.  We only use this macro for
vectors of chars, so adding (char *) diretly will do for now.

gdb/ChangeLog:

	* ada-lang.h (GROW_VECT): Add cast.
2015-10-27 09:27:40 -04:00
Jan Kratochvil 5e2e7507b4 Fix access_to_packed_array.exp typos/errors
Running ./gdb.ada/access_to_packed_array.exp ...
ERROR: tcl error sourcing ./gdb.ada/access_to_packed_array.exp.
ERROR: extra characters after close-quote
    while executing
"gdb_test "print pack.a" "\\(0 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\)")"
    (file "./gdb.ada/access_to_packed_array.exp" line 29)
    invoked from within
"source ./gdb.ada/access_to_packed_array.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source ./gdb.ada/access_to_packed_array.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

Unrelated to the typos I have changed the print expectations s/"x"/" = x"/
as for example expectation "3" should not match " = 43".

2015-10-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.ada/access_to_packed_array.exp: Fix typos erroring the testfile.
2015-10-27 06:08:45 +01:00
Doug Evans a04a15f586 symtab.h (struct general_symbol_info> <ada_mangled>: Update comment.
gdb/ChangeLog:

	* symtab.h (struct general_symbol_info> <ada_mangled>: Update comment.
2015-10-26 20:24:16 -07:00
Simon Marchi d7f3ff3ea7 target.c: Add a cast and change a type
Fixes some errors in C++ build.

gdb/ChangeLog:

	* target.c (memory_xfer_partial): Change type of buf to gdb_byte
	pointer.
	(simple_search_memory): Cast return of memmem.
2015-10-26 22:07:27 -04:00
Simon Marchi bf6778dab2 stap-probe.c: Add casts
gdb/ChangeLog:

	* stap-probe.c (handle_stap_probe): Add (const char *) casts.
2015-10-26 22:04:10 -04:00
Simon Marchi c92444842b ctf_xfer_partial: Return TARGET_XFER_E_IO instead of -1 on error
Use the enum value instead of the corresponding int value.

gdb/ChangeLog:

	* ctf.c (ctf_xfer_partial): Return TARGET_XFER_E_IO instead of
	-1 on error.
2015-10-26 22:01:45 -04:00
Doug Evans 0fde2c536b PR symtab/17391 gdb internal error: assertion fails in regcache.c:178
gdb/ChangeLog:

	* dwarf2-frame.c (dwarf2_restore_rule): Call dwarf_reg_to_regnum
	instead of gdbarch_dwarf2_reg_to_regnum.
	(dwarf2_frame_cache): Ditto.
	(read_addr_from_reg): Call dwarf_reg_to_regnum_or_error instead of
	gdbarch_dwarf2_reg_to_regnum.
	(get_reg_value): Ditto.
	(dwarf2_fetch_cfa_info): Ditto.
	(dwarf2_frame_prev_register): Ditto.
	* dwarf2loc.c: #include "complaints.h".
	(dwarf_expr_read_addr_from_reg): Call dwarf_reg_to_regnum_or_error
	instead of gdbarch_dwarf2_reg_to_regnum.
	(dwarf_expr_get_reg_value): Ditto.
	(read_pieced_value): Ditto.
	(write_pieced_value): Ditto.
	(dwarf2_evaluate_loc_desc_full): Ditto.
	(dwarf_reg_to_regnum): New function.
	(throw_bad_regnum_error): New function.
	(dwarf_reg_to_regnum_or_error): Renamed from
	dwarf2_reg_to_regnum_or_errorChange to take a ULONGEST regnum.
	All callers updated.  Call throw_bad_regnum_error.
	(locexpr_regname): Improve text of bad register number.
	* dwarf2loc.h (dwarf_reg_to_regnum): Declare.
	(dwarf_reg_to_regnum_or_error): Update prototype.
	* dwarf2expr.c: #include "dwarf2loc.h".
	(dwarf_block_to_sp_offset): Call dwarf_reg_to_regnum instead of
	gdbarch_dwarf2_reg_to_regnum.
	* gdbarch.sh (dwarf2_reg_to_regnum): Add comment.
	* gdbarch.h: Regenerate.
	* amd64-tdep.c (amd64_dwarf_reg_to_regnum): Remove warning for bad
	register.
	* avr-tdep.c (avr_dwarf_reg_to_regnum): Ditto.
	* cris-tdep.c (cris_dwarf2_reg_to_regnum): Ditto.
	* bfin-tdep.c (bfin_reg_to_regnum): Fix error checking.
	* hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Improve error checking.
	Remove warning for bad register.
	* hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Ditto.
	* i386-tdep.c (i386_svr4_dwarf_reg_to_regnum): Renamed from
	i386_svr4_reg_to_regnum.  Return -1 for bad registers.
	(i386_svr4_reg_to_regnum): New function.
	(i386_gdbarch_init): Update call to set_gdbarch_dwarf2_reg_to_regnum.
	* microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Don't assert
	on bad registers, return -1.
	* msp430-tdep.c (msp430_dwarf2_reg_to_regnum): Improve error checking.
	Remove warning for bad register.
	* nios2-tdep.c: Add static assert for NIOS2_NUM_REGS.
	(nios2_dwarf_reg_to_regnum): Fix off-by-one error.
	Remove warning for bad register.  Return -1 for bad register.
	* rl78-tdep.c (rl78_dwarf_reg_to_regnum): Don't flag an internal error
	for bad register, return -1.
	* rx-tdep.c (rx_dwarf_reg_to_regnum): Ditto.
	* m68k-tdep.c (m68k_dwarf_reg_to_regnum): Fix error result.
	* mep-tdep.c (mep_debug_reg_to_regnum): Ditto.
	* mips-tdep.c (mips_stab_reg_to_regnum): Ditto.
	(mips_dwarf_dwarf2_ecoff_reg_to_regnum): Ditto.
	* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Remove warning
	for bad regs.
	* xtensa-tdep.c (xtensa_reg_to_regnum): Remove internal error for
	bad regs.  Fix error result.
	* stabsread.c (stab_reg_to_regnum): Watch for negative regno.
	(reg_value_complaint): Update complaint text.
	* mdebugread.c (reg_value_complaint): New function.
	(mdebug_reg_to_regnum): Rewrite to watch for bad reg numbers.

gdb/testsuite/ChangeLog:

	* lib/dwarf.exp (_location): Add support for DW_OP_regx.
	* gdb.dwarf2/bad-regnum.c: New file.
	* gdb.dwarf2/bad-regnum.exp: New file.
2015-10-26 16:05:21 -07:00
Doug Evans 1a70ae976b PR python/18938: source -s foo.py with foo.py a symlink to foo.notpy fails
gdb/ChangeLog:

	PR python/18938
	* cli/cli-cmds (source_script_fron_sctream): New arg file_to_open.
	All callers updated.

gdb/testsuite/ChangeLog:

	* gdb.python/python.exp: Add test for symlink from .py file to .notpy
	file.
2015-10-26 14:33:19 -07:00
Doug Evans 372405a5e8 Print address map in output of "mt print psymbols"
gdb/ChangeLog:

	* psymtab.c (struct dump_psymtab_addrmap_data): Define.
	(dump_psymtab_addrmap_1, dump_psymtab_addrmap): New functions.
	(maintenance_print_psymbols): Print address map.
2015-10-26 14:12:51 -07:00
Doug Evans 682b25469e Move __SIGRTMIN.
gdb/ChangeLog:

	* nat/linux-nat.h (__SIGRTMIN): Move here from gdbserver/linux-low.c.

gdb/gdbserver/ChangeLog:

	* linux-low.c (__SIGRTMIN): Move to nat/linux-nat.h.
2015-10-26 13:30:57 -07:00
Doug Evans 963843d4d0 musl: Move W_STOPCODE to common/gdb_wait.h.
gdb/ChangeLog:

	* common/gdb_wait.h (W_STOPCODE): Define, moved here from
	gdbserver/linux-low.c.
	(WSETSTOP): Simplify.

gdb/gdbserver/ChangeLog:

	* linux-low.c (W_STOPCODE): Moved to common/gdb_wait.h.
2015-10-26 13:24:01 -07:00
Doug Evans d41401ace0 Add some casts for building on musl.
gdb/ChangeLog:

	* linux-thread-db.c (find_new_threads_callback): Cast ti.ti_tid to
	unsigned long for debug_printf.
	(thread_db_pid_to_str): Ditto.

gdb/gdbserver/ChangeLog:

	* thread-db.c (find_one_thread): Cast ti.ti_tid to unsigned long
	for debug_printf.
	(attach_thread, find_new_threads_callback): Ditto.
2015-10-26 13:20:12 -07:00
Simon Marchi 1522597b05 guile: Simplify ioscm_make_gdb_stdio_port
As pointed out by Pedro, it's clearer to do it this way.  We can trust
that scm_mode_bits won't try to modify our string, even though it takes
a non-const char *.

gdb/ChangeLog:

	* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Do not pass a
	local char array to scm_mode_bits, use a cast instead.
2015-10-26 15:05:50 -04:00
Simon Marchi 7acd011bef tui: Simplify tui_alloc_content
I stumbled upon this while doing some cxx-conversion work.  Since the
x-family alloc functions throw on failure, it is useless to test their
result for failure.  The else branch of != NULL is basically dead code.

I changed the type of element_block_ptr to struct tui_win_element, which
seems obvious (this is actually what raised the flag, casting the result
of xmalloc to struct tui_win_element* wouldn't work).

gdb/ChangeLog:

	* tui/tui-data.c (tui_alloc_content): Don't check xmalloc
	result.  Change type of element_block_ptr.  Change allocation to
	use XNEWVEC.
2015-10-26 12:58:32 -04:00
Luis Machado 7cc53fba0a Do not pass NULL for the string in catch_errors
I caught a segmentation fault while running gdb.reverse/sigall-reverse.exp,
in a mingw32 GDB, in this code path. It boils down to the code trying to
strlen () a NULL pointer. I tracked things down and it looks like
record_full_message_wrapper_safe is the only offender.

gdb/ChangeLog:

2015-10-26  Luis Machado  <lgustavo@codesourcery.com>

	* record-full.c (record_full_message_wrapper_safe): Pass empty string to
	catch_errors call instead of NULL.
2015-10-26 11:17:29 -02:00
Simon Marchi 48ffa2b8cd Fix constness problem in ioscm_make_gdb_stdio_port
ioscm_make_gdb_stdio_port passes const char pointers (literal strings) to
scm_mode_bits, which takes a non-const char pointer.  Ideally, we would
change scm_mode_bits to take a const char pointer, but it's not part of
an API we control.

Instead, it's easy enough to build the string to pass to scm_mode_bits in
a (non-const) char array and pass that.

gdb/ChangeLog:

	* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Pass non-const
	char pointer to scm_mode_bits.
2015-10-26 08:41:39 -04:00
Simon Marchi 585a269afb symtab.c: Add cast
gdb/ChangeLog:

	* symtab.c (default_make_symbol_completion_list_break_on_1): Add
	cast.
2015-10-26 08:41:38 -04:00
Simon Marchi e0dd41e967 gdbscm_memory_port_write: use local variable to avoid adding casts
By having a local variable of type (const gdb_byte *), we can avoid adding
two casts.

gdb/ChangeLog:

	* guile/scm-ports.c (gdbscm_memory_port_write): Declare new
	"data" local variable and use it.
2015-10-26 08:41:37 -04:00
Simon Marchi 74ef968fba scm-symbol.c: Add (domain_enum) casts
We currently pass integers as domain_enums to lookup_symbol.  The
most obvious fix is to add casts there.

I first thought of changing the type of the domain variables to
domain_enum.  However, because we pass a pointer to them to
gdbscm_parse_function_args, which expects them to be integers (because
of the format string), I don't think it would be correct.  If the enum
does not have the same size as an int, gdbscm_parse_function_args could
write past the memory of domain, overwriting something else on the
stack.

gdb/ChangeLog:

	* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
	domain_enum cast.
	(gdbscm_lookup_symbol): Likewise.
2015-10-26 08:41:36 -04:00
Jan Kratochvil 27dc26ab39 Fix compile.exp error message expectation
commit cdaec3f3e7
Author: Luis Machado <lgustavo@codesourcery.com>
Date:   Thu Aug 27 02:00:16 2015 -0300
    Mention language in compile error message

regressed:

-PASS: gdb.compile/compile.exp: compile code globalvar
+FAIL: gdb.compile/compile.exp: compile code globalvar

Update the expected message.

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

	* gdb.compile/compile.exp (compile code globalvar): Update expectation
	for a change by "Mention language in compile error message".
2015-10-25 12:16:10 +01:00
Iain Buclaw 2d5a88dc50 Re-apply change for handling non-local references in nested functions.
gdb/ChangeLog:

	* d-exp.y: Remove an obsolete comment and propagate the block
	information to the produced expression.
2015-10-25 09:17:24 +01:00
Simon Marchi f4ee58bde9 tui-data.c: Remove unnecessary casts
The (void *) casts make the build fail in C++ mode and are unnecessary.

gdb/ChangeLog:

	* tui/tui-data.c (tui_add_to_source_windows): Remove void *
	cast.
	(tui_add_content_elements): Likewise.
2015-10-24 22:40:37 -04:00
Simon Marchi 1650ca1124 cli-setshow.c: Constify variable
Fixes:

/home/simark/src/binutils-gdb/gdb/cli/cli-setshow.c:390:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  p = strchr (arg, ' ');
             ^
gdb/ChangeLog:

	* cli/cli-setshow.c (do_set_command): Constify p.
2015-10-24 22:29:16 -04:00
Simon Marchi 55e5bf59f0 Replace (void *) cast with (gdb_byte *)
Fixes:

/home/simark/src/binutils-gdb/gdb/nat/linux-ptrace.c:207:6: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   pc = (void *) (uintptr_t) l;
         ^

gdb/ChangeLog:

	* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Replace
	(void *) cast with (gdb_byte *).
2015-10-24 18:36:26 -04:00
Simon Marchi 49e66b4deb proc-service.c: Add (gdb_byte *) cast
A cast here is necessary, just as it's necessary in ps_pdwrite just
below.  The type of buf can't be changed, since it's fixed in the ps_pd*
API.

gdb/ChangeLog:

	* proc-service.c (ps_pdread): Add cast.
2015-10-24 18:36:25 -04:00
Simon Marchi cfcb22a541 sparc64-tdep.c: Don't assign using memcpy return
This:

  valbuf = memcpy (buf, valbuf, len);

causes a build failure in C++, because memcpy returns the value of
"buf" as a void *.  Instead of adding a cast, we can just do the
assignment separately.

gdb/ChangeLog:

	* sparc64-tdep.c (sparc64_store_arguments): Split assignment of
	valbuf.
2015-10-24 18:36:24 -04:00
Simon Marchi ce746418ef ia64-tdep.c: Remove (void *) casts
Remove these (void *) casts, which cause a build failure in C++ mode.

gdb/ChangeLog:

	* ia64-tdep.c (ia64_pseudo_register_write): Remove cast.
	(ia64_push_dummy_call): Remove cast and change type of "to" to
	array of gdb_byte.
2015-10-24 18:36:23 -04:00
Simon Marchi a55515eecb Add mmap casts in linux-btrace.c
gdb/ChangeLog:

	* linux-btrace.c (linux_enable_pt): Add cast to mmap return.
2015-10-23 19:54:09 -04:00
Simon Marchi 6ecf4e06a4 Add cast to observer.sh
gdb/ChangeLog:

	* observer.h (observer_${event}_notification_stub): Add cast.
2015-10-23 16:58:13 -04:00
Antoine Tremblay 3db2885585 Remove set_breakpoint_data definition in GDBServer.
This patch removes the now unused set_breakpoint_data function from mem_break.h

gdb/gdbserver/ChangeLog:

	* mem-break.h (set_breakpoint_data): Remove.
2015-10-23 13:21:33 -04:00
Antoine Tremblay fb78e89c56 Fix nto,spu and win32 builds of GDBServer.
This patch fixes the build that was broken by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

It implements the sw_breakpoint_from_kind operation on these targets and removes
the calls to set_breakpoint_data.

Compiliation tested on win32.

Not tested : nto, spu.

gdb/gdbserver/ChangeLog:

	* nto-low.c (nto_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
	(initialize_low): Remove set_breakpoint_data call.
	* spu-low.c (spu_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Iniitalize.
	(initialize_low): Remove set_breakpoint_data call.
	* win32-low.c (win32_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
	(initialize_low): Remove set_breakpoint_data call.
2015-10-23 13:21:11 -04:00
Antoine Tremblay 2e6ee069ae Refactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.
This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro
so that all targets can easily use it.

This allows the breakpoint_kind_from_pc operation to be left unimplemented in
targets that do not need it.

This is preparation to fix the win32/nto/spu build that was broken by this
patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

	* linux-low.c (default_breakpoint_kind_from_pc): Move to target.c.
	* mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc.
	* target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c
	* target.h (target_breakpoint_kind_from_pc): New macro.
2015-10-23 13:20:39 -04:00
Yao Qi 034f1a812d Initialize field insn_count correctly
This patch initialize dsd.insn_count, otherwise, it triggers the assert
below on testings we did recently.

gdb:

2015-10-23  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Set
	dsd.insn_count to zero.
2015-10-23 09:23:22 +01:00
Pedro Alves d236ad1955 garbage collect gdb/infrun.c:stop_after_trap
No longer used anywhere.

gdb/ChangeLog:
2015-10-22  Pedro Alves  <palves@redhat.com>

	* infrun.c (stop_after_trap): Delete.
	(clear_proceed_status, handle_signal_stop, struct
	infcall_control_state, save_infcall_control_state)
	(restore_infcall_control_state): Remove references to
	stop_after_trap.
2015-10-22 17:41:10 +01:00
Antoine Tremblay 1652a98612 Fix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer.
This patch fixes a regression introduced by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

Tests : gdb.trace/trace-break.exp and gdb.trace/trace-mt.exp would fail on x86
with gdbserver-{native,extended}.

Before this patch, the breakpoint kind set by GDB with a Z packet and the one
set in the case of a tracepoint would be inconsistent on targets that did not
implement breakpoint_kind_from_pc. On x86 for example a breakpoint set by GDB
would have a kind of 1 but a breakpoint set by a tracepoint would have a kind of
0.

This created a missmatch when trying to insert a tracepoint and a breakpoint at
the same location. One of the two breakpoints would be removed with debug
message : "Inconsistent breakpoint kind".

This patch fixes the issue by changing the default 0 breakpoint kind to be
the size of the breakpoint according to sw_breakpoint_from_kind.

The default breakpoint kind must be the breakpoint length to keep consistency
between breakpoints set via GDB and the ones set internally by GDBServer.

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

	* linux-low.c (default_breakpoint_kind_from_pc): New function.
	(linux_breakpoint_kind_from_pc): Use default_breakpoint_kind_from_pc for
	the default breakpoint kind.
2015-10-22 12:23:58 -04:00
Simon Marchi db0f0d0c1d Add cast in python.c
gdb/ChangeLog:

	* python/python.c (_initialize_python): Add cast.
2015-10-22 12:13:19 -04:00
Simon Marchi fb70bc1a74 Add cast in nto-tdep.c
gdb/ChangeLog:

	* nto-tdep.c (nto_inferior_data): Add cast.
2015-10-22 11:58:38 -04:00
Pedro Alves c72f45d16c gdb/Windows: use windows_wait/windows_resume directly in initial startup
Explation below based on what Joel wrote at:

  https://sourceware.org/ml/gdb-patches/2015-10/msg00274.html

The merge async/sync code paths patch broke attaching on Windows.

This is what we observe, after attaching to any process.  At first, it
seems like everything worked fine, since the process stops, and we get
the prompt back:

    (gdb) att 3156
    Attaching to program `C:\[...]\foo.exe', process 3156
    [New Thread 3156.0xcd8]
    [New Thread 3156.0xfe4]
    0x7770000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
    (gdb)

However, enter any commands at all, and GDB appears to be hanging.
For instance:

    (gdb) set lang ada
    [nothing happens]

Despite appearances, GDB is not reading from the prompt.  It is
blocked waiting for an event from the inferior.  And since our
inferior is stopped, there aren't going to be any events to read.

In chronological order, what happens is that windows_attach calls
do_initial_windows_stuff, which performs the inferior creation,
and repeatedly waits until we get the first SIGTRAP:

  while (1)
    {
      stop_after_trap = 1;
      wait_for_inferior ();
      tp = inferior_thread ();
      if (tp->suspend.stop_signal != GDB_SIGNAL_TRAP)
        resume (tp->suspend.stop_signal);
      else
        break;
    }

The call to wait_for_inferior triggers a call to do_target_wait to get
the event, followed by handle_inferior_event to process it.  However,
because the first couple of events are "spurious" events, GDB resumes
the execution, and prepares the inferior to wait again:

    case TARGET_WAITKIND_SPURIOUS:
      [...]
      resume (GDB_SIGNAL_0);
      prepare_to_wait (ecs);

And prepare_to_wait just does...

  ecs->wait_some_more = 1;
  if (!target_is_async_p ())
    mark_infrun_async_event_handler ();

... which as a result sets the infrun_async_event_handler "ready"
flag to 1.

We get a couple of spurious events before we get the initial SIGTRAP,
at which point we exit the "while (1)" loop above, after which we
reach the end of the attach_command, followed by the normal
end-of-command processing (normal_stop, bp handling, printing the GDB
prompt), back finally to the root of the event loop.

Notice that, at this point, nothing has unset the "ready" flag for the
infrun_async_event_handler.  So, when another cycle of
gdb_do_one_event from the event loop, we eventually call
check_async_event_handlers, which finds that the infrun async event
handler is "ready", and therefore calls it's associated "proc"
callback, which does...

      inferior_event_handler (INF_REG_EVENT, NULL);

... triggering a blocking call to target_wait, thus hanging forever.

The fix is to use windows_wait and windows_resume directly, similarly
to gdbserver.  This will also allow getting rid of 'stop_after_trap'.

gdb/ChangeLog:
2015-10-22  Pedro Alves  <palves@redhat.com>

	* windows-nat.c (do_initial_windows_stuff): Rewrite loop using
	windows_wait and windows_resume directly instead of
	wait_for_inferior and resume.
2015-10-22 16:40:45 +01:00
Simon Marchi 60905b1e2a xtensa: Fix implicit enum conversions
XTREG is used with raw numbers, like:

...
  XTREG( 78,312,32, 4, 4,0x02d7,0x0007,-2, 2,0x1000,excsave7,    0,0,0,0,0,0)
  XTREG( 79,316, 8, 4, 4,0x02e0,0x0007,-2, 2,0x1000,cpenable,    0,0,0,0,0,0)
  XTREG( 80,320,22, 4, 4,0x02e2,0x000b,-2, 2,0x1000,interrupt,   0,0,0,0,0,0)
  XTREG( 81,324,22, 4, 4,0x02e2,0x000d,-2, 2,0x1000,intset,      0,0,0,0,0,0)
...

So just add the explicit cast to the macro.

In file included from /home/pedro/gdb/mygit/src/gdb/xtensa-config.c:25:0:
/home/pedro/gdb/mygit/src/gdb/xtensa-tdep.h:289:2: error: invalid conversion from ‘int’ to ‘call_abi_t’ [-fpermissive]
  }
  ^

gdb/ChangeLog:

	* xtensa-tdep.h (XTREG): Add casts.
	(XTREG_END): Likewise.
2015-10-22 09:47:47 -04:00
Simon Marchi 5af9928d44 solib-spu: Add gdb_byte* cast
Fixes this error:

/home/simark/src/binutils-gdb/gdb/solib-spu.c: In function ‘file_ptr spu_bfd_iovec_pread(bfd*, void*, void*, file_ptr, file_ptr)’:
/home/simark/src/binutils-gdb/gdb/solib-spu.c:299:55: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   ret = target_read_memory (addr + offset, buf, nbytes);
                                                       ^
In file included from /home/simark/src/binutils-gdb/gdb/target.h:65:0,
                 from /home/simark/src/binutils-gdb/gdb/exec.h:23,
                 from /home/simark/src/binutils-gdb/gdb/gdbcore.h:29,
                 from /home/simark/src/binutils-gdb/gdb/solib-spu.c:23:
/home/simark/src/binutils-gdb/gdb/target/target.h:35:12: note:   initializing argument 2 of ‘int target_read_memory(CORE_ADDR, gdb_byte*, ssize_t)’
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,

gdb/ChangeLog:

	* solib-spu.c (spu_bfd_iovec_pread): Add (gdb_byte *) cast.
2015-10-22 09:47:46 -04:00
Simon Marchi 3e45d68b70 rs6000: Add cast for int to enum conversion
Fixes this error:

/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:3091:1: error: invalid conversion from ‘int’ to ‘bfd_architecture’ [-fpermissive]
 };
 ^
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c: In function ‘void powerpc_set_vector_abi(char*, int, cmd_list_element*)’:
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:6063:28: error: invalid conversion from ‘int’ to ‘powerpc_vector_abi’ [-fpermissive]
  powerpc_vector_abi_global = vector_abi;
                            ^

gdb/ChangeLog:

	* rs6000-tdep.c (variants): Add (enum bfd_architecture) cast.
2015-10-22 09:47:44 -04:00
Simon Marchi 709476c3c5 mips: fix void*/gdb_byte* compilation errors
The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
to be a gdb_byte*, as usual.  supply_32bit_reg and mips64_fill_gregset
do some more complicated things however, so it's safer just to add the
explicit cast and avoid changing the code too much.

gdb/ChangeLog:

	* mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
	buf to gdb_byte*.
	(supply_32bit_reg): Add cast.
	(mips64_fill_gregset): Likewise.
2015-10-22 09:47:41 -04:00
Simon Marchi bed91f4da2 Fix accessing a function's fields (parameters) from Python (PR 18073)
Since 7.4, gdb doesn't allow calling .fields() on a function type, even
though the documentation states it should return a list corresponding to
the function's parameters.  This patch restores the intended behaviour
and adds a test for it.

Reg-tested on Arch Linux x86-64.

gdb/ChangeLog:

	PR python/18073
	* python/py-type.c (typy_get_composite): Allow returning a
	function type.

gdb/testsuite/ChangeLog:

	PR python/18073
	* gdb.python/py-type.c (C::a_method): New.
	(C::a_const_method): New.
	(C::a_static_method): New.
	(a_function): New.
	* gdb.python/py-type.exp (test_fields): Test getting fields
	from function and method.
2015-10-21 15:57:22 -04:00
Keven Boell 3f2f83ddcb fort_dyn_array: add basic fortran dyn array support
Fortran provide types whose values may be dynamically allocated
or associated with a variable under explicit program control.
The purpose of this commit is:

  * to read allocated/associated DWARF tags and store them in
    the dynamic property list of main_type.

  * enable GDB to print the value of a dynamic array in Fortran
    in case the type is allocated or associated (pointer to
    dynamic array).

Examples:
    (gdb) p vla_not_allocated
    $1 = <not allocated>

    (gdb) p vla_allocated
    $1 = (1, 2, 3)

    (gdb) p vla_ptr_not_associated
    $1 = <not associated>

    (gdb) p vla_ptr_associated
    $1 = (1, 2, 3)

Add basic test coverage for most dynamic array use-cases in Fortran.
The commit contains the following tests:
  * Ensure that values of Fortran dynamic arrays
    can be evaluated correctly in various ways and states.
  * Ensure that Fortran primitives can be evaluated
    correctly when used as a dynamic array.
  * Dynamic arrays passed to subroutines and handled
    in different ways inside the routine.
  * Ensure that the ptype of dynamic arrays in
    Fortran can be printed in GDB correctly.
  * Ensure that dynamic arrays in different states
    (allocated/associated) can be evaluated.
  * Dynamic arrays passed to functions and returned from
    functions.
  * History values of dynamic arrays can be accessed and
    printed again with the correct values.
  * Dynamic array evaluations using MI protocol.
  * Sizeof output of dynamic arrays in various states.

The patch was tested using the test suite on Ubuntu 12.04 64bit.

gdb/ChangeLog:

        * dwarf2read.c (set_die_type): Add read of
        DW_AT_allocated and DW_AT_associated.
        * f-typeprint.c: New include of typeprint.h
        (f_print_type): Add check for allocated/associated
        status of type.
        (f_type_print_varspec_suffix): Add check for
        allocated/associated status of type.
        * gdbtypes.c (create_array_type_with_stride):
        Add check for valid data location of type in
        case allocated or associated attributes are set.
        Length of an array should be only calculated if
        allocated or associated is resolved as true.
        (is_dynamic_type_internal): Add check for allocated/
        associated.
        (resolve_dynamic_array): Evaluate allocated/associated
        properties.
        * gdbtypes.h (enum dynamic_prop_node_kind): <DYN_PROP_ALLOCATED>
        <DYN_PROP_ASSOCIATED>: New enums.
        (TYPE_ALLOCATED_PROP, TYPE_ASSOCIATED_PROP): New macros.
        (type_not_allocated): New function.
        (type_not_associated): New function.
        * valarith.c (value_subscripted_rvalue): Add check for
        allocated/associated.
        * valprint.c: New include of typeprint.h.
        (valprint_check_validity): Add check for allocated/associated.
        (value_check_printable): Add check for allocated/
        associated.
        * typeprint.h (val_print_not_allocated): New function.
        (val_print_not_associated): New function.
        * typeprint.c (val_print_not_allocated): New function.
        (val_print_not_associated): New function.

gdb/testsuite/ChangeLog:

        * gdb.fortran/vla-alloc-assoc.exp: New file.
        * gdb.fortran/vla-datatypes.exp: New file.
        * gdb.fortran/vla-datatypes.f90: New file.
        * gdb.fortran/vla-history.exp: New file.
        * gdb.fortran/vla-ptype-sub.exp: New file.
        * gdb.fortran/vla-ptype.exp: New file.
        * gdb.fortran/vla-sizeof.exp: New file.
        * gdb.fortran/vla-sub.f90: New file.
        * gdb.fortran/vla-value-sub-arbitrary.exp: New file.
        * gdb.fortran/vla-value-sub-finish.exp: New file.
        * gdb.fortran/vla-value-sub.exp: New file.
        * gdb.fortran/vla-value.exp: New file.
        * gdb.fortran/vla-ptr-info.exp: New file.
        * gdb.mi/mi-vla-fortran.exp: New file.
        * gdb.mi/vla.f90: New file.
2015-10-21 15:37:46 -04:00
Sandra Loosemore 27145d5070 Adjust timeout in gdb.base/freebpcmd.exp.
2015-10-21  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.base/freebpcmd.exp: Use with_timeout_factor instead
	of hardwired timeout value.
2015-10-21 09:54:49 -07:00
Antoine Tremblay abeead094e Support software breakpoints for ARM linux in GDBServer.
This patch enables software breakpoints via GDB's Z0 packets on ARM.

No regressions, tested on ubuntu 14.04 ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

	* linux-arm-low.c (arm_supports_z_point_type): Add software
	breakpoint support.
2015-10-21 11:26:05 -04:00
Antoine Tremblay b0b4b50194 Refactor the breakpoint definitions in linux-arm-low.c.
Before arm_sw_breakpoint_from_kind would use an #ifdef to return the right
arm_breakpoint from the abi or eabi breakpoint type.

arm_breakpoint_at would also check for the arm_breakpoint ||
arm_eabi_breakpoint.

Thus the selected arm_breakpoint would be what arm_sw_breakpoint_from_kind
returned and arm_breakpoint was arm_abi_breakpoint.

This patch makes it more clear by naming those for what they are : 2 separate
entities: arm_abi_breakpoint and arm_eabi_breakpoint and set the current used
one as arm_breakpoint.

This allows a cleaner arm_sw_breakpoint_from_kind as it just returns
arm_breakpoint rather than having the #ifdef in that function.

Any other reference to the arm_breakpoint can now also be clear of #ifdefs...

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

	* linux-arm-low.c: Refactor breakpoint definitions.
	(arm_breakpoint_at): Adjust for arm_abi_breakpoint.
	(arm_sw_breakpoint_from_kind): Adjust for arm_breakpoint.
2015-10-21 11:26:05 -04:00
Antoine Tremblay 8689682cc3 Implement breakpoint_kind_from_pc and sw_breakpoint_from_kind for ARM in GDBServer.
ARM can have multiple breakpoint types based on the instruction set
it's currently in: arm, thumb or thumb2.

GDBServer needs to know what breakpoint is to be inserted at location
when inserting a breakpoint.

This is handled by the breakpoint_kind_from_pc and sw_breakpoint_from_kind
target ops introduced in a previous patch, this patch adds the
arm_breakpoint_kind_from_pc and arm_sw_breakpoint_from_kind implementation so
that the proper breakpoint type is returned based on the pc.

Also in order to share some code with GDB a new file called arm.c have been
introduced in arch/.

While this file does not contain much yet future patches will add more
to it thus the inclusion at this stage.

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/ChangeLog:

	* Makefile.in: Add arm.c/o.
	* arch/arm.c: New file.
	* arch/arm.h: (IS_THUMB_ADDR): Move macro from arm-tdep.c.
	(MAKE_THUMB_ADDR): Likewise.
	(UNMAKE_THUMB_ADDR): Likewise.
	* arm-tdep.c (int thumb_insn_size): Move to arm.c.
	(IS_THUMB_ADDR): Move to arm.h.
	(MAKE_THUMB_ADDR): Likewise.
	(UNMAKE_THUMB_ADDR): Likewise.
	* configure.tgt: Add arm.o to all ARM configs.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Add arm.c/o.
	* configure.srv: Likewise.
	* linux-arm-low.c (arm_breakpoint_kinds): New enum.
	(arm_breakpoint_kind_from_pc): New function.
	(arm_sw_breakpoint_from_kind): Return proper kind.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize.
2015-10-21 11:26:05 -04:00
Antoine Tremblay 2716529498 Support breakpoint kinds for software breakpoints in GDBServer.
There's two ways to set breakpoints in GDBServer.

 - GDBServer setting its own breakpoints, through API set_breakpoint_at.

 - GDBServer setting breakpoints according to the information in Z
   packets, through API set_gdb_breakpoint.

Before this patch the breakpoint kinds were a concept unique to GDB and Z
packets, as GDBServer never had to set different kinds of breakpoint on its
own.

This patch teaches GDBServer to handle breakpoint kinds for its own
breakpoints. It generalizes the breakpoint kind as per Z packets to
represent different kinds of breakpoints directly set by GDBServer also.

GDBServer now querys breakpoint_kind_from_pc to know what breakpoint kind to
set on its own.

As the kind is now a differentiating factor equivalent to size for the
breakpoint struct and that it's size can be queried using
sw_breakpoint_from_kind, the size field has been replaced with the kind field.
All references to size are now replaced by kind or a call to bp_size that wraps
sw_breakpoing_from_kind and returns the size of the breakpoint in memory.

To fetch the software breakpoint data bp_opcode is called and wraps the
sw_breakpoint_from_kind call.

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

	* linux-low.c (initialize_low): Ajdust for breakpoint global variables
	removal.
	* mem-break.c : Remove breakpoint_data/breakpoint_len global variables.
	(struct raw_breakpoint) <size>: Remove.
	(struct raw_breakpoint) <kind>: Add.
	(bp_size): New function.
	(bp_opcode): Likewise.
	(find_raw_breakpoint_at): Adjust for kind.
	(insert_memory_breakpoint): Adjust for kind call bp_size,bp_opcode.
	(remove_memory_breakpoint): Adjust for kind call bp_size.
	(set_raw_breakpoint_at): Adjust for kind.
	(set_breakpoint): Likewise.
	(set_breakpoint_at): Call breakpoint_kind_from_pc.
	(delete_raw_breakpoint): Adjust for kind.
	(delete_breakpoint): Likewise.
	(find_gdb_breakpoint): Likewise.
	(set_gdb_breakpoint_1): Likewise.
	(set_gdb_breakpoint): Likewise.
	(delete_gdb_breakpoint_1): Likewise.
	(delete_gdb_breakpoint): Likewise.
	(uninsert_raw_breakpoint): Likewise.
	(reinsert_raw_breakpoint): Likewise.
	(set_breakpoint_data): Remove.
	(validate_inserted_breakpoint): Adjust for kind call bp_size,bp_opcode.
	(check_mem_read): Adjust for kind call bp_size.
	(check_mem_write): Adjust for kind call bp_size,bp_opcode.
	(clone_one_breakpoint): Adjust for kind.
	* mem-break.h (set_gdb_breakpoint): Likewise.
	(delete_gdb_breakpoint): Likewise.
	* server.c (process_serial_event): Likewise.
2015-10-21 11:24:55 -04:00
Antoine Tremblay dd37334957 Add the target_ops needed for software breakpoints in GDBServer.
This patch is in preparation for software breakpoints on ARM linux.  It
refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and
sw_breakpoint_from kind to prepare the case where we have multiple types of
breakpoints.

Kind is the type of breakpoint (hardware or software) to be inserted, usually it
is the lenght of the software breakpoint but can be something else depending on
the target.

This patch introduces the linux_target_ops breakpoint_kind_from_pc and
sw_breakpoint_from_kind.

breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the
real memory location in case a flag was present in the PC. E.g the instruction
mode on ARM.

sw_breakpoint_from_kind returns the software breakpoint for this kind as a
string of bytes, the length of the breakpoint is adjusted for the breakpoint's
size in memory.

For targets that have only one kind of breakpoint, the default value 0 is
returned by linux_breakpoint_kind_from_pc so that not all targets need to
implement the breakpoint_kind_from_pc operation.

No regressions, tested on Ubuntu 14.04 on ARMv7 and x86
With gdbserver-{native,extended} / { -marm -mthumb }

Also since the target_ops have been changed compilation was tested on
affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r,
m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins.

Not tested : sh

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-arm-low.c (arm_breakpoint_kind_from_pc): New function.
	(arm_sw_breakpoint_from_kind): New function.
	* linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-cris-low.c (cris_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc
	and sw_breakpoint_from_kind to increment the pc.
	(linux_breakpoint_kind_from_pc): New function.
	(linux_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Initialize field.
	(initialize_low): Call breakpoint_kind_from_pc and
	sw_breakpoint_from_kind to replace breakpoint_data/len.
	* linux-low.h (struct linux_target_ops) <breakpoint_kind_from_pc>:
	New field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Likewise.
	* linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-mips-low.c (mips_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-s390-low.c (s390_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-sh-low.c (sh_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-tile-low.c (tile_sw_breakpoint_from_kind): New function.
	* linux-x86-low.c (x86_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
2015-10-21 11:24:55 -04:00
Yao Qi 80f0110c98 Remove checking vCont;s in exec_cmd_expect_vCont_count
Nowadays, in the range-stepping tests, we check not only the number of
vCont;r packets but also the number of vCont;s packets, because we think
the remote target which can do range stepping must support single step.

However, if we turn displaced stepping on, the remote target (GDBserver)
can do range stepping, and support single step, but GDB may decide to
resume instructions in the scratchpad rather than single step them one
by one for displaced stepping.  For example, when aarch64 GDB debugs
arm linux program with aarch64 GDBserver, GDBserver supports both range
stepping and single step, but GDB (with the gdbarch for arm-linux)
decides resume instructions in the scratchpad, so in the RSP traffic,
there is no vCont;s packet at all, and some range-stepping.exp tests
fail,

FAIL: gdb.base/range-stepping.exp: multi insns: next: vCont;s=1 vCont;r=1

This patch is to get rid of the checking to the number of vCont;s in
exec_cmd_expect_vCont_count.

gdb/testsuite:

2015-10-21  Yao Qi  <yao.qi@linaro.org>

	* lib/range-stepping-support.exp (exec_cmd_expect_vCont_count):
	Remove argument exp_vCont_s.
	* gdb.base/range-stepping.exp: Callers updated.
	* gdb.trace/range-stepping.exp: Likewise.
2015-10-21 16:16:25 +01:00
Aleksandar Ristovski d7161de46a [nto] Improve ABI sniffing.
Use qnx specific notes to figure out the OS.

gdb/ChangeLog:
	* gdb/nto-tdep.c (QNX_NOTE_NAME, QNX_INFO_SECT_NAME): New defines.
	(nto_sniff_abi_note_section): New function.
	(nto_elf_osabi_sniffer): Use new function to recognize nto specific
	binary.
2015-10-21 10:37:33 -04:00
Aleksandar Ristovski a9889169e5 [nto] Fix nto target stopped by watchpoint.
Fix 'stopped by watchpoint' detection: add inferior data, use inferior data
for storing last stopped flags needed for detection.

gdb/ChangeLog:

	* nto-procfs.c (procfs_wait): Set stopped_flags nad stopped_pc.
	(procfs_stopped_by_watchpoint): Use flags stored in inferior data.
	* nto-tdep.c (nto_new_inferior_data_reg): New definition.
	(nto_new_inferior_data, nto_inferior_data_cleanup, nto_inferior_data):
	New functions.
	(_initialize_nto_tdep): New forward declaration, new function.
	* nto-tdep.h (struct nto_inferior_data): New struct.
	(nto_inferior_data): New function declaration.
2015-10-21 10:37:33 -04:00
Antoine Tremblay 4cd98a1920 Fix --host cris-*-linux build of GDBServer.
Compiling GDBServer with --host cris-*-linux yields a compilation error :

linux-cris-low.c:65:21: error: ‘void’ must be the only parameter

This patch fixes the issue by removing the void parameter in cris_get_pc.

gdb/gdbserver/ChangeLog:
	* linux-cris-low.c (cris_get_pc): Remove void arg.
2015-10-21 07:45:56 -04:00
Jan Kratochvil 5f3ff4f893 Fix internal error on DW_OP_bregx(-1)
https://bugzilla.redhat.com/show_bug.cgi?id=1270564#c15
https://bugzilla.redhat.com/attachment.cgi?id=1081772

clang-3.5.0-9.fc22.x86_64
 <3><22b2>: Abbrev Number: 69 (DW_TAG_variable)
    <22b3>   DW_AT_location    : 7 byte block: 92 ff ff ff ff f 0	(DW_OP_bregx: 4294967295 (r-1) 0)
    <22bb>   DW_AT_name        : (indirect string, offset: 0x2a36): texture_data
    <22c1>   DW_AT_type        : <0x1d3>

(gdb) p variable
warning: Unmapped DWARF Register #-1 encountered.
regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs
(gdbarch))' failed.
[...]
Quit this debugging session? (y or n) FAIL: gdb.dwarf2/dw2-regno-invalid.exp: p variable (GDB internal error)

-> (x86_64)
(gdb) p variable
warning: Unmapped DWARF Register #-1 encountered.
Invalid register #-1, expecting 0 <= # < 220
(gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable
-> (i386)
(gdb) p variable
Invalid register #104, expecting 0 <= # < 104
(gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable

GDB calls gdbarch_dwarf2_reg_to_regnum() first which returns -1 in the x86_64
case
  if (regnum == -1)
    warning (_("Unmapped DWARF Register #%d encountered."), reg);
but in i386 case it does:
  /* This will hopefully provoke a warning.  */
  return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
and the default implementation is a nop, leaving whatever register number
the DWARF specified.

gdb/ChangeLog
2015-10-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* findvar.c (address_from_register): Check REGNUM validity.

gdb/testsuite/ChangeLog
2015-10-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-regno-invalid.exp: New file.
	* lib/dwarf.exp (Dwarf): Add DW_OP_bregx.
2015-10-20 20:40:38 +02:00
Aleksandar Ristovski e5343fde20 [nto] Implement procfs_pid_to_exec_file.
gdb/ChangeLog:

	* gdb/nto-procfs.c (procfs_pid_to_exec_file): New function.
	(init_procfs_targets): Wire new function.
2015-10-20 13:11:53 -04:00
Aleksandar Ristovski 8a6c0ccdd2 [nto] Implement TARGET_OBJECT_AUXV.
Fix 'info auxv' for nto.

gdb/ChangeLog:

	* nto-procfs.c (sys/auxv.h): Include.
	(procfs_xfer_partial): Implement TARGET_OBJECT_AUXV.
	* nto-tdep.c (nto_read_auxv_from_initial_stack): New function.
	* nto-tdep.h (nto_read_auxv_from_initial_stack): New declaration.
2015-10-20 13:02:33 -04:00
Aleksandar Ristovski 609c3040c2 [nto] Fixes for nto procfs.
Fix errnoeus construction of procfs path. The issue is, after the first
info pidlist or first run, the path for local node (the most common node)
will be reset to empty which makes subsequent queries and runs impossible.

gdb/ChangeLog:

	* nto-procfs.c (nto_procfs_path): Rename to...
	(nodestr): ... this, and change type.
	(nto_node): Use new variable and logic accordingly.
	(procfs_open_1): Use new variable name. Use local buffer to construct
	procfrs path.
	(procfs_pidlist): Use NODESTR to construct procfs path.
	(procfs_files_info): Use NODESTR to output meaningful text.
	(do_attach): Construct procfs using NODESTR.
	(procfs_create_inferior): Compare pointer to NULL.
2015-10-20 13:02:09 -04:00
Josh Stone bfd09d203f gdb: Improve syscall entry/return tracking on Linux
The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.

This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps.  Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry.  Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.

Three new test scenarios are added to catch-syscall.exp:

- Disable 'catch syscall' from an entry to deliberately miss the return
  event, then re-enable to make sure a new entry is recognized.

- Enable 'catch syscall' for the first time from a vfork event, which is
  a PTRACE_EVENT_VFORK in the middle of the syscall.  Make sure the next
  syscall event is recognized as the return.

- Make sure entry and return are recognized for an ENOSYS syscall.  This
  is to defeat a common x86 hack that uses the pre-filled ENOSYS return
  value as a sign of being on the entry side.

gdb/ChangeLog:

2015-10-19  Josh Stone  <jistone@redhat.com>

	* linux-nat.c (linux_handle_syscall_trap): Always update entry/
	return state, even when not actively catching syscalls at all.
	(linux_handle_extended_wait): Mark syscall_state like an entry.
	(wait_lwp): Set syscall_state ignored for other traps.
	(linux_nat_filter_event): Likewise.

gdb/testsuite/ChangeLog:

2015-10-19  Josh Stone  <jistone@redhat.com>

	* gdb.base/catch-syscall.c: Include <sched.h>.
	(unknown_syscall): New variable.
	(main): Trigger a vfork and an unknown syscall.
	* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
	(unknown_syscall_number): Likewise.
	(check_call_to_syscall): Accept an optional syscall pattern.
	(check_return_from_syscall): Likewise.
	(check_continue): Likewise.
	(test_catch_syscall_without_args): Check for vfork and ENOSYS.
	(test_catch_syscall_skipping_return): New test toggling off 'catch
	syscall' to step over the syscall return, then toggling back on.
	(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
	during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
	(do_syscall_tests): Call test_catch_syscall_without_args and
	test_catch_syscall_mid_vfork.
	(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
	(fill_all_syscalls_numbers): Initialize unknown_syscall_number.
2015-10-19 17:59:38 -07:00
Luis Machado 29090fb629 Make GDB wait for events after handling target File-I/O
_ftext () at arm-vector.S:25
25              ldr pc, [pc, #24] @ reset
(gdb) load
Loading section .text, size 0xc01c lma 0x0
Loading section .eh_frame, size 0x48 lma 0xc01c
Loading section .ARM.exidx, size 0x8 lma 0xc064
Loading section .rodata, size 0x398 lma 0xc070
Loading section .data, size 0x8e0 lma 0xc408
Start address 0x40, load size 52452
Transfer rate: 17074 KB/sec, 1748 bytes/write.
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (Thread 1)
infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 1] at 0x40
Sending packet: $vCont?#49...Ack
Packet received:
Packet vCont (verbose-resume) is NOT supported
Sending packet: $Hc0#db...Ack
Packet received: OK
Sending packet: $c#63...Ack
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Ffstat,00000001,07fffdb0
Sending packet: $M7fffdb0,40:000000000000000000002080000000010000c336000001180000000000000000000000000000000000000200000000000000000055dfb11b55dfb11b55dfb11b#5a...Ack
Packet received: OK
Sending packet: $F0#76...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = no-resumed
infrun: TARGET_WAITKIND_NO_RESUMED
infrun: stop_waiting
infrun: clear_step_over_info
Sending packet: $qfThreadInfo#bb...Ack
Packet received: m1
Sending packet: $qsThreadInfo#c8...Ack
Packet received: l
No unwaited-for children left.
infrun: infrun_async(0)
(gdb) c
Continuing.
Cannot execute this command while the selected thread is running.
(gdb)
Continuing.
Cannot execute this command while the selected thread is running.

This behavior shows up whenever GDB is in all-stop mode and is handling
target-initiated File-I/O requests, in the middle of, say, a continue
request.

When GDB is done handling the File-I/O request, it doesn't set
rs->waiting_for_stop_reply back to 1, meaning GDB should wait for
further target events.

This seems to be a latent bug, because in the past this didn't really
cause any issues. But it seems to have been uncovered by commit
567420d108, which explicitly checks
for rs->waiting_for_stop_reply == 0, triggering the failures above.

The following patch fixes this by reorganizing the setting of
rs->waiting_for_stop_reply.

infrun: prepare_to_wait
Packet received: Ffstat,00000001,07fffdb0
Sending packet: $M7fffdb0,40:000000000000000000002080000000010000c336000001180000000000000000000000000000000000000200000000000000000055dfb19e55dfb19e55dfb19e#7b...Ack
Packet received: OK
Sending packet: $F0#76...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Fisatty,00000001
Sending packet: $F1#77...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Fwrite,00000001,0000d098,00000004
Sending packet: $md098,4#d2...Ack
Packet received: 3732300a
720
Sending packet: $F4#7a...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Fwrite,00000001,07ffffac,00000011
Sending packet: $m7ffffac,11#8e...Ack
Packet received: 0a2a2a2a204558495420636f646520300a

*** EXIT code 0

Regression-tested on Ubuntu x86-64 and qemu-system-based debugging
for arm eabi.

gdb/ChangeLog:

2015-10-16  Luis Machado  <lgustavo@codesourcery.com>

	* remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to 0
	when handling 'E', 'T', 'S', 'X' and 'W' packets.
	Do not set rs->waiting_for_stop_reply back to 1.
2015-10-19 11:36:01 -02:00
Andrew Stubbs 65808c9664 Fixup comments oops in last commit. 2015-10-19 11:23:12 +01:00
Andrew Stubbs b32b93c614 Robustify inherit.exp and virtbase.exp.
2015-10-19  Andrew Stubbs  <ams@codesourcery.com>

	gdb/testsuite/
	* gdb.cp/inherit.exp (print g_vB, print g_vC, print g_vD,
	print g_vE): Add new pass patterns.
	* gdb.cp/virtbase.exp (print *this, print *(D *) e): Allow GDB to
	print various symbol names for vptr fields.
2015-10-19 11:15:21 +01:00
Aleksandar Ristovski 774ee6d252 [nto] Fix nto build.
gdb/gdbserver/ChangeLog:

	* gdbserver/nto-low.c (nto_insert_point, nto_remove_point): Fix
	variable name.

gdb/ChangeLog:

	* nto-procfs.c (common/filestuff.h): Include.
	(procfs_can_use_hw_breakpoint): Fix enum name.
	(procfs_open_1): Fix compiler warning.
	(procfs_pidlist): Make static.
	(procfs_meminfo): Make static, fix type name, add missing argument.
	(procfs_store_registers): Make static.
	(procfs_thread_info): Remove unused function.
	(_initialize_procfs): Forward declare.
2015-10-16 11:49:03 -04:00
Aleksandar Ristovski 833dcd2975 gdbserver: Reset current_thread when the thread is removed.
Reset current_thread and make sure 'remove_process' is used
after all associated threads have been removed first.

gdb/gdbserver/ChangeLog:
	* inferiors.c (thread_pid_matches_callback): New function.
	(find_thread_process): New function.
	(remove_thread): Reset current_thread.
	(remove_process): Assert threads have been removed first.
2015-10-16 11:13:31 -04:00
Aleksandar Ristovski 96e7a1eb6d gdbserver: Reset current_thread when the thread is removed.
Reset current_thread and make sure 'remove_process' is used
after all associated threads have been removed first.

gdb/gdbserver/ChangeLog:
	* inferiors.c (thread_pid_matches_callback): New function.
	(find_thread_process): New function.
	(remove_thread): Reset current_thread.
	(remove_process): Assert threads have been removed first.
2015-10-16 11:11:07 -04:00
Yao Qi e66acfb155 MAINTAINERS: Fix my inconsistent email address
Hi,
This patch fixes inconsistency in my email address.

2015-10-16  Yao Qi  <yao.qi@arm.com>

	* MAINTAINERS: Update my email address.
2015-10-16 12:31:45 +01:00
Yao Qi 8d689ee570 aarch64 multi-arch part 6: HW breakpoint on unaligned address
Nowadays, both aarch64 GDB and linux kernel assumes that address for
setting breakpoint should be 4-byte aligned.  However that is not true
after we support multi-arch, because thumb instruction can be at 2-byte
aligned address.  Patch http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/375141.html
to linux kernel is to teach kernel to handle 2-byte aligned address for
HW breakpoint, while this patch is to teach aarch64 GDB handle 2-byte
aligned address.

First of all, we call gdbarch_breakpoint_from_pc to get the instruction
length rather than using hard-coded 4.  Secondly, in GDBserver, we set
length back to 2 if it is 3, because GDB encode 3 in it to indicate it
is a 32-bit thumb breakpoint.  Then we relax the address alignment
check from 4-byte aligned to 2-byte aligned.

This patch enables some tests (such as gdb.base/break-idempotent.exp,
gdb.base/cond-eval-mode.exp, gdb.base/watchpoint-reuse-slot.exp,) and
fixes many fails (such as gdb.base/hbreak2.exp) when the program is
compiled in thumb mode on aarch64.

Regression tested on aarch64-linux, both native and gdbserver.  This
is the last patch of multi-arch work.

gdb:

2015-10-15  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint):
	Call gdbarch_breakpoint_from_pc to instruction length.
	(aarch64_linux_remove_hw_breakpoint): Likewise.
	* common/common-regcache.h (regcache_register_size): Declare.
	* nat/aarch64-linux-hw-point.c: Include "common-regcache.h".
	(aarch64_point_is_aligned): Set alignment to 2 for breakpoint if
	the process is 32bit, otherwise set alignment to 4.
	(aarch64_handle_breakpoint): Update comments.
	* regcache.c (regcache_register_size): New function.

gdb/gdbserver:

2015-10-15  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_insert_point): Set len to 2
	if it is 3.
	(aarch64_remove_point): Likewise.
	* regcache.c (regcache_register_size): New function.
2015-10-15 15:05:10 +01:00
Simon Marchi 38bc821765 Normalize my (personal) email address in ChangeLog 2015-10-15 09:05:37 -04:00
Aleksandar Ristovski 89fdc87fdb Remove core_regset_section
gdb/ChangeLog:

	* gdbarch.sh (core_regset_section): Remove.
	* gdbarch.h: Regenerate.
2015-10-15 08:56:23 -04:00
Yao Qi 6448a3e4da Define enum out of struct
This patch moves the definition of enum out of the scope of struct
aarch64_memory_operand, otherwise it breaks GDB build in c++ mode.

gdb:

2015-10-14  Yao Qi  <yao.qi@linaro.org>

	* arch/aarch64-insn.h (struct aarch64_memory_operand): Move enum
	out of it.
	(enum aarch64_memory_operand_type): New.
2015-10-14 09:30:39 +01:00
David Edelsohn 33f914a197 Recognize a few more AIX XCOFF DWARF sections.
gdb/ChangeLog:

        * xcoffread.c (dwarf2_xcoff_names): Add .dwmac and .dwpbtyp.
2015-10-13 18:45:38 -04:00
Pedro Alves e6a959d68b More char constification
Trivial constifications flagged by G++.  E.g.:

 src/gdb/c-varobj.c: In function ‘void c_describe_child(const varobj*, int, char**, value**, type**, char**)’:
 src/gdb/c-varobj.c:373:33: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
    char *join = was_ptr ? "->" : ".";
				  ^

gdb/ChangeLog:
2015-10-13  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_enum_name): Constify local.
	* ada-typeprint.c (print_range_bound): Constify locals.
	* c-varobj.c (c_describe_child): Likewise.
	* cli/cli-setshow.c (do_set_command): Likewise.
	* gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise.
	* dwarf2read.c (find_file_and_directory): Likewise.
	(anonymous_struct_prefix, dwarf2_name): Likewise.
	* gnu-v3-abi.c (gnuv3_rtti_type): Likewise.
	* go-lang.c (unpack_mangled_go_symbol): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* ser-tcp.c (net_open): Likewise.
	* symfile.c (deduce_language_from_filename): Likewise.
	* symtab.c (gdb_mangle_name): Likewise.
	* tui/tui-io.c (tui_redisplay_readline): Likewise.
2015-10-13 19:40:50 +01:00
Pedro Alves 170742de5d Fix execution_direction's type
This fixes a few build errors like these in C++ mode:

  src/gdb/reverse.c: In function ‘void exec_reverse_once(char*, char*, int)’:
  src/gdb/reverse.c:49:34: error: invalid conversion from ‘int’ to ‘exec_direction_kind’ [-fpermissive]
     enum exec_direction_kind dir = execution_direction;
				    ^
  make: *** [reverse.o] Error 1

gdb/ChangeLog:
2015-10-13  Pedro Alves  <palves@redhat.com>

	* infrun.c (restore_execution_direction): New function.
	(fetch_inferior_event): Use it instead of
	make_cleanup_restore_integer.
	(execution_direction): Change type to enum
	exec_direction_kind.
	* infrun.h (execution_direction): Likewise.
2015-10-13 19:40:50 +01:00
Pedro Alves bfb1c7963b ada-lang.c:ada_value_primitive_packed_val: const correctness
gdb/ChangeLog:
2015-10-13  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_value_primitive_packed_val): Constify
	locals.  Use value_contents_writeable.  Remove casts.
2015-10-13 19:40:50 +01:00
Pedro Alves aa5c10ce9b ada-lang.c: malloc/alloca casts for C++
gdb/ChangeLog:
2015-10-13  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_value_primitive_packed_val): Add casts to malloc
	and alloca calls.
2015-10-13 19:40:50 +01:00
Simon Marchi 4666fec3b4 lm32: Replace call to write_memory with write_memory_unsigned_integer
Fixes this error:

/home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c: In function ‘CORE_ADDR lm32_push_dummy_call(gdbarch*, value*, regcache*, CORE_ADDR, int, value**, CORE_ADDR, int, CORE_ADDR)’:
/home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c:292:59: error: invalid conversion from ‘void*’ to ‘const gdb_byte* {aka const unsigned char*}’ [-fpermissive]
    write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
                                                           ^
In file included from /home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c:29:0:
/home/emaisin/src/binutils-gdb/gdb/gdbcore.h:107:13: error:   initializing argument 2 of ‘void write_memory(CORE_ADDR, const gdb_byte*, ssize_t)’ [-fpermissive]
 extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
             ^

gdb/ChangeLog:

	* lm32-tdep.c (lm32_push_dummy_call): Replace call to
	write_memory with write_memory_unsigned_integer.
2015-10-13 13:37:13 -04:00
Simon Marchi 3953f15ce4 Constify arguments of gdb_bfd_lookup_symbol and related functions
Fixes this error:

/home/pedro/gdb/mygit/src/gdb/solib-frv.c: In function ‘int enable_break2()’:
/home/pedro/gdb/mygit/src/gdb/solib-frv.c:622:72: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
       addr = gdb_bfd_lookup_symbol (tmp_bfd, cmp_name, "_dl_debug_addr");
                                                                        ^
In file included from /home/pedro/gdb/mygit/src/gdb/solib-frv.c:23:0:
/home/pedro/gdb/mygit/src/gdb/solib.h:82:18: error:   initializing argument 3 of ‘CORE_ADDR gdb_bfd_lookup_symbol(bfd*, int (*)(asymbol*, void*), void*)’ [-fpermissive]
 extern CORE_ADDR gdb_bfd_lookup_symbol (bfd *abfd,
                  ^

The call in question is:

      addr = gdb_bfd_lookup_symbol (tmp_bfd, cmp_name, "_dl_debug_addr");

gdb/ChangeLog:

	* solib-dsbt.c (cmp_name): Constify arguments.
	* solib-frv.c (cmp_name): Likewise.
	* solib-svr4.c (svr4_create_solib_event_breakpoints): Likewise.
	* solib.c (gdb_bfd_lookup_symbol_from_symtab): Likewise.
	(bfd_lookup_symbol_from_dyn_symtab): Likewise.
	(gdb_bfd_lookup_symbol): Likewise.
	* solib.h (gdb_bfd_lookup_symbol): Likewise.
	(gdb_bfd_lookup_symbol_from_symtab): Likewise.
2015-10-13 12:42:35 -04:00
Andrew Burgess a0d34a3956 gdb: Simplify parse_frame_specification.
Remove an unneeded parameter from parse_frame_specification, replace
with a fixed string within parse_frame_specification.  The message was
the same in every place that parse_frame_specification was used anyway.

gdb/ChangeLog:

	* stack.c (parse_frame_specification): Remove message parameter,
	replace with fixed string in function body, update function
	comment.
	(frame_info): Remove message to parse_frame_specification.
	(select_frame_command): Likewise.
2015-10-12 23:30:39 +02:00
Andrew Burgess edbbff4a22 gdb: Avoid unneeded calls to parse_frame_specification.
Within the stack command there are a couple of places where fixed
strings are passed into functions that are really intended for
processing user input.  These fixed strings are then processed and the
result returned.

Given that the input strings in these cases are fixed, and are always
"0", then the result will always be the same, the current frame.  By
switching to using get_current_frame instead the code can be simplified,
and the intention of the code is clearer.

gdb/ChangeLog:

	* stack.c (parse_frame_specification): Delete.
	(parse_frame_specification_1): Rename to
	parse_frame_specification.
	(frame_info): Use parse_frame_specification.
	(select_frame_command): Likewise.
	(return_command): Use select_frame and print_stack_frame rather
	than frame_command and select_frame_command.
	(func_command): Use get_current_frame rather than
	parse_frame_specification.
2015-10-12 23:30:10 +02:00
Andrew Burgess 9d622bda56 gdb: Fix bug with dbx style func command.
The func command, available when starting gdb in dbx mode, is supposed
to take a function name and locate the frame for that function in the
stack.  This has been broken for a while due to an invalid check of the
arguments within the worker function.  Fixed in this commit.

gdb/ChangeLog:

	* stack.c (func_command): Return early when there is no ARG
	string.

gdb/testsuite/ChangeLog:

	* gdb.base/dbx.exp (test_func): Remove xfails, update expected
	results.
2015-10-12 23:29:43 +02:00
Andrew Burgess fc58fa65d4 gdb/doc: Restructure frame command documentation.
The 'frame' command is documented in two places.  The 'select-frame'
command is only mentioned in one of these places.

Of the two places, having the description of 'frame' and 'select-frame'
in the section 'Selecting a Frame' seems like the most obvious choice,
which is where things like 'up' and 'down' are also documented.

This commit moves the documentation of 'frame' and 'select-frame' into
the 'Selecting a Frame' section, and removes the duplicate documentation
of the 'frame' command.

At the same time I have reordered the sections in the 'Examining the
Stack' chapter, moving the discussion of frame filters to the end of the
chapter; it feels odd that we talk about frame filters before such basic
things like navigating the stack, or examining stack frames in general.

gdb/doc/ChangeLog:

	* gdb.texinfo (Frames): Remove 'frame' and 'select-frame'
	description.
	(Frame Filter Management): Move to later in the 'Examining the
	Stack' chapter.
	(Selection): Add entry for 'select-frame'.
2015-10-12 23:28:58 +02:00
Andrew Burgess 8d3fea161a gdb: Make use of safe-ctype.h header.
In stack.c switch to using safe-ctype.h instead of ctype.h, update code
as required.

gdb/ChangeLog:

	* stack.c: Include safe-ctype.h not ctype.h.
	(parse_frame_specification): Use ISSPACE not isspace.
	(backtrace_command): Use TOLOWER not tolower.
2015-10-12 23:28:24 +02:00
Simon Marchi f54b226fb0 mep: Add cast for int to enum conversion
Taken directly from Pedro's branch.

gdb/ChangeLog:

	* mep-tdep.c (current_me_module): Add cast.
	(mep_gdbarch_init): Likewise.
2015-10-12 12:43:23 -04:00
Simon Marchi 6da660c76d m32c: Split m32c_move_reg_t in read/write variants
This allows to avoid casting away the const qualification in
m32c_pseudo_register_write (which is the entry points for all other
register read/write functions).

Also, use gdb_byte* instead of void* to avoid casts when calling gdb
common memory functions.  It also allows to remove those "For adderss
arithmetic" local variables.

gdb/ChangeLog:

	* m32c-tdep.c (m32c_move_reg_t): Replace with...
	(m32c_write_reg_t): ...this and...
	(m32c_read_reg_t): ...this.
	(struct m32c_reg): Update types of read and write.
	(m32c_raw_read): Change declaration type to m32c_read_reg_t and
	adjust definition.
	(m32c_banked_read): Likewise.
	(m32c_sb_read): Likewise.
	(m32c_part_read): Likewise.
	(m32c_cat_read): Likewise.
	(m32c_r3r2r1r0_read): Likewise.
	(m32c_raw_write): Change declaration type to m32c_write_reg_t
	and adjust definition.
	(m32c_banked_write): Likewise.
	(m32c_sb_write): Likewise.
	(m32c_part_write): Likewise.
	(m32c_cat_write): Likewise.
	(m32c_r3r2r1r0_write): Likewise.
2015-10-12 12:39:40 -04:00
Simon Marchi 1f713e48f0 aarch64: Add cast for integer to enum cast
/home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c: In function ‘int aarch64_linux_syscall_record(regcache*, long unsigned int)’:
/home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c:904:57: error: invalid conversion from ‘long unsigned int’ to ‘aarch64_syscall’ [-fpermissive]
   syscall_gdb = aarch64_canonicalize_syscall (svc_number);
                                                         ^
/home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c:645:1: note:   initializing argument 1 of ‘gdb_syscall aarch64_canonicalize_syscall(aarch64_syscall)’
 aarch64_canonicalize_syscall (enum aarch64_syscall syscall_number)
 ^

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_syscall_record): Add cast.
2015-10-12 12:24:38 -04:00
Simon Marchi cb65d272fd aarch64: Use gdb_sys_no_syscall enum instead of -1
Fixes:

/home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c: In function "gdb_syscall aarch64_canonicalize_syscall(aarch64_syscall)":
/home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c:874:13: error: invalid conversion from "int" to "gdb_syscall" [-fpermissive]
     return -1;
             ^

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_canonicalize_syscall): Return
	gdb_sys_no_syscall instead of -1.
2015-10-12 12:24:37 -04:00
Yao Qi eda14cf259 Mention the change in NEWS
gdb:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* NEWS: Mention the change.
2015-10-12 11:28:39 +01:00
Yao Qi 1c2e1515c4 Rename emit_load_store to aarch64_emit_load_store
Likewise, this patch renames emit_load_store to
aarch64_emit_load_store.

gdb:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* arch/aarch64-insn.c (emit_load_store): Rename to ...
	(aarch64_emit_load_store): ... it.  All callers updated.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c: Update all callers as emit_load_store
	is renamed to aarch64_emit_load_store.
2015-10-12 11:28:39 +01:00
Yao Qi e1c587c312 Rename emit_insn to aarch64_emit_insn
As emit_insn becomes extern, the prefix "aarch64_" is needed.  This
patch renames emit_insn to aarch64_emit_insn.

gdb:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* arch/aarch64-insn.c (emit_insn): Rename to ...
	(aarch64_emit_insn): ... it.  All callers updated.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c: Update all callers of function renaming
	from emit_insn to aarch64_emit_insn.
2015-10-12 11:28:39 +01:00
Yao Qi 0fd8ac1c45 New test case gdb.arch/disp-step-insn-reloc.exp
This patch adds a new test case which uses gdb.arch/insn-reloc.c too
to test displaced stepping.  Nowadays, tests are for x86, x86_64 and
aarch64.

gdb/testsuite:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/disp-step-insn-reloc.exp: New test case.
2015-10-12 11:28:38 +01:00
Yao Qi 34240514b5 Support displaced stepping in support_displaced_stepping for aarch64*-*-linux*
gdb/testsuite:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* lib/gdb.exp (support_displaced_stepping): Return 1 if target
	is aarch64*-*-linux*.
2015-10-12 11:28:38 +01:00
Yao Qi b6542f81d0 Support displaced stepping in aarch64-linux
This patch is to support displaced stepping in aarch64-linux.  A
visitor is implemented for displaced stepping, and used to record
information to fixup pc after displaced stepping if needed.  Some
emit_* functions are converted to macros, and moved to
arch/aarch64-insn.{c,h} so that they can be shared.

gdb:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-tdep.c: Include arch-utils.h.
	(aarch64_linux_init_abi): Call set_gdbarch_max_insn_length,
	set_gdbarch_displaced_step_copy_insn,
	set_gdbarch_displaced_step_fixup,
	set_gdbarch_displaced_step_free_closure,
	set_gdbarch_displaced_step_location,
	and set_gdbarch_displaced_step_hw_singlestep.
	* aarch64-tdep.c (struct displaced_step_closure): New.
	(struct aarch64_displaced_step_data): New.
	(aarch64_displaced_step_b): New function.
	(aarch64_displaced_step_b_cond): Likewise.
	(aarch64_register): Likewise.
	(aarch64_displaced_step_cb): Likewise.
	(aarch64_displaced_step_tb): Likewise.
	(aarch64_displaced_step_adr): Likewise.
	(aarch64_displaced_step_ldr_literal): Likewise.
	(aarch64_displaced_step_others): Likewise.
	(aarch64_displaced_step_copy_insn): Likewise.
	(aarch64_displaced_step_fixup): Likewise.
	(aarch64_displaced_step_hw_singlestep): Likewise.
	* aarch64-tdep.h (DISPLACED_MODIFIED_INSNS): New macro.
	(aarch64_displaced_step_copy_insn): Declare.
	(aarch64_displaced_step_fixup): Declare.
	(aarch64_displaced_step_hw_singlestep): Declare.
	* arch/aarch64-insn.c (emit_insn): Moved from
	gdbserver/linux-aarch64-low.c.
	(emit_load_store): Likewise.
	* arch/aarch64-insn.h (enum aarch64_opcodes): Moved from
	gdbserver/linux-aarch64-low.c.
	(struct aarch64_register): Likewise.
	(struct aarch64_memory_operand): Likewise.
	(ENCODE): Likewise.
	(can_encode_int32): New macro.
	(emit_b, emit_bcond, emit_cb, emit_ldr, emit_ldrsw): Likewise.
	(emit_tb, emit_nop): Likewise.
	(emit_insn): Declare.
	(emit_load_store): Declare.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (enum aarch64_opcodes): Move to
	arch/aarch64-insn.h.
	(struct aarch64_memory_operand): Likewise.
	(ENCODE): Likewise.
	(emit_insn): Move to arch/aarch64-insn.c.
	(emit_b, emit_bcond, emit_cb, emit_tb): Remove.
	(emit_load_store): Move to arch/aarch64-insn.c.
	(emit_ldr, emit_ldrb, emit_ldrsw, emit_nop): Remove.
	(can_encode_int32): Remove.
2015-10-12 11:28:38 +01:00
Yao Qi 246994ce35 Move aarch64_relocate_instruction to arch/aarch64-insn.c
This patch moves aarch64_relocate_instruction and visitor class to
arch/aarch64-insn.c, so that both GDB and GDBserver can use it.

gdb:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* arch/aarch64-insn.c (aarch64_decode_ldr_literal): Moved from
	gdbserver/linux-aarch64-low.c.
	(aarch64_relocate_instruction): Likewise.
	* arch/aarch64-insn.h (aarch64_decode_ldr_literal): Declare.
	(struct aarch64_insn_data): Moved from
	gdbserver/linux-aarch64-low.c.
	(struct aarch64_insn_visitor): Likewise.
	(aarch64_relocate_instruction): Declare.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (extract_signed_bitfield): Remove.
	(aarch64_decode_ldr_literal): Move to gdb/arch/aarch64-insn.c.
	(aarch64_relocate_instruction): Likewise.
	(struct aarch64_insn_data): Move to gdb/arch/aarch64-insn.h.
	(struct aarch64_insn_visitor): Likewise.
2015-10-12 11:28:38 +01:00
Yao Qi 0badd99faf Use visitor in aarch64_relocate_instruction
Nowadays, the instruction decodings and handling are mixed together
inside aarch64_relocate_instruction.  The patch decouples instruction
decoding and instruction handling by using visitor pattern.  That is,
aarch64_relocate_instruction decode instructions and visit each
instruction by different visitor methods.  Each visitor defines the
concrete things to different instructions.  Fast tracepoint instruction
relocation and displaced stepping can define their own visitors,
sub-class of struct aarch64_insn_data.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (struct aarch64_insn_data): New.
	(struct aarch64_insn_visitor): New.
	(struct aarch64_insn_relocation_data): New.
	(aarch64_ftrace_insn_reloc_b): New function.
	(aarch64_ftrace_insn_reloc_b_cond): Likewise.
	(aarch64_ftrace_insn_reloc_cb): Likewise.
	(aarch64_ftrace_insn_reloc_tb): Likewise.
	(aarch64_ftrace_insn_reloc_adr): Likewise.
	(aarch64_ftrace_insn_reloc_ldr_literal): Likewise.
	(aarch64_ftrace_insn_reloc_others): Likewise.
	(visitor): New.
	(aarch64_relocate_instruction): Use visitor.
2015-10-12 11:28:38 +01:00
Yao Qi dfaffe9d93 Move append_insns out of aarch64_relocate_instruction
aarch64_relocate_instruction should only decode instructions, and other
operations should be done out side of it.  This patch moves append_insns
out of aarch64_relocate_instruction, to its caller.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_relocate_instruction): Return
	int.  Add argument buf.
	(aarch64_install_fast_tracepoint_jump_pad): Pass buf to
	aarch64_relocate_instruction.
2015-10-12 11:28:38 +01:00
Yao Qi 70b439f0a8 Move target_read_uint32 out of aarch64_relocate_instruction
This patch is to move target_read_uint32 out of
aarch64_relocate_instruction and pass INSN to
aarch64_relocate_instruction, so that it is cleaner, only decode
instructions.

gdb/gdbserver:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_relocate_instruction): Add
	argument insn.  Remove local variable insn.  Don't call
	target_read_uint32.
	(aarch64_install_fast_tracepoint_jump_pad): Call
	target_read_uint32.
2015-10-12 11:28:38 +01:00
Yao Qi 8240f4421f More tests in gdb.arch/insn-reloc.c
This patch adds more tests in gdb.arch/insn-reloc.c to cover
instruction BL and cover B.CON when CON is false.  These new added
tests can be used for displaced stepping too.

gdb/testsuite:

2015-10-12  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/insn-reloc.c (can_relocate_bcond): Rename to ...
	(can_relocate_bcond_true): ... it.
	(can_relocate_bcond_false): New function.
	(foo): Likewise.
	(can_relocate_bl): Likewise.
	(testcases) [__aarch64__]: Add can_relocate_bcond_false and
	can_relocate_bl.
2015-10-12 11:28:38 +01:00
Pierre-Marie de Rodat 2520f728b7 Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT
Assume foo_array is a pointer to a C structure. GDB must evaluate the
following expression properly, but it does not currently:

    (gdb) print 1 && &foo_array[1].a
    Attempt to take address of value not located in memory.

The problem is that in EVAL_AVOID_SIDE_EFFECTS mode,
eval.c:evaluate_subexp_standard always returns a not_lval value as the
result for a STRUCTOP_STRUCT operation. As a consequence, the rest of
the code believes that one cannot take the address of the returned
value.

This patch fixes STRUCTOP_STRUCT handling so that the VALUE_LVAL
attribute for the returned value is properly initialized.  After this
change, the above session becomes:

    (gdb) print 1 && &foo_array[1].a
    $1 = 1

gdb/ChangeLog:

	* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT>: If
	EVAL_AVOID_SIDE_EFFECTS mode, forward the VALUE_LVAL attribute
	to the returned value.

gdb/testsuite/ChangeLog:

	* gdb.base/nested-addr.c: New file.
	* gdb.base/nested-addr.exp: New testcase.

Tested on x86_64-linux, no regression.
2015-10-12 12:22:10 +02:00
Joel Brobecker 5b639deae1 [Ada] ada_unpack_from_contents: Error if target buffer not large enough
This adds a guard that the size of the "unpacked" buffer is large enough
to contain at least BIT_SIZE bits.  If not, report an error.  This is to
guard this routine from doing buffer overflows when called incorrectly.

gdb/ChangeLog:

        * ada-lang.c (ada_unpack_from_contents): Add guard that unpacked
        is large enough for BIT_SIZE.  Update function comment.
2015-10-09 14:33:57 -07:00
Joel Brobecker 0cafa88cc0 [Ada] Buffer overflow in ada_unpack_from_contents
This patch fixes a buffer overflow in ada_unpack_from_contents
caused by one of the previous commits. This happens when trying
to print the value of an array of variant records.

The overflow happens while trying to print one element of the array.
Because the size of each element in the array is variable, the array
has a DWARF byte_stride attribute, which makes us treat the array
as if it was packed. And during the extraction of each array element,
we try to unpack an object using the array's byte stride as the size,
into an element whose size is actually less than the stride.

This patch fixes the issue by overriding the byte-stride with
the actual element's length.

gdb/ChangeLog:

        * ada-lang.c (ada_value_primitive_packed_val): Move
        src_len variable to local block where used.  Override
        BIT_SIZE if bigger than size of resolved type.
2015-10-09 14:33:28 -07:00
Joel Brobecker 220475ed8b make is_scalar_type non-static and use it in ada-lang.c
Just a small cleanup, to avoid code duplication...

gdb/ChangeLog:

        * gdbtypes.h (is_scalar_type): Add extern declaration.
        * gdbtypes.c (is_scalar_type): Make non-static.
        * ada-lang.c (ada_value_primitive_packed_val): Use is_scalar_type
        to compute IS_SCALAR instead of doing it ourselves.
2015-10-09 14:32:23 -07:00
Joel Brobecker d0a9e81089 [Ada] Better handling of dynamic types in ada_value_primitive_packed_val
There is some partial handling for dynamic types in
ada_value_primitive_packed_val, but this support was added
in a fairly ad hoc way, and actually only covered the situation
where OBJ is not NULL and its contents had not been fetched yet.
In addition, even in the cases that it does cover, it doesn't make
much sense. In particular, it was adjusting BIT_SIZE and SRC_LEN,
which are properties of the data to be extracted _from_, based
on TYPE's length once resolved, which is a property of the data
we want to extract _to_.

This patch hopefully adjust this function to handle dynamic types
correctly, and in all cases. It does so by unpacking the data into
a temporary buffer in order to use that buffer to resolve the type.
And _then_ creates the resulting value from that resolved type.

gdb/ChangeLog:

        * ada-lang.c (ada_value_primitive_packed_val): Rework handling
        of case where TYPE is dynamic.
2015-10-09 14:30:38 -07:00
Joel Brobecker f93fca700f [Ada] split data unpacking code out of ada_value_primitive_packed_val.
This patch is just preparation work which splits the function
ada_value_primitive_packed_val into two function: one which unpacks
the data, and the other which now uses it to implement
ada_value_primitive_packed_val.

This simplifies a bit ada_value_primitive_packed_val, but will also
allow us to use the new function to unpack data without actually creating
a struct value as a result.

gdb/ChangeLog:

        * ada-lang.c (ada_unpack_from_contents): New function,
        extracted from ada_value_primitive_packed_val.
        (ada_value_primitive_packed_val): Replace extracted out code
        by call to ada_unpack_from_contents.
2015-10-09 14:30:06 -07:00
Joel Brobecker a1c95e6b6e Reorder variable declarations in ada_value_primitive_packed_val
This patch just changes the order in which local variables are declared
so as to group the logically-related variables together.  No code
change otherwise.

gdb/ChangeLog:

        * ada-lang.c (ada_value_primitive_packed_val): Reorder local
        variable declarations.
2015-10-09 14:28:50 -07:00
Joel Brobecker fbd000da7c use gdb_byte in ada-lang.c::ada_value_primitive_packed_val...
... instead of "unsigned char".

gdb/Changelog:

        * ada-lang.c (ada_value_primitive_packed_val): Change the type
        of local variables src and unpacked to "gdb_type *" instead of
        "unsigned char *".
2015-10-09 14:28:21 -07:00
Joel Brobecker 086ca51f46 More explicit local variable names in ada_value_primitive_packed_val
A number of local variables declared in ada_value_primitive_packed_val
have a name that could, IMO, be improved to, either: Be more explicit
about what the variable is about (Eg: "src" is an index, so rename it
to "src_idx"); or be more consistent with other variables that they
relate to: for instance, several variables refer to the source via
"src" (Eg: srcBitsLeft, nsrc), but the buffer they refer to is called
"bytes", so patch renames "bytes" to "src".

This should help read and understand a little more easily the code
inside this function.  No real code change otherwise.

gdb/ChangeLog:

        * ada-lang.c (ada_value_primitive_packed_val): Make the name
        of various local variables more explicit and consistent.
        No real code change otherwise.
2015-10-09 14:27:43 -07:00
Simon Marchi c5bcd27856 i386: Fix type of gdbarch_tdep::register_reggroup_p
gdb/ChangeLog:

	* i386-tdep.h (struct gdbarch_tdep): Change type of
	register_reggroup_p to gdbarch_register_reggroup_p_ftype.
2015-10-09 10:12:22 -04:00
Simon Marchi 78c5b88248 cris: Use enum bfd_endian to represent endianness
gdb/ChangeLog:

	* cris-tdep.c (struct instruction_environment): Change type of
	byte_order to enum bfd_endian.
2015-10-09 10:12:21 -04:00
Simon Marchi f9fa37b325 arm-linux-tdep: Add explicit cast for int to gdb_syscall conversion
This patch is taken from Pedro's branch.

gdb/ChangeLog:

	* arm-linux-tdep.c (arm_canonicalize_syscall): Add
	enum gdb_syscall casts.
2015-10-09 10:12:21 -04:00
Simon Marchi 7c543f7b07 Change some void* to gdb_byte*
There are a bunch of places where a void* is implicitely casted into a
gdb_byte*.  The auto-insert-casts script added explicit casts at those
places.  However, in many cases, it makes more sense to just change the
void* to a gdb_byte*.

gdb/ChangeLog:

	* aarch64-tdep.c (stack_item_t): Change type of data to gdb_byte*.
	* arm-tdep.c (struct stack_item): Likewise.
	(push_stack_item): Add gdb_byte* cast.
	* avr-tdep.c (struct stack_item): Change type of data to gdb_byte*.
	(push_stack_item): Add gdb_byte* cast.
	* cli/cli-dump.c (dump_memory_to_file): Change type of buf to gdb_byte*
	and add cast.
	* cris-tdep.c (struct stack_item): Change type of data to gdb_byte*.
	(push_stack_item): Add gdb_byte* cast.
	* gcore.c (gcore_copy_callback): Change type of memhunk to gdb_byte* and
	add cast.
	* gdbtypes.h (print_scalar_formatted): Change type of first parameter to
	gdb_byte*.
	* h8300-tdep.c (h8300_extract_return_value): Change type of valbuf to
	gdb_byte* and remove unnecessary cast.
	(h8300h_extract_return_value): Likewise.
	(h8300_store_return_value): Change type of valbuf to gdb_byte*.
	(h8300h_store_return_value): Likewise.
	* iq2000-tdep.c (iq2000_extract_return_value): Change type of valbuf to
	gdb_byte* and remove unnecessary cast.
	* jit.c (jit_reader_try_read_symtab): Change type of gdb_mem to gdb_byte*
	and add cast.
	* m32r-tdep.c (m32r_store_return_value): Change type of valbuf to
	gdb_byte* and remove unnecessary cast.
	(m32r_extract_return_value): Change type of dst to gdb_byte* and remove
	valbuf.
	* mep-tdep.c (mep_pseudo_cr32_read): Change type of buf to gdb_byte*.
	(mep_pseudo_cr64_read): Likewise.
	(mep_pseudo_csr_write): Likewise.
	(mep_pseudo_cr32_write): Likewise.
	(mep_pseudo_cr64_write): Likewise.
	* mi/mi-main.c (mi_cmd_data_write_memory): Change type of buffer to
	gdb_byte* and add cast.
	* moxie-tdep.c (moxie_store_return_value): Change type of valbuf to
	gdb_byte* and remove unnecessary cast.
	(moxie_extract_return_value): Change type of dst to gdb_byte* and remove
	valbuf.
	* p-valprint.c (print_scalar_formatted): Change type of valaddr to
	gdb_byte*.
	* printcmd.c (void): Likewise.
	* python/py-inferior.c (infpy_read_memory): Change type of buffer to
	gdb_byte* and add cast.
	(infpy_write_memory): Likewise.
	(infpy_search_memory): Likewise.
	* regcache.c (regcache_raw_write_signed): Change type of buf to gdb_byte*
	and add cast.
	(regcache_raw_write_unsigned): Likewise.
	(regcache_cooked_write_signed): Likewise.
	(regcache_cooked_write_unsigned): Likewise.
	* sh64-tdep.c (h64_extract_return_value): Change type of valbuf to
	gdb_byte*.
2015-10-09 10:08:23 -04:00
Simon Marchi 7567e115d3 Add two callback data casts
gdb/ChangeLog:

	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Add cast.
	* linux-tdep.c (linux_collect_regset_section_cb_data): Likewise.
2015-10-09 09:41:30 -04:00
Eli Zaretskii f9acce4a4f Fix typos in comments
gdb/

2015-10-09  Eli Zaretskii  <eliz@gnu.org>

	* stack.c (print_stack_frame):
	* utils.c (printchar): Fix typos in commentary.
2015-10-09 16:21:08 +03:00
Markus Metzger abcef95aa5 btrace, test: avoid gdb.btrace/vdso.exp fail
The vdso.exp test checks that we can access the VDSO memory when replaying.

Depending on the line information generated by the compiler, runto_main may run
to the line marked with bp.1 or stop before that line.  The test incorrectly
assumes that it will always run to the marked line and fails if it doesn't.

The test does not really care about what is traced.  It does care that GDB is
replaying when capturing the second disassemble output.

Reflect that in the test by ignoring the output of the stepping and record goto
begin commands and by checking that GDB is actually replaying.

testsuite/
	* gdb.btrace/vdso.c (main): Remove breakpoint markers.
	* gdb.btrace/vdso.exp: Change stepping command to "next" and ignore
	its output.  Ignore the output of "record goto begin" and instead
	check that GDB is replaying.
2015-10-09 14:29:41 +02:00
Pedro Alves 145e3ddb4b Fix gdb.base/a2-run.exp race
This patch fixes this racy failure, with the native-extended-gdbserver
board:

 (gdb) run
 Starting program: build/gdb/testsuite/outputs/gdb.base/a2-run/a2-run
 Remote debugging from host 127.0.0.1
 Process build/gdb/testsuite/outputs/gdb.base/a2-run/a2-run created; pid = 23832
 Reading /lib64/ld-linux-x86-64.so.2 from remote target...
 warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
 Reading /lib64/ld-linux-x86-64.so.2 from remote target...
 Reading /lib64/libm.so.6 from remote target...
 Reading /lib64/libc.so.6 from remote target...
 [Inferior 1 (process 23832) exited with code 01]
 (gdb) FAIL: gdb.base/a2-run.exp: run "a2-run" with no args
 PASS: gdb.base/a2-run.exp: no spurious messages at program exit
 run 5
 Starting program: build/gdb/testsuite/outputs/gdb.base/a2-run/a2-run 5
 Reading /lib64/ld-linux-x86-64.so.2 from remote target...
 usage:  factorial <number>

 Child exited with status 1

Note that the output is correct; it's just that inferior output
appeared after gdb's output, and the test doesn't handle that
correctly.

This comment isn't really correct, unfortunately:

	# waiting.  If we had already seen the status wrapper exit,
	# gdb_test_multiple/expect has no spawn ids left, and thus
	# returns.

That's true of expect in general, but I had missed / forgot that
gdb_test_multiple internally has extra matches using "-i
$gdb_spawn_id", so even if the caller clears all the indirect spawn id
lists, gdb_test_multiple will continue waiting.

So do a conditional exp_continue manually instead.

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

	* gdb.base/a2-run.exp (maybe_exp_continue): New procedure.
	(top level): Use it in the run with no args test.
2015-10-09 12:56:26 +01:00
Iain Buclaw d5d8c4e12b [D] Support D style sizeof and typeof expressions.
gdb/ChangeLog:

	* d-exp.y: (UnaryExpression): Support `type.sizeof' expressions.
	(PostfixExpression): Support `expr.sizeof' expressions.
	(PrimaryExpression): Support `typeof(expr)' expressions.

gdb/testsuite/ChangeLog:

	* gdb.dlang/properties.exp: New file.
2015-10-08 21:42:36 +02:00
Maciej W. Rozycki 4e7de1556a MAINTAINERS: Update my email address
gdb/
	* MAINTAINERS: Update my email address.
2015-10-08 18:57:56 +01:00
Markus Metzger 04c4fe8c59 btrace: fix void return
record_btrace_resume returns the void return from the to_resume method of the
target beneath.  Split this into calling to_resume and return.

gdb/
	* record-btrace.c (record_btrace_resume): Fix void return.
2015-10-08 09:00:57 +02:00
Yao Qi f77ee8026d [aarch64] use aarch64_decode_insn to decode instructions in GDB
In this patch, we start to use aarch64_decode_insn to decode instructions
in aarch64_software_single_step.

gdb:

2015-10-07  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c: Include opcode/aarch64.h.
	(submask): Move it above.
	(bit): Likewise.
	(bits): Likewise.
	(aarch64_software_single_step): Call aarch64_decode_insn.
	Decode instruction by aarch64_inst instead of using
	aarch64_decode_bcond and decode_masked_match.
2015-10-07 09:52:46 +01:00
Pitchumani Sivanupandi cbd641edf3 parse load_offset (bias) of restore command as long
Following failures are noticed for avr-gdb. This may be the case
for targets like AVR which has integer_to_address hook defined.

FAIL: gdb.base/dump.exp: struct copy, srec; value restored ok
FAIL: gdb.base/dump.exp: struct copy, ihex; value restored ok
FAIL: gdb.base/dump.exp: struct copy, tekhex; value restored ok

These tests are failed because load_offset(bias) of restore command
parsed as address.

command: restore filename [binary] bias start end

Except binary, other BFDs have a built-in location; gdb restores content
at offset 'bias' from that location. So, 'bias' of 'restore' command should
be parsed as address only when the file is binary.

Below patch changes gdb to parse 'bias' as long if the file is not binary.

gdb/ChangeLog

2015-10-06  Pitchumani Sivanupandi  <pitchumani.s@atmel.com>

	* cli/cli-dump.c (restore_command): Parse load_offset (bias) as address
	only when the file is binary.
2015-10-06 18:29:03 +02:00
jamesbowman ae4e25019d [FT32] gdb: Correctly interpret function prologs
The stack unwinder did not understand the function prologs
generated by gcc with -Os. Add code to recognize and interpret the
prolog calls.

[gdb]

2015-10-02  James Bowman  <james.bowman@ftdichip.com>

	* ft32-tdep.c (ft32_analyze_prologue): Add function prolog
	subroutine handling.
2015-10-02 17:32:47 -07:00
Sandra Loosemore 06e635ef63 Fix gdb.dwarf2/staticvirtual.exp regexp.
2015-10-02  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.dwarf2/staticvirtual.exp: Generalize regexp so it can match
	whether or not address 0x1000 is mapped on the target.
2015-10-02 13:12:56 -07:00
Simon Marchi dd0a637a3d vec.h: Add casts for C++ compat
gdb/ChangeLog:

	* common/vec.h (VEC_OP (T,cleanup)): Add pointer cast.
2015-10-01 11:29:08 -04:00
Doug Evans 1fd60fc077 dwarf2read.c (setup_type_unit_groups): Add comment.
gdb/ChangeLog:

	* dwarf2read.c (setup_type_unit_groups): Add comment.
2015-09-30 12:29:48 -07:00
Pedro Alves 398e081380 x86/Linux: reenable all-stop on top of non-stop
Since the record-btrace target now supports non-stop mode, we no
longer need to force-disable as-ns on x86.

gdb/ChangeLog:
2015-09-30  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (linux_nat_always_non_stop_p): Always return 1.
	* x86-linux-nat.c (x86_linux_always_non_stop_p): Delete.
	(x86_linux_create_target): Don't install
	x86_linux_always_non_stop_p.
2015-09-30 19:23:39 +01:00
Don Breazeal 6ab24463cb Call strprefix instead of strncmp in event parsing
This fixes a typo that used strncmp instead of strprefix when
checking for an exec event in a stop reply packet.

gdb/ChangeLog:

	* remote.c (remote_parse_stop_reply): Call strprefix instead
	of strncmp.
2015-09-30 10:14:45 -07:00
Simon Marchi ede5f15146 gdbarch.h: Change gdbarch_info::tdep_info's type to void *
As reported by Ulrich here:

  https://sourceware.org/ml/gdb-patches/2015-09/msg00604.html

The system compiler (gcc 4.1) in Centos 5 doesn't like that we cast to a
pointer to a type that doesn't exist.  I see no real value in using this
kind iof construct over just using void *.  So this patch changes the
tdep_info field to void * and removes the casts.  Even in C++, we
should not need an explicit cast when assigning to a void *.

gdb/ChangeLog:

	* gdbarch.sh (struct gdbarch_info): Change tdep_info's type to void *.
	* gdbarch.h: Regenerate.
	* i386-tdep.c (i386_gdbarch_init): Remove cast to
	struct gdbarch_tdep_info *.
	* mips-tdep.c (mips_gdbarch_init): Likewise.
	* ppc-linux-tdep (ppu2spu_sniffer): Likewise.
	* rs6000-tdep.c (rs6000_gdbarch_init): Likewise.
	* spu-multiarch.c (spu_gdbarch): Likewise.
2015-09-30 11:21:52 -04:00
Yao Qi 7781c06f6e Shorten long lines in linux-aarch64-low.c
Happen to see these lines are too long.  This patch shortens them.

gdb/gdbserver:

2015-09-30  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (emit_movk): Shorten a long line.
	(emit_load_store_pair): Likewise.
2015-09-30 16:01:47 +01:00
Simon Marchi e019fd1d14 py-type.exp: Do not run tests if binary fails to build
I noticed this while working on the test case.  I believe it would make
sense to skip running the tests if the binary failed to build.  Although
I would understand the opposite argument: if the binary does not build
for some reason, we probably want to know about it, and some catastrophic
failures in the tests might alarm us better than a timid "UNTESTED".

gdb/testsuite/ChangeLog:

	* gdb.python/py-type.exp: Do not run tests if binaries fail to
	build.
2015-09-30 10:04:33 -04:00
Kevin Buettner 51c935fa4a Fix ChangeLog Date for previous push. 2015-09-30 05:58:56 -07:00
Kevin Buettner aca20ec473 infcmd.c: Don't attempt to record a NULL value after a finish command.
Architectures which use RETURN_VALUE_STRUCT_CONVENTION will have a
NULL return value after executing a finish command.  See get_return_value()
in infcmd.c.

This patch avoids an eventual SIGSEV (caused by attempting to
derefrence a NULL pointer) by adding a suitable test to
finish_command_fsm_should_stop().

I encountered this problem while testing msp430:

(gdb) PASS: gdb.base/structs.exp: zed L<n> for finish; return 1 structs-tc
finish
Run till exit from #0  fun1 () at /ironwood1/sourceware-git/msp430-elf/../binutils-gdb/gdb/testsuite/gdb.base/structs.c:125
ERROR: Process no longer exists

gdb/ChangeLog:
    	* infcmd.c (finish_command_fsm_should_stop): Don't attempt to
    	record a NULL value.
2015-09-30 05:56:03 -07:00
Markus Metzger 77ba2a6796 btrace, testsuite: fix spurious gdb.btrace/tsx.exp fails
If the atomic section in x86-tsx.S is aborted, the tsx.exp test will fail
even if the traced output is actually correct.

Consider abort scenarios in the test.

testsuite/
	* gdb.btrace/tsx.exp: Consider multiple correct outputs in the record
	instruction-history test.
2015-09-30 14:48:38 +02:00
Kevin Buettner 3b1ad7d510 msp430: Fix bug regarding large memory model inferior function call arguments.
This change causes reference, struct, and union arguments to be treated
the same as pointer arguments when determining the size of the value to
place into a register.

The case for doing this for reference arguments is obvious.

The msp430 ABI specifies that struct and union arguments are passed by
reference.  This is why they're treated in the same manner as pointer
and reference arguments when computing the size of the value to place
into a register.

In my testing using this multilib...

msp430-sim/-msim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either

... I find that the the following failures, 125 in all, are fixed by this
patch.

FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns char
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns short
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns int
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns long
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns float
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns double
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns float _Complex
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns double _Complex
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns long double _Complex
FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns char *
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns char
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns short
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns int
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns long
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns float
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns double
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns float _Complex
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns double _Complex
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns long double _Complex
FAIL: gdb.base/callfuncs.exp: noproto: call inferior func with struct - returns char *
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 6 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 7 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 8 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 9 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 10 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 11 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 12 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 13 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 14 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 15 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 16 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 17 structs-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-ti
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-ti
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-ti
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-tl
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tl
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tl
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-tll
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tll
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-td
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-td
FAIL: gdb.base/structs.exp: p/c L<n>; call 1 structs-tld
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tld
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 6 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 7 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 8 structs-ts-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-ti-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-ti-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-ti-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-ti-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 6 structs-ti-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tl-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tl-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tl-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-tl-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 6 structs-tl-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tll-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tf-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tf-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tf-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-tf-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 6 structs-tf-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-td-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tld-tc
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tc-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tc-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 5 structs-tc-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 6 structs-tc-ts
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-ti
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tc-ti
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tc-ti
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-tl
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tc-tl
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tc-tl
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-tll
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 3 structs-tc-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 4 structs-tc-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-td
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tc-tld
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-td-tf
FAIL: gdb.base/structs.exp: p/c L<n>; call 2 structs-tf-td
FAIL: gdb.cp/classes.exp: call class_param.Aref_a (g_A)
FAIL: gdb.cp/classes.exp: call class_param.Aref_x (g_A)
FAIL: gdb.cp/classes.exp: call class_param.Aref_a (g_B)
FAIL: gdb.cp/classes.exp: call class_param.Aref_x (g_B)
FAIL: gdb.cp/classes.exp: call class_param.Aval_a (g_A)
FAIL: gdb.cp/classes.exp: call class_param.Aval_x (g_A)
FAIL: gdb.cp/classes.exp: call class_param.Aval_a (g_B)
FAIL: gdb.cp/classes.exp: call class_param.Aval_x (g_B)
FAIL: gdb.cp/ref-params.exp: print value of f1 on Child in main
FAIL: gdb.cp/ref-params.exp: print value of f2 on Child in main
FAIL: gdb.cp/ref-params.exp: print value of f1 on (Child&) in main
FAIL: gdb.cp/ref-params.exp: print value of f2 on (Child&) in main
FAIL: gdb.cp/ref-params.exp: print value of f1 on Child& in f2
FAIL: gdb.cp/ref-params.exp: print f1(MQ)
FAIL: gdb.cp/ref-params.exp: print mf1(MQ)
FAIL: gdb.cp/ref-params.exp: print mf2(MQ)
FAIL: gdb.cp/ref-params.exp: print f1(MQR)
FAIL: gdb.cp/ref-params.exp: print mf1(MQR)
FAIL: gdb.cp/ref-params.exp: print mf2(MQR)
FAIL: gdb.python/py-xmethods.exp: Before: a1 + a2
FAIL: gdb.python/py-xmethods.exp: Before: a2 - a1
FAIL: gdb.python/py-xmethods.exp: Before: b1 - a1
FAIL: gdb.python/py-xmethods.exp: After: a2 - a1
FAIL: gdb.python/py-xmethods.exp: After: b1 - a1

gdb/ChangeLog:

	* msp430-tdep.c (msp430_push_dummy_call): Treat reference, struct,
	and union arguments the same as pointer arguments when determining
	size of argument.
2015-09-29 21:55:31 -07:00
jamesbowman 0bcf3dd690 Undo accidental commit 2015-09-29 09:37:38 -07:00
jamesbowman 4f714dd43e Rebase patch #7 2015-09-29 09:31:09 -07:00