Commit Graph

35447 Commits

Author SHA1 Message Date
Ajit Kumar Agarwal cc3afae25a Microblaze: Reject invalid target descriptions
We currently validate the target description, but then forget to
reject it if found invalid.

Tested that incorrect descriptions are rejected and GDB warns about
them.

Tested the Microblaze Design with and without stack-protect registers.
The gdb command "info registers" displayed the register correctly.  If
a stack protect design is not selected, only core registers are
displayed.  When the stack-protect registers are selected in the
design, the core registers along with stack-protect registers are
displayed.

gdb/
2014-10-10  Ajit Agarwal  <ajitkum@xilinx.com>

	* microblaze-tdep.c (microblaze_gdbarch_init): If the description
	isn't valid, release the tdesc arch data and return NULL.
2014-10-10 18:07:06 +01:00
Pedro Alves cdfa0b0ac1 Cache the vsyscall/vDSO range per-inferior
We're now doing a vsyscall/vDSO address range lookup whenever we fetch
shared libraries, either through an explicit "info shared", or when
the target reports new libraries have been loaded, in order to filter
out the vDSO from glibc's DSO list.  Before we started doing that, GDB
would only ever lookup the vsyscall's address range once in the
process's lifetime.

Looking up the vDSO address range requires an auxv lookup (which is
already cached, so no problem), but also reading the process's
mappings from /proc to find out the vDSO's mapping's size.  That
generates extra RSP traffic when remote debugging.  Particularly
annoying when the process's mappings grow linearly as more libraries
are mapped in, and we went through the trouble of making incremental
DSO list updates work against gdbserver (when the probes-based dynamic
linker interface is available).

The vsyscall/vDSO is mapped by the kernel when the process is
initially mapped in, and doesn't change throughout the process's
lifetime, so we can cache its address range.

Caching at this level brings GDB back to one and only one vsyscall
address range lookup per process.

Tested on x86_64 Fedora 20.

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

	* linux-tdep.c: Include observer.h.
	(linux_inferior_data): New global.
	(struct linux_info): New structure.
	(invalidate_linux_cache_inf, linux_inferior_data_cleanup)
	(get_linux_inferior_data): New functions.
	(linux_vsyscall_range): Rename to ...
	(linux_vsyscall_range_raw): ... this.
	(linux_vsyscall_range): New function; handles caching.
	(_initialize_linux_tdep): Register linux_inferior_data.  Install
	inferior_exit and inferior_appeared observers.
2014-10-10 16:36:38 +01:00
Pedro Alves 8b9a549d3a PR symtab/14466: Work around PR libc/13097 "linux-vdso.so.1"
With upstream glibc, GDB prints:

  warning: Could not load shared library symbols for linux-vdso.so.1.
  Do you need "set solib-search-path" or "set sysroot"?

A bug's been filed for glibc a few years back:

  http://sourceware.org/bugzilla/show_bug.cgi?id=13097

but it's still not resolved.  It's not clear whether there's even
consensus that this is indeed a glibc bug.  It would actually be nice
if GDB also listed the vDSO in the shared library list, but there are
some design considerations with that:

 - the vDSO is mapped by the kernel, not userspace, therefore we
   should load its symbols right from the process's start of life,
   even before glibc / the userspace loader sets up the initial DSO
   list.  The program might even be using a custom loader or no
   loader.

 - that kind of hints at that solib.c should handle retrieving shared
   library lists from more than one source, and that symfile-mem.c's
   loading of the vDSO would be converted to load and relocate the
   vDSO's bfd behind the target_so_ops interface.

 - and then, once glibc links in the vDSO to its DSO list, we'd need
   to either:

    a) somehow hand over the vDSO from one target_so_ops to the other

    b) simply keep hiding glibc's entry.

And then b) seems the simplest.

With that in mind, this patch simply discards the vDSO from glibc's
reported shared library list.

We can match the vDSO address range with the addresses found iterating
the dynamic linker list, to tell which dynamic linker entry is the
vDSO.

Tested on x86_64 Fedora 20.

gdb/
2014-10-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	PR symtab/14466
	* solib-svr4.c (svr4_read_so_list): Rename to ...
	(svr4_current_sos_1): ... this and change the function comment.
	(svr4_current_sos): New function.

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

	PR symtab/14466
	* gdb.base/vdso-warning.c: New file.
	* gdb.base/vdso-warning.exp: New file.
2014-10-10 16:30:59 +01:00
Pedro Alves 3437254d7b Split vDSO range lookup to a gdbarch hook
We have a case in solib-svr4.c where we could reuse symfile-mem.c's
vDSO range lookup.  Since symfile-mem.c is not present in all
configurations solib-svr4.c is, move that lookup to a gdbarch hook.

This has the minor (good) side effect that we stop even trying the
target_auxv_search lookup against targets that don't have a concept of
a vDSO, in case symfile-mem.c happens to be linked in the build
(--enable-targets=all).

Tested on x86_64 Fedora 20.

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

	* arch-utils.c (default_vsyscall_range): New function.
	* arch-utils.h (default_vsyscall_range): New declaration.
	* gdbarch.sh (vsyscall_range): New hook.
	* gdbarch.h, gdbarch.c: Regenerate.
	* linux-tdep.c (linux_vsyscall_range): New function.
	(linux_init_abi): Install linux_vsyscall_range as
	vsyscall_range gdbarch hook.
	* memrange.c (address_in_mem_range): New function.
	* memrange.h (address_in_mem_range): New declaration.
	* symfile-mem.c (find_vdso_size): Delete function.
	(add_vsyscall_page): Use gdbarch_vsyscall_range.
2014-10-10 15:57:13 +01:00
Pedro Alves 31cc0b807b infrun.c:normal_stop: Fix typo in comment
gdb/
2014-10-10  Pedro Alves  <palves@redhat.com>

	* infrun.c (normal_stop): Fix typo in comment.
2014-10-10 13:50:05 +01:00
Sergio Durigan Junior 3e3286a28a PR tdep/9390: Fix typo on xstorxstormy16-tdep.c
This patch fixes the bug described in PR tdep/9390, which is about a
wrong check in the following code:

    ...

    /* optional copying of args in r2-r7 to r10-r13.  */
    /* Probably only in optimized case but legal action for prologue.  */
    else if ((inst & 0xff00) == 0x4600	/* 46SD   mov rD, rS */
	     && (inst & 0x00f0) >= 0x0020 && (inst & 0x00f0) <= 0x0070
	     && (inst & 0x000f) >= 0x00a0 && (inst & 0x000f) <= 0x000d)
                ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...

This condition will never trigger, and the fix proposed in the bug
(which made sense to me) was to test against 0x000a.  I tried finding
documentation about this target, but couldn't find anything.  I don't
even know if it is still used, but decided to submit the fix anyway.

Tested on my x86_64 Fedora 20 GNU/Linux.

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

	PR tdep/9390
	* xstorxstormy16-tdep.c (xstormy16_analyze_prologue): Fix possible
	typo when using logical AND to determine instruction type.
2014-10-09 13:45:09 -04:00
Yao Qi fcbdedf866 Remove unused local variable
As a result of commit b57bacec, local variable 'printed' is no longer
used.  This patch is to remove it.

gdb:

2014-10-09  Yao Qi  <yao@codesourcery.com>

	* infrun.c (handle_signal_stop): Remove local variable 'printed'.
2014-10-09 09:48:42 +08:00
Stan Shebs db98461618 Add Yao Qi as global maintainer
gdb/ChangeLog:

2014-10-08  Stan Shebs  <stan@codesourcery.com>

	    * MAINTAINERS (GLOBAL MAINTAINERS): Add Yao Qi.
2014-10-08 11:23:16 -07:00
Gary Benson 3ba37e6c30 Do not include unnecessary files in fbsd-tdep.c
This commit makes fbsd-tdep.c not include string.h or gdb_assert.h
as both are already included by defs.h.

gdb/ChangeLog:

	* fbsd-tdep.c: Do not include string.h or gdb_assert.h.
2014-10-08 09:52:38 +01:00
Gary Benson a442d0713a Include common-exceptions.h in common-defs.h
This commit includes common-exceptions.h in common-defs.h and removes
all other inclusions.

gdb/ChangeLog:

	* common/common-defs.h: Include common-exceptions.h.
	* exceptions.h: Do not include common-exceptions.h.

gdb/gdbserver/ChangeLog:

	* server.h: Do not include common-exceptions.h.
2014-10-08 09:33:22 +01:00
Gary Benson 6f1947e8a2 Include cleanups.h in common-defs.h
This commit includes cleanups.h in common-defs.h and removes all other
inclusions.

gdb/ChangeLog:

	* common/common-defs.h: Include cleanups.h.
	* common/common-exceptions.c: Do not include cleanups.h.
	* utils.h: Likewise.

gdb/gdbserver/ChangeLog:

	* server.h: Do not include cleanups.h.
2014-10-08 09:33:22 +01:00
Gary Benson c765fdb902 Remove spurious exceptions.h inclusions
defs.h includes utils.h, and utils.h includes exceptions.h.  All GDB
.c files include defs.h as their first line, so no file other than
utils.h needs to include exceptions.h.  This commit removes all such
inclusions.

gdb/ChangeLog:

	* ada-lang.c: Do not include exceptions.h.
	* ada-valprint.c: Likewise.
	* amd64-tdep.c: Likewise.
	* auto-load.c: Likewise.
	* block.c: Likewise.
	* break-catch-throw.c: Likewise.
	* breakpoint.c: Likewise.
	* btrace.c: Likewise.
	* c-lang.c: Likewise.
	* cli/cli-cmds.c: Likewise.
	* cli/cli-interp.c: Likewise.
	* cli/cli-script.c: Likewise.
	* completer.c: Likewise.
	* corefile.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-support.c: Likewise.
	* cp-valprint.c: Likewise.
	* darwin-nat.c: Likewise.
	* dwarf2-frame-tailcall.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* event-top.c: Likewise.
	* f-valprint.c: Likewise.
	* frame-unwind.c: Likewise.
	* frame.c: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* guile/scm-auto-load.c: Likewise.
	* guile/scm-breakpoint.c: Likewise.
	* guile/scm-cmd.c: Likewise.
	* guile/scm-frame.c: Likewise.
	* guile/scm-lazy-string.c: Likewise.
	* guile/scm-param.c: Likewise.
	* guile/scm-symbol.c: Likewise.
	* guile/scm-type.c: Likewise.
	* hppa-hpux-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* inf-loop.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* interps.c: Likewise.
	* interps.h: Likewise.
	* jit.c: Likewise.
	* linespec.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* m32r-rom.c: Likewise.
	* main.c: Likewise.
	* memory-map.c: Likewise.
	* mi/mi-cmd-break.c: Likewise.
	* mi/mi-cmd-stack.c: Likewise.
	* mi/mi-interp.c: Likewise.
	* mi/mi-main.c: Likewise.
	* monitor.c: Likewise.
	* nto-procfs.c: Likewise.
	* objc-lang.c: Likewise.
	* p-valprint.c: Likewise.
	* parse.c: Likewise.
	* ppc-linux-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* probe.c: Likewise.
	* python/py-auto-load.c: Likewise.
	* python/py-breakpoint.c: Likewise.
	* python/py-cmd.c: Likewise.
	* python/py-finishbreakpoint.c: Likewise.
	* python/py-frame.c: Likewise.
	* python/py-framefilter.c: Likewise.
	* python/py-function.c: Likewise.
	* python/py-gdb-readline.c: Likewise.
	* python/py-inferior.c: Likewise.
	* python/py-infthread.c: Likewise.
	* python/py-lazy-string.c: Likewise.
	* python/py-linetable.c: Likewise.
	* python/py-param.c: Likewise.
	* python/py-prettyprint.c: Likewise.
	* python/py-symbol.c: Likewise.
	* python/py-type.c: Likewise.
	* python/py-value.c: Likewise.
	* python/python-internal.h: Likewise.
	* python/python.c: Likewise.
	* record-btrace.c: Likewise.
	* record-full.c: Likewise.
	* regcache.c: Likewise.
	* remote-fileio.c: Likewise.
	* remote-mips.c: Likewise.
	* remote.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* rs6000-nat.c: Likewise.
	* skip.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-dsbt.c: Likewise.
	* solib-frv.c: Likewise.
	* solib-ia64-hpux.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* solib.c: Likewise.
	* spu-tdep.c: Likewise.
	* stack.c: Likewise.
	* stap-probe.c: Likewise.
	* symfile-mem.c: Likewise.
	* symmisc.c: Likewise.
	* target.c: Likewise.
	* thread.c: Likewise.
	* top.c: Likewise.
	* tracepoint.c: Likewise.
	* tui/tui-interp.c: Likewise.
	* typeprint.c: Likewise.
	* utils.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* windows-nat.c: Likewise.
	* xml-support.c: Likewise.
2014-10-08 09:33:22 +01:00
Maciej W. Rozycki 484933d11f MIPS: Rewrite `add_offset_16' to match its name
A helper function called `add_offset_16' is used by
`extended_mips16_next_pc' to calculate branch destinations.  Weirdly
enough the helper does not do what the name suggests and rather than
doing its work for a 16-bit immediate branch offset it makes its
calculations on a 26-bit immediate target used by JAL and JALX
instructions.  Furthermore the JAL/JALX calculation is only needed once
by `extended_mips16_next_pc' while a 16-bit branch offset calculation
is made inline several times across `extended_mips16_next_pc'.

This change therefore replaces the contents of `add_offset_16' with the
16-bit branch offset calculation and updates `extended_mips16_next_pc'
accordingly.

	* mips-tdep.c (add_offset_16): Rewrite to implement what the
	name implies.
	(extended_mips16_next_pc): Update accordingly.
2014-10-05 23:37:53 +01:00
Maciej W. Rozycki ab50adb6a6 MIPS: Correct heuristic prologue termination conditions
This change addresses a regression in gdb.dwarf2/dw2-skip-prologue.exp
across MIPS16 multilibs:

(gdb) file .../gdb.dwarf2/dw2-skip-prologue
Reading symbols from .../gdb.d/gdb.dwarf2/dw2-skip-prologue...done.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break main
warning: Breakpoint address adjusted from 0x00400725 to 0x00400721.
Breakpoint 1 at 0x400721
(gdb) set remotetimeout 5
(gdb) kill
The program is not being run.
(gdb)
[...]
target remote ...:2345
Reading symbols from .../mips16/lib/ld.so.1...done.
warning: Breakpoint address adjusted from 0x00400725 to 0x00400721.
warning: Breakpoint address adjusted from 0x00400725 to 0x00400721.
0x2aaa8e81 in __start () from .../mips16/lib/ld.so.1
(gdb) continue
Continuing.
warning: Breakpoint address adjusted from 0x00400725 to 0x00400721.
warning: Breakpoint 1 address previously adjusted from 0x00400725 to
0x00400721.
Breakpoint 1, 0x00400721 in main ()
(gdb) break func
Breakpoint 2 at 0x4006a1: func. (2 locations)
(gdb) continue
Continuing.
warning: GDB can't find the start of the function at 0x4006dd.

    GDB is unable to find the start of the function at 0x4006dd
and thus can't determine the size of that function's stack frame.
This means that GDB may be unable to access that stack frame, or
the frames below it.
    This problem is most likely caused by an invalid program counter or
stack pointer.
    However, if you think GDB should simply search farther back
from 0x4006dd for code which looks like the beginning of a
function, you can increase the range of the search using the `set
heuristic-fence-post' command.

Program received signal SIGBUS, Bus error.
0x0040072b in main ()
(gdb) FAIL: gdb.dwarf2/dw2-skip-prologue.exp: continue to breakpoint: func

-- notice the breakpoint adjustment messages that are already a bad
sign.  These happen when a breakpoint is requested in a branch delay
slot and are not supposed to happen unless explicitly requested with an
address pointing to a branch delay slot instruction.  No symbol or line
debug information is supposed to direct GDB to place a breakpoint in a
delay slot.

Here's how `main' looks like:

00400718 <main>:
  400718:	64f5      	save	40,ra,s0-s1
  40071a:	1a00 01a8 	jal	4006a0 <func>
  40071e:	0104      	addiu	s1,sp,16
  400720:	1a00 01b7 	jal	4006dc <func+0x3c>
  400724:	6702      	move	s0,v0
  400726:	e049      	addu	v0,s0,v0
  400728:	65b9      	move	sp,s1
  40072a:	6473      	restore	24,ra,s0-s1
  40072c:	e8a0      	jrc	ra
  40072e:	6500      	nop

-- so 0x400725 is the MIPS16 instruction address of the first MOVE
instruction seen above, in a delay slot of the preceding JAL instruction
indeed.  This test case arranges for `main' to have no debug information
so it is one of the heuristic prologue scanners, `mips16_scan_prologue'
specifically in this case, that is responsible for finding the right
location for the breakpoint to place.

In this case the prologue really ends with the ADDIU instruction,
reordered into the delay slot of the first JAL instruction.  Of course
we can't place the breakpoint for `main' after it as by doing so we'll
let `func' to be called before hitting this breakpoint.  So the
breakpoint has to go at the JAL instruction instead, or 0x40071b.

To make a general case out of it we must never consider any jump or
branch instruction to be a part of a function's prologue.  In the
presence of a jump or branch at the beginning of a function the furthest
instruction examined for the purpose of constructing frame information
can be one in the delay slot of that jump or branch if present, and
otherwise -- that is when the jump or branch is compact and has no delay
slot -- the instruction immediately preceding the jump or branch.

This change implements that approach across prologue scanners for the
three instruction ISAs.  In implementing it I have factored out code
from the existing `*_instruction_has_delay_slot' handlers to be shared
and a side effect for the microMIPS implementation is it now always
fetches the second 16-bit halfword of 32-bit instructions even if it
eventually is not going to be needed.  I think it's an acceptable
tradeoff for the purpose of code sharing.

To make things more consistent I also carried logic from
`micromips_scan_prologue' over to the other two scanners to accept (and
ignore) a single non-prologue non-control transfer instruction reordered
by the compiler into the prologue.  While doing this I simplified the
exit path from the scan loop such that `end_prologue_addr' is set only
once.  This made some concerns expressed in comments no longer
applicable, although even before they were not valid.

I have not fixed the logic around `load_immediate_bytes' in
`mips32_scan_prologue' though, it remains broken, although I took care
not to break it more.  An approach similar to one taken for handling
larger stack adjustments in `micromips_scan_prologue' will have to be
eventually implemented here.

For regression testing I used my usual choice of the mips-linux-gnu
target and the following multilibs:

-EB
-EB -msoft-float
-EB -mips16
-EB -mips16 -msoft-float
-EB -mmicromips
-EB -mmicromips -msoft-float
-EB -mabi=n32
-EB -mabi=n32 -msoft-float
-EB -mabi=64
-EB -mabi=64 -msoft-float

and the -EL variants of same.

That removed gdb.dwarf2/dw2-skip-prologue.exp failures across MIPS16
multilibs, the test log now shows:

(gdb) file .../gdb.dwarf2/dw2-skip-prologue
Reading symbols from .../gdb.d/gdb.dwarf2/dw2-skip-prologue...done.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break main
Breakpoint 1 at 0x40071b
(gdb) set remotetimeout 5
(gdb) kill
The program is not being run.
(gdb)
[...]
target remote ...:2345
Reading symbols from .../mips16/lib/ld.so.1...done.
0x2aaa8e81 in __start () from .../mips16/lib/ld.so.1
(gdb) continue
Continuing.

Breakpoint 1, 0x0040071b in main ()
(gdb) break func
Breakpoint 2 at 0x4006a1: func. (2 locations)
(gdb) continue
Continuing.

Breakpoint 2, func (param=0) at main.c:5
5	   This program is free software; you can redistribute it and/or modify
(gdb) PASS: gdb.dwarf2/dw2-skip-prologue.exp: continue to breakpoint: func

-- so things look like intended.

That also did regress, again across MIPS16 multilibs, another test case,
gdb.base/step-symless.exp:

(gdb) file .../gdb.d/gdb.base/step-symless
Reading symbols from .../gdb.base/step-symless...done.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break main
Breakpoint 1 at 0x4006d3
(gdb) set remotetimeout 5
(gdb) kill
The program is not being run.
(gdb)
[...]
target remote ...:2345
Reading symbols from .../mips16/lib/ld.so.1...done.
0x2aaa8e81 in __start () from .../mips16/lib/ld.so.1
(gdb) continue
Continuing.

Breakpoint 1, 0x004006d3 in main ()
(gdb) break symful
Breakpoint 2 at 0x4006a5
(gdb) step
Single stepping until exit from function main,
which has no line number information.
warning: GDB can't find the start of the function at 0x4006b9.

    GDB is unable to find the start of the function at 0x4006b9
and thus can't determine the size of that function's stack frame.
This means that GDB may be unable to access that stack frame, or
the frames below it.
    This problem is most likely caused by an invalid program counter or
stack pointer.
    However, if you think GDB should simply search farther back
from 0x4006b9 for code which looks like the beginning of a
function, you can increase the range of the search using the `set
heuristic-fence-post' command.
0x004006b9 in ?? ()
(gdb) FAIL: gdb.base/step-symless.exp: step

-- but that is actually a good sign.  Here `main', again, has no debug
information and code involved looks like:

004006a0 <symful>:
  4006a0:	6491      	save	8,s1
  4006a2:	673d      	move	s1,sp
  4006a4:	b204      	lw	v0,4006b4 <symful+0x14>
  4006a6:	9a40      	lw	v0,0(v0)
  4006a8:	4261      	addiu	v1,v0,1
  4006aa:	b203      	lw	v0,4006b4 <symful+0x14>
  4006ac:	da60      	sw	v1,0(v0)
  4006ae:	65b9      	move	sp,s1
  4006b0:	6411      	restore	8,s1
  4006b2:	e8a0      	jrc	ra
  4006b4:	0041      	addiu	s0,sp,260
  4006b6:	0860      	la	s0,400834 <__libc_start_main@mips16plt+0x54>
  4006b8:	6491      	save	8,s1
  4006ba:	673d      	move	s1,sp
  4006bc:	b204      	lw	v0,4006cc <symful+0x2c>
  4006be:	9a40      	lw	v0,0(v0)
  4006c0:	4261      	addiu	v1,v0,1
  4006c2:	b203      	lw	v0,4006cc <symful+0x2c>
  4006c4:	da60      	sw	v1,0(v0)
  4006c6:	65b9      	move	sp,s1
  4006c8:	6411      	restore	8,s1
  4006ca:	e8a0      	jrc	ra
  4006cc:	0041      	addiu	s0,sp,260
  4006ce:	0860      	la	s0,40084c <__libc_start_main@mips16plt+0x6c>

004006d0 <main>:
  4006d0:	64d4      	save	32,ra,s1
  4006d2:	1a00 01ae 	jal	4006b8 <symful+0x18>
  4006d6:	0104      	addiu	s1,sp,16
  4006d8:	1a00 01a8 	jal	4006a0 <symful>
  4006dc:	6500      	nop
  4006de:	6740      	move	v0,zero
  4006e0:	65b9      	move	sp,s1
  4006e2:	6452      	restore	16,ra,s1
  4006e4:	e8a0      	jrc	ra
  4006e6:	6500      	nop
  4006e8:	6500      	nop
  4006ea:	6500      	nop
  4006ec:	6500      	nop
  4006ee:	6500      	nop

-- and the original log:

(gdb) file .../gdb.base/step-symless
Reading symbols from .../gdb.base/step-symless...done.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break main
warning: Breakpoint address adjusted from 0x004006dd to 0x004006d9.
Breakpoint 1 at 0x4006d9
(gdb) set remotetimeout 5
(gdb) kill
The program is not being run.
(gdb)
[...]
target remote ...:2345
Reading symbols from .../mips16/lib/ld.so.1...done.
warning: Breakpoint address adjusted from 0x004006dd to 0x004006d9.
warning: Breakpoint address adjusted from 0x004006dd to 0x004006d9.
0x2aaa8e81 in __start () from .../mips16/lib/ld.so.1
(gdb) continue
Continuing.
warning: Breakpoint address adjusted from 0x004006dd to 0x004006d9.
warning: Breakpoint 1 address previously adjusted from 0x004006dd to
0x004006d9.
Breakpoint 1, 0x004006d9 in main ()
(gdb) break symful
Breakpoint 2 at 0x4006a5
(gdb) step
Single stepping until exit from function main,
which has no line number information.

Breakpoint 2, 0x004006a5 in symful ()
(gdb) PASS: gdb.base/step-symless.exp: step

So the breakpoint at `main' was actually set at an instruction after the
call to `symful+0x18' aka `symless' and the test only passed because
single-stepping through `symless' wasn't actually done at all.  With
this change in place this test fails for MIPS16 multilibs consistently
with all the other multilibs where it already failed in this manner
previously.

	* mips-tdep.c (mips16_instruction_is_compact_branch): New
	function.
	(micromips_instruction_is_compact_branch): Likewise.
	(mips16_scan_prologue): Terminate scanning upon seeing a branch
	or a compact jump, reaching a jump delay slot, or seeing a
	second non-prologue instruction.
	(micromips_scan_prologue): Also terminate scanning upon seeing a
	compact branch or jump, or reaching a branch or jump delay slot.
	(mips32_scan_prologue): Terminate scanning upon reaching a branch
	or jump delay slot, or seeing a second non-prologue instruction.
	(mips32_instruction_has_delay_slot): Retain instruction
	examination code only, update arguments accordingly and move
	instruction fetch pieces to...
	(mips32_insn_at_pc_has_delay_slot): ... this new function.
	(micromips_instruction_has_delay_slot): Likewise and to...
	(micromips_insn_at_pc_has_delay_slot): ... this new function.
	(mips16_instruction_has_delay_slot): Likewise and to...
	(mips16_insn_at_pc_has_delay_slot): ... this new function.
	(mips_single_step_through_delay): Update accordingly.
	(mips_adjust_breakpoint_address): Likewise.
2014-10-05 23:20:10 +01:00
Maciej W. Rozycki ae79065284 MIPS: Correct MUSTBE32 interpretation in delay slot handling
This change addresses `micromips_instruction_has_delay_slot' and
`mips16_instruction_has_delay_slot' that both incorrectly interpret
their MUSTBE32 argument.  Their callers assume that when the flag is
clear these functions will return 1 when any non-compact jump or branch
instruction is present at ADDR, while in fact they will only return 1
for 16-bit such instructions only.  This change makes the implementation
match the expectations.

	* mips-tdep.c (micromips_instruction_has_delay_slot): When
	!mustbe32 also return 1 for 32-bit instructions.
	(mips16_instruction_has_delay_slot): Likewise.  Add an
	explanatory comment.
2014-10-05 21:50:47 +01:00
Maciej W. Rozycki 9b807e7bbb Also mark ELF solib trampoline minimal symbols special
In installing minimal symbols for ELF shared library trampolines
we "forget" to make individual symbols special where required.  This
leads to problems on the MIPS target using microMIPS SVR4 lazy stubs.
Lacking the special annotation these stubs are treated as standard
MIPS code and this makes GDB insert the wrong software breakpoint
instruction, breaking e.g. single-stepping through these stubs.  This
is not a very frequent scenario as microMIPS SVR4 lazy stubs are
typically only used in shared libraries with the main executable
using PLT, handled elsewhere.  Still it triggers e.g. when a software
watchpoint has been installed.  The symptom is SIGILL or the program
going astray, depending on the endianness.  Disassembly of these stubs
is also wrong.

	* elfread.c (elf_symtab_read): Also mark solib trampoline minimal
	symbols special.
2014-10-03 17:38:39 +01:00
Maciej W. Rozycki 0d5ed15352 Avoid software breakpoint's instruction shadow inconsistency
This change:

commit b775012e84
Author: Luis Machado <luisgpm@br.ibm.com>
Date:   Fri Feb 24 15:10:59 2012 +0000

    2012-02-24  Luis Machado  <lgustavo@codesourcery.com>

	* remote.c (remote_supports_cond_breakpoints): New forward
	declaration.
[...]

changed the way breakpoints are inserted and removed such that
`insert_bp_location' can now be called with the breakpoint being handled
already in place, while previously the call was only ever made for
breakpoints that have not been put in place.  This in turn caused an
issue for software breakpoints and targets for which a breakpoint's
`placed_address' may not be the same as the original requested address.

The issue is `insert_bp_location' overwrites the previously adjusted
value in `placed_address' with the original address, that is only
replaced back with the correct adjusted address later on when
`gdbarch_breakpoint_from_pc' is called.  Meanwhile there's a window
where the value in `placed_address' does not correspond to data stored
in `shadow_contents', leading to incorrect instruction bytes being
supplied when `one_breakpoint_xfer_memory' is called to supply the
instruction overlaid by the breakpoint.

And this is exactly what happens on the MIPS target with software
breakpoints placed in microMIPS code.  In this case not only
`placed_address' is not the original address because of the ISA bit, but
`mips_breakpoint_from_pc' has to read the original instruction to
determine which one of the two software breakpoint instruction encodings
to choose as well.  The 16-bit encoding is used to replace 16-bit
instructions and similarly the 32-bit one is used with 32-bit
instructions, to satisfy branch delay slot size requirements.

The mismatch between `placed_address' and the address data in
`shadow_contents' has been obtained from leads to the wrong encoding
being used in some cases, which in the case of a 32-bit software
breakpoint instruction replacing a 16-bit instruction causes corruption
to the adjacent following instruction and leads the debug session astray
if execution reaches there e.g. with a jump.

To address this problem I made the change below, that adds a
`reqstd_address' field to `struct bp_target_info' and leaves
`placed_address' unchanged once it has been set.  This ensures data in
`shadow_contents' is always consistent with `placed_address'.

This approach also has this good side effect that all the places that
examine the breakpoint's address see a consistent value, either
`reqstd_address' or `placed_address', as required.  Currently some
places see either the original or the adjusted address in
`placed_address', depending on whether they have been called before
`gdbarch_remote_breakpoint_from_pc' or afterwards.  This is in
particular true for subsequent calls to
`gdbarch_remote_breakpoint_from_pc' itself, e.g. from
`one_breakpoint_xfer_memory'.  This is also important for places like
`find_single_step_breakpoint' where a breakpoint's address is compared
to the raw value of $pc.

	* breakpoint.h (bp_target_info): Add `reqstd_address' member,
	update comments.
	* breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address'
	for the breakpoint's address.  Don't preinitialize `placed_size'.
	(insert_bp_location): Set `reqstd_address' rather than
	`placed_address'.
	(bp_target_info_copy_insertion_state): Also copy `placed_address'.
	(bkpt_insert_location): Use `reqstd_address' for the breakpoint's
	address.
	(bkpt_remove_location): Likewise.
	(deprecated_insert_raw_breakpoint): Likewise.
	(deprecated_remove_raw_breakpoint): Likewise.
	(find_single_step_breakpoint): Likewise.
	* mem-break.c (default_memory_insert_breakpoint): Use
	`reqstd_address' for the breakpoint's address.  Don't set
	`placed_address' or `placed_size' if breakpoint contents couldn't
	have been determined.
	* remote.c (remote_insert_breakpoint): Use `reqstd_address' for
	the breakpoint's address.
	(remote_insert_hw_breakpoint): Likewise.  Don't set
	`placed_address' or `placed_size' if breakpoint couldn't have been
	set.
	* aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use
	`reqstd_address' for the breakpoint's address.
	* arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise.
	* ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise.
	* m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise.
	* microblaze-linux-tdep.c
	(microblaze_linux_memory_remove_breakpoint): Likewise.
	* monitor.c (monitor_insert_breakpoint): Likewise.
	* nto-procfs.c (procfs_insert_breakpoint): Likewise.
	(procfs_insert_hw_breakpoint): Likewise.
	* ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise.
	* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
	* remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise.
	* remote-mips.c (mips_insert_breakpoint): Likewise.
	* x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 12:54:34 +01:00
Luis Machado 3e87153251 MIPS bit field failures in gdb.base/store.exp
On MIPS64 little endian, attempting an assignment to a bit field
that lives in a register yields the wrong result. It just corrupts
the data in the register depending on the specific position of the
bit field inside the structure.

FAIL: gdb.base/store.exp: f_1.j
FAIL: gdb.base/store.exp: f_1.k
FAIL: gdb.base/store.exp: F_1.i
FAIL: gdb.base/store.exp: F_1.j
FAIL: gdb.base/store.exp: F_1.k
FAIL: gdb.base/store.exp: f_2.j
FAIL: gdb.base/store.exp: f_2.k
FAIL: gdb.base/store.exp: F_2.i
FAIL: gdb.base/store.exp: F_2.j
FAIL: gdb.base/store.exp: F_2.k
FAIL: gdb.base/store.exp: f_3.j
FAIL: gdb.base/store.exp: f_3.k
FAIL: gdb.base/store.exp: F_3.i
FAIL: gdb.base/store.exp: F_3.j
FAIL: gdb.base/store.exp: F_3.k
FAIL: gdb.base/store.exp: f_4.j
FAIL: gdb.base/store.exp: f_4.k
FAIL: gdb.base/store.exp: F_4.i
FAIL: gdb.base/store.exp: F_4.j
FAIL: gdb.base/store.exp: F_4.k

                === gdb Summary ===

Now, GDB knows how to do bit field assignment properly, but MIPS is
one of those architectures that uses a hook for the register-to-value
conversion. Although we can properly tell when the type being passed
is a structure or union, we cannot tell when it is a bit field,
because the bit field data lives in a value structure.  Such data
only lives in a "type" structure when the parent structure is being
referenced, thus you can collect them from the flds_bnds members.

A bit field type structure looks pretty much the same as any other
primitive type like int or char, so we can't distinguish them.
Forcing more fields into the type structure wouldn't help much,
because the type structs are shared.

2014-10-03  Luis Machado  <lgustavo@codesourcery.com>

	* valops.c (value_assign): Check for bit field assignments
	before calling architecture-specific register value
	conversion functions.
2014-10-03 08:21:33 -03:00
Pierre Muller ec48dc8bd4 [RFA] Stabs: Ignore N_BNSYM/N_ENSYM entry types
Trying to debug gdb with itself,
I stumbled on the following complaints
Unknown symbol type 0x2e
or
Unknown symbol type 0x4e

It appears that those corrspond to N_BNSYM and N_ENSYM,
which are MacOS extensions of stabs debugging format.
But these extensions have been used inside gcc probalby
for a while already, see:
https://gcc.gnu.org/ml/gcc/2004-08/msg00157.html

As the only purpose of these entries is to allow for removal
of stabs information if the function is removed,
it can be safely ignored by GDB.

This patch simply adds those two entry types to the list
of ignored entry type in read_dbx_symtab function.

Is this OK?

Pierre Muller

2014-10-03  Pierre Muller  <muller@sourceware.org>

	* dbxread.c (read_dbx_symtab): Also ignore N_BNSYM/N_ENSYM.
2014-10-03 09:29:57 +02:00
Doug Evans d48ba5e8cf gdb.base/structs.c (main): Don't run forever.
gdb/testsuite/ChangeLog:

	* gdb.base/structs.c (main): Don't run forever.
2014-10-02 13:07:40 -07:00
Pedro Alves 2278c276a8 gdb.threads/manythreads.exp: clean up and add comment
In git b57bacec, I said:

> With that in place, the need to delay "Program received signal FOO"
> was actually caught by the manythreads.exp test.  Without that bit, I
> was getting:
>
>   [Thread 0x7ffff7f13700 (LWP 4499) exited]
>   [New Thread 0x7ffff7f0b700 (LWP 4500)]
>   ^C
>   Program received signal SIGINT, Interrupt.
>   [New Thread 0x7ffff7f03700 (LWP 4501)]           <<< new output
>   [Switching to Thread 0x7ffff7f0b700 (LWP 4500)]
>   __GI___nptl_death_event () at events.c:31
>   31      {
>   (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1
>
> That is, I was now getting "New Thread" lines after the "Program
> received signal" line, and the test doesn't expect them.  As the
> number of new threads discovered before and after the "Program
> received signal" output is unbounded, it's much nicer to defer
> "Program received signal" until after synching the thread list, thus
> close to the "switching to thread" output and "current frame/source"
> info:
>
>   [Thread 0x7ffff7863700 (LWP 7647) exited]
>   ^C[New Thread 0x7ffff786b700 (LWP 7648)]
>
>   Program received signal SIGINT, Interrupt.
>   [Switching to Thread 0x7ffff7fc4740 (LWP 6243)]
>   __GI___nptl_create_event () at events.c:25
>   25      {
>   (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1

This commit factors out the two places in the test that are effected
by this, and adds there a destilled version of the comment above.

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

	* gdb.threads/manythreads.exp (interrupt_and_wait): New procedure.
	(top level) <stop threads 1, stop threads 2>: Use it.
2014-10-02 10:13:56 +01:00
Pedro Alves b57bacecd5 Fix non-stop regressions caused by "breakpoints always-inserted off" changes
Commit a25a5a45 (Fix "breakpoint always-inserted off"; remove
"breakpoint always-inserted auto") regressed non-stop remote
debugging.

This was exposed by mi-nsintrall.exp intermittently failing with a
spurious SIGTRAP.

The problem is that when debugging with "target remote", new threads
the target has spawned but have never reported a stop aren't visible
to GDB until it explicitly resyncs its thread list with the target's.

For example, in a program like this:

 int
 main (void)
 {
   pthread_t child_thread;
   pthread_create (&child_thread, NULL, child_function, NULL);
   return 0;  <<<< set breakpoint here
 }

If the user sets a breakpoint at the "return" statement, and runs the
program, when that breakpoint hit is reported, GDB is only aware of
the main thread.  So if we base the decision to remove or insert
breakpoints from the target based on whether all the threads we know
about are stopped, we'll miss that child_thread is running, and thus
we'll remove breakpoints from the target, even through they should
still remain inserted, otherwise child_thread will miss them.

The break-while-running.exp test actually should also be exposing this
thread-list-out-of-synch problem.  That test sets a breakpoint while
the main thread is stopped, but other threads are running.  Because
other threads are running, the breakpoint is supposed to be inserted
immediately.  But, unless something forces a refetch of the thread
list, like, e.g., "info threads", GDB won't be aware of the other
threads that had been spawned by the main thread, and so won't insert
new or old breakpoints in the target.  And it turns out that the test
is exactly doing an explicit "info threads", masking out the
problem...  This commit adjust the test to exercise the case of not
issuing "info threads".  The test then fails without the GDB fix.

In the ni-nsintrall.exp case, what happens is that several threads hit
the same breakpoint, and when the first thread reports the stop,
because GDB wasn't aware other threads exist, all threads known to GDB
are found stopped, so GDB removes the breakpoints from the target.
The other threads follow up with SIGTRAPs too for that same
breakpoint, which has already been removed.  For the first few
threads, the moribund breakpoints machinery suppresses the SIGTRAPs,
but after a few events (precisely '3 * thread_count () + 1' at the
time the breakpoint was removed, see update_global_location_list), the
moribund breakpoint machinery is no longer aware of the removed
breakpoint, and the SIGTRAP is reported as a spurious stop.

The fix is naturally then to stop assuming that if no thread in the
list is executing, then the target is fully stopped.  We can't know
that until we fully sync the thread list.  Because updating the thread
list on every stop would be too much RSP traffic, I chose instead to
update it whenever we're about to present a stop to the user.

Actually updating the thread list at that point happens to be an item
I had added to the local/remote parity wiki page a while ago:

  Native GNU/Linux debugging adds new threads to the thread list as
  the program creates them "The [New Thread foo] messages". Remote
  debugging can't do that, and it's arguable whether we shouldn't even
  stop native debugging from doing that, as it hinders inferior
  performance. However, a related issue is that with remote targets
  (and gdbserver), even after the program stops, the user still needs
  to do "info threads" to pull an updated thread list. This, should
  most likely be addressed, so that GDB pulls the list itself, perhaps
  just before presenting a stop to the user.

With that in place, the need to delay "Program received signal FOO"
was actually caught by the manythreads.exp test.  Without that bit, I
was getting:

  [Thread 0x7ffff7f13700 (LWP 4499) exited]
  [New Thread 0x7ffff7f0b700 (LWP 4500)]
  ^C
  Program received signal SIGINT, Interrupt.
  [New Thread 0x7ffff7f03700 (LWP 4501)]           <<< new output
  [Switching to Thread 0x7ffff7f0b700 (LWP 4500)]
  __GI___nptl_death_event () at events.c:31
  31      {
  (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1

That is, I was now getting "New Thread" lines after the "Program
received signal" line, and the test doesn't expect them.  As the
number of new threads discovered before and after the "Program
received signal" output is unbounded, it's much nicer to defer
"Program received signal" until after synching the thread list, thus
close to the "switching to thread" output and "current frame/source"
info:

  [Thread 0x7ffff7863700 (LWP 7647) exited]
  ^C[New Thread 0x7ffff786b700 (LWP 7648)]

  Program received signal SIGINT, Interrupt.
  [Switching to Thread 0x7ffff7fc4740 (LWP 6243)]
  __GI___nptl_create_event () at events.c:25
  25      {
  (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1

Tested on x86_64 Fedora 20, native and gdbserver.

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

	* breakpoint.c (breakpoints_should_be_inserted_now): Use
	threads_are_executing.
	* breakpoint.h (breakpoints_should_be_inserted_now): Add
	describing comment.
	* gdbthread.h (threads_are_executing): Declare.
	(handle_signal_stop) <random signals>: Don't print about the
	signal here if stopping.
	(end_stepping_range): Don't notify observers here.
	(normal_stop): Update the thread list.  If stopped by a random
	signal or a stepping range ended, notify observers.
	* thread.c (threads_executing): New global.
	(init_thread_list): Clear 'threads_executing'.
	(set_executing): Set or clear 'threads_executing'.
	(threads_are_executing): New function.
	(update_threads_executing): New function.
	(update_thread_list): Use it.

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

	* gdb.threads/break-while-running.exp (test): Add new
	'update_thread_list' argument.  Skip "info threads" if false.
	(top level): Add new 'update_thread_list' axis.
2014-10-02 10:08:00 +01:00
Pedro Alves 13fd3ff343 PR17431: following execs with "breakpoint always-inserted on"
Following an exec with "breakpoint always-inserted on" tries to insert
breakpoints in the new image at the addresses the symbols had in the
old image.

With "always-inserted off", we see:

 gdb gdb.multi/multi-arch-exec -ex "set breakpoint always-inserted off"
 GNU gdb (GDB) 7.8.50.20140924-cvs
 ...
 (gdb) b main
 Breakpoint 1 at 0x400664: file gdb.multi/multi-arch-exec.c, line 24.
		 ^^^^^^^^
 (gdb) c
 The program is not being run.
 (gdb) r
 Starting program: testsuite/gdb.multi/multi-arch-exec

 Breakpoint 1, main () at gdb/testsuite/gdb.multi/multi-arch-exec.c:24
 24        execl (BASEDIR "/multi-arch-exec-hello",
 (gdb) c
 Continuing.
 process 9212 is executing new program: gdb/testsuite/gdb.multi/multi-arch-exec-hello

 Breakpoint 1, main () at gdb/testsuite/gdb.multi/hello.c:40
 40        bar();
 (gdb) info breakpoints
 Num     Type           Disp Enb Address    What
 1       breakpoint     keep y   0x080484e4 in main at gdb/testsuite/gdb.multi/hello.c:40
				 ^^^^^^^^^^
	 breakpoint already hit 2 times
 (gdb)

Note how main was 0x400664 in multi-arch-exec, and 0x080484e4 in
gdb.multi/hello.

With "always-inserted on", we get:

 Breakpoint 1, main () at gdb/testsuite/gdb.multi/multi-arch-exec.c:24
 24        execl (BASEDIR "/multi-arch-exec-hello",
 (gdb) c
 Continuing.
 infrun: target_wait (-1, status) =
 infrun:   9444 [process 9444],
 infrun:   status->kind = execd
 infrun: infwait_normal_state
 infrun: TARGET_WAITKIND_EXECD
 Warning:
 Cannot insert breakpoint 1.
 Cannot access memory at address 0x400664

(gdb)

That is, GDB is trying to insert a breakpoint at 0x400664, after the
exec, and then that address happens to not be mapped at all in the new
image.

The problem is that update_breakpoints_after_exec is creating
breakpoints, which ends up in update_global_location_list immediately
inserting breakpoints if "breakpoints always-inserted" is "on".
update_breakpoints_after_exec is called very early when we see an exec
event.  At that point, we haven't loaded the symbols of the new
post-exec image yet, and thus haven't reset breakpoint's addresses to
whatever they may be in the new image.  All we should be doing in
update_breakpoints_after_exec is deleting breakpoints that no longer
make sense after an exec.  So the fix removes those breakpoint
creations.

The question is then, if not here, where are those breakpoints
re-created?  Turns out we don't need to do anything else, because at
the end of follow_exec, we call breakpoint_re_set, whose tail is also
creating exactly the same breakpoints update_breakpoints_after_exec is
currently creating:

  breakpoint_re_set (void)
  {
  ...
    create_overlay_event_breakpoint ();
    create_longjmp_master_breakpoint ();
    create_std_terminate_master_breakpoint ();
    create_exception_master_breakpoint ();
  }

A new test is added to exercise this.

Tested on x86_64 Fedora 20.

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

	PR breakpoints/17431
	* breakpoint.c (update_breakpoints_after_exec): Don't create
	overlay, longjmp, std terminate nor exception breakpoints here.

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

	PR breakpoints/17431
	* gdb.base/execl-update-breakpoints.c: New file.
	* gdb.base/execl-update-breakpoints.exp: New file.
2014-10-02 10:05:46 +01:00
Pedro Alves 32990adaad Reduce Hg packet (select remote general thread) bouncing
A patch I wrote made GDB pull the thread list sooner when debugging
with target remote, and I noticed an intended consequence.  GDB
started bouncing around the currently selected remote/general thread
more frequently.  E.g.:

  Sending packet: $qTMinFTPILen#3b...Packet received: 5
 +Sending packet: $Hgp726d.726d#53...Packet received: OK
  Sending packet: $m400680,40#2f...Packet received: 85c0741455bff00d60004889e5ffd05de97bffffff0f1f00e973ffffff0f1f00554889e5c745fc00000000c745fc01000000e900000000c745fc02000000b800
 +Sending packet: $Hgp726d.7278#28...Packet received: OK
  Sending packet: $m4006b2,1#28...Packet received: e9
  Fast tracepoint 2 at 0x4006b2: file gdb/testsuite/gdb.trace/range-stepping.c, line 53.
  Sending packet: $qTStatus#49...Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes::

This ended up breaking "tstart" when one has fast tracepoints set,
because gdbserver isn't expecting an Hg packet in response to
qRelocInsn:

 (gdb) ftrace *set_point
 Fast tracepoint 3 at 0x4006b2: file gdb/testsuite/gdb.trace/range-stepping.c, line 53.
 (gdb) PASS: gdb.trace/range-stepping.exp: ftrace: ftrace *set_point
 tstart
 gdbserver: Malformed response to qRelocInsn, ignoring: Hgp2783.2783

 Target does not support this command.
 (gdb) FAIL: gdb.trace/range-stepping.exp: ftrace: tstart

remote_trace_start should probably start by making sure the remote
current thread matches inferior_ptid (calling set_general_thread), but
still, reducing unnecessary bouncing is a good idea.  It happens
because the memory/symbol/breakpoint routines use
switch_to_program_space_and_thread to do something in the right
context and then revert back to the previously current thread.

The fix is to simply make any_thread_of_process,
find_inferior_for_program_space, etc. give preference to the current
thread/inferior it if matches.

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

	* gdbthread.h (any_thread_of_process, any_live_thread_of_process):
	Adjust comments.
	* inferior.c (find_inferior_for_program_space): Give preference to
	the current inferior.
	* inferior.h (find_inferior_for_program_space): Update comment.
	* progspace.c (switch_to_program_space_and_thread): Prefer the
	current inferior if it's bound to the program space requested.  If
	the inferior found doesn't have a PID yet, don't bother looking up
	a thread.
	* progspace.h (switch_to_program_space_and_thread): Adjust
	comment.
	* thread.c (any_thread_of_process, any_live_thread_of_process):
	Give preference to the current thread.
2014-10-02 09:55:38 +01:00
Pedro Alves 0fec99e8be Really fail inserting software breakpoints on read-only regions
Currently, with "set breakpoint auto-hw off", we'll still try to
insert a software breakpoint at addresses covered by supposedly
read-only or inacessible regions:

 (top-gdb) mem 0x443000 0x450000 ro
 (top-gdb) set mem inaccessible-by-default off
 (top-gdb) disassemble
 Dump of assembler code for function main:
    0x0000000000443956 <+34>:    movq   $0x0,0x10(%rax)
 => 0x000000000044395e <+42>:    movq   $0x0,0x18(%rax)
    0x0000000000443966 <+50>:    mov    -0x24(%rbp),%eax
    0x0000000000443969 <+53>:    mov    %eax,-0x20(%rbp)
 End of assembler dump.
 (top-gdb) b *0x0000000000443969
 Breakpoint 5 at 0x443969: file ../../src/gdb/gdb.c, line 29.
 (top-gdb) c
 Continuing.
 warning: cannot set software breakpoint at readonly address 0x443969

 Breakpoint 5, 0x0000000000443969 in main (argc=1, argv=0x7fffffffd918) at ../../src/gdb/gdb.c:29
 29        args.argc = argc;
 (top-gdb)

We warn, saying that the insertion can't be done, but then proceed
attempting the insertion anyway, and in case of manually added
regions, the insert actually succeeds.

This is a regression; GDB used to fail inserting the breakpoint.  More
below.

I stumbled on this as I wrote a test that manually sets up a read-only
memory region with the "mem" command, in order to test GDB's behavior
with breakpoints set on read-only regions, even when the real memory
the breakpoints are set at isn't really read-only.  I wanted that in
order to add a test that exercises software single-stepping through
read-only regions.

Note that the memory regions that target_memory_map returns aren't
like e.g., what would expect to see in /proc/PID/maps on Linux.
Instead, they're the physical memory map from the _debuggers_
perspective.  E.g., a read-only region would be real ROM or flash
memory, while a read-only+execute mapping in /proc/PID/maps is still
read-write to the debugger (otherwise the debugger wouldn't be able to
set software breakpoints in the code segment).

If one tries to manually write to memory that falls within a memory
region that is known to be read-only, with e.g., "p foo = 1", then we
hit a check in memory_xfer_partial_1 before the write mananges to make
it to the target side.

But writing a software/memory breakpoint nowadays goes through
target_write_raw_memory, and unlike when writing memory with
TARGET_OBJECT_MEMORY, nothing on the TARGET_OBJECT_RAW_MEMORY path
checks whether we're trying to write to a read-only region.

At the time "breakpoint auto-hw" was added, we didn't have the
TARGET_OBJECT_MEMORY vs TARGET_OBJECT_RAW_MEMORY target object
distinction yet, and the code path in memory_xfer_partial that blocks
writes to read-only memory was hit for memory breakpoints too.  With
GDB 6.8 we had:

 warning: cannot set software breakpoint at readonly address 0000000000443943
 Warning:
 Cannot insert breakpoint 1.
 Error accessing memory address 0x443943: Input/output error.

So I started out by fixing this by adding the memory region validation
to TARGET_OBJECT_RAW_MEMORY too.

But later, when testing against GDBserver, I realized that that would
only block software/memory breakpoints GDB itself inserts with
gdb/mem-break.c.  If a target has a to_insert_breakpoint method, the
insertion request will still pass through to the target.  So I ended
up converting the "cannot set breakpoint" warning in breakpoint.c to a
real error return, thus blocking the insertion sooner.

With that, we'll end up no longer needing the TARGET_OBJECT_RAW_MEMORY
changes once software single-step breakpoints are converted to real
breakpoints.  We need them today as software single-step breakpoints
bypass insert_bp_location.  But, it'll be best to leave that in as
safeguard anyway, for other direct uses of TARGET_OBJECT_RAW_MEMORY.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (insert_bp_location): Error out if inserting a
	software breakpoint at a read-only address.
	* target.c (memory_xfer_check_region): New function, factored out
	from ...
	(memory_xfer_partial_1): ... this.  Make the 'reg_len' local a
	ULONGEST.
	(target_xfer_partial) <TARGET_OBJECT_RAW_MEMORY>: Check the access
	against the memory region attributes.

gdb/testsuite/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* gdb.base/breakpoint-in-ro-region.c: New file.
	* gdb.base/breakpoint-in-ro-region.exp: New file.
2014-10-01 23:31:55 +01:00
Simon Marchi 2ddf430110 Exit code of exited inferiors in -list-thread-groups
Don't reset the exit code at inferior exit and print it in
-list-thread-groups.

gdb/ChangeLog:

	* NEWS: Announce new exit-code field in -list-thread-groups
	output.
	* inferior.c (exit_inferior_1): Don't clear exit code.
	(inferior_appeared): Clear exit code.
	* mi/mi-main.c (print_one_inferior): Add printing of the exit
	code.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-exit-code.exp: New file.
	* gdb.mi/mi-exit-code.c: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Miscellaneous gdb/mi Commands): Document new
	exit-code field in -list-thread-groups output.
2014-10-01 10:20:49 -04:00
Pedro Alves 5fdeec1db0 Add read-only markers to generated gdb/regformats/ .dat files
We have read-only markers in most generated sources already, so that
Emacs/Vi users won't edit them accidentally, but were missing them on
the generated gdb/regformats/ .dat files.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/Makefile ($(outdir)/%.dat): Output "THIS FILE IS
	GENERATED" along with emacs/vi read-only markers.
	* regformats/aarch64.dat: Regenerate.
	* regformats/arm-with-iwmmxt.dat: Regenerate.
	* regformats/arm-with-neon.dat: Regenerate.
	* regformats/arm-with-vfpv2.dat: Regenerate.
	* regformats/arm-with-vfpv3.dat: Regenerate.
	* regformats/i386/amd64-avx-linux.dat: Regenerate.
	* regformats/i386/amd64-avx.dat: Regenerate.
	* regformats/i386/amd64-avx512-linux.dat: Regenerate.
	* regformats/i386/amd64-avx512.dat: Regenerate.
	* regformats/i386/amd64-linux.dat: Regenerate.
	* regformats/i386/amd64-mpx-linux.dat: Regenerate.
	* regformats/i386/amd64-mpx.dat: Regenerate.
	* regformats/i386/amd64.dat: Regenerate.
	* regformats/i386/i386-avx-linux.dat: Regenerate.
	* regformats/i386/i386-avx.dat: Regenerate.
	* regformats/i386/i386-avx512-linux.dat: Regenerate.
	* regformats/i386/i386-avx512.dat: Regenerate.
	* regformats/i386/i386-linux.dat: Regenerate.
	* regformats/i386/i386-mmx-linux.dat: Regenerate.
	* regformats/i386/i386-mmx.dat: Regenerate.
	* regformats/i386/i386-mpx-linux.dat: Regenerate.
	* regformats/i386/i386-mpx.dat: Regenerate.
	* regformats/i386/i386.dat: Regenerate.
	* regformats/i386/x32-avx-linux.dat: Regenerate.
	* regformats/i386/x32-avx.dat: Regenerate.
	* regformats/i386/x32-avx512-linux.dat: Regenerate.
	* regformats/i386/x32-avx512.dat: Regenerate.
	* regformats/i386/x32-linux.dat: Regenerate.
	* regformats/i386/x32.dat: Regenerate.
	* regformats/microblaze-with-stack-protect.dat: Regenerate.
	* regformats/mips-dsp-linux.dat: Regenerate.
	* regformats/mips-linux.dat: Regenerate.
	* regformats/mips64-dsp-linux.dat: Regenerate.
	* regformats/mips64-linux.dat: Regenerate.
	* regformats/nios2-linux.dat: Regenerate.
	* regformats/rs6000/powerpc-32.dat: Regenerate.
	* regformats/rs6000/powerpc-32l.dat: Regenerate.
	* regformats/rs6000/powerpc-64l.dat: Regenerate.
	* regformats/rs6000/powerpc-altivec32l.dat: Regenerate.
	* regformats/rs6000/powerpc-altivec64l.dat: Regenerate.
	* regformats/rs6000/powerpc-cell32l.dat: Regenerate.
	* regformats/rs6000/powerpc-cell64l.dat: Regenerate.
	* regformats/rs6000/powerpc-e500l.dat: Regenerate.
	* regformats/rs6000/powerpc-vsx32l.dat: Regenerate.
	* regformats/rs6000/powerpc-vsx64l.dat: Regenerate.
	* regformats/s390-linux32.dat: Regenerate.
	* regformats/s390-linux32v1.dat: Regenerate.
	* regformats/s390-linux32v2.dat: Regenerate.
	* regformats/s390-linux64.dat: Regenerate.
	* regformats/s390-linux64v1.dat: Regenerate.
	* regformats/s390-linux64v2.dat: Regenerate.
	* regformats/s390-te-linux64.dat: Regenerate.
	* regformats/s390x-linux64.dat: Regenerate.
	* regformats/s390x-linux64v1.dat: Regenerate.
	* regformats/s390x-linux64v2.dat: Regenerate.
	* regformats/s390x-te-linux64.dat: Regenerate.
	* regformats/tic6x-c62x-linux.dat: Regenerate.
	* regformats/tic6x-c62x.dat: Regenerate.
	* regformats/tic6x-c64x-linux.dat: Regenerate.
	* regformats/tic6x-c64x.dat: Regenerate.
	* regformats/tic6x-c64xp-linux.dat: Regenerate.
	* regformats/tic6x-c64xp.dat: Regenerate.
2014-10-01 13:40:13 +01:00
Pedro Alves db74e4ba01 features/Makefile: Make 'make cfiles' default to generating all C files
This makes it easier to rebuild all GDB's generated target description
C files.

It also clarifies the comments a bit.  One might think we need a GDB
configured for the particular arquitecture (--target=foo).  But a
build that includes support for the target description is sufficient.
(GDB rejects target descriptions that explicitly specify the
architecture, with an <architecture> element, if the architecture is
unknown.)

Tested that "make clean-cfiles" deletes all .c files under
src/gdb/features/, and that "make cfiles" generates them all without
error, and that diffing the newly generated C files against master
comes out an empty diff.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/Makefile: Update comments.
	(XMLTOC): List all xml files we build C files from.
	(clean-cfiles): New rule.
2014-10-01 12:08:40 +01:00
Pedro Alves d63f2f8402 Regenerate AVX512 target description C files
I regenerated all the .c files under src/gdb/features/ and this is
what I got.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/i386/amd64-avx512-linux.c: Regenerate.
	* features/i386/amd64-avx512.c: Regenerate.
	* features/i386/x32-avx512-linux.c: Regenerate.
	* features/i386/x32-avx512.c: Regenerate.
2014-10-01 11:59:46 +01:00
Pedro Alves 20ad026db6 gdb/regformats: Don't build .dat files that aren't used by GDBserver
The only reason .dat files exist is for GBBserver to use them in its
build system.

A few .dat files are listed as targets for generation that shouldn't.
The target descriptions these files are built from aren't used by
GDBserver.  They're fallback descriptions GDB itself has baked in.

Remove them from the list of .dat files to be generated, otherwise a
plain "make" under src/gdb/features/ generates new .dat files that
aren't even in the tree today.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/Makefile (WHICH): Remove arm-with-m,
	arm-with-m-fpa-layout and arm-with-m-vfp-d16.
2014-10-01 11:12:04 +01:00
Pedro Alves acc9fe4500 features/Makefile: Add a "clean" rule.
So that we can do "make clean all" to regenerate all the renerated
.dat files.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/Makefile (clean): New rule.
2014-10-01 11:07:39 +01:00
Pedro Alves e001e535f6 Fix features/i386/64bit-avx512.xml
This file's format is invalid, as it's missing some end quotes.

I noticed this because I tried to regenerate all the .dat files in
gdb/regformats/.  I got:

    sh ../../move-if-change ../regformats/i386/x32-avx.tmp ../regformats/i386/x32-avx.dat
    echo "# DO NOT EDIT: generated from i386/x32-avx512.xml" > ../regformats/i386/x32-avx512.tmp
    echo "name:`echo x32-avx512 | sed 's/-/_/g'`" >> ../regformats/i386/x32-avx512.tmp
    echo "xmltarget:x32-avx512.xml" >> ../regformats/i386/x32-avx512.tmp
    echo "expedite:rbp,rsp,rip" \
      >> ../regformats/i386/x32-avx512.tmp
    xsltproc --path "/home/pedro/gdb/mygit/src/gdb/features" --xinclude number-regs.xsl i386/x32-avx512.xml | \
      xsltproc sort-regs.xsl - | \
      xsltproc gdbserver-regs.xsl - >> ../regformats/i386/x32-avx512.tmp
    i386/64bit-avx512.xml:81: parser error : Unescaped '<' not allowed in attributes values
      <reg name="zmm11h" bitsize="256" type="v2ui128/>
      ^
    i386/64bit-avx512.xml:81: parser error : attributes construct error
      <reg name="zmm11h" bitsize="256" type="v2ui128/>
      ^
    i386/64bit-avx512.xml:81: parser error : Couldn't find end of Start Tag reg line 80
      <reg name="zmm11h" bitsize="256" type="v2ui128/>
      ^
    i386/64bit-avx512.xml:82: parser error : Unescaped '<' not allowed in attributes values
      <reg name="zmm12h" bitsize="256" type="v2ui128/>
      ^
    i386/64bit-avx512.xml:82: parser error : attributes construct error
      <reg name="zmm12h" bitsize="256" type="v2ui128/>
      ^
...
    i386/x32-avx512.xml:17: element include: XInclude error : could not load i386/64bit-avx512.xml, and no fallback was found
    -:1: parser error : Document is empty

    ^
    -:1: parser error : Start tag expected, '<' not found

    ^
    unable to parse -
    -:1: parser error : Document is empty

    ^
    -:1: parser error : Start tag expected, '<' not found

    ^
    unable to parse -
    make: *** [../regformats/i386/x32-avx512.dat] Error 6

Interestingly, gdb/expat manages to grok the broken file.

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/i386/64bit-avx512.xml (zmm10h, zmm11h, zmm12h, zmm13h)
	(zmm14h): Add missing end quotes.
2014-10-01 10:52:54 +01:00
Pedro Alves bdc144174b Aarch64: Make CPSR a 32-bit register again in the target description
This reverts commit a4d9ba85 - 'AARCH64: Change cpsr type to be
64bit.'.

Even though Linux's ptrace exposes CPSR as 64-bit, CPSR is really
32-bit, and basing GDB's fundamentals on a particular OS's ptrace(2)
implementation is a bad idea.

In addition, while that commit intended to fix big endian Aarch64, it
ended up breaking floating point debugging against GDBserver, for both
big and little endian, because it changed the CPSR to be 64-bit in the
features/aarch64-core.xml file, but missed regenerating the
regformats/aarch64.dat file.  If we generate it now, we see this:

  diff --git c/gdb/regformats/aarch64.dat w/gdb/regformats/aarch64.dat
  index afe1028..0d32183 100644
  --- c/gdb/regformats/aarch64.dat
  +++ w/gdb/regformats/aarch64.dat
  @@ -35,7 +35,7 @@ expedite:x29,sp,pc
   64:x30
   64:sp
   64:pc
  -32:cpsr
  +64:cpsr
   128:v0
   128:v1
   128:v2

IOW, that commit left regformats/aarch64.dat still considering CPSR as
32-bits.  regformats/aarch64.dat is used by GDBserver for its internal
regcache layout, and for the g/G packet register block.  See the
generated aarch64.c file in GDBserver's build dir.

So the target description xml file that GDBserver reports to GDB is
now claiming that CPSR is 64-bit, but what GDBserver actually puts in
the g/G register packets is 32-bits.  Because GDB thinks CPSR is
64-bit (because that's what the XML description says), GDB will be
reading the remaining 32-bit bits of CPSR out of v0 (the register
immediately afterwards), and then all the registers that follow CPSR
in the register packet end up wrong in GDB, because they're being read
from the wrong offsets...

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

	* features/aarch64-core.xml (cpsr): Change back to 32-bit.
	* features/aarch64.c: Regenerate.
2014-10-01 10:06:45 +01:00
Don Breazeal d83ad864a2 Refactor native follow-fork.
This patch reorganizes the code that implements follow-fork and
detach-on-fork in preparation for implementation of those features for the
extended-remote target.  The function linux-nat.c:linux_child_follow_fork
contained target-independent code mixed in with target-dependent code.  The
target-independent pieces need to be accessible for the host-side
implementation of follow-fork for extended-remote Linux targets.

The changes are fairly mechanical.  A new routine, follow_fork_inferior,
is implemented in infrun.c, containing those parts of
linux_child_follow_fork that manage inferiors and the inferior list.  The
parts of linux_child_follow_fork that deal with LWPs and target-specifics
were left in-place.  Although the order of some operations was changed, the
resulting functionality was not.

Modifications were made to the other native target follow-fork functions,
inf_ttrace_follow_fork and inf_ptrace_follow_fork, that should allow them
to work with follow_fork_inferior.  Some other adjustments were necessary
in inf-ttrace.c.  The changes to inf-ttrace.c and inf-ptrace.c were not
tested.

gdb/ChangeLog:

	* inf-ptrace.c (inf_ptrace_follow_fork): Remove target-independent
	code so as to work with follow_fork_inferior.
	* inf-ttrace.c (inf_ttrace_follow_fork): Ditto.
	(inf_ttrace_create_inferior): Remove reference to
	inf_ttrace_vfork_ppid.
	(inf_ttrace_attach): Ditto.
	(inf_ttrace_detach): Ditto.
	(inf_ttrace_kill): Use current_inferior instead of
	inf_ttrace_vfork_ppid.
	(inf_ttrace_wait): Eliminate use of inf_ttrace_vfork_ppid, report
	TARGET_WAITKIND_VFORK_DONE event, delete HACK that switched the
	inferior away from the parent.
	* infrun.c (follow_fork): Call follow_fork_inferior instead of
	target_follow_fork.
	(follow_fork_inferior): New function.
	(follow_inferior_reset_breakpoints): Make function static.
	* infrun.h (follow_inferior_reset_breakpoints): Remove declaration.
	* linux-nat.c (linux_child_follow_fork): Move target-independent
	code to infrun.c:follow_fork_inferior.
2014-09-30 11:01:57 -07:00
James Hogan 63b434a437 Clean up after generated c files for MIPS DSP targets
The gdbserver "clean" Makefile target wasn't removing the generated files
mips-dsp-linux.c and mips64-dsp-linux.c. Add rm commands to delete them.

gdb/gdbserver/ChangeLog:

	* Makefile.in (clean): Add rm -f commands for mips-dsp-linux.c and
	mips64-dsp-linux.c.
2014-09-30 15:50:21 +01:00
Andreas Arnez 29082443fc Drop 'regset_from_core_section' gdbarch method
Now that all instances of the regset_from_core_section gdbarch method
have been replaced by the new iterator method, delete the obsolete
method from the gdbarch interface.  Adjust all invocations and
references to it.

gdb/ChangeLog:

	* gdbarch.sh (regset_from_core_section): Remove gdbarch method.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* corelow.c (sniff_core_bfd): Drop presence check for deleted
	gdbarch method 'regset_from_core_section'.
	(get_core_register_section): Remove handling for the case that
	regset == NULL and regset_from_core_section is defined.
	(get_core_registers): Drop check for deleted method.
	* procfs.c (procfs_do_thread_registers): Adjust comment.
2014-09-30 09:14:39 +02:00
Andreas Arnez f968fe80b0 Linux targets: drop fall back to target method for 'make_corefile_notes'
Now that all Linux targets use the regset iterator, the fall back to
the deprecated target method is dropped.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_collect_thread_registers): Remove.
	(linux_nat_make_corefile_notes): Remove.
	(linux_target_install_ops): Do not set target method
	'make_corefile_notes'.
	* linux-tdep.c (struct linux_corefile_thread_data)<collect>:
	Remove field.
	(linux_corefile_thread_callback): Instead of args->collect, call
	linux_collect_thread_registers.
	(linux_make_corefile_notes): Remove 'collect' parameter.  Return
	NULL unless there is a regset iterator.
	(linux_make_corefile_notes_1): Remove.
	(linux_init_abi): Replace reference to linux_make_corefile_notes_1
	by linux_make_corefile_notes.
	* linux-tdep.h (linux_make_corefile_notes): Remove prototype.
2014-09-30 09:14:39 +02:00
Andreas Arnez 174ad59a8e Drop target method 'fbsd_make_corefile_notes'
Now that all users of the target method 'fbsd_make_corefile_notes'
have been converted to the version in fbsd-tdep.c, the old method is
removed.

gdb/ChangeLog:

	* fbsd-nat.c (find_signalled_thread, find_stop_signal)
	(fbsd_collect_regset_section_cb, fbsd_make_corefile_notes):
	Remove.
	* fbsd-nat.h (fbsd_make_corefile_notes): Remove prototype.
2014-09-30 09:14:39 +02:00
Andreas Arnez 970940347a XTENSA: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For Xtensa targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* xtensa-tdep.c (xtensa_regset_from_core_section): Remove.
	(xtensa_iterate_over_regset_sections): New.
	(xtensa_gdbarch_init): Adjust gdbarch initialization.
2014-09-30 09:14:39 +02:00
Andreas Arnez f73d3ce7f8 VAX: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For VAX targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* vax-tdep.c (vax_regset_from_core_section): Remove.
	(vax_iterate_over_regset_sections): New.
	(vax_gdbarch_init): Adjust gdbarch initialization.
2014-09-30 09:14:38 +02:00
Andreas Arnez cb24567a55 TILEGX: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For TILE-Gx GNU/Linux targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* tilegx-linux-tdep.c (TILEGX_LINUX_SIZEOF_GREGSET): New macro.
	(tilegx_regset_from_core_section): Remove.
	(tilegx_iterate_over_regset_sections): New.
	(tilegx_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:38 +02:00
Andreas Arnez e5139de88e SPARC: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For SPARC targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* sparc-tdep.c (sparc_regset_from_core_section): Remove.
	(sparc_iterate_over_regset_sections): New.
	(sparc32_gdbarch_init): Adjust gdbarch initialization.
	* configure.tgt (gdb_target_obs): Add fbsd-tdep.o for SPARC FreeBSD
	targets.
	* sparc64fbsd-tdep.c (fbsd-tdep.h): Include.
	(sparc64fbsd_init_abi): Call fbsd_init_abi.
	* sparc64fbsd-nat.c (_initialize_sparc64fbsd_nat): Do not set
	target method 'make_corefile_notes'.
2014-09-30 09:14:38 +02:00
Andreas Arnez c6d41a6f53 SH: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For Super-H targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* sh-linux-tdep.c (sh_linux_init_abi): Set tdep fields
	'sizeof_gregset' and 'sizeof_fpregset'.
	* sh-tdep.c (sh_regset_from_core_section): Remove.
	(sh_iterate_over_regset_sections): New.
	(sh_gdbarch_init): Adjust gdbarch initialization.
	* sh-tdep.h (struct gdbarch_tdep): New fields sizeof_gregset and
	sizeof_fpregset.
	* shnbsd-tdep.c (shnbsd_init_abi): Set tdep field
	'sizeof_gregset'.
2014-09-30 09:14:37 +02:00
Andreas Arnez 9845a0b521 SCORE: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For S+core targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* score-tdep.c (score7_linux_regset_from_core_section): Remove.
	(score7_linux_iterate_over_regset_sections): New.
	(score_gdbarch_init): Adjust gdbarch initialization.
2014-09-30 09:14:37 +02:00
Andreas Arnez 23ea9aebce PPC: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For PPC targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* configure.tgt (gdb_target_obs): Add fbsd-tdep.o for PowerPC
	FreeBSD targets.
	* ppcfbsd-nat.c (_initialize_ppcfbsd_nat): Do not set target
	method 'make_corefile_notes'.
	* ppcfbsd-tdep.c (fbsd-tdep.h): Include.
	(ppcfbsd_regset_from_core_section): Remove.
	(ppcfbsd_iterate_over_regset_sections): New.
	(ppcfbsd_init_abi): Call fbsd_init_abi.  Adjust gdbarch
	initialization.
	* ppcnbsd-tdep.c (ppcnbsd_regset_from_core_section): Remove.
	(ppcnbsd_iterate_over_regset_sections): New.
	(ppcnbsd_init_abi): Adjust.
	* ppcobsd-tdep.c (ppcobsd_regset_from_core_section): Remove.
	(ppcobsd_iterate_over_regset_sections): New.
	(ppcobsd_init_abi): Adjust.
	* rs6000-aix-tdep.c (rs6000_aix_regset_from_core_section): Remove.
	(rs6000_aix_iterate_over_regset_sections): New.
	(rs6000_aix_init_osabi): Adjust.
2014-09-30 09:14:37 +02:00
Andreas Arnez c5b8d704bc NIOS2: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For Nios II GNU/Linux targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* nios2-linux-tdep.c (NIOS2_GREGS_SIZE): New macro.
	(nios2_regset_from_core_section): Remove.
	(nios2_iterate_over_regset_sections): New.
	(nios2_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:37 +02:00
Andreas Arnez 3636e6083c MN10300: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'.
For MN10300 GNU/Linux targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* mn10300-linux-tdep.c (am33_regset_from_core_section): Remove.
	(am33_iterate_over_regset_sections): New.
	(am33_linux_init_osabi): Adjust gdbarch initialization.
2014-09-30 09:14:36 +02:00
Andreas Arnez d40362355c MIPS: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For MIPS targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* mips-linux-tdep.c (mips_linux_regset_from_core_section): Remove.
	(mips_linux_iterate_over_regset_sections): New.
	(mips_linux_init_abi): Adjust gdbarch initialization.
	* mips64obsd-tdep.c (mips64obsd_regset_from_core_section): Remove.
	(mips64obsd_iterate_over_regset_sections): New.
	(mips64obsd_init_abi): Adjust.
	* mipsnbsd-tdep.c (mipsnbsd_regset_from_core_section): Remove.
	(mipsnbsd_iterate_over_regset_sections): New.
	(mipsnbsd_init_abi): Adjust.
2014-09-30 09:14:36 +02:00
Andreas Arnez b61ddd6e24 M88K: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For M88K targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* m88k-tdep.c (m88k_regset_from_core_section): Remove.
	(m88k_iterate_over_regset_sections): New.
	(m88k_gdbarch_init): Adjust gdbarch initialization.
2014-09-30 09:14:36 +02:00
Andreas Arnez 55a2906a41 IA64: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For IA-64 GNU/Linux targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* ia64-linux-tdep.c (ia64_linux_regset_from_core_section): Remove.
	(ia64_linux_iterate_over_regset_sections): New.
	(ia64_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:36 +02:00
Andreas Arnez 022c98ab88 M68K: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For m68k BSD and GNU/Linux targets, no longer define the gdbarch
method 'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* m68kbsd-tdep.c (m68kbsd_regset_from_core_section): Remove.
	(m68kbsd_iterate_over_regset_sections): New.
	(m68kbsd_init_abi): Adjust gdbarch initialization.
	* m68klinux-tdep.c (m68k_linux_regset_from_core_section): Remove.
	(m68k_linux_iterate_over_regset_sections): New.
	(m68k_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:35 +02:00
Andreas Arnez 5fac247f47 M32R: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For m32r GNU/Linux targets, don't define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* m32r-linux-tdep.c (M32R_LINUX_GREGS_SIZE): New macro.
	(m32r_linux_regset_from_core_section): Remove.
	(m32r_linux_iterate_over_regset_sections): New.
	(m32r_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:35 +02:00
Andreas Arnez 490496c342 X86: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For all I386 and AMD64 targets, replace all occurrences of
regset_from_core_section by the iterator method.

gdb/ChangeLog:

	* amd64obsd-tdep.c (amd64obsd_regset_from_core_section): Remove.
	(amd64obsd_iterate_over_regset_sections): New.
	(amd64obsd_core_init_abi): Adjust gdbarch initialization.
	* i386-cygwin-tdep.c (i386_windows_regset_from_core_section):
	Remove.
	(i386_cygwin_init_abi): Clear tdep->sizeof_fpregset.  Drop
	regset_from_core_section initialization.
	* i386-tdep.c (i386_regset_from_core_section): Remove.
	(i386_iterate_over_regset_sections): New.
	(i386_gdbarch_init): Adjust gdbarch initialization.
	* i386-tdep.h (i386_regset_from_core_section): Remove prototype.
	(i386_iterate_over_regset_sections): New prototype.
	* i386obsd-tdep.c (i386obsd_aout_regset_from_core_section):
	Remove.
	(i386obsd_aout_iterate_over_regset_sections): New.
	(i386obsd_aout_init_abi): Adjust gdbarch initialization.
	* configure.tgt (gdb_target_obs): Add fbsd-tdep.o for all x86 FreeBSD
	targets.
	* amd64fbsd-tdep.c (fbsd-tdep.h): Include.
	(amd64fbsd_init_abi): Call fbsd_init_abi.
	* i386fbsd-tdep.c (fbsd-tdep.h): Include.
	(i386fbsd4_init_abi): Call fbsd_init_abi.
	* amd64fbsd-nat.c (_initialize_amd64fbsd_nat): No longer set
	target method 'make_corefile_notes'.
	* i386fbsd-nat.c (_initialize_i386fbsd_nat): Likewise.
2014-09-30 09:14:35 +02:00
Andreas Arnez 50c5eb5335 HPPA: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For HP PA-RISC targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* hppa-hpux-tdep.c (hppa_hpux_regset_from_core_section): Remove.
	(hppa_hpux_iterate_over_regset_sections): New.
	(hppa_hpux_init_abi): Adjust gdbarch initialization.
	* hppa-linux-tdep.c (hppa_linux_regset_from_core_section): Remove.
	(hppa_linux_iterate_over_regset_sections): New.
	(hppa_linux_init_abi): Adjust.
	* hppanbsd-tdep.c (hppaobsd_regset_from_core_section): Remove.
	(hppanbsd_iterate_over_regset_sections): New.
	(hppanbsd_init_abi): Adjust.
	* hppaobsd-tdep.c (hppaobsd_regset_from_core_section): Remove.
	(hppaobsd_iterate_over_regset_sections): New.
	(hppaobsd_init_abi): Adjust.
2014-09-30 09:14:34 +02:00
Andreas Arnez 66afae4f0a FRV: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For FR-V GNU/Linux targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* frv-linux-tdep.c (frv_linux_regset_from_core_section): Remove.
	(frv_linux_iterate_over_regset_sections): New.
	(frv_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:34 +02:00
Andreas Arnez ed09174e35 ARM: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
For ARM BSD targets, don't define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

	* arm-tdep.h (armbsd_regset_from_core_section): Remove prototype.
	(armbsd_iterate_over_regset_sections): New prototype.
	* armbsd-tdep.c (armbsd_regset_from_core_section): Remove.
	(armbsd_iterate_over_regset_sections): New.
	* armobsd-tdep.c (armobsd_init_abi): Adjust gdbarch
	initialization.
2014-09-30 09:14:34 +02:00
Andreas Arnez dff2166ef9 ALPHA: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
Don't define the 'regset_from_core_section' method, but the iterator
method instead.  Do this for GNU/Linux- as well as
Net/OpenBSD-targets.  In the case of GNU/Linux this should enable
non-native use of the 'generate-core-file' command.

gdb/ChangeLog:

	* alpha-linux-tdep.c (alpha_linux_regset_from_core_section): Remove.
	(alpha_linux_iterate_over_regset_sections): New.
	(alpha_linux_init_abi): Adjust gdbarch initialization.
	* alphabsd-tdep.h (alphanbsd_regset_from_core_section): Remove
	prototype.
	(alphanbsd_iterate_over_regset_sections): New prototype.
    	* alphafbsd-tdep.c (alphafbsd_init_abi): Add comment for missing
    	fbsd_init_abi invocation.
	* alphanbsd-tdep.c (alphanbsd_supply_gregset): Move below
	alphanbsd_aout_supply_gregset.  Invoke the latter for the
	appropriate size.
	(alphanbsd_aout_gregset): Remove.
	(alphanbsd_regset_from_core_section): Remove.
	(alphanbsd_iterate_over_regset_sections): New.
	(alphanbsd_init_abi): Adjust gdbarch initialization.
	* alphaobsd-tdep.c (alphaobsd_init_abi): Likewise.
2014-09-30 09:14:34 +02:00
Andreas Arnez 4108500a2a AARCH64: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
Don't define the 'regset_from_core_section' method, but the iterator
method instead.  This slightly reduces the code and enables non-native
use of the 'generate-core-file' command.

Also, when all instances of 'regset_from_core_section' are replaced,
it can be dropped from the gdbarch interface.

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_linux_regset_from_core_section):
	Remove.
	(aarch64_linux_iterate_over_regset_sections): New.
	(aarch64_linux_init_abi): Adjust gdbarch initialization.
2014-09-30 09:14:33 +02:00
Andreas Arnez a904c024b0 Add multi-arch capable 'fbsd_make_corefile_notes' variant
This creates a new version of the FreeBSD core file note generation
logic in the new target-dependent file "fbsd-tdep.c".  The new version
is mostly copied from "fbsd-nat.c", but uses the iterator instead of
regset_from_core_section and defines fbsd_make_corefile_notes as a
gdbarch method instead of a target method.

Consecutive architecture-dependent changes exploit the new version,
migrating away from the target method.  When all FreeBSD targets are
changed, the target method can go away.

gdb/ChangeLog:

	* fbsd-tdep.c: New file.
	* fbsd-tdep.h: New file.
	* Makefile.in (ALL_TARGET_OBS): Add fbsd-tdep.o.
	(HFILES_NO_SRCDIR): Add fbsd-tdep.h.
	(ALLDEPFILES): Add fbsd-tdep.c.
2014-09-30 09:14:33 +02:00
Andreas Arnez 8f0435f75e Add 'regset' parameter to 'iterate_over_regset_sections_cb'
This adds the 'regset' parameter to the iterator callback.
Consequently the 'regset_from_core_section' method is dropped for all
targets that provide the iterator method.

This change prepares for replacing regset_from_core_section
everywhere, thereby eliminating one gdbarch interface.  Since the
iterator is usually no more complex than regset_from_core_section
alone, targets that previously didn't define core_regset_sections will
then gain multi-arch capable core file generation support without
increased complexity.

gdb/ChangeLog:

	* gdbarch.sh (iterate_over_regset_sections_cb): Add regset
	parameter.
	* gdbarch.h: Regenerate.
	* corelow.c (sniff_core_bfd): Don't sniff if gdbarch has a regset
	iterator.
	(get_core_register_section): Add parameter 'regset' and use it, if
	set.  Add parameter 'min_size' and verify the bfd section size
	against it.
	(get_core_registers_cb): Add parameter 'regset' and pass it to
	get_core_register section.  For the "standard" register sections
	".reg" and ".reg2", set an appropriate default for human_name.
	(get_core_registers): Don't abort when the gdbarch has an iterator
	but no regset_from_core_section.  Add NULL/0 for parameters
	'regset'/'min_size' in calls to get_core_register_section.
	* linux-tdep.c (linux_collect_regset_section_cb): Add parameter
	'regset' and use it instead of calling the
	regset_from_core_section gdbarch method.
	* i386-tdep.h (struct gdbarch_tdep): Add field 'fpregset'.
	* i386-tdep.c (i386_supply_xstateregset)
	(i386_collect_xstateregset, i386_xstateregset): Moved to
	i386-linux-tdep.c.
	(i386_regset_from_core_section): Drop handling for .reg-xfp and
	.reg-xstate.
	(i386_gdbarch_init): Set tdep field 'fpregset'.  Enable generic
	core file support only if the regset iterator hasn't been set.
	* i386-linux-tdep.c (i386_linux_supply_xstateregset)
	(i386_linux_collect_xstateregset, i386_linux_xstateregset): New.
	Moved from i386-tdep.c and renamed to *_linux*.
	(i386_linux_iterate_over_regset_sections): Add regset parameter to
	each callback invocation.  Allow any .reg-xstate size when reading
	from a core file.
	* amd64-tdep.c (amd64_supply_xstateregset)
	(amd64_collect_xstateregset, amd64_xstateregset): Moved to
	amd64-linux-tdep.c.
	(amd64_regset_from_core_section): Remove.
	(amd64_init_abi): Set new tdep field 'fpregset'.  No longer
	install an amd64-specific regset_from_core_section gdbarch method.
	* amd64-linux-tdep.c (amd64_linux_supply_xstateregset)
	(amd64_linux_collect_xstateregset, amd64_linux_xstateregset): New.
	Moved from amd64-tdep.c and renamed to *_linux*.
	(amd64_linux_iterate_over_regset_sections): Add regset parameter
	to each callback invocation.  Allow any .reg-xstate size when
	reading from a core file.
	* arm-linux-tdep.c (arm_linux_regset_from_core_section): Remove.
	(arm_linux_iterate_over_regset_sections): Add regset parameter to
	each callback invocation.
	(arm_linux_init_abi): No longer set the regset_from_core_section
	gdbarch method.
	* ppc-linux-tdep.c (ppc_linux_regset_from_core_section): Remove.
	(ppc_linux_iterate_over_regset_sections): Add regset parameter to
	each callback invocation.
	(ppc_linux_init_abi): No longer set the regset_from_core_section
	gdbarch method.
	* s390-linux-tdep.c (struct gdbarch_tdep): Remove the fields
	gregset, sizeof_gregset, fpregset, and sizeof_fpregset.
	(s390_regset_from_core_section): Remove.
	(s390_iterate_over_regset_sections): Add regset parameter to each
	callback invocation.
	(s390_gdbarch_init): No longer set the regset_from_core_section
	gdbarch method.  Drop initialization of deleted tdep fields.
2014-09-30 09:14:33 +02:00
Andreas Arnez 5aa82d050d Replace 'core_regset_sections' by iterator method
The core_regset_sections list in gdbarch (needed for multi-arch
capable core file generation support) is replaced by an iterator
method.  Overall, this reduces the code a bit, and it allows for more
flexibility.

gdb/ChangeLog:

	* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
	(amd64_linux_iterate_over_regset_sections): New.
	(amd64_linux_init_abi_common): Don't install the regset section
	list, but the new iterator in gdbarch.
	* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
	(arm_linux_vfp_regset_sections): Remove.  Move combined logic...
	(arm_linux_iterate_over_regset_sections): ...here.  New function.
	(arm_linux_init_abi): Set iterator instead of section list.
	* corelow.c (get_core_registers_cb): New function, logic moved
	from...
	(get_core_registers): ...loop body here.  Use new iterator method
	instead of walking through the regset section list.
	* gdbarch.sh: Remove 'core_regset_sections'.  New method
	'iterate_over_regset_sections'.  New typedef
	'iterate_over_regset_sections_cb'.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* i386-linux-tdep.c (i386_linux_regset_sections)
	(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
	Remove.
	(i386_linux_iterate_over_regset_sections): New.
	(i386_linux_init_abi): Don't choose a regset section list, but
	install new iterator in gdbarch.
	* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
	(linux_collect_regset_section_cb): New function, logic moved
	from...
	(linux_collect_thread_registers): ...loop body here.  Use iterator
	method instead of walking through list.
	(linux_make_corefile_notes_1): Check for presence of iterator
	method instead of regset section list.
	* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
	(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
	(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
	(ppc64_linux_fp_regset_sections): Remove.  Move combined logic...
	(ppc_linux_iterate_over_regset_sections): ...here.  New function.
	(ppc_linux_init_abi): Don't choose from above regset section
	lists, but install new iterator in gdbarch.
	* regset.h (struct core_regset_section): Remove.
	* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
	have_linux_v1, have_linux_v2, and have_tdb.
	(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
	(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
	(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
	(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
	(s390x_linux64v2_regset_sections): Remove.  Move combined logic...
	(s390_iterate_over_regset_sections): ...here.  New function.  Use
	new tdep fields.
	(s390_gdbarch_init): Set new tdep fields.  Don't choose from above
	regset section lists, but install new iterator.
2014-09-30 09:14:32 +02:00
Yao Qi 6a5f3f4353 Error in build_executable_own_libs for non-native target
gdb/testsuite:

2014-09-30  Yao Qi  <yao@codesourcery.com>

	* lib/prelink-support.exp (build_executable_own_libs): Error if
	the target isn't native.
2014-09-30 11:42:56 +08:00
Yao Qi 345bcc73f2 Skip dlopen-libpthread.exp in cross testing
I see the following fails on arm-linux-gnueabi,

result of ldd build-git/arm/gdb/testsuite/gdb.threads/dlopen-libpthread.so is 1
output of ldd build-git/arm/gdb/testsuite/gdb.threads/dlopen-libpthread.so is not a dynamic executable
child process exited abnormally
FAIL: gdb.threads/dlopen-libpthread.exp: ldd dlopen-libpthread.so
FAIL: gdb.threads/dlopen-libpthread.exp: ldd dlopen-libpthread.so output contains libs

the test script invokes ldd (on host) for the target libraries, which
is wrong.  ldd can't be cross because it invokes dynamic linker with
LD_TRACE_LOADED_OBJECTS and gets the dependent libraries.  My first
reaction to this problem is to execute ld.so on the target (like
remote_exec target).  When I start to hack proc build_executable_own_libs,
I find it has assumptions here and there that the native testing is
performed.  Then I check the callers of build_executable_own_libs,
and they are all skipped if isnative is false.  It is reasonable to do
the same in dlopen-libpthread.exp too.

gdb/testsuite:

2014-09-30  Yao Qi  <yao@codesourcery.com>

	* gdb.threads/dlopen-libpthread.exp: Skip it if isnative is
	false.
2014-09-30 11:42:51 +08:00
Jan Kratochvil 2eca4a8d84 Fix library-list.dtd -> library-list-svr4.dtd
commit 2268b414f4
added file "features/library-list-svr4.dtd" but the added code uses
"library-list.dtd" instead.

Curiously after changing for a test s/name/nXme/ in the DTD making the
gdbserver output non-conforming there is no warning or regression seen (tested
gdb.base/shlib-call.exp, using_xfer is still 1).  I did not check more why the
DTD conformance verification does not work.

gdb/ChangeLog
2014-09-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* solib-svr4.c (svr4_parse_libraries): Use "library-list-svr4.dtd".
2014-09-29 17:38:12 +02:00
Simon Marchi a73c2b56cd Don't prune program spaces when doing "maintenance info program-spaces"
Remove the pruning of program spaces in print_program_space to remove
unwanted side-effects. "info" commands and print routines should
generally not change the state of the debugger.

gdb/Changelog:

	* progspace.c (print_program_space): Don't prune program spaces
	before printing them.
2014-09-26 10:35:12 -04:00
Pedro Alves 03d4695724 infrun.c:user_visible_resume_ptid: Don't check singlestep_breakpoints_inserted_p
What matters for this function, is whether the user requested a
"step", for "set scheduler-locking step", not whether GDB is doing an
internal step for some reason.

 /* Return a ptid representing the set of threads that we will proceed,
    in the perspective of the user/frontend.  */
 extern ptid_t user_visible_resume_ptid (int step);

Therefore, the check for singlestep_breakpoints_inserted_p is actually
incorrect, and we end up applying schedlock more often on sss targets
than on non-sss targets.

Found by inspection while working on a patch that eliminates the
singlestep_breakpoints_inserted_p global.

Tested on x86_64 Fedora 20 on top of my 'software single-step on x86'
series.

gdb/
2014-09-25  Pedro Alves  <palves@redhat.com>

	* infrun.c (user_visible_resume_ptid): Don't check
	singlestep_breakpoints_inserted_p.
2014-09-25 16:56:00 +01:00
Pedro Alves e558d7c109 breakpoint.c: debug output when we skip inserting a breakpoint
gdb/
2014-09-25  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (should_be_inserted): Add debug output.
2014-09-25 16:49:43 +01:00
Pedro Alves 7f89fd6519 infrun.c: comment/typo fixes
gdb/
2014-09-25  Pedro Alves  <palves@redhat.com>

	* infrun.c (stepping_past_instruction_at)
	(clear_exit_convenience_vars): Point at infrun.h instead of
	inferior.h.
	(handle_signal_stop): Fix typo.
2014-09-25 16:31:04 +01:00
Yao Qi b7576e5cf4 Fix typo in thumb_in_function_epilogue_p
This patch fixes a typo in the bit mask I've made in my previous code
refactor.  If PC is in the register list, the bit 8 is one, so bit
mask 0xff00 should be used.  Current condition is a constant false.

gdb:

2014-09-24  Yao Qi  <yao@codesourcery.com>

	* arm-tdep.c (thumb_in_function_epilogue_p): Fix typo in the
	bitmask.
2014-09-24 20:55:01 +08:00
Yao Qi c4d9ceb647 Honour SIGILL and SIGSEGV in cancel breakpoint and event lwp selection
I see the following fail on arm-none-linux-gnueabi testing,

(gdb) continue^M
Continuing.^M
^M
Program received signal SIGILL, Illegal instruction.^M
[Switching to Thread 1003]^M
handler (signo=10) at
/scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.threads/sigstep-threads.c:33^M
33        tgkill (getpid (), gettid (), SIGUSR1);       /* step-2 */^M
(gdb) FAIL: gdb.threads/sigstep-threads.exp: continue

the cause is that GDBserver doesn't cancel the breakpoint if the stop
signal is SIGILL.  The kernel used here is a little old, 2.6.x, and
doesn't translate SIGILL to SIGTRAP when program hits breakpoint
instruction (which is an illegal instruction actually).  GDB and
GDBserver can translate SIGILL to SIGTRAP under certain circumstance,
so it is not a problem here.  See gdbserver/linux-low.c:linux_wait_1

  /* If this event was not handled before, and is not a SIGTRAP, we
     report it.  SIGILL and SIGSEGV are also treated as traps in case
     a breakpoint is inserted at the current PC.  If this target does
     not support internal breakpoints at all, we also report the
     SIGTRAP without further processing; it's of no concern to us.  */
  maybe_internal_trap
    = (supports_breakpoints ()
       && (WSTOPSIG (w) == SIGTRAP
	   || ((WSTOPSIG (w) == SIGILL
		|| WSTOPSIG (w) == SIGSEGV)
	       && (*the_low_target.breakpoint_at) (event_child->stop_pc))));

However, SIGILL and SIGSEGV is not considered when cancelling
breakpoint, which causes the fail above.  That is, when GDB is doing
software single step on address ADDR, both thread A and thread B hits the
software single step breakpoint, and get SIGILL.  GDB selects the event
from thread A, removes the software single step breakpoint, and resume
the program.  The event (SIGILL) from thread B is reported to GDB, but
GDB doesn't regard this SIGILL as SIGTRAP, because the breakpoint on
address ADDR was removed, so GDB reports "Program received signal
SIGILL".

The patch is to allow calling cancel_breakpoint if the signal is
SIGILL and SIGSEGV.  This patch fixes the fail above.  Likewise, event
lwp selection should honour SIGILL and SIGSEGV too.

gdb/gdbserver:

2014-09-23  Yao Qi  <yao@codesourcery.com>

	* linux-low.c (lp_status_maybe_breakpoint): New function.
	(linux_low_filter_event): Call lp_status_maybe_breakpoint.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(cancel_breakpoints_callback): Likewise.
2014-09-23 20:36:38 +08:00
Jan-Benedict Glaw 342cc09114 2014-09-22 Jan-Benedict Glaw <jbglaw@lug-owl.de>
* gdb.texinfo (Set Breaks): Add missing "@end table".
2014-09-22 13:02:10 +02:00
Gary Benson 9a6cf3683d Update target_stop's documentation
This commit updates target_stop's documentation to clarify that
it is asynchronous.

gdb/ChangeLog:

	* target.c (target_stop): Updated comment.
2014-09-22 11:33:59 +01:00
Gary Benson 03f4463bfc Rename target_{stop,continue}_ptid
This commit renames target_stop_ptid as target_stop_and_wait and
target_continue_ptid as target_continue_no_signal.  Comments are
updated to more fully describe the functions' behaviour.

gdb/ChangeLog:

	* target/target.h (target_stop_ptid): Renamed as...
	(target_stop_and_wait): New function.  Updated comment.
	All uses updated.
	(target_continue_ptid): Renamed as...
	(target_continue_no_signal): New function.  Updated comment.
	All uses updated.
2014-09-22 11:33:59 +01:00
Pedro Alves a25a5a45ef Fix "breakpoint always-inserted off"; remove "breakpoint always-inserted auto"
By default, GDB removes all breakpoints from the target when the
target stops and the prompt is given back to the user.  This is useful
in case GDB crashes while the user is interacting, as otherwise,
there's a higher chance breakpoints would be left planted on the
target.

But, as long as any thread is running free, we need to make sure to
keep breakpoints inserted, lest a thread misses a breakpoint.  With
that in mind, in preparation for non-stop mode, we added a "breakpoint
always-inserted on" mode.  This traded off the extra crash protection
for never having threads miss breakpoints, and in addition is more
efficient if there's a ton of breakpoints to remove/insert at each
user command (e.g., at each "step").

When we added non-stop mode, and for a period, we required users to
manually set "always-inserted on" when they enabled non-stop mode, as
otherwise GDB removes all breakpoints from the target as soon as any
thread stops, which means the other threads still running will miss
breakpoints.  The test added by this patch exercises this.

That soon revealed a nuisance, and so later we added an extra
"breakpoint always-inserted auto" mode, that made GDB behave like
"always-inserted on" when non-stop was enabled, and "always-inserted
off" when non-stop was disabled.  "auto" was made the default at the
same time.

In hindsight, this "auto" setting was unnecessary, and not the ideal
solution.  Non-stop mode does depends on breakpoints always-inserted
mode, but only as long as any thread is running.  If no thread is
running, no breakpoint can be missed.  The same is true for all-stop
too.  E.g., if, in all-stop mode, and the user does:

 (gdb) c&
 (gdb) b foo

That breakpoint at "foo" should be inserted immediately, but it
currently isn't -- currently it'll end up inserted only if the target
happens to trip on some event, and is re-resumed, e.g., an internal
breakpoint triggers that doesn't cause a user-visible stop, and so we
end up in keep_going calling insert_breakpoints.  The test added by
this patch also covers this.

IOW, no matter whether in non-stop or all-stop, if the target fully
stops, we can remove breakpoints.  And no matter whether in all-stop
or non-stop, if any thread is running in the target, then we need
breakpoints to be immediately inserted.  And then, if the target has
global breakpoints, we need to keep breakpoints even when the target
is stopped.

So with that in mind, and aiming at reducing all-stop vs non-stop
differences for all-stop-on-stop-of-non-stop, this patch fixes
"breakpoint always-inserted off" to not remove breakpoints from the
target until it fully stops, and then removes the "auto" setting as
unnecessary.  I propose removing it straight away rather than keeping
it as an alias, unless someone complains they have scripts that need
it and that can't adjust.

Tested on x86_64 Fedora 20.

gdb/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention merge of "breakpoint always-inserted" modes "off"
	and "auto" merged.
	* breakpoint.c (enum ugll_insert_mode): New enum.
	(always_inserted_mode): Now a plain boolean.
	(show_always_inserted_mode): No longer handle AUTO_BOOLEAN_AUTO.
	(breakpoints_always_inserted_mode): Delete.
	(breakpoints_should_be_inserted_now): New function.
	(insert_breakpoints): Pass UGLL_INSERT to
	update_global_location_list instead of calling
	insert_breakpoint_locations manually.
	(create_solib_event_breakpoint_1): New, factored out from ...
	(create_solib_event_breakpoint): ... this.
	(create_and_insert_solib_event_breakpoint): Use
	create_solib_event_breakpoint_1 instead of calling
	insert_breakpoint_locations manually.
	(update_global_location_list): Change parameter type from boolean
	to enum ugll_insert_mode.  All callers adjusted.  Adjust to use
	breakpoints_should_be_inserted_now and handle UGLL_INSERT.
	(update_global_location_list_nothrow): Change parameter type from
	boolean to enum ugll_insert_mode.
	(_initialize_breakpoint): "breakpoint always-inserted" option is
	now a boolean command.  Update help text.
	* breakpoint.h (breakpoints_always_inserted_mode): Delete declaration.
	(breakpoints_should_be_inserted_now): New declaration.
	* infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>:
	Remove breakpoints_always_inserted_mode check.
	(normal_stop): Adjust to use breakpoints_should_be_inserted_now.
	* remote.c (remote_start_remote): Likewise.

gdb/doc/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Set Breaks): Document that "set breakpoint
	always-inserted off" is the default mode now.  Delete
	documentation of "set breakpoint always-inserted auto".

gdb/testsuite/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* gdb.threads/break-while-running.exp: New file.
	* gdb.threads/break-while-running.c: New file.
2014-09-22 10:07:04 +01:00
Pedro Alves 04086b458a Tell update_global_location_list to insert breakpoints
This adds a new mode for update_global_location_list, that allows
callers saying "please insert breakpoints, even if
breakpoints_always_inserted_mode() is false".  This allows removing a
couple breakpoints_always_inserted_mode checks.

gdb/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (enum ugll_insert_mode): Add UGLL_INSERT.
	(insert_breakpoints): Don't call insert_breakpoint_locations here.
	Instead, pass UGLL_INSERT to update_global_location_list.
	(update_global_location_list): Change parameter type from boolean
	to enum ugll_insert_mode.  All callers adjusted.  Adjust to use
	breakpoints_should_be_inserted_now and handle UGLL_INSERT.
	(create_solib_event_breakpoint_1): New, factored out from ...
	(create_solib_event_breakpoint): ... this.
	(create_and_insert_solib_event_breakpoint): Use
	create_solib_event_breakpoint_1 instead of calling
	insert_breakpoint_locations manually.
	(update_global_location_list): Handle UGLL_INSERT.
2014-09-22 10:06:25 +01:00
Pedro Alves 447023601a Change parameter type of update_global_location_list from boolean to enum
Later we'll want a tristate, but for now, convert to an enum that maps 1-1
with the current boolean's true/false.

gdb/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (enum ugll_insert_mode): New enum.
	(update_global_location_list)
	(update_global_location_list_nothrow): Change parameter type from
	boolean to enum ugll_insert_mode.  All callers adjusted.
2014-09-22 09:56:54 +01:00
Joel Brobecker 93c6145af6 Add Sergio Durigan Junior as maintainer of SystemTap support in GDB.
gdb/ChangeLog:

	* MAINTAINERS: Add Sergio Durigan Junior as maintainer of
	SystemTap support in GDB.
2014-09-19 16:50:28 -07:00
Don Breazeal 89a5711c56 Refactor ptrace extended event status.
This commit implements functions for identifying and extracting extended
ptrace event information from a Linux wait status.  These are just
convenience functions intended to hide the ">> 16" used to extract the
event from the wait status word, replacing the hard-coded shift with a more
descriptive function call.  This is preparatory work for implementation of
follow-fork and detach-on-fork for extended-remote linux targets.

gdb/ChangeLog:

	* linux-nat.c (linux_handle_extended_wait): Call
	linux_ptrace_get_extended_event.
	(wait_lwp): Call linux_is_extended_waitstatus.
	(linux_nat_filter_event): Call linux_ptrace_get_extended_event
	and linux_is_extended_waitstatus.
	* nat/linux-ptrace.c (linux_test_for_tracefork): Call
	linux_ptrace_get_extended_event.
	(linux_ptrace_get_extended_event): New function.
	(linux_is_extended_waitstatus): New function.
	* nat/linux-ptrace.h (linux_ptrace_get_extended_event)
	(linux_is_extended_waitstatus): New declarations.

gdb/gdbserver/ChangeLog:

	* linux-low.c (handle_extended_wait): Call
	linux_ptrace_get_extended_event.
	(get_stop_pc, get_detach_signal, linux_low_filter_event): Call
	linux_is_extended_waitstatus.

---
2014-09-19 10:54:34 -07:00
Yao Qi 00ba3162ed Run dw2-var-zero-addr.exp with --readnow
This patch is to extend dw2-var-zero-add.exp to cover the case that
partial symtabl is not used while full symtab is used, in order to
cover the changes in patch 2/3.  This patch restarts GDB with
--readnow and does the same test again.

gdb/testsuite:

2014-09-19  Yao Qi  <yao@codesourcery.com>

	* gdb.dwarf2/dw2-var-zero-addr.exp: Move test into new proc test.
	Invoke test.  Restart GDB with --readnow and invoke test again.
2014-09-19 16:53:34 +08:00
Yao Qi c3b7b696c2 Check function is GC'ed
I see the following fail on arm-none-eabi target,

(gdb) b 24^M
Breakpoint 1 at 0x4: file
../../../../git/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc,
line 24.^M
(gdb) FAIL: gdb.base/break-on-linker-gcd-function.exp: b 24

Currently, we are using flag has_section_at_zero to determine whether
address zero in debug info means the corresponding code has been
GC'ed, like this:

	case DW_LNE_set_address:
	  address = read_address (abfd, line_ptr, cu, &bytes_read);

	  if (address == 0 && !dwarf2_per_objfile->has_section_at_zero)
	    {
	      /* This line table is for a function which has been
		 GCd by the linker.  Ignore it.  PR gdb/12528 */

However, this is incorrect on some bare metal targets, as .text
section is located at 0x0, so dwarf2_per_objfile->has_section_at_zero
is true.  If a function is GC'ed by linker, the address is zero.  GDB
thinks address zero is a function's address rather than this function
is GC'ed.

In this patch, we choose 'lowpc' got in read_file_scope to check
whether 'lowpc' is greater than zero.  If it isn't, address zero really
means the function is GC'ed.  In this patch, we pass 'lowpc' in
read_file_scope through handle_DW_AT_stmt_list and dwarf_decode_lines,
and to dwarf_decode_lines_1 finally.

This patch fixes the fail above. This patch also covers the path that
partial symbol isn't used, which is tested by starting gdb with
--readnow option.

It is regression tested on x86-linux with
target_board=dwarf4-gdb-index, and arm-none-eabi.  OK to apply?

gdb:

2014-09-19  Yao Qi  <yao@codesourcery.com>

	* dwarf2read.c (dwarf_decode_lines): Update declaration.
	(handle_DW_AT_stmt_list): Add argument 'lowpc'.  Update
	comments.  Callers update.
	(dwarf_decode_lines): Likewise.
	(dwarf_decode_lines_1): Add argument 'lowpc'.  Update
	comments.  Skip the line table if  'lowpc' is greater than
	'address'.  Don't check
	dwarf2_per_objfile->has_section_at_zero.

gdb/testsuite:

2014-09-19  Yao Qi  <yao@codesourcery.com>

	* gdb.base/break-on-linker-gcd-function.exp: Move test into new
	proc set_breakpoint_on_gcd_function.  Invoke
	set_breakpoint_on_gcd_function.  Restart GDB with --readnow and
	invoke set_breakpoint_on_gcd_function again.
2014-09-19 16:53:27 +08:00
Doug Evans 2b4fd423cf New "producer" attribute of python gdb.Symtab.
gdb/ChangeLog:

	* NEWS: Mention new "producer" attribute of gdb.Symtab.
	* python/py-symtab.c (stpy_get_producer): New function.
	(symtab_object_getset): Add "producer" attribute.

gdb/doc/ChangeLog:

	* python.texi (Symbol Tables In Python): Document "producer"
	attribute of gdb.Symtab objects.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/symtab-producer.exp: New file.
2014-09-18 10:09:12 -07:00
Ulrich Weigand 5e43d46791 PR gdb/17384: Do not print memory errors in safe_read_memory_integer
If accessing memory via safe_read_memory_integer fails, that function
used to print an error message even though callers were perfectly able
to handle (and even expected!) failures.

This patch removes the confusing message by changing the routine to
directly use target_read_memory.

gdb/ChangeLog:

	PR gdb/17384
	* corefile.c (struct captured_read_memory_integer_arguments): Remove.
	(do_captured_read_memory_integer): Remove.
	(safe_read_memory_integer): Use target_read_memory directly instead
	of catching errors in do_captured_read_memory_integer.
2014-09-17 17:29:27 +02:00
Sergio Durigan Junior a594760181 Add test for global variable that is nested by another DSO
This is just a testcase addition that I am proposing for upstream GDB.
We have this in our internal tree, and the related RH bug is:

  <https://bugzilla.redhat.com/show_bug.cgi?id=809179>

(You might not be able to see all the comments without privileges.)

This bug is about a global variable that got incorrectly displayed by
GDB.  This bug has already been fixed a long time ago by Joel's
commit:

  commit 19630284f5
  Author: Joel Brobecker <brobecker@gnat.com>
  Date:   Tue Jun 5 13:50:50 2012 +0000

But I think a testcase for it wouldn't hurt.

So, consider the following scenario:

  $ cat solib1.c
  int test;
  void c_main (void)
  {
    test = 42;
  }

  $ cat solib2.c
  int test;
  void b_main (void)
  {
    test = 42;
  }

  $ cat main.c
  int main (int argc, char *argv[])
  {
    c_main ();
    b_main ();
    return 0;
  }

  $ gcc -g -fPIC -shared -o libSO1.so -c solib1.c
  $ gcc -g -fPIC -shared -o libSO2.so -c solib2.c
  $ gcc -g -o main -L$PWD -lSO1 -lSO2 main.c
  $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main
  ...
  $1 = 0

This happened with GDB before Joel's commit above.  Now, things work
and GDB is able to correctly display the nested global variable:

  $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main
  ...
  $1 = 42

The testcase attached tests this behavior.

gdb/testsuite/ChangeLog:
2014-09-16  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/global-var-nested-by-dso-solib1.c: New file.
	* gdb.base/global-var-nested-by-dso-solib2.c: Likewise.
	* gdb.base/global-var-nested-by-dso.c: Likewise.
	* gdb.base/global-var-nested-by-dso.exp: Likewise.
2014-09-16 22:57:06 -04:00
Maciej W. Rozycki 04e799796f CONTRIBUTE: For internals refer to wiki, not gdb/doc 2014-09-16 23:45:30 +01:00
Joel Brobecker bffc0964c7 Fix CPPFLAGS handling in gdbserver's build.
In gdb/gdbserver/Makefile.in, IPAGENT_CFLAGS is defined using
an expression which references $(CPPFLAGS). But CPPFLAGS isn't
actually defined.

This patch first adds a CPPFLAGS definition, so as to inherit
the value passed at configure time (if any). And it then makes it
part of INTERNAL_CFLAGS_BASE, instead. There is no reason that
CPPFLAGS be useful for a certain class of source files, and not
the rest. This is also consistent with what's done in GDB.

gdb/gdbserver/ChangeLog:

        * Makefile.in (CPPFLAGS): Define.
        (INTERNAL_CFLAGS_BASE): Add ${CPPFLAGS}.
        (IPAGENT_CFLAGS): Remove ${CPPFLAGS}.

Tested by rebuilding GDBserver with a dummy CPPFLAGS, and verifying
that the compilation command was altered as expected.
2014-09-16 13:31:07 -07:00
Sergio Durigan Junior 76aeec5b98 Remove dead code from objc-lang.c (spurious "fprintf (stderr...")
This obvious change removes dead code from objc-lang.c.  I was
grepping for "fprintf (stderr..." and found this code between "#if
0".."#endif" blocks.

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

	* objc-lang.c (find_implementation_from_class): Remove dead code.
2014-09-16 15:34:27 -04:00
Sergio Durigan Junior 2f693f9d21 Replace "fprintf (stderr..." by "fprintf_unfiltered (gdb_stdlog..."
This is an obvious replacement of "fprintf (stderr..." by
"fprintf_unfiltered (gdb_stdlog...", which is the standard to use in
these cases.

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

	PR cli/7233
	* linux-nat.c (linux_nat_wait_1): Replace "fprintf (stderr..." by
	"fprintf_unfiltered (gdb_stdlog...)".
2014-09-16 15:30:41 -04:00
Sergio Durigan Junior 91c190590a gdb.base/watch-bitfields.exp: Improve test
Make test messages unique and a couple other tweaks.

gdb/testsuite/
2014-09-16  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.base/watch-bitfields.exp: Pass string other than test file
	name to prepare_for_testing.
	(watch): New procedure.
	(expect_watchpoint): Use with_test_prefix.
	(top level): Factor out tests to ...
	(test_watch_location, test_regular_watch): ... these new
	procedures, and use with_test_prefix and gdb_continue_to_end.
2014-09-16 17:55:21 +01:00
Patrick Palka bb9d5f81c3 Fix PR12526: -location watchpoints for bitfield arguments
PR 12526 reports that -location watchpoints against bitfield arguments
trigger false positives when bits around the bitfield, but not the
bitfield itself, are modified.

This happens because -location watchpoints naturally operate at the
byte level, not at the bit level.  When the address of a bitfield
lvalue is taken, information about the bitfield (i.e. its offset and
size) is lost in the process.

This information must first be retained throughout the lifetime of the
-location watchpoint.  This patch achieves this by adding two new
fields to the watchpoint struct: val_bitpos and val_bitsize.  These
fields are set when a watchpoint is first defined in watch_command_1.
They are both equal to zero if the watchpoint is not a -location
watchpoint or if the argument is not a bitfield.

Then these bitfield parameters are used inside update_watchpoint and
watchpoint_check to extract the actual value of the bitfield from the
watchpoint address, with the help of a local helper function
extract_bitfield_from_watchpoint_value.

Finally when creating a HW breakpoint pointing to a bitfield, we
optimize the address and length of the breakpoint.  By skipping over
the bytes that don't cover the bitfield, this step reduces the
frequency at which a read watchpoint for the bitfield is triggered.
It also reduces the number of times a false-positive call to
check_watchpoint is triggered for a write watchpoint.

gdb/
	PR breakpoints/12526
	* breakpoint.h (struct watchpoint): New fields val_bitpos and
	val_bitsize.
	* breakpoint.c (watch_command_1): Use these fields to retain
	bitfield information.
	(extract_bitfield_from_watchpoint_value): New function.
	(watchpoint_check): Use it.
	(update_watchpoint): Use it.  Optimize the address and length of a
	HW watchpoint pointing to a bitfield.
	* value.h (unpack_value_bitfield): New prototype.
	* value.c (unpack_value_bitfield): Make extern.

gdb/testsuite/
	PR breakpoints/12526
	* gdb.base/watch-bitfields.exp: New file.
	* gdb.base/watch-bitfields.c: New file.
2014-09-16 17:40:06 +01:00
Pedro Alves deb8ff2b7a Remove documention of dead "target vxworks"
"target vxworks" and friends have been removed 10 years ago already:

  commit e84ecc995d
  Author:     Andrew Cagney <cagney@redhat.com>
  AuthorDate: Sat Nov 13 23:10:02 2004 +0000

     2004-11-13  Andrew Cagney  <cagney@gnu.org>

         * configure.tgt: Delete i[34567]86-*-vxworks*, m68*-netx-*,
         m68*-*-vxworks*, mips*-*-vxworks*, powerpc-*-vxworks*, and
         sparc-*-vxworks*.
         * NEWS: Mention that vxworks was deleted.
     (...)
         * remote-vxmips.c, remote-vx.c: Delete.
         * remote-vx68.c: Delete.
     (...)

This removes related leftover cruft from the manual.

gdb/doc/
2014-09-16  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Starting) <run command>: Don't mention VxWorks.
	(Embedded OS): Remove VxWorks menu entry.
	(VxWorks): Remove node.
2014-09-16 16:38:12 +01:00
Gary Benson 0bfdf32fa1 Rename current_inferior as current_thread in gdbserver
GDB has a function named "current_inferior" and gdbserver has a global
variable named "current_inferior", but the two are not equivalent;
indeed, gdbserver does not have any real equivalent of what GDB calls
an inferior.  What gdbserver's "current_inferior" is actually pointing
to is a structure describing the current thread.  This commit renames
current_inferior as current_thread in gdbserver to clarify this.  It
also renames the function "set_desired_inferior" to "set_desired_thread"
and renames various local variables from foo_inferior to foo_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.h (current_inferior): Renamed as...
	(current_thread): New variable.  All uses updated.
	* linux-low.c (get_pc): Renamed saved_inferior as saved_thread.
	(maybe_move_out_of_jump_pad): Likewise.
	(cancel_breakpoint): Likewise.
	(linux_low_filter_event): Likewise.
	(wait_for_sigstop): Likewise.
	(linux_resume_one_lwp): Likewise.
	(need_step_over_p): Likewise.
	(start_step_over): Likewise.
	(linux_stabilize_threads): Renamed save_inferior as saved_thread.
	* linux-x86-low.c (x86_linux_update_xmltarget): Likewise.
	* proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread
	and save_inferior as saved_thread.
	* regcache.c (get_thread_regcache): Renamed saved_inferior as
	saved_thread.
	(regcache_invalidate_thread): Likewise.
	* remote-utils.c (prepare_resume_reply): Likewise.
	* thread-db.c (thread_db_get_tls_address): Likewise.
	(disable_thread_event_reporting): Likewise.
	(remove_thread_event_breakpoints): Likewise.
	* tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior
	as saved_thread.
	* target.h (set_desired_inferior): Renamed as...
	(set_desired_thread): New declaration.  All uses updated.
	* server.c (myresume): Updated comment to reference thread instead
	of inferior.
	(handle_serial_event): Likewise.
	(handle_target_event): Likewise.
2014-09-16 15:57:13 +01:00
Pedro Alves 635856f584 Fix watchpoint-stops-at-right-insn.exp
Silly typo...

gdb/testsuite/
2014-09-16  Pedro Alves  <palves@redhat.com>

	* gdb.base/watchpoint-stops-at-right-insn.exp (test): Compare
	software and hardware addresses, not software address against
	itself.
2014-09-16 14:27:57 +01:00
Pedro Alves 7280ceea02 Add test to make sure GDB knows which "kind" of watchpoint the target has
This adds a test that makes sure GDB knows whether the target has
continuable, or non-continuable watchpoints.

That is, the test confirms that GDB presents a watchpoint value change
at the first instruction right after the instruction that changes
memory.

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

	* gdb.base/watchpoint-stops-at-right-insn.c: New file.
	* gdb.base/watchpoint-stops-at-right-insn.exp: New file.
2014-09-16 14:05:06 +01:00
Samuel Thibault 05db5edd79 Add hardware watchpoint support for x86 GNU Hurd.
gdb/
	* config/i386/i386gnu.mh (NATDEPFILES): Add x86-nat.o and
	x86-dregs.o.
	* gnu-nat.c (inf_threads): New function.
	* gnu-nat.h (inf_threads_ftype): New typedef.
	(inf_threads): New declaration.
	* i386gnu-nat.c: Include "x86-nat.h" and "inf-child.h".
	[i386_DEBUG_STATE] (i386_gnu_dr_get, i386_gnu_dr_set)
	(i386_gnu_dr_set_control_one, i386_gnu_dr_set_control)
	(i386_gnu_dr_set_addr_one, i386_gnu_dr_set_addr)
	(i386_gnu_dr_get_reg, i386_gnu_dr_get_addr, 386_gnu_dr_get_status)
	(i386_gnu_dr_get_control): New functions.
	(reg_addr): New structure.
	(_initialize_i386gnu_nat) [i386_DEBUG_STATE]: Initialize hardware
	i386 debugging register hooks.
	* NEWS: Mention this.
2014-09-16 14:38:09 +02:00
Pedro Alves 428b16bd5a Remove support for testing against dead "target vxworks"
"target vxworks" and friends have been removed 10 years ago already:

 commit e84ecc995d
 Author:     Andrew Cagney <cagney@redhat.com>
 AuthorDate: Sat Nov 13 23:10:02 2004 +0000

    2004-11-13  Andrew Cagney  <cagney@gnu.org>

        * configure.tgt: Delete i[34567]86-*-vxworks*, m68*-netx-*,
        m68*-*-vxworks*, mips*-*-vxworks*, powerpc-*-vxworks*, and
        sparc-*-vxworks*.
        * NEWS: Mention that vxworks was deleted.
	(...)
        * remote-vxmips.c, remote-vx.c: Delete.
        * remote-vx68.c: Delete.
	(...)

This removes related leftover cruft from the testsuite.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/testsuite/
2014-09-16  Pedro Alves  <palves@redhat.com>

	* config/vx.exp, config/vxworks.exp, config/vxworks29k.exp: Delete
	files.
	* gdb.base/a2-run.exp: Remove all code guarded by istarget
	"*-*-vxworks*" throughout.
	* gdb.base/break.exp: Likewise.
	* gdb.base/default.exp: Likewise.
	* gdb.base/scope.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.
	* gdb.base/break.c: Remove all code guarded by #ifdef vxworks
	throughout.
	* gdb.base/run.c: Likewise.
	* gdb.base/sepdebug.c: Likewise.
	* gdb.hp/gdb.aCC/run.c: Likewise.
	* gdb.reverse/until-reverse.c: Likewise.
	* lib/gdb.exp (gdb_compile): Remove is_vxworks branch.
2014-09-16 12:37:03 +01:00
Yao Qi 666d413cc3 Another board file for remote host
In the recent review to my patch about copying files to remote host,
we find that we need a board file which is more closely mapped real
remote host testing to improve coverage.  With the board file
local-remote-host-native.exp, DejaGNU copies files to
$build/gdb/testsuite/remote-host to emulate the effect of remote host.
Is it OK?

gdb/testsuite:

2014-09-16  Yao Qi  <yao@codesourcery.com>

	* boards/local-remote-host-native.exp: New file.
2014-09-16 19:13:01 +08:00
Omair Javaid 5a578da5e2 Implement support for recording vector data transfer instructions
gdb:

2014-08-13  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (arm_record_vdata_transfer_insn): Added record handler for
	vector data transfer instructions.
	(arm_record_coproc_data_proc): Updated.
2014-09-16 04:06:43 +05:00
Omair Javaid f20f80ddff Implement support for recording extension register ld/st insn
gdb:

2014-08-13  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (arm_record_asimd_vfp_coproc): Replace stub handler with
	arm_record_exreg_ld_st_insn.
	(arm_record_exreg_ld_st_insn): Add record handler for ex-register
	load/store insns.
2014-09-16 04:04:20 +05:00
Omair Javaid 851f26ae7b Implement support for recording VFP data processing instructions
gdb:

2014-08-13  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (arm_record_coproc_data_proc): Updated.
	(arm_record_vfp_data_proc_insn): Added record handler for VFP data
	processing instructions.
2014-09-16 04:01:24 +05:00
Omair Javaid 1e1b656356 Implement support for recording thumb2 ASIMD struct ld/st insns
gdb:

2014-08-13  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (thumb2_record_asimd_struct_ld_st): Add record handler
	for advance SIMD struct ld/st insn.
	(thumb2_record_decode_insn_handler): Replace stub handler with
	thumb2_record_asimd_struct_ld_st.
2014-09-16 03:56:38 +05:00
Omair Javaid 60cc5e93e5 Implement support for recording arm/thumb mode coprocessor instructions
gdb:

2014-08-13  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (arm_record_coproc_data_proc): Add record handler stubs
	for asimd, vfp and coprocessor insns.
	(arm_record_asimd_vfp_coproc): Add record handler for asimd, vfp
	and coprocessor insns.
	(thumb2_record_coproc_insn): New function.
	(thumb2_record_decode_insn_handler): Update coprocessor insns record
	handlers.
	(decode_insn): Install arm_record_asimd_vfp_coproc as handler for
	opcode 110 insns.
2014-09-16 03:53:02 +05:00
Doug Evans 57cbd724c3 Fix set up of queue-signal.exp test.
The test does a backtrace to see which thread (#2 or #3) is assigned
to which SIGUSR (1 or 2).  If the main thread gets to all_threads_running
before the sigusr threads get to their entry point, then the function
name isn't in the backtrace and the test fails.

Alas this version of the code is within epsilon of what I started with,
and then over-simplified things.
2014-09-14 10:48:38 -07:00
Doug Evans 81219e5358 New command queue-signal.
If I want to change the signalled state of multiple threads
it's a bit cumbersome to do with the "signal" command.
What you really want is a way to set the signal state of the
desired threads and then just do "continue".

This patch adds a new command, queue-signal, to accomplish this.
Basically "signal N" == "queue-signal N" + "continue".
That's not precisely true in that "signal" can be used to inject
any signal, including signals set to "nopass"; whereas "queue-signal"
just queues the signal as if the thread stopped because of it.
"nopass" handling is done when the thread is resumed which
"queue-signal" doesn't do.

One could add extra complexity to allow queue-signal to be used to
deliver "nopass" signals like the "signal" command.  I have no current
need for it so in the interests of incremental complexity, I have
left such support out and just have the code flag an error if one
tries to queue a nopass signal.

gdb/ChangeLog:

	* NEWS: Mention new "queue-signal" command.
	* infcmd.c (queue_signal_command): New function.
	(_initialize_infcmd): Add new queue-signal command.

gdb/doc/ChangeLog:

	* gdb.texinfo (Signaling): Document new queue-signal command.

gdb/testsuite/ChangeLog:

	* gdb.threads/queue-signal.c: New file.
	* gdb.threads/queue-signal.exp: New file.
2014-09-13 21:44:00 -07:00
Doug Evans d36bf488d8 * linux-nat.c (wait_lwp): Add debugging printf.
(linux_nat_wait_1): Ditto.
2014-09-13 16:00:13 -07:00
Doug Evans 3714cea7d4 Pass plain-text prompt to with_gdb_prompt.
I had occasion to use with_gdb_prompt in a test for the patch for PR 17314
and was passing the plain text prompt as the value, "(top-gdb)",
instead of a regexp, "\(top-gdb\)" (expressed as "\\(top-gdb\\)" in TCL).

I then discovered that in order to restore the prompt gdb passes the
original value of $gdb_prompt to "set prompt", which works because
"set prompt \(gdb\) " is equivalent to "set prompt (gdb) ".
Perhaps I'm being overly cautious but this feels a bit subtle,
but at any rate as an API choice I'd much rather pass the plain text
form to with_gdb_prompt.

I also discovered that the initial value of gdb_prompt is set in
two places to two different values.
At the global level gdb.exp sets it to "\[(\]gdb\[)\]"
and default_gdb_init sets it to "\\(gdb\\)".
The former form is undesirable as an argument to "set prompt",
but it's not clear to me that just deleting this code won't break
anything.  Thus I just changed the value to be consistent and added
a comment.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_prompt): Add comment and change initial value to
	be consistent with what default_gdb_init uses.
	(with_gdb_prompt): Change form of PROMPT argument from a regexp to
	the plain text of the prompt.  Add some logging printfs.
	* gdb.perf/disassemble.exp: Update call to with_gdb_prompt.
2014-09-13 15:52:15 -07:00
Pedro Alves fa43b1d7ca after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_test
See:
  https://sourceware.org/ml/gdb-patches/2014-09/msg00404.html

We have a number of places that do gdb_run_cmd followed by gdb_expect,
when it would be better to use gdb_test_multiple or gdb_test.

This converts all that "grep gdb_run_cmd -A 2 | grep gdb_expect"
found.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/testsuite/
2014-09-12  Pedro Alves  <palves@redhat.com>

	* gdb.arch/gdb1558.exp: Replace uses of gdb_expect after
	gdb_run_cmd with gdb_test_multiple or gdb_test throughout.
	* gdb.arch/i386-size-overlap.exp: Likewise.
	* gdb.arch/i386-size.exp: Likewise.
	* gdb.arch/i386-unwind.exp: Likewise.
	* gdb.base/a2-run.exp: Likewise.
	* gdb.base/break.exp: Likewise.
	* gdb.base/charset.exp: Likewise.
	* gdb.base/chng-syms.exp: Likewise.
	* gdb.base/commands.exp: Likewise.
	* gdb.base/dbx.exp: Likewise.
	* gdb.base/find.exp: Likewise.
	* gdb.base/funcargs.exp: Likewise.
	* gdb.base/jit-simple.exp: Likewise.
	* gdb.base/reread.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.
	* gdb.base/step-bt.exp: Likewise.
	* gdb.cp/mb-inline.exp: Likewise.
	* gdb.cp/mb-templates.exp: Likewise.
	* gdb.objc/basicclass.exp: Likewise.
	* gdb.threads/killed.exp: Likewise.
2014-09-12 22:16:31 +01:00
Pedro Alves f37f681c2b [IRIX] eliminate deprecated_insert_raw_breakpoint uses
The IRIX support wants to set a breakpoint to be hit when the startup
phase is complete, which is where shared libraries have been mapped
in.  AFAIU, for most IRIX ports, that location is the entry point.

For MIPS IRIX however, GDB needs to set a breakpoint earlier, in
__dbx_link, as explained by:

 #ifdef SYS_syssgi
   /* On mips-irix, we need to stop the inferior early enough during
      the startup phase in order to be able to load the shared library
      symbols and insert the breakpoints that are located in these shared
      libraries.  Stopping at the program entry point is not good enough
      because the -init code is executed before the execution reaches
      that point.

      So what we need to do is to insert a breakpoint in the runtime
      loader (rld), more precisely in __dbx_link().  This procedure is
      called by rld once all shared libraries have been mapped, but before
      the -init code is executed.  Unfortuantely, this is not straightforward,
      as rld is not part of the executable we are running, and thus we need
      the inferior to run until rld itself has been mapped in memory.

      For this, we trace all syssgi() syscall exit events.  Each time
      we detect such an event, we iterate over each text memory maps,
      get its associated fd, and scan the symbol table for __dbx_link().
      When found, we know that rld has been mapped, and that we can insert
      the breakpoint at the symbol address.  Once the dbx_link() breakpoint
      has been inserted, the syssgi() notifications are no longer necessary,
      so they should be canceled.  */
   proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
 #endif

The loop in irix_solib_create_inferior_hook then runs until whichever
breakpoint is hit first, the one set by solib-irix.c or the one set by
procfs.c.

Note the comment in disable_break talks about __dbx_init, but I think
that's a typo for __dbx_link:

 -  /* Note that it is possible that we have stopped at a location that
 -     is different from the location where we inserted our breakpoint.
 -     On mips-irix, we can actually land in __dbx_init(), so we should
 -     not check the PC against our breakpoint address here.  See procfs.c
 -     for more details.  */

This looks very much like referring to the loop in
irix_solib_create_inferior_hook stopping at __dbx_link instead of at
the entry point.

What this patch does is convert these deprecated raw breakpoints to
standard solib_event breakpoints.  When the first solib-event
breakpoint is hit, we delete all solib-event breakpoints.  We do that
in the so_ops->handle_event hook.

This allows getting rid of the loop in irix_solib_create_inferior_hook
completely, which should allow properly handling signals and other
events in the early startup phase, like in SVR4.

Built on x86_64 Fedora 20 with --enable-targets=all (builds
solib-irix.c).

Joel tested that with an earlier version of this patch "info shared"
after starting a program gave the same list of shared libraries as
before.

gdb/ChangeLog:
2014-09-12  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (remove_solib_event_breakpoints_at_next_stop)
	(create_and_insert_solib_event_breakpoint): New functions.
	* breakpoint.h (create_and_insert_solib_event_breakpoint)
	(remove_solib_event_breakpoints_at_next_stop): New declarations.
	* procfs.c (dbx_link_bpt_addr, dbx_link_bpt): Delete globals.
	(remove_dbx_link_breakpoint): Delete function.
	(insert_dbx_link_bpt_in_file): Use
	create_and_insert_solib_event_breakpoint instead of
	deprecated_insert_raw_breakpoint.
	(procfs_wait): Don't check whether we hit __dbx_link here.
	(procfs_mourn_inferior): Don't delete the __dbx_link breakpoint
	here.
	* solib-irix.c (base_breakpoint): Delete global.
	(disable_break): Delete function.
	(enable_break): Use create_solib_event_breakpoint
	instead of deprecated_insert_raw_breakpoint.
	(irix_solib_handle_event): New function.
	(irix_solib_create_inferior_hook): Don't run the target or disable
	the mapping-complete breakpoint here.
	(_initialize_irix_solib): Install irix_solib_handle_event as
	so_ops->handle_event hook.
2014-09-12 20:02:01 +01:00
Edjunior Barbosa Machado 9d9bf2df89 PR tdep/17379: Fix internal-error when stack pointer is invalid.
The problem is that rs6000_frame_cache attempts to read the stack backchain via
read_memory_unsigned_integer, which throws an exception if the stack pointer is
invalid.  With this patch, it calls safe_read_memory_integer instead, which
doesn't throw an exception and allows for safe handling of that situation.

gdb/ChangeLog
2014-09-12  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
	    Ulrich Weigand  <uweigand@de.ibm.com>

	PR tdep/17379
	* rs6000-tdep.c (rs6000_frame_cache): Use safe_read_memory_integer
	instead of read_memory_unsigned_integer.

gdb/testcase/ChangeLog
2014-09-12  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	PR tdep/17379
	* gdb.arch/powerpc-stackless.S: New file.
	* gdb.arch/powerpc-stackless.exp: New file.
2014-09-12 09:20:25 -03:00
Jan Kratochvil 1cf2f1b045 testsuite: Fix runaway attach processes
I have started seeing occasional runaway 'attach' processes these days.
I cannot be certain it is really caused by this patch, for example
grep 'FAIL.*cmdline attach run' does not show anything in my logs.

But as I remember this 'attach' runaway process always happened in GDB (but
I do not remember it in the past months) I think it would be most safe to just
solve it forever by [attached].

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

	* gdb.base/attach.c: Include unistd.h.
	(main): Call alarm.  Add label postloop.
	* gdb.base/attach.exp (do_attach_tests): Use gdb_get_line_number,
	gdb_breakpoint, gdb_continue_to_breakpoint.
	(test_command_line_attach_run): Kill ${testpid} in one exit path.
2014-09-12 13:39:04 +02:00
Gary Benson b006a80e5f Clarify GDBSERVER use in linux-waitpid.c
This commit makes linux-waitpid.c include common-defs.h.  GDB's
inclusion of defs.h is removed, but gdbserver's inclusion of
server.h remains to support some gdbserver-specific debug code
that cannot presently be merged.  A new FIXME documents this.

gdb/ChangeLog:

	* nat/linux-waitpid.c: Include common-defs.h.
	[GDBSERVER]: Add FIXME comment.
	[!GDBSERVER]: Don't include defs.h or signal.h.
	(linux_debug) [!GDBSERVER]: Remove empty block.
2014-09-12 11:03:49 +01:00
Gary Benson 296b1496f7 Remove GDBSERVER uses from x86-dregs.c
This commit makes nat/x86-dregs.c include common-defs.h rather than
defs.h or server.h.  An extra header required including in order to
support this change.

gdb/ChangeLog:

	* nat/x86-dregs.c: Include common-defs.h and break-common.h.
	Don't include defs.h or server.h.
2014-09-12 10:11:42 +01:00
Gary Benson 53f8136297 Remove GDBSERVER uses from linux-btrace.c
This commit makes nat/linux-btrace.c include common-defs.h rather
than defs.h or server.h.  A couple of minor changes were required
to support this change.

gdb/ChangeLog:

	* nat/linux-btrace.c: Include common-defs.h.
	Don't include defs.h, server.h or gdbthread.h.
	* nat/linux-btrace.h (struct target_ops): New forward declaration.
2014-09-12 10:11:42 +01:00
Gary Benson 727605ca75 Include common-defs.h instead of defs.h/server.h in shared code
This commit makes 19 of the 22 shared .c files in common, nat and
target include common-defs.h instead of defs.h/server.h.  The
remaining three files need slight extra work and are dealt with
in separate commits.

gdb/ChangeLog:

	* common/agent.c: Include common-defs.h.
	Don't include defs.h or server.h.
	* common/buffer.c: Likewise.
	* common/common-debug.c: Likewise.
	* common/common-utils.c: Likewise.
	* common/errors.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/format.c: Likewise.
	* common/gdb_vecs.c: Likewise.
	* common/print-utils.c: Likewise.
	* common/ptid.c: Likewise.
	* common/rsp-low.c: Likewise.
	* common/signals.c: Likewise.
	* common/vec.c: Likewise.
	* common/xml-utils.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-procfs.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* target/waitstatus.c: Likewise.
2014-09-12 10:11:42 +01:00
Gary Benson 361c8ade9c Introduce common-regcache.h
This introduces common-regcache.h.  This contains two functions that
allow nat/linux-btrace.c to be simplified.  A better long term
solution would be unify the regcache code, but this is sufficient for
now.

gdb/ChangeLog:

	* common/common-regcache.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/common-regcache.h.
	* regcache.h: Include common-regcache.h.
	(regcache_read_pc): Don't declare.
	* regcache.c (get_thread_regcache_for_ptid): New function.
	* nat/linux-btrace.c: Don't include regcache.h.
	Include common-regcache.h.
	(perf_event_read_bts): Use get_thread_regcache_for_ptid.

gdb/gdbserver/ChangeLog:

	* regcache.h: Include common-regcache.h.
	(regcache_read_pc): Don't declare.
	* regcache.c (get_thread_regcache_for_ptid): New function.
2014-09-12 10:11:42 +01:00
Thomas Schwinge a01cbb490b Make gdb/regcache.h self-contained.
gdb/
	* regcache.h (struct regset): Declare.

Commit 0b3092721e added uses of struct regset to
gdb/regcache.h, but that struct is not declared in this file, and, as it
happens, also nowhere else in the #include chain on x86 GNU/Hurd.  This results
in warnings/errors such as:

    gcc-4.8 [...] ../../W._C._Handy/gdb/gdb.c
    In file included from ./nm.h:25:0,
                     from ../../W._C._Handy/gdb/defs.h:454,
                     from ../../W._C._Handy/gdb/gdb.c:19:
    ../../W._C._Handy/gdb/regcache.h:190:9: warning: 'struct regset' declared inside parameter list [enabled by default]
             size_t size);
             ^
    ../../W._C._Handy/gdb/regcache.h:190:9: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
    ../../W._C._Handy/gdb/regcache.h:193:10: warning: 'struct regset' declared inside parameter list [enabled by default]
              int regnum, void *buf, size_t size);
              ^
2014-09-11 22:39:01 +02:00
Pedro Alves 98880d46bd gdb/17347 - Regression: GDB stopped on run with attached process
Doing:

  gdb --pid=PID -ex run

Results in GDB getting a SIGTTIN, and thus ending stopped.  That's
usually indicative of a missing target_terminal_ours call.

E.g., from the PR:

 $ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run
 [1] 28263
 [1]   Killed                  sleep 1h

 [2]+  Stopped                 gdb -batch sleep $p -ex run

The workaround is doing:

 gdb -ex "attach $PID" -ex "run"

instead of

 gdb [-p] $PID -ex "run"

With the former, gdb waits for the attach command to complete before
moving on to the "run" command, because the interpreter is in sync
mode at this point, within execute_command.  But for the latter,
attach_command is called directly from captured_main, and thus misses
that waiting.  IOW, "run" is running before the attach continuation
has run, before the program stops and attach completes.  The broken
terminal settings are just one symptom of that.  Any command that
queries or requires input results in the same.

The fix is to wait in catch_command_errors (which is specific to
main.c nowadays), just like we wait in execute_command.

gdb/ChangeLog:
2014-09-11  Pedro Alves  <palves@redhat.com>

	PR gdb/17347
	* main.c: Include "infrun.h".
	(catch_command_errors, catch_command_errors_const): Wait for the
	foreground command to complete.
	* top.c (maybe_wait_sync_command_done): New function, factored out
	from ...
	(maybe_wait_sync_command_done): ... here.
	* top.h (maybe_wait_sync_command_done): New declaration.

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

	PR gdb/17347
	* lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure.
	* gdb.base/attach.exp (test_command_line_attach_run): New
	procedure.
	(top level): Call it.
2014-09-11 13:08:21 +01:00
Pedro Alves 4c92ff2c35 testsuite: refactor spawn and wait for attach
Several places in the testsuite have a copy of a snippet of code that
spawns a test program, waits a bit, and then does some PID munging for
Cygwin.  This is in order to have GDB attach to the spawned program.

This refactors all that to a common procedure.

(multi-attach.exp wants to spawn multiple processes, so this makes the
new procedure's interface work with lists.)

Tested on x86_64 Fedora 20.

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

	* lib/gdb.exp (spawn_wait_for_attach): New procedure.
	* gdb.base/attach.exp (do_attach_tests, do_call_attach_tests)
	(do_command_attach_tests): Use spawn_wait_for_attach.
	* gdb.base/solib-overlap.exp: Likewise.
	* gdb.multi/multi-attach.exp: Likewise.
	* gdb.python/py-prompt.exp: Likewise.
	* gdb.python/py-sync-interp.exp: Likewise.
	* gdb.server/ext-attach.exp: Likewise.
2014-09-11 13:04:14 +01:00
Gary Benson bd9269f70c Introduce common/symbol.h
This introduces common/symbol.h.  This file declares a function that
the shared code can use and that the clients must implement.  It also
changes some shared code to use these functions.

gdb/ChangeLog:

	* common/symbol.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/symbol.h.
	* minsyms.c (find_minimal_symbol_address): New function.
	* common/agent.c: Include common/symbol.h.
	[!GDBSERVER]: Don't include objfiles.h.
	(agent_look_up_symbols): Use find_minimal_symbol_address.

gdb/gdbserver/ChangeLog:

	* symbol.c: New file.
	* Makefile.in (SFILES): Add symbol.c.
	(OBS): Add symbol.o.
2014-09-11 11:43:21 +01:00
Gary Benson f8c1d06b82 Introduce target_{stop,continue}_ptid
This commit introduces two new functions to stop and restart target
processes that shared code can use and that clients must implement.
It also changes some shared code to use these functions.

gdb/ChangeLog:

	* target/target.h (target_stop_ptid, target_continue_ptid):
	Declare.
	* target.c (target_stop_ptid, target_continue_ptid): New
	functions.
	* common/agent.c [!GDBSERVER]: Don't include infrun.h.
	(agent_run_command): Always use target_stop_ptid and
	target_continue_ptid.

gdb/gdbserver/ChangeLog:

	* target.c (target_stop_ptid, target_continue_ptid): New
	functions.
2014-09-11 11:19:56 +01:00
Gary Benson 721ec300e1 Introduce target/target.h
This introduces target/target.h.  This file declares some functions
that the shared code can use and that clients must implement.  It also
changes some shared code to use these functions.

gdb/ChangeLog:

	* target/target.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add target/target.h.
	* target.h: Include target/target.h.
	(target_read_memory, target_write_memory): Don't declare.
	* target.c (target_read_uint32): New function.
	* common/agent.c: Include target/target.h.
	[!GDBSERVER]: Don't include target.h.
	(helper_thread_id): Type changed to uint32_t.
	(agent_get_helper_thread_id): Use target_read_uint32.
	(agent_run_command): Always use target_read_memory and
	target_write_memory.
	(agent_capability): Type changed to uint32_t.
	(agent_capability_check): Use target_read_uint32.

gdb/gdbserver/ChangeLog:

	* target.h: Include target/target.h.
	* target.c (target_read_memory, target_read_uint32)
	(target_write_memory): New functions.
2014-09-11 11:19:56 +01:00
Gary Benson c5e92cca56 Introduce show_debug_regs
This commit adds a new global flag show_debug_regs to common-debug.h
to replace the flag debug_hw_points used by gdbserver and by the
Linux x86 and AArch64 ports, and to replace the flag maint_show_dr
used by the Linux MIPS port.

Note that some debug printing in the AArch64 port was enabled only if
debug_hw_points > 1 but no way to set debug_hw_points to values other
than 0 and 1 was provided; that code was effectively dead.  This
commit enables all debug printing if show_debug_regs is nonzero, so
the AArch64 output will be more verbose than previously.

gdb/ChangeLog:

	* common/common-debug.h (show_debug_regs): Declare.
	* common/common-debug.c (show_debug_regs): Define.
	* aarch64-linux-nat.c (debug_hw_points): Don't define.  Replace
	all uses with show_debug_regs.  Replace all uses that considered
	debug_hw_points as a multi-value integer with straight boolean
	uses.
	* x86-nat.c (debug_hw_points): Don't define.  Replace all uses
	with show_debug_regs.
	* nat/x86-dregs.c (debug_hw_points): Don't declare.  Replace
	all uses with show_debug_regs.
	* mips-linux-nat.c (maint_show_dr): Don't define.  Replace all
	uses with show_debug_regs.

gdb/gdbserver/ChangeLog:

	* server.h (debug_hw_points): Don't declare.
	* server.c (debug_hw_points): Don't define.  Replace all uses
	with show_debug_regs.
	* linux-aarch64-low.c (debug_hw_points): Don't define.  Replace
	all uses with show_debug_regs.
2014-09-11 11:19:56 +01:00
Gabriel Krisman Bertazi 3adc1a7d45 Fix gdb.fortran/array-element.exp failures.
This fixes two FAIL results on this testcase which were caused by a
misplaced "continue" command.  This testcase used to end inferior's
execution too soon, causing the following tests to fail.  Now we break
right after inferior's loop and perform the rest of the tests there.

gdb/testsuite/ChangeLog:

	* gdb.fortran/array-element.exp: Remove unexpected "continue"
	command in testcase.  Simplify testcase.
2014-09-11 00:14:39 -03:00
Ulrich Weigand eeef931a6a Support gdbarch_convert_register_p targets in address_from_register
Since the last change to address_from_register, it no longer supports
targets that require a special conversion (gdbarch_convert_register_p)
for plain pointer type; I had assumed no target does so.

This turned out to be incorrect: MIPS64 n32 big-endian needs such a
conversion in order to properly sign-extend pointer values.

This patch fixes this regression by handling targets that need a
special conversion in address_from_register as well.

gdb/ChangeLog:

	* findvar.c (address_from_register): Handle targets requiring
	a special conversion routine even for plain pointer types.
2014-09-10 19:01:26 +02:00
Ulrich Weigand 8efa985582 AIX: Remove exec_one_dummy_insn hack
Old AIX versions required GDB to update the stack pointer register and
execute at least one instruction before accessing the space newly allocated
on the user stack.  This was done using the exec_one_dummy_insn routine
in rs6000-nat.c

However, in currently supported AIX versions (tested on AIX 6.1), this hack
is no longer necessary.  In fact, removing the hack actually fixed several
test case failures, and removes a call to deprecated_insert_raw_breakpoint.

gdb/ChangeLog:

	* rs6000-nat.c (exec_one_dummy_insn): Remove.
	(store_register): Do not call exec_one_dummy_insn.
2014-09-10 15:59:33 +02:00
Joel Brobecker 963349348e dynarr-ptr.exp: Add ptype tests.
This patch adds a number of "ptype" tests to gdb.dwarf2/dynarr-ptr.exp.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/dynarr-ptr.exp: Add a few ptype tests.
2014-09-10 06:33:25 -07:00
Joel Brobecker eb47903935 Ada: Print bounds/length of pointer to array with dynamic bounds
Trying to print the bounds or the length of a pointer to an array
whose bounds are dynamic results in the following error:

    (gdb) p foo.three_ptr.all'first
    Location address is not set.
    (gdb) p foo.three_ptr.all'length
    Location address is not set.

This is because, after having dereferenced our array pointer, we
use the type of the resulting array value, instead of the enclosing
type.  The former is the original type where the bounds are unresolved,
whereas we need to get the actual array bounds.

Similarly, trying to apply those attributes to the array pointer
directly (without explicitly dereferencing it with the '.all'
operator) yields the same kind of error:

    (gdb) p foo.three_ptr'first
    Location address is not set.
    (gdb) p foo.three_ptr'length
    Location address is not set.

This is caused by the fact that the dereference was done implicitly
in this case, and perform at the type level only, which is not
sufficient in order to resolve the array type.

This patch fixes both issues, thus allowing us to get the expected output:

    (gdb) p foo.three_ptr.all'first
    $1 = 1
    (gdb) p foo.three_ptr.all'length
    $2 = 3
    (gdb) p foo.three_ptr'first
    $3 = 1
    (gdb) p foo.three_ptr'length
    $4 = 3

gdb/ChangeLog:

        * ada-lang.c (ada_array_bound): If ARR is a TYPE_CODE_PTR,
        dereference it first.  Use value_enclosing_type instead of
        value_type.
        (ada_array_length): Likewise.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/dynarr-ptr.exp: Add 'first, 'last and 'length tests.
2014-09-10 06:32:00 -07:00
Joel Brobecker deede10c77 Ada subscripting of pointer to array with dynamic bounds
Consider a pointer to an array which dynamic bounds, described in
DWARF as follow:

        <1><25>: Abbrev Number: 4 (DW_TAG_array_type)
           <26>   DW_AT_name        : foo__array_type
        [...]
        <2><3b>: Abbrev Number: 5 (DW_TAG_subrange_type)
           [...]
           <40>   DW_AT_lower_bound : 5 byte block: 97 38 1c 94 4
                  (DW_OP_push_object_address; DW_OP_lit8; DW_OP_minus;
                   DW_OP_deref_size: 4)
           <46>   DW_AT_upper_bound : 5 byte block: 97 34 1c 94 4
                  (DW_OP_push_object_address; DW_OP_lit4; DW_OP_minus;
                   DW_OP_deref_size: 4)

GDB is now able to correctly print the entire array, but not one
element of the array. Eg:

    (gdb) p foo.three_ptr.all
    $1 = (1, 2, 3)
    (gdb) p foo.three_ptr.all(1)
    Cannot access memory at address 0xfffffffff4123a0c

The problem occurs because we are missing a dynamic resolution of
the variable's array type when subscripting the array. What the current
code does is "fix"-ing the array type using the GNAT encodings, but
that operation ignores any of the array's dynamic properties.

This patch fixes the issue by using ada_value_ind to dereference
the array pointer, which takes care of the array type resolution.
It also continues to "fix" arrays described using GNAT encodings,
so backwards compatibility is preserved.

gdb/ChangeLog:

        * ada-lang.c (ada_value_ptr_subscript): Remove parameter "type".
        Adjust function implementation and documentation accordingly.
        (ada_evaluate_subexp) <OP_FUNCALL>: Only assign "type" if
        NOSIDE is EVAL_AVOID_SIDE_EFFECTS.
        Update call to ada_value_ptr_subscript.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/dynarr-ptr.exp: Add subscripting tests.
2014-09-10 06:30:58 -07:00
Joel Brobecker 7828a5f5fa print PTR.all where PTR is an Ada thin pointer
Consider the following declaration:

   type Array_Type is array (Natural range <>) of Integer;
   type Array_Ptr is access all Array_Type;
   for Array_Ptr'Size use 64;
   Three_Ptr : Array_Ptr := new Array_Type'(1 => 1, 2 => 2, 3 => 3);

This creates a pointer to an array where the bounds are stored
in a memory region just before the array itself (aka a "thin pointer").
In DWARF, this is described as a the usual pointer type to an array
whose subrange has dynamic values for its bounds:

    <1><25>: Abbrev Number: 4 (DW_TAG_array_type)
       <26>   DW_AT_name        : foo__array_type
    [...]
    <2><3b>: Abbrev Number: 5 (DW_TAG_subrange_type)
       [...]
       <40>   DW_AT_lower_bound : 5 byte block: 97 38 1c 94 4
              (DW_OP_push_object_address; DW_OP_lit8; DW_OP_minus;
               DW_OP_deref_size: 4)
       <46>   DW_AT_upper_bound : 5 byte block: 97 34 1c 94 4
              (DW_OP_push_object_address; DW_OP_lit4; DW_OP_minus;
               DW_OP_deref_size: 4)

GDB is currently printing the value of the array incorrectly:

    (gdb) p foo.three_ptr.all
    $1 = (26629472 => 1, 2,
    value.c:819: internal-error: value_contents_bits_eq: [...]

The dereferencing (".all" operator) is done by calling ada_value_ind,
which itself calls value_ind. It first produces a new value where
the bounds of the array were correctly resolved to their actual value,
but then calls readjust_indirect_value_type which replaces the resolved
type by the original type.

The problem starts when ada_value_print does not take this situation
into account, and starts using the type of the resulting value, which
has unresolved array bounds, instead of using the value's enclosing
type.

After fixing this issue, the debugger now correctly prints:

    (gdb) p foo.three_ptr.all
    $1 = (1, 2, 3)

gdb/ChangeLog:

        * ada-valprint.c (ada_value_print): Use VAL's enclosing type
        instead of VAL's type.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/dynarr-ptr.c: New file.
        * gdb.dwarf2/dynarr-ptr.exp: New file.
2014-09-10 06:24:25 -07:00
Joel Brobecker 35782f1465 Add <sys/uio.h> #include back in amd64-linux-nat.c.
This include is needed to access the definition of "struct iovec".

gdb/ChangeLog:

        * amd64-linux-nat.c: Add <sys/uio.h> #include.
2014-09-10 06:11:26 -07:00
Doug Evans d342a0da4f PR guile/17367
gdb/ChangeLog:

	* acinclude.m4 (GDB_GUILE_PROGRAM_NAMES): Pass guile version as
	last parameter to pkg-config, not first.
	* configure.ac: Pass --with-guile provided pkg-config path to
	GDB_GUILE_PROGRAM_NAMES.
	* configure: Regenerate.
2014-09-09 21:18:25 -07:00
Gabriel Krisman Bertazi b4a3d263b0 Add myself as write-after-approval GDB maintainer.
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Add "Gabriel Krisman
	Bertazi".
2014-09-10 00:05:35 -03:00
Maciej W. Rozycki 6e46637421 MIPS: Don't infer IRIX OS ABI from generic section names
There are `.MIPS.abiflags', `.MIPS.options' and `.MIPS.stubs' sections
also present in Linux executables, so we can't infer IRIX OS ABI solely
from the existence of these sections.  This is not going to be a problem
as there are bound to be other sections whose names start with `.MIPS.'
in IRIX executables and this selection only matters for a non-default OS
ABI in a multiple-target GDB executable.  As a last resort the automatic
selection can be overridden with `set osabi'.

	* mips-irix-tdep.c (mips_irix_elf_osabi_sniff_abi_tag_sections):
	Exclude `.MIPS.abiflags', `.MIPS.options' and `.MIPS.stubs' from
	the list of sections determining GDB_OSABI_IRIX.
2014-09-10 00:02:02 +01:00
James Hogan a1ada89ac6 Add myself as write-after-approval GDB maintainer
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Add "James Hogan".
2014-09-09 21:59:34 +01:00
Maciej W. Rozycki 33aeebcf58 GDB/testsuite: Correct gdb.base/watchpoint-solib.exp timeout tweak
Similarly to the previous changes to gdb.reverse/sigall-reverse.exp and
gdb.reverse/until-precsave.exp this corrects the timeout tweak in
gdb.base/watchpoint-solib.exp.

This test case executes a large amount of code with a software watchpoint
enabled.  This means single-stepping all the way through and takes a lot
of time, e.g. for an ARMv7 Panda board and a `-march=armv5te' multilib:

PASS: gdb.base/watchpoint-solib.exp: continue to foo again
elapsed: 714

for the same board and a `-mthumb -march=armv5te' multilib:

PASS: gdb.base/watchpoint-solib.exp: continue to foo again
elapsed: 1275

and for QEMU in the system emulation mode and a `-march=armv4t'
multilib:

PASS: gdb.base/watchpoint-solib.exp: continue to foo again
elapsed: 115

(values in seconds) -- all of which having the default timeout of 60s,
set based on the requirement of the remaining test cases (other than
gdb.reverse ones).

Here again the timeout extension to have a meaning should be calculated
by scaling rather than using an arbitrary constant, and a larger factor
of 30 will do, leaving some margin.  Hopefully for everyone or otherwise
we'll probably have to come up with a smarter solution.

OTOH the other test cases in this script do not require the extension so
they can be moved outside its umbrella so as to avoid unnecessary delays
if something goes wrong and a genuine timeout triggers.

	* gdb.base/watchpoint-solib.exp: Increase the timeout by a factor
	of 30 rather than hardcoding 120 for a slow test case.  Take the
	`gdb,timeout' target setting into account for this calculation.
	Don't extend the timeout for the test cases that don't need it.
2014-09-09 17:39:17 +01:00
Maciej W. Rozycki 7b4159018e GDB/testsuite: Add/correct gdb.reverse timeout tweaks
There are three cases in two scripts in the gdb.reverse subset that
take a particularly long time.  Two of them are already attempted to
take care of by extending the timeout from the default.  The remaining
one has no precautions taken.  The timeout extension is ineffective
though, it is done by adding a constant rather than by scaling and as
a result while it may work for target boards that get satisfied with
the detault test timeout of 10s, it does not serve its purpose for
slower ones.

Here are indicative samples of execution times (in seconds) observed
for these cases respectively, for an ARMv7 Panda board running Linux
and a `-march=armv5te' multilib:

PASS: gdb.reverse/sigall-reverse.exp: continue to signal exit
elapsed: 385
PASS: gdb.reverse/until-precsave.exp: run to end of main
elapsed: 4440
PASS: gdb.reverse/until-precsave.exp: save process recfile
elapsed: 965

for the same board and a `-mthumb -march=armv5te' multilib:

PASS: gdb.reverse/sigall-reverse.exp: continue to signal exit
elapsed: 465
PASS: gdb.reverse/until-precsave.exp: run to end of main
elapsed: 4191
PASS: gdb.reverse/until-precsave.exp: save process recfile
elapsed: 669

and for QEMU in the system emulation mode and a `-march=armv4t'
multilib:

PASS: gdb.reverse/sigall-reverse.exp: continue to signal exit
elapsed: 45
PASS: gdb.reverse/until-precsave.exp: run to end of main
elapsed: 433
PASS: gdb.reverse/until-precsave.exp: save process recfile
elapsed: 104

Based on the performance of other tests these two test configurations
have their default timeout set to 450s and 60s respectively.

The remaining two multilibs (`-mthumb -march=armv4t' and `-mthumb
-march=armv7-a') do not produce test results usable enough to have data
available for these cases.

 Based on these results I have tweaked timeouts for these cases as
follows.  This, together with a suitable board timeout setting, removes
timeouts for these cases.  Note that for the default timeout of 10s the
new setting for the first case in gdb.reverse/until-precsave.exp is
compatible with the old one, just a bit higher to keep the convention
of longer timeouts to remain multiples of 30s.  The second case there
does not need such a high setting so I have lowered it a bit to avoid
an unnecessary delay where this test case genuinely times out.

	* gdb.reverse/sigall-reverse.exp: Increase the timeout by
	a factor of 2 for a slow test case.  Take the `gdb,timeout'
	target setting into account for this calculation.
	* gdb.reverse/until-precsave.exp: Increase the timeout by
	a factor of 15 and 3 respectively rather than adding 120
	for a pair of slow test cases.  Take the `gdb,timeout'
	target setting into account for this calculation.
2014-09-09 17:03:24 +01:00
Maciej W. Rozycki 4a40f85a84 GDB/testsuite: Avoid timeout lowering
The recent change to introduce `gdb_reverse_timeout' turned out
ineffective for board setups that set the `gdb,timeout' target variable.
A lower `gdb,timeout' setting takes precedence and defeats the effect of
`gdb_reverse_timeout'.  This is because the global timeout is overridden
in gdb_test_multiple and then again in gdb_expect.

Three timeout variables are taken into account in these two places, in
this precedence:

1. The `gdb,timeout' target variable.

2. The caller's local `timeout' variable (upvar timeout)

3. The global `timeout' variable.

This precedence is obeyed by gdb_test_multiple strictly.  OTOH
gdb_expect will select the higher of the two formers and will only take
the latter into account if none of the formers is present.  However the
two timeout selections are conceptually the same and gdb_test_multiple
does its only for the purpose of passing it down to gdb_expect.

Therefore I decided there is no point to keep carrying on this
duplication and removed the sequence from gdb_test_multiple, however
retaining the `upvar timeout' variable definition.  This way gdb_expect
will still access gdb_test_multiple's caller `timeout' variable (if any)
via its own `upvar timeout' reference.

Now as to the sequence in gdb_expect.  In addition to the three
variables described above it also takes a timeout argument into account,
as the fourth value to choose from.  It is currently used if it is
higher than the timeout selected from the variables as described above.

With the timeout selection code from gdb_test_multiple gone, gone is
also the most prominent use of this timeout argument, it's now used in
a couple of places only, mostly within this test framework library code
itself for preparatory commands or suchlike.  With this being the case
this timeout selection code can be simplified as follows:

1. Among the three timeout variables, the highest is always chosen.
   This is so that a test case doesn't inadvertently lower a high value
   timeout needed by slow target boards.  This is what all test cases
   use.

2. Any timeout argument takes precedence.  This is for special cases
   such as within the framework library code, e.g. it doesn't make sense
   to send `set height 0' with a timeout of 7200 seconds.  This is a
   local command that does not interact with the target and setting a
   high timeout here only risks a test suite run taking ages if it goes
   astray for some reason.

3. The fallback timeout of 60s remains.

	* lib/gdb.exp (gdb_test_multiple): Remove code to select the
	timeout, don't pass one down to gdb_expect.
	(gdb_expect): Rework timeout selection.
2014-09-09 16:51:00 +01:00
James Hogan 86db008d5a Remove trad_frame_set_reg_unknown declaration
The trad_frame_set_reg_unknown declaration was added in commit
0db9b4b709 (March 2004), but apparently never defined or referenced.

gdb/ChangeLog:

	* trad-frame.h (trad_frame_set_reg_unknown): Remove declaration.
2014-09-09 08:41:45 -07:00
Maciej W. Rozycki 09635af7cd gdbserver-support: Handle gdbserver start failures
As it happens we have a board that fails a gdb.base/gcore-relro.exp
test case reproducibly and moreover the case appears to trigger a
kernel bug making the it less than usable.  Specifically the board
remains responsive to some extent, however processes do not appear
to be able to successfully complete termination anymore and perhaps
more importantly further gdbserver processes can be started, but they
never reach the stage of listening on the RSP socket.

This change handles timeouts in gdbserver start properly, by throwing
a TCL error exception when gdbserver does not report listening on the
RSP socket in time.  This is then caught at the outer level and
reported, and 2 rather than 1 is returned so that the caller may tell
the failure to start gdbserver and other issues apart and act
accordingly (or do nothing).

I thought letting the exception unwind further on might be a good idea
for any test harnesses out there to break outright where a gdbserver
start error is silently ignored right now, however I figured out the
calls to gdbserver-support.exp are buried down too deep in the GDB test
suite for such a change to be made easily.  I think returning a distinct
return value is good enough (the API says "non-zero", so 2 is as good as
1) and we can always make the error harder in a later step if required.

With config/gdbserver.exp being used this change remains transparent
to the target board, the return value is passed up by gdb_reload and
the error exception unwinds through gdbserver_gdb_load and is caught
and handled by mi_gdb_target_load.  A call to perror is still made,
reporting the timeout, and in the case of mi_gdb_target_load the
procedure returns a value denoting unsuccessful completion.  An
unsuccessful completion of gdb_reload is already handled elsewhere.

An alternative gdbserver board configuration can interpret the return
value in its gdb_reload implementation and catch the error in
gdbserver_gdb_load in an attempt to recover a target board that has
gone astray, for example by rebooting the board somehow.  This has
proved effective with our failing board, that now completes the
remaining test cases with no further hiccups.

	* lib/gdbserver-support.exp (gdbserver_start): Throw an error
	exception on timeout.
	(gdbserver_run): Catch any `gdbserver_spawn' error exceptions.
	(gdbserver_start_extended): Catch any `gdbserver_start' error
	exceptions.
	(gdbserver_start_multi, mi_gdbserver_start_multi): Likewise.
	* lib/mi-support.exp (mi_gdb_target_load): Catch any
	`gdbserver_gdb_load' error exceptions.
2014-09-09 16:17:38 +01:00
Maciej W. Rozycki 2bdd10b78e GDB/testsuite: Extend the time gdbserver is waited for
Gdbserver support code uses the global timeout value to determine when
to stop waiting for a gdbserver process being started to respond before
continuing anyway.  This timeout is usually as low as 10s and may not
be enough in this context, for example on the first run where the
filesystem cache is cold, even if it is elsewhere.

E.g. I observe this reliably with gdbserver started the first time in
QEMU running in the system emulation mode:

(gdb) file .../gdb.base/advance
Reading symbols from .../gdb.base/advance...done.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break main
Breakpoint 1 at 0x87f8: file .../gdb.base/advance.c,
line 41.
(gdb) set remotetimeout 15
(gdb) kill
The program is not being run.
(gdb)
[...]
.../bin/gdbserver --once :6014 advance
target remote localhost:6014
Remote debugging using localhost:6014
Remote communication error.  Target disconnected.: Connection reset by peer.
(gdb) continue
The program is not being run.
(gdb) Process advance created; pid = 999
Listening on port 6014
FAIL: gdb.base/advance.exp: Can't run to main

-- notice how the test harness proceeded with the `target remote ...'
command even though gdbserver hasn't completed its startup yet.  A
while later when it's finally ready it's too late already.  I checked
the timing here and it takes gdbserver roughly 25 seconds to start in
this scenario.  Subsequent gdbserver starts in the same test run take
less time and usually complete within 10 seconds although occasionally
`target remote ...' precedes the corresponding `Listening on port...'
message again.

Therefore I have fixed this problem by setting an explicit timeout to
120s on the expect call in question.  If this turns out too arbitrary
sometime, then perhaps a separate `gdbserver_timeout' setting might be
due.

	* lib/gdbserver-support.exp (gdbserver_start): Set timeout to
	120 on waiting for the TCP socket to open.
2014-09-09 16:06:15 +01:00
Joel Brobecker 72fde3dfe9 Fix missing "struct iovec" definition on some x86-linux.
The following patch...

    commit 3116063bd6
    Date:   Fri Jun 27 09:52:29 2014 +0100
    Subject: Tidy #include lists

... introduced a build failure on certain x86 GNU/Linux distributions
(reproduced on SuSE 10 and RHES4) due to "struct iovec" not being
defined. This struct is defined in <sys/uio.h>, which used to be
explicitly included, but no longer is after the commit above was
applied.

    [...]/i386-linux-nat.c: In function 'fetch_xstateregs':
    [...]/i386-linux-nat.c:325:16: error: storage size of 'iov' isn't known
    [...]/i386-linux-nat.c: In function 'store_xstateregs':
    [...]/i386-linux-nat.c:348:16: error: storage size of 'iov' isn't known
    make[2]: *** [i386-linux-nat.o] Error 1

It seems to be working on newer GNU/Linux distros thanks to indirect
inclusion of <sys/uio.h>, but it does not work on some other versions
of the same distros. This is why indirect includes of public APIs
should be avoided if at all possible.

This patch fixes the issue by adding the explicit include back.

gdb/ChangeLog:

        * i386-linux-nat.c, x86-linux-nat.c: Add <sys/uio.h> #include.
2014-09-09 17:01:27 +02:00
Doug Evans 316935f0ad Fix regression in default.exp caused by _caller_is, etc.
gdb/testsuite/ChangeLog:

	* gdb.base/default.exp (show_conv_list): Add _caller_is,
	_caller_matches, _any_caller_is, _any_caller_matches.
2014-09-08 23:01:01 -07:00
Doug Evans 92d8d229d9 Fix for PR 17247: Block SIGCHLD while initializing Guile.
The problem here is that if a thread other than gdb's main thread
gets a SIGCHLD (it's an asynchronous signal so the kernel will
essentially pick a random thread) then gdb will hang if it is
in sigsuspend when the SIGCHLD is delivered.  The other thread
will see the signal and the sigsuspend won't "wake up".

Guile and libgc should be blocking SIGCHLD in their threads,
but we need to work with Guile 2.0 and libgc 7.4.
The problem first shows up in libgc 7.4 because it is the first
release that enables multiple marker threads by default.

gdb/ChangeLog:

	PR 17247
	* guile.c: #include <signal.h>.
	(_initialize_guile): Block SIGCHLD while initializing Guile.

	Replaces the following, which is reverted.

	2014-07-26  Doug Evans  <xdje42@gmail.com>

	PR 17185
	* configure.ac: Add check for header gc/gc.h.
	Add check for function setenv.
	* configure: Regenerate.
	* config.in: Regenerate.
	* guile/guile.c (_initialize_guile): Add workaround for libgc 7.4.0.
2014-09-08 22:45:34 -07:00
Doug Evans 8374059704 gdb.guile/scm-error.exp: Handle guile 2.2 backtrace output.
gdb/testsuite/ChangeLog:

	* gdb.guile/scm-error.exp: Handle guile 2.2 backtrace output.
2014-09-08 22:19:32 -07:00
Doug Evans d81412aa4b Replace use of magic number with named constant.
gdb/ChangeLog:

	* guile/scm-cmd.c (gdbscm_parse_command_name): Replace magic number
	with named constant.  Fix style of pointer comparison.
	* python/py-cmd.c (gdbpy_parse_command_name): Ditto.
2014-09-08 20:47:57 -07:00
Yao Qi 4c122fc315 Set print symbol off in mi-var-display.exp
Hi,
I see the following fail on arm-none-eabi target,

-var-evaluate-expression -f nat foo^M
^done,value="0x3 <_ftext+2>"^M
(gdb) ^M
FAIL: gdb.mi/mi-var-display.exp: eval variable -f nat foo

the "<_ftext+2>" isn't expected in the test, so "set print symbol off"
can prevent printing it.  It is obvious and I'll commit it in three
days if no comments.

gdb/testsuite:

2014-09-09  Yao Qi  <yao@codesourcery.com>

	* gdb.mi/mi-var-display.exp: Set print symbol off.
2014-09-09 09:57:01 +08:00
Edjunior Barbosa Machado 2e4bb98a0e Fix ppc_collect/supply_ptrace_register() routines
This patch fixes the routines to collect and supply ptrace registers on ppc64le
gdbserver. Originally written for big endian arch, they were causing several
issues on little endian. With this fix, the number of unexpected failures in
the testsuite dropped from 263 to 72 on ppc64le.

gdb/gdbserver/ChangeLog

	* linux-ppc-low.c (ppc_collect_ptrace_register): Adjust routine to take
	endianness into account.
	(ppc_supply_ptrace_register): Likewise.
2014-09-08 13:37:23 -03:00
Gabriel Krisman Bertazi a9f116cbf2 Fix PR gdb/17035: "show user" doesn't list user-defined commands that
have empty bodies.

User-defined commands that have empty bodies weren't being shown because
the print function returned too soon.  Now, it prints the command's name
before checking if it has any body at all.  This also fixes the same
problem on "show user <myemptycommand>", which wasn't being printed due
to a similar reason.

gdb/Changelog:

	* cli/cli-cmds.c (show_user): Use cli_user_command_p to
	decide whether we display the command on "show user".
	* cli/cli-script.c (show_user_1): Only verify cmdlines after
	printing command name.
	* cli/cli-decode.h (cli_user_command_p): Declare new function.
	* cli/cli-decode.c (cli_user_command_p): Create helper function
	to verify whether cmd_list_element is a user-defined command.

gdb/testsuite/Changelog:

	* gdb.base/commands.exp: Add tests to verify user-defined
	commands with empty bodies.
	* gdb.python/py-cmd.exp: Test that we don't show user-defined
	python commands in `show user command`.
	* gdb.python/scm-cmd.exp: Test that we don't show user-defined
	scheme commands in `show user command`.
2014-09-07 20:12:19 -03:00
Jan Kratochvil c75bd3a239 Fix crash on Python frame filters with unreadable arg
https://bugzilla.redhat.com/show_bug.cgi?id=1126177

ERROR: AddressSanitizer: SEGV on unknown address 0x000000000050 (pc 0x000000992bef sp 0x7ffff9039530 bp 0x7ffff9039540
T0)
    #0 0x992bee in value_type .../gdb/value.c:925
    #1 0x87c951 in py_print_single_arg python/py-framefilter.c:445
    #2 0x87cfae in enumerate_args python/py-framefilter.c:596
    #3 0x87e0b0 in py_print_args python/py-framefilter.c:968

It crashes because frame_arg::val is documented it may contain NULL
(frame_arg::error is then non-NULL) but the code does not handle it.

Another bug is that py_print_single_arg() calls goto out of its TRY_CATCH
which messes up GDB cleanup chain crashing GDB later.

It is probably 7.7 regression (I have not verified it) due to the introduction
of Python frame filters.

gdb/ChangeLog

	PR python/17355
	* python/py-framefilter.c (py_print_single_arg): Handle NULL FA->VAL.
	Fix goto out of TRY_CATCH.

gdb/testsuite/ChangeLog

	PR python/17355
	* gdb.python/amd64-py-framefilter-invalidarg.S: New file.
	* gdb.python/py-framefilter-invalidarg-gdb.py.in: New file.
	* gdb.python/py-framefilter-invalidarg.exp: New file.
	* gdb.python/py-framefilter-invalidarg.py: New file.
2014-09-07 14:09:59 +02:00
Doug Evans 1a52a81ccd Add missing author to previous entry (PR 15276). 2014-09-06 09:22:57 -07:00
Doug Evans faa42425cb PR 15276: Add $_caller_is, $_caller_matches, $_any_caller_is, $_any_caller_matches
gdb/ChangeLog:

	PR 15276
	* NEWS: Mention $_caller_is, $_caller_matches, $_any_caller_is,
	$_any_caller_matches.
	* data-directory/Makefile.in (PYTHON_FILE_LIST): Add caller_is.py.
	* python/lib/gdb/function/caller_is.py: New file.

gdb/testsuite/ChangeLog:

	PR 15276
	* gdb.python/py-caller-is.c: New file.
	* gdb.python/py-caller-is.exp: New file.

gdb/doc/ChangeLog:

	PR 15276
	* gdb.texinfo (Convenience Funs): Document $_caller_is,
	$_caller_matches, $_any_caller_is, $_any_caller_matches.
2014-09-06 09:15:44 -07:00
Doug Evans 0d41ba00c6 infcmd.c (program_info): Fix typo.
gdb/ChangeLog:

	* infcmd.c (program_info): Fix typo.
2014-09-06 08:24:56 -07:00
Sergio Durigan Junior 474ca4f687 Fix for PR gdb/17235: possible bug extracting systemtap probe operand
This patch is a fix to PR gdb/17235.  The bug is about an unused
variable that got declared and set during one of the parsing phases of
an SDT probe's argument.  I took the opportunity to rewrite some of the
code to improve the parsing.  The bug was actually a thinko, because
what I wanted to do in the code was to discard the number on the string
being parsed.

During this portion, the code identifies that it is dealing with an
expression that begins with a sign ('+', '-' or '~').  This means that
the expression could be:

- a numeric literal (e.g., '+5')
- a register displacement (e.g., '-4(%rsp)')
- a subexpression (e.g., '-(2*3)')

So, after saving the sign and moving forward 1 char, now the code needs
to know if there is a digit followed by a register displacement prefix
operand (e.g., '(' on x86_64).  If yes, then it is a register
operation.  If not, then it will be handled recursively, and the code
will later apply the requested operation on the result (either a '+', a
'-' or a '~').

With the bug, the code was correctly discarding the digit (though using
strtol unnecessarily), but it wasn't properly dealing with
subexpressions when the register indirection prefix was '(', like on
x86_64.  This patch also fixes this bug, and includes a testcase.  It
passes on x86_64 Fedora 20.
2014-09-05 15:21:44 -04:00
Pedro Alves ebf13736b4 parse_number("0") reads uninitialized memory
valgrind caught that parse_number reads uninitialized memory when we
parse literal "0":

 $ valgrind ./gdb -q -nx -ex "set height 0"
 (...)
 ==10378== Conditional jump or move depends on uninitialised value(s)
 ==10378==    at 0x548A10: parse_number (c-exp.y:1828)
 ==10378==    by 0x54A340: lex_one_token (c-exp.y:2638)
 ==10378==    by 0x54B4BB: c_lex (c-exp.y:3089)
 ==10378==    by 0x544951: c_parse_internal (c-exp.c:2208)
 ==10378==    by 0x54BF8C: c_parse (c-exp.y:3260)
 ==10378==    by 0x6502E7: parse_exp_in_context_1 (parse.c:1221)
 ==10378==    by 0x650064: parse_exp_in_context (parse.c:1122)
 ==10378==    by 0x65001F: parse_exp_1 (parse.c:1114)
 ==10378==    by 0x650421: parse_expression (parse.c:1266)
 ==10378==    by 0x5A74B7: parse_and_eval_long (eval.c:92)
 ==10378==    by 0x501ABD: do_set_command (cli-setshow.c:302)
 ==10378==    by 0x721059: execute_command (top.c:452)
 ==10378==
 (gdb)

I've pushed the obvious fix.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
	* c-exp.y (parse_number): Skip handling base-switching prefixes if
	the input is only one character long.
2014-09-04 21:46:28 +01:00
Sergio Durigan Junior eb0b04635f Fix PR fortran/17237: bug in f-valprint.c
This commit fixes the PR mentioned in $subject.  It is about a set but
unused variable that refers to the output format of integer values
printed in Fortran.

This was probably a thinko (like most set-but-unused-vars), but it
could cause an internal error depending on the scenario.  I am sending
a testcase which triggers this error as well.

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

	PR fortran/17237
	* f-valprint.c (f_val_print): Specify the correct print option to
	use when printing integer values.

gdb/testsuite/ChangeLog:
2014-09-04  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR fortran/17237
	* gdb.fortran/print-formatted.exp: New file.
	* gdb.fortran/print-formatted.f90: Likewise.
2014-09-04 10:30:01 -04:00
Gary Benson 5ee44bfa6b Remove code to cope with LWPs wrapped as PIDs
Historically the Linux x86 watchpoint code did not cope with multi-
threaded processes and LWP IDs were passed to it wrapped as PIDs.
Not all entry points were converted when the Linux x86 watchpoint
code was made multi-thread-aware, so a handler was left in place to
cope with wrapped LWPs.  Since then all such entry points have been
converted to pass regular LWPs and the handler is now redundant.
This commit removes the handler and adds assertions to ensure no
wrapped LWPs are passed in future.

gdb/ChangeLog:

	* x86-linux-nat.c (x86_linux_dr_get, x86_linux_dr_set):
	Remove code to cope with LWPs wrapped as PIDs.
	Add assertions to ensure no wrapped LWPs are passed.
2014-09-04 15:23:21 +01:00
Pedro Alves 4875ffdbda Regression for i686 gdb.dwarf2/pieces-optimized-out.exp
Git 9a0dc9e3 regressed gdb.dwarf2/pieces-optimized-out.exp, visible on
i686 (the test doesn't run on x86_64):

 (gdb) p s
 -$1 = {a = 5, b = <optimized out>, c = <optimized out>, d = <optimized out>}
 +$1 = {a = 5, b = <optimized out>, c = 0, d = 0}
 -(gdb) PASS: gdb.dwarf2/pieces-optimized-out.exp: print s
 +(gdb) FAIL: gdb.dwarf2/pieces-optimized-out.exp: print s

The regression was caused by this removal in cp-valprint.c:

  @@ -293,12 +293,6 @@ cp_print_value_fields (struct type *type, struct type *real_type,
		  {
		    fputs_filtered (_("<synthetic pointer>"), stream);
		  }
  -             else if (!value_bits_valid (val,
  -                                         TYPE_FIELD_BITPOS (type, i),
  -                                         TYPE_FIELD_BITSIZE (type, i)))
  -               {
  -                 val_print_optimized_out (val, stream);
  -               }
		else
		  {
		    struct value_print_options opts = *options;

The idea was that we'd just fallback to calling value_field_bitfield,
which handles unavailable values (in unpack_value_bits_as_long_1) so
should be able to handle optimized out values too.  Alas, it doesn't.
This is currently a bit too messy.  Instead of teaching
unpack_value_bits_as_long_1 about optimized out bits, let's bite the
bullet and teach the value code to handle partially optimized out
bitfield, by having it unpack a bitfield and then propagate the range
metadata.  Turns out the resulting code looks simpler and clearer.

Tested on x86_64 Fedora 20, -m64/-m32.

gdb/ChangeLog:

	* value.c (value_ranges_copy_adjusted): New function, factored out
	from ...
	(value_contents_copy_raw): ... here.
	(unpack_value_bits_as_long_1): Rename back to ...
	(unpack_bits_as_long): ... this.  Remove 'original_value' and
	'result' parameters.  Change return type to LONGEST.
	(unpack_value_bits_as_long): Delete.
	(unpack_value_field_as_long_1): Delete.
	(unpack_value_field_as_long, unpack_field_as_long): Reimplement.
	(unpack_value_bitfield): New function.
	(value_field_bitfield): Reimplement using unpack_value_bitfield.
	(value_fetch_lazy): Use unpack_value_bitfield.
	* value.h (unpack_value_bits_as_long): Delete declaration.
2014-09-04 12:12:41 +01:00
Justin Lebar 1a6a384be1 Improve Type.template_argument docs in Python API.
gdb/doc/ChangeLog:

	* python.texi (Types In Python): Type.template_argument(n) returns a
	gdb.Value or a gdb.Type and throws an exception if n is out of
	range.
2014-09-03 16:40:22 -07:00
Sasha Smundak 5f3b99cfed Add support for reading frame registers to Python API.
The ability to read registers is needed to use Frame Filter API to
display the frames created by JIT compilers.

gdb/ChangeLog:

2014-08-29  Sasha Smundak  <asmundak@google.com>

	* python/py-frame.c (frapy_read_register): New function.

gdb/doc/ChangeLog:

2014-08-26  Sasha Smundak  <asmundak@google.com>

	* python.texi (Frames in Python): Add read_register description.

gdb/testsuite/ChangeLog:

2014-08-26  Sasha Smundak  <asmundak@google.com>

	* gdb.python/py-frame.exp: Test Frame.read_register.
2014-09-03 16:34:47 -07:00
James Hogan ac740bc7a9 Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROL
PTRACE_PEEKUSER can return -1, which is usually used to determine whether
a system call has reported an error, so errno must be used alone to
determine whether an error occurred. However errno isn't modified by a
successful system call so it must be reset to a known value (0) before the
syscall call.

Add the missing errno reset when reading the DSP_CONTROL register in the
native MIPS Linux backend and the MIPS gdbserver backend.

gdb/:
	* mips-linux-nat.c (mips_linux_read_description): Reset errno to 0
	prior to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call.

gdb/gdbserver/:
	* linux-mips-low.c (mips_read_description): Reset errno to 0 prior
	to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call.
2014-09-03 22:09:10 +01:00
Sergio Durigan Junior 7d793aa9f0 PR python/16699: GDB Python command completion with overriden complete vs. completer class
This PR came from a Red Hat bug that was filed recently.  I checked and
it still exists on HEAD, so here's a proposed fix.  Although this is
marked as a Python backend bug, this is really about the completion
mechanism used by GDB.  Since this code reminds me of my first attempt
to make a good noodle, it took me quite some time to fix it in a
non-intrusive way.

The problem is triggered when one registers a completion method inside a
class in a Python script, rather than registering the command using a
completer class directly.  For example, consider the following script:

    class MyFirstCommand(gdb.Command):
          def __init__(self):
              gdb.Command.__init__(self,'myfirstcommand',gdb.COMMAND_USER,gdb.COMPLETE_FILENAME)

              def invoke(self,argument,from_tty):
                  raise gdb.GdbError('not implemented')

    class MySecondCommand(gdb.Command):
          def __init__(self):
              gdb.Command.__init__(self,'mysecondcommand',gdb.COMMAND_USER)

              def invoke(self,argument,from_tty):
                  raise gdb.GdbError('not implemented')

                  def complete(self,text,word):
                      return gdb.COMPLETE_FILENAME

    MyFirstCommand ()
    MySecondCommand ()

When one loads this into GDB and tries to complete filenames for both
myfirstcommand and mysecondcommand, she gets:

    (gdb) myfirstcommand /hom<TAB>
    (gdb) myfirstcommand /home/
                               ^
    ...
    (gdb) mysecondcommand /hom<TAB>
    (gdb) mysecondcommand /home
                                ^

(The "^" marks the final position of the cursor after the TAB).

So we see that myfirstcommand honors the COMPLETE_FILENAME class (as
specified in the command creation), but mysecondcommand does not.  After
some investigation, I found that the problem lies with the set of word
break characters that is used for each case.  The set should be the same
for both commands, but it is not.

During the process of deciding which type of completion should be used,
the code in gdb/completer.c:complete_line_internal analyses the command
that requested the completion and tries to determine the type of
completion wanted by checking which completion function will be called
(e.g., filename_completer for filenames, location_completer for
locations, etc.).

This all works fine for myfirstcommand, because immediately after the
command registration the Python backend already sets its completion
function to filename_completer (which then causes the
complete_line_internal function to choose the right set of word break
chars).  However, for mysecondcommand, this decision is postponed to
when the completer function is evaluated, and the Python backend uses an
internal completer (called cmdpy_completer).  complete_line_internal
doesn't know about this internal completer, and can't choose the right
set of word break chars in time, which then leads to a bad decision when
completing the "/hom" word.

So, after a few attempts, I decided to create another callback in
"struct cmd_list_element" that will be responsible for handling the case
when there is an unknown completer function for complete_line_internal
to work with.  So far, only the Python backend uses this callback, and
only when the user provides a completer method instead of registering
the command directly with a completer class.  I think this is the best
option because it not very intrusive (all the other commands will still
work normally), but especially because the whole completion code is so
messy that it would be hard to fix this without having to redesign
things.

I have regtested this on Fedora 18 x86_64, without regressions.  I also
included a testcase.

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

	PR python/16699
	* cli/cli-decode.c (set_cmd_completer_handle_brkchars): New
	function.
	(add_cmd): Set "completer_handle_brkchars" to NULL.
	* cli/cli-decode.h (struct cmd_list_element)
	<completer_handle_brkchars>: New field.
	* command.h (completer_ftype_void): New typedef.
	(set_cmd_completer_handle_brkchars): New prototype.
	* completer.c (set_gdb_completion_word_break_characters): New
	function.
	(complete_line_internal): Call "completer_handle_brkchars"
	callback from command.
	* completer.h: Include "command.h".
	(set_gdb_completion_word_break_characters): New prototype.
	* python/py-cmd.c (cmdpy_completer_helper): New function.
	(cmdpy_completer_handle_brkchars): New function.
	(cmdpy_completer): Adjust to use cmdpy_completer_helper.
	(cmdpy_init): Set completer_handle_brkchars to
	cmdpy_completer_handle_brkchars.

gdb/testsuite/ChangeLog:
2014-09-03  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR python/16699
	* gdb.python/py-completion.exp: New file.
	* gdb.python/py-completion.py: Likewise.
2014-09-03 16:30:28 -04:00
Gary Benson 97ea6506c4 x86 debug address register clarifications
The loop macro ALL_DEBUG_REGISTERS does not iterate over the status or
control registers, so its name is misleading.  This commit renames it
as ALL_DEBUG_ADDRESS_REGISTERS and updates all uses.  This commit also
updates its loop conditions to an equivalent but better form, and
makes two functions use it that had previously hardwired the loop.
A comment on a related field in the x86_debug_reg_state structure is
also updated to reflect that the field refers specifically to address
registers only.

gdb/ChangeLog:

	* nat/x86-dregs.h (ALL_DEBUG_REGISTERS): Renamed as...
	(ALL_DEBUG_ADDRESS_REGISTERS): New macro.  All uses updated.
	Loop conditions	changed to equivalent form.
	(struct x86_debug_reg_state): Updated dr_ref_count comment.
	* x86-linux-nat.c (x86_linux_prepare_to_resume): Use
	ALL_DEBUG_ADDRESS_REGISTERS.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_linux_prepare_to_resume): Use
	ALL_DEBUG_ADDRESS_REGISTERS.
2014-09-03 12:40:49 +01:00
Joel Brobecker d143781548 Fix dwarf2loc.h::dwarf2_evaluate_property function description.
gdb/ChangeLog:

        * dwarf2loc.h (dwarf2_evaluate_property): Minor function
        description fix.
2014-09-03 10:10:41 +02:00
Doug Evans 9b94fcf1fa typeprint.c (find_global_typedef): Fix comment.
gdb/ChangeLog:

	* typeprint.c (find_global_typedef): Fix comment.
2014-09-02 16:29:16 -07:00
Gary Benson df7e526582 Rename 32- and 64-bit Intel files from "i386" to "x86"
This commit renames nine files that contain code used by both 32- and
64-bit Intel ports such that their names are prefixed with "x86"
rather than "i386".  All types, functions and variables within these
files are likewise renamed such that their names are prefixed with
"x86" rather than "i386".  This makes GDB follow the convention used
by gdbserver such that 32-bit Intel code lives in files called
"i386-*", 64-bit Intel code lives in files called "amd64-*", and code
for both 32- and 64-bit Intel lives in files called "x86-*".

This commit only renames OS-independent files.  The Linux ports of
both GDB and gdbserver now follow the i386/amd64/x86 convention fully.
Some ports still use the old convention where "i386" in file/function/
type/variable names can mean "32-bit only" or "32- and 64-bit" but I
don't want to touch ports I can't fully test except where absolutely
necessary.

gdb/ChangeLog:

	* i386-nat.h: Renamed as...
	* x86-nat.h: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.
	* i386-nat.c: Renamed as...
	* x86-nat.c: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.
	* common/i386-xstate.h: Renamed as...
	* common/x86-xstate.h: New file.  All type, function and variable
	name prefixes changed from "i386_" to "x86_".  All references
	updated.
	* nat/i386-cpuid.h: Renamed as...
	* nat/x86-cpuid.h: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.
	* nat/i386-gcc-cpuid.h: Renamed as...
	* nat/x86-gcc-cpuid.h: New file.  All type, function and variable
	name prefixes changed from "i386_" to "x86_".  All references
	updated.
	* nat/i386-dregs.h: Renamed as...
	* nat/x86-dregs.h: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.
	* nat/i386-dregs.c: Renamed as...
	* nat/x86-dregs.c: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.

gdb/gdbserver/ChangeLog:

	* i386-low.h: Renamed as...
	* x86-low.h: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.
	* i386-low.c: Renamed as...
	* x86-low.c: New file.  All type, function and variable name
	prefixes changed from "i386_" to "x86_".  All references updated.
2014-09-02 16:54:08 +01:00
Gary Benson ed859da732 Use XCNEW rather than xcalloc (1, ...) in linux-x86-low.c
This commit replaces two uses of xcalloc (1, ...) with XCNEW.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_linux_new_process): Use XCNEW.
	(x86_linux_new_thread): Likewise.
2014-09-02 16:31:20 +01:00
Maciej W. Rozycki 1c3569d467 Move `_initialize_varobj' to the end of varobj.c
* varobj.c (_initialize_varobj): Move to the end of file.
2014-09-01 15:09:59 +01:00
Gary Benson 860789c7d5 Use exceptions and cleanups in gdbserver
This commit replaces the hacky "exception" system in gdbserver with
the exceptions and cleanups subsystem from GDB.

Only the catch/cleanup code in what was "main" has been updated to
use the new system.  Other parts of gdbserver can now be converted
to use TRY_CATCH and cleanups on an as-needed basis.

A side-effect of this commit is that some error messages will change
slightly, and in cases with multiple errors the error messages will
be printed in a different order.

gdb/gdbserver/ChangeLog:

	* server.h (setjmp.h): Do not include.
	(toplevel): Do not declare.
	(common-exceptions.h): Include.
	(cleanups.h): Likewise.
	* server.c (toplevel): Do not define.
	(exit_code): New static global.
	(detach_or_kill_for_exit_cleanup): New function.
	(main): New function.  Original main renamed to...
	(captured_main): New function.
	* utils.c (verror) [!IN_PROCESS_AGENT]: Use throw_verror.
2014-08-29 10:53:56 +01:00
Gary Benson ff55e1b548 Introduce common/common-exceptions.[ch]
This commit moves the exception throwing and catching code
into gdb/common/.  All exception printing code remains in
gdb/exceptions.[ch].

gdb/ChangeLog:

	* common/common-exceptions.h: New file.
	* common/common-exceptions.c: Likewise.
	* Makefile.in (SFILES): Add common/common-exceptions.c.
	(HFILES_NO_SRCDIR): Add common/common-exceptions.h.
	(COMMON_OBS): Add common-exceptions.o.
	(common-exceptions.o): New rule.
	* exceptions.h (common-exceptions.h): Include.
	(gdb_setjmp.h): Do not include.
	(return_reason): Moved to common-exceptions.h.
	(enum return_reason): Likewise.
	(RETURN_MASK): Likewise.
	(typedef return_mask): Likewise.
	(enum errors): Likewise.
	(struct gdb_exception): Likewise.
	(exceptions_state_mc_init): Likewise.
	(exceptions_state_mc_action_iter): Likewise.
	(exceptions_state_mc_action_iter_1): Likewise.
	(TRY_CATCH): Likewise.
	(throw_exception): Likewise.
	(throw_verror): Likewise.
	(throw_vquit): Likewise.
	(throw_error): Likewise.
	(throw_quit): Likewise.
	* exceptions.c (enum catcher_state): Moved to common-exceptions.c.
	(enum catcher_action): Likewise.
	(struct catcher): Likewise.
	(current_catcher): Likewise.
	(catcher_list_size): Likewise.
	(exceptions_state_mc_init): Likewise.
	(catcher_pop): Likewise.
	(exceptions_state_mc): Likewise.
	(exceptions_state_mc_action_iter): Likewise.
	(exceptions_state_mc_action_iter_1): Likewise.
	(throw_exception): Likewise.
	(exception_messages): Likewise.
	(exception_messages_size): Likewise.
	(throw_it): Likewise.
	(throw_verror): Likewise.
	(throw_vquit): Likewise.
	(throw_error): Likewise.
	(throw_quit): Likewise.
	(prepare_to_throw_exception): New function.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/common-exceptions.c.
	(OBS): Add common-exceptions.o.
	(common-exceptions.o): New rule.
	* utils.c (prepare_to_throw_exception): New function.
2014-08-29 10:53:37 +01:00
Gary Benson e9bcb65852 Introduce common/gdb_setjmp.h
This commit creates a new file, common/gdb_setjmp.h, to hold some
portability macros for setjmp/longjmp et al. that are used by the
exceptions subsystem and by the demangler crash catcher.

gdb/ChangeLog:

	* common/gdb_setjmp.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_setjmp.h.
	* configure.ac: Move sigsetjmp check...
	* common/common.m4: ...here.
	* configure: Regenerate.
	* cp-support.c (SIGJMP_BUF): Delete.
	(SIGSETJMP): Likewise.
	(SIGLONGJMP): Likewise.
	* exceptions.h (gdb_setjmp.h): Include.
	(setjmp.h): Do not include.
	(EXCEPTIONS_SIGJMP_BUF): Delete.
	(EXCEPTIONS_SIGSETJMP): Likewise.
	(EXCEPTIONS_SIGLONGJMP): Likewise.
	Replace all uses of EXCEPTIONS_SIG* macros with SIG* macros
	from gdb_setjmp.h.
	* exceptions.c: Likewise.

gdb/gdbserver/ChangeLog:

	* config.in: Regenerate.
	* configure: Likewise.
2014-08-29 10:53:36 +01:00
Gary Benson e31806255f Move cleanups.[ch] to common
This commit moves cleanups.[ch] into gdb/common/.  The only change to
the content of the files is that cleanups.c's include list was altered
to match its new location.

gdb/ChangeLog:

	* cleanups.h: Moved to...
	* common/cleanups.h: New file.
	* cleanups.c: Moved to...
	* common/cleanups.c: New file.  Include common-defs.h and
	cleanups.h.  Do not include defs.h.
	* Makefile.in (SFILES): Replace cleanups.c with common/cleanups.c.
	(HFILES_NO_SRCDIR): Replace cleanups.h with common/cleanups.h.
	(cleanups.o): New rule.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/cleanups.c.
	(OBS): cleanups.o.
	(cleanups.o): New rule.
2014-08-29 10:53:35 +01:00
Gary Benson e3d6ba5d32 Move internal_{,v}warning to common/errors.[ch]
This commit moves internal_warning and internal_vwarning into
common/errors.[ch].

gdb/ChangeLog:

	* common/errors.h (internal_warning): New declaration.
	(internal_vwarning): Likewise.
	* common/errors.c (internal_warning): New function.
	* utils.h (internal_warning): Don't declare.
	(internal_vwarning): Likewise.
	* utils.c (internal_warning): Removed.

gdb/gdbserver/ChangeLog:

	* utils.c (internal_vwarning): New function.
2014-08-29 10:53:35 +01:00
Gary Benson 075c703382 Unify startup and option-parsing warnings
Various warnings are emitted during startup and option-parsing using
fprintf_unfiltered.  One warning is prefixed with the command name,
the others are not.  This commit replaces these hardwired warnings
with calls to warning.  It also sets warning_pre_print to prefix all
warnings with the command name until option parsing is complete.

gdb/ChangeLog:

	* main.c (captured_main): Use warning during startup.
	Prefix startup warning messages with command name.
2014-08-29 10:12:04 +01:00
Gary Benson 91b35fd05c Replace all usage errors with calls to error
This commit replaces the hardwired fprintf/exit error handlers
for usage errors with calls to error.

gdb/ChangeLog:

	* main.c (captured_main): Handle usage errors with error.
2014-08-29 10:12:04 +01:00
Gary Benson b1ec390e09 Replace hardwired error handler in go32_create_inferior
go32_create_inferior invokes a hardwired fprintf/exit error handler
if v2loadimage fails.  I could find no reason for this other than that
the block seems to have been copy-and-pasted from v2loadimage's
manpage.  This commit replaces the hardwired handler with a call to
error.

gdb/ChangeLog:

	* go32-nat.c (go32_create_inferior): Replace a fprintf/
	exit pair with a call to error.  Wrap the message with _().
2014-08-29 10:12:03 +01:00
Gary Benson fd0ef3dda9 Replace hardwired error handler in captured_main
If the requested interpreter cannot be set captured_main reports the
error with a hardwired fprintf/exit pair.  A fprintf/exit pair on the
previous line was replaced with a call to error in March 2003
(https://sourceware.org/ml/gdb-patches/2003-03/msg00444.html) but I
found no documentation as to why this particular hardwired handler
was left untouched.  I was also unable to come up with a situation
where error would not be suitable, so I have replaced it with a call
to error.

gdb/ChangeLog:

	* main.c (captured_main): Replace a fprintf/exit
	pair with a call to error.  Wrap the message with _().
2014-08-29 10:12:02 +01:00
Gary Benson e0e6bcab59 Replace hardwired error handlers in tui_initialize_io
tui_initialize_io contains a pair of hardwired fprintf/exit error
handlers.  I was unable to find any documentation as to why they're
hardwired (the code appeared in a monolithic block back in 2001:
https://sourceware.org/ml/gdb-patches/2001-07/msg00490.html) and I
was also unable to come up with a situation where error would not
be suitable, so I have replaced both handlers with calls to error.

gdb/ChangeLog:

	* tui/tui-io.c (tui_initialize_io): Replace two fprintf/exit
	pairs with calls to error.  Wrap the message with _().
2014-08-29 10:12:01 +01:00
Gary Benson 0d2f5c0791 Make warning usable earlier
warning will crash if called before the first call to set_width.  This
commit makes the warning usable from the moment gdb_stderr is set up.

gdb/ChangeLog:

	* utils.c (vwarning): Protect calls to target_terminal_ours
	and wrap_here.
2014-08-29 10:12:00 +01:00
Gary Benson 5df4399815 Make error usable earlier
error (and other exception-throwing functions) are callable from the
first line of captured_main, but the exception printing code will
crash if called before the first call to set_width.  This commit makes
the exception printing code usable from the moment gdb_stderr is set
up.

gdb/ChangeLog:

	* exceptions.c (print_flush): Protect calls to
	target_terminal_ours and wrap_here.
2014-08-29 10:11:59 +01:00
Gary Benson 2437fd32f1 Make internal_vproblem always work
internal_vproblem can be called (via malloc_failure) from almost the
first line of captured_main, but it will crash if called before the
first call to set_width.  This commit makes internal_vproblem work
at any time.

There are two parts to this.  If called before gdb_stderr is set up,
internal_vproblem will fall back to printing the message on regular
stderr and aborting.  If called after gdb_stderr is set up but before
filtered printing is set up, internal_vproblem will operate as usual
except that it can not query whether to quit and/or dump core so it
defaults to doing both.

gdb/ChangeLog:

	* utils.h (filtered_printing_initialized): New declaration.
	* utils.c (abort_with_message): New function.
	(internal_vproblem): Use abort_with_message for first level
	recursive internal problems, and if gdb_stderr is not set up.
	Protect calls to target_terminal_ours, begin_line and query.
2014-08-29 10:11:59 +01:00
Doug Evans f1f58506e2 Move definition of some prologue-related functions to a better location.
gdb/ChangeLog:

	* symtab.c (in_prologue): Move definition to better spot.
	(skip_prologue_using_sal): Ditto.
2014-08-28 16:15:23 -07:00
Doug Evans aab2f20890 symtab.c (find_function_start_sal): Move definition to better spot.
gdb/ChangeLog:

	* symtab.c (find_function_start_sal): Move definition to better spot.
2014-08-28 16:09:50 -07:00
Doug Evans fb0576e983 Rewrite {amd64,i386}-pseudo.c to better specify register liveness.
clang was using eax to construct %0 here:

  asm ("mov %%eax, 0(%0)\n\t"
       "mov %%ebx, 4(%0)\n\t"
       "mov %%ecx, 8(%0)\n\t"
       "mov %%edx, 12(%0)\n\t"
       "mov %%esi, 16(%0)\n\t"
       "mov %%edi, 20(%0)\n\t"
       : /* no output operands */
       : "r" (data)
       : "eax", "ebx", "ecx", "edx", "esi", "edi");

which caused amd64-word.exp (and others similarly) to fail.
It's a perfectly legit thing for clang to do given the available data.
The patch fixes this by marking the registers as live from the
time of the preceding breakpoint.

gdb/testsuite/ChangeLog:

	* gdb.arch/amd64-pseudo.c (main): Rewrite to better specify when
	eax,etc. are live with values set by gdb and thus the compiler can't
	use them.
	* gdb.arch/i386-pseudo.c (main): Ditto.
2014-08-28 11:38:22 -07:00
Gary Benson 7096e88625 Remove fatal function and prototype
This commit removes the now-unused fatal function and prototype.

gdb/gdbserver/ChangeLog:

	* utils.h (fatal): Remove declaration.
	* utils.c (fatal): Remove function.
2014-08-28 15:06:48 +01:00
Gary Benson 14ce319239 Convert fatal to perror_with_name in IPA code
This commit converts four calls to fatal into calls to
perror_with_name.  perror_with_name calls error, which
in IPA terminates with exit (1) rather than longjmp, so
there is no functional change here.

gdb/gdbserver/ChangeLog:

	* tracepoint.c (gdb_agent_init): Replace fatal with
	perror_with_name.
	(initialize_tracepoint): Likewise.
2014-08-28 15:06:48 +01:00
Gary Benson 50278d599d Convert fatal to error in remote_prepare
This commit converts a call to fatal in remote_prepare with a call to
error.  remote_prepare is called precisely once, from main, at a point
where jumping to toplevel will call exit (1), so error and fatal are
functionally equivalent at this point.  Note that remote_prepare calls
perror_with_name (which calls error) so callers of remote_prepare must
already handle the fact that it may exit via longjmp.

gdb/gdbserver/ChangeLog:

	* remote-utils.c (remote_prepare): Replace fatal with error.
2014-08-28 15:06:47 +01:00
Gary Benson aa96c426c6 Downgrade fatal to warning in linux_async
This commit downgrades a fatal error to a warning in linux_async.
linux_async is called from two different places in gdbserver:

 Via target_async from handle_accept_event.  The argument
   is always zero, so the warning will never be printed here.

 Via start_non_stop from handle_general_set.  This prints
   its own error message to stderr on failure, which will
   be preceded by the warning if it is emitted.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_async): Replace fatal with warning.
	Tidy up and return.
	(linux_start_non_stop): Return -1 if linux_async failed.
2014-08-28 15:06:46 +01:00
Gary Benson f7160e9741 Convert fatal to gdb_assert in both i386_dr_low_set_addr
This commit converts if..fatal checks in both i386_dr_low_set_addr
implementations to gdb_asserts.  It's not obvious from the context,
but the conditional in both cases is changed to match the equivalent
conditional in the i386_dr_low_get_addr implementations.  Nothing
fundamental has changed because DR_FIRSTADDR is zero.  This commit
also removes a vague comment in Linux i386_dr_low_get_addr.  I could
have reworded the comment (and replicated it three times for the other
identical assertions) but I think the existence of specific functions
for the status and control registers makes it fairly obvious what is
going on.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (i386_dr_low_set_addr): Replace check with
	gdb_assert.
	(i386_dr_low_get_addr): Remove vague comment.
	* win32-i386-low.c (i386_dr_low_set_addr): Replace check with
	gdb_assert.
2014-08-28 15:06:46 +01:00
Gary Benson 38e08fcac0 Straightforward fatal to internal_error conversions
This commit replaces most of the calls to fatal that represent
internal errors with calls to internal_error, either directly
or via gdb_assert and gdb_assert_not_reached.

gdb/gdbserver/ChangeLog:

	* inferiors.c (get_thread_process): Replace check with gdb_assert.
	* linux-low.c (linux_wait_for_event_filtered): Replace fatal with
	internal_error.
	(linux_resume_one_lwp): Likewise.
	* linux-x86-low.c (x86_siginfo_fixup): Replace checks with
	gdb_assert.
	* mem-break.c (raw_bkpt_type_to_target_hw_bp_type): Replace fatal
	with internal_error.
	* regcache.c (get_thread_regcache): Replace check with gdb_assert.
	(init_register_cache): Replace fatal with gdb_assert_not_reached.
	(find_register_by_name): Replace fatal with internal_error.
	(find_regno): Likewise.
	* tdesc.c (init_target_desc): Replace check with gdb_assert.
	* thread-db.c (thread_db_create_event): Likewise.
	(thread_db_load_search): Likewise.
	(try_thread_db_load_1): Likewise.
	* tracepoint.c (get_jump_space_head): Replace fatal with
	internal_error.
	(claim_trampoline_space): Likewise.
	(have_fast_tracepoint_trampoline_buffer): Likewise.
	(cmd_qtstart): Likewise.
	(stop_tracing): Likewise.
	(fast_tracepoint_collecting): Likewise.
	(target_malloc): Likewise.
	(download_tracepoint): Likewise.
	(download_trace_state_variables): Replace check with gdb_assert.
	(upload_fast_traceframes): Replace fatal with internal_error.
2014-08-28 15:06:45 +01:00
Yao Qi 6b65d1b6b3 arm software watchpoint: return to epilogue
Hi,
This patch is to handle a software watchpoint case that program returns
to caller's epilogue, and it causes the fail in thumb mode,

finish^M
Run till exit from #0  func () at gdb/testsuite/gdb.base/watchpoint-cond-gone.c:26^M
0x000001f6 in jumper ()^M
(gdb) FAIL: gdb.base/watchpoint-cond-gone.exp: Catch the no longer valid watchpoint

In the test, jumper calls func, and programs returns from func to
jumper's epilogue, IOW, the branch instruction is the last instruction
of jumper's function body.

    jumper:
    .....
    0x000001f2 <+10>:    bl      0x200   [1] <---- indirect call to func
    0x000001f6 <+14>:    mov     sp, r7  [2] <---- start of the epilogue
    0x000001f8 <+16>:    add     sp, #8
    0x000001fa <+18>:    pop     {r7}
    0x000001fc <+20>:    pop     {r0}
    0x000001fe <+22>:    bx      r0

When the inferior returns from func back to jumper, it is expected
that an expression of a software watchpoint becomes out-of-scope.
GDB validates the expression by checking the corresponding frame,
but this check is guarded by gdbarch_in_function_epilogue_p.  See
breakpoint.c:watchpoint_check.

It doesn't work in this case, because program returns from func's
epilogue back to jumper's epilogue [2], GDB thinks the program is
still within the epilogue, but in fact it goes to a different one.
When PC points at [2], the sp-restore instruction is to be
executed, so the stack frame isn't destroyed yet and we can still
use the frame mechanism reliably.

Note that when PC points to the first instruction of restoring SP,
it is part of epilogue, but we still return zero.  When goes to
the next instruction, the backward scan will still match the
epilogue sequence correctly.  The reason for doing this is to
handle the "return-to-epilogue" case.

What this patch does is to restrict the epilogue matching that let
GDB think the first SP restore instruction isn't part of the epilogue,
and fall back to use frame mechanism.  We set 'found_stack_adjust'
zero before backward scan, and we've done this for arm mode
counterpart (arm_in_function_epilogue_p) too.

The patch is tested in arm-none-eabi and arm-none-linux-gnueabi with
various multilibs.  OK to apply?

gdb:

2014-08-28  Yao Qi  <yao@codesourcery.com>

	* arm-tdep.c (thumb_in_function_epilogue_p): Don't set
	found_stack_adjust in forward scan.  Remove condition check
	on found_stack_adjust which is always true.  Indent the code.
2014-08-28 15:21:21 +08:00
Yao Qi a1b34d156a Remove dwarf_decode_lines argumewant_line_info
Hi,
dwarf_decode_lines is called in two functions,
dwarf2_build_include_psymtabs and handle_DW_AT_stmt_list, in which, 1
is passed to argument 'want_line_info' and 'want_line_info' is a
conditional variable in dwarf_decode_lines.  We can simplify it by
removing 'want_line_info' and propagating the constant 1 into
dwarf_decode_lines.  This is what this patch does.  This patch also
remove one line comment about WANT_LINE_INFO in
handle_DW_AT_stmt_list, as handle_DW_AT_stmt_list doesn't have such
argument.

gdb:

2014-08-28  Yao Qi  <yao@codesourcery.com>

	* dwarf2read.c (dwarf_decode_lines): Update declaration.
	(handle_DW_AT_stmt_list): Remove comment about WANT_LINE_INFO.
	(dwarf_decode_lines): Remove argument
	want_line_info.  Remove condition check on want_line_info.
	Callers update.
2014-08-28 10:44:15 +08:00
Doug Evans d5962de546 dwarf2read.c (dwarf_record_line): Fix typo.
gdb/ChangeLog:

  * dwarf2read.c (dwarf_record_line): Fix typo.
2014-08-27 10:13:09 -07:00
Sergio Durigan Junior 9b13900280 Adding last commit's ChangeLog entry. 2014-08-27 13:01:01 -04:00
Patrick Palka 3278a9f568 Fix terminal state corruption when starting a program from within TUI
The TUI terminal state becomes corrupted (e.g. key sequences such as
Alt_F and Alt_B no longer work) when one attaches to an inferior process
(via "run" or "attach") from within TUI.  This terminal corruption
remains until you switch out of TUI mode.

This happens because the terminal state is not properly saved when
switching to and out from TUI mode.  Although the functions tui_enable()
and tui_disable() both call the function target_terminal_save_ours() to
save the terminal state, this function is a no-op unless GDB has already
attached to an inferior process.  This is because only the "native"
target has a useful implementation of target_terminal_save_ours()
(namely child_terminal_save_ours()) and we only have the "native" target
in our target vector if GDB has already attached to an inferior process.

So without an inferior process, switching to and from TUI mode does not
actually save the terminal state.  Therefore when you attach to an
inferior process from within TUI mode, the proper terminal state is not
restored (after swapping from the inferior's terminal back to the GDB
terminal).

To fix this we just have to ensure that the terminal state is always
being properly saved when switching from and to TUI mode.  To achieve
this, this patch removes the polymorphic function
target_terminal_save_ours() and replaces it with a regular function
gdb_save_tty_state() that always saves the terminal state.

Tested on x86_64-unknown-linux-gnu by running "make check", no new
regressions.

gdb/ChangeLog:
	* target.h (struct target_ops::to_terminal_save_ours): Remove
	declaration.
	(target_terminal_save_ours): Remove macro.
	* target-delegates.c: Regenerate.
	* inf-child.c (inf_child_target): Don't set the nonexistent
	field to_terminal_save_ours.
	* inferior.h (child_terminal_save_ours): Remove declaration.
	* terminal.h (gdb_save_tty_state): New declaration.
	* inflow.c (child_terminal_save_ours): Rename to ...
	(gdb_save_tty_state): ... this.
	* tui/tui.c: Include terminal.h.
	(tui_enable): Use gdb_save_tty_state instead of
	target_terminal_save_ours.
	(tui_disable): Likewise.
2014-08-27 12:49:54 -04:00
Doug Evans ee92b0dd4e lib/gdb.exp (gdb_compile_shlib): Add support for clang.
gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_compile_shlib): Add support for clang.
2014-08-27 09:40:21 -07:00
Doug Evans 6649db3523 Fix clang compilation errors in gdb.mi/basics.c.
gdb/testsuite/ChangeLog:

	* gdb.mi/basics.c (callee3, callee2, callee1): Specify result type.
	(main): Ditto.
2014-08-25 12:40:54 -07:00
Doug Evans 564b7600f2 gdb.threads/thread-execl.exp: #include <stdio.h>.
gdb/testsuite/ChangeLog:

	* gdb.threads/thread-execl.exp: #include <stdio.h>.
2014-08-25 12:23:50 -07:00
Doug Evans 9debeba0ed linux-nat.c (linux_nat_close): Don't pass NULL for "this".
gdb/ChangeLog:

	* linux-nat.c (linux_nat_close): Don't pass NULL for "this".
	Pass NULL instead of 0 for context pointer.
2014-08-25 12:19:01 -07:00
Yao Qi 428fc5fcd1 Fix grammatical error in comments
gdb:

2014-08-25  Yao Qi  <yao@codesourcery.com>

	* dwarf2read.c: Fix grammatical error.
2014-08-25 20:23:33 +08:00
Yao Qi cdc07690a4 Update comments in scan_partial_symbols and add_partial_subprogram
I read comment of scan_partial_symbols about NEED_PC and how *LOWPC
and *HIGHPC are updated:

   DW_AT_ranges).  If NEED_PC is set, then this function will set
   *LOWPC and *HIGHPC to the lowest and highest PC values found in CU
   and record the covered ranges in the addrmap.

NEED_PC is only used in the callee of scan_partial_symbols,
add_partial_subprogram,

  if (pdi->tag == DW_TAG_subprogram)
    {
      if (pdi->has_pc_info)
        {
          if (pdi->lowpc < *lowpc)
            *lowpc = pdi->lowpc;
          if (pdi->highpc > *highpc)
            *highpc = pdi->highpc;
	  if (need_pc)

*LOWPC and *HIGHPC is updated regardless of NEED_PC.  When NEED_PC is
true, addrmap is updated.  It would be clear to rename NEED_PC to
SET_ADDRMAP.  That is what this patch does.  Beside this, this patch
also adjust comments in related functions.

gdb:

2014-08-24  Yao Qi  <yao@codesourcery.com>

	* dwarf2read.c (scan_partial_symbols):  Update comments.
	Rename argument 'need_pc' with 'set_addrmap'.
	(add_partial_namespace): Rename argument 'need_pc' with
	'set_addrmap'.
	(add_partial_module): Likewise.
	(add_partial_subprogram): Likewise.  Update comments.
	(dwarf2_name): Fix typo.
2014-08-24 21:43:27 +08:00
Yao Qi 3881fb67b7 set print symbol off in py-value.exp and scm-value.exp
I see the following fails on arm-none-eabi target,

print sn^M
$14 = 0x0 <_ftext>^M
(gdb) FAIL: gdb.python/py-value.exp: print sn

print sn^M
$14 = 0x0 <_ftext>^M
(gdb) FAIL: gdb.guile/scm-value.exp: print sn

as <_ftext> is unexpected.  This patch is to set print symbol off to
avoid printing this.

gdb/testsuite:

2014-08-24  Yao Qi  <yao@codesourcery.com>

	* gdb.guile/scm-value.exp (test_lazy_strings): Set print
	symbol off.
	* gdb.python/py-value.exp (test_lazy_strings): Likewise.
2014-08-24 20:21:40 +08:00
Doug Evans a05a36a5fc Fix pr 17276.
See the description here:
https://sourceware.org/ml/gdb-patches/2014-08/msg00283.html

This patch keeps track of whether the current line has seen a
non-zero discriminator, and if so coalesces consecutive entries
for the same line (by ignoring all entries after the first).

gdb/ChangeLog:

	PR 17276
	* dwarf2read.c (dwarf_record_line_p): New function.
	(dwarf_decode_lines_1): Ignore subsequent line number entries
	for the same line if any entry had a non-zero discriminator.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-single-line-discriminators.S: New file.
	* gdb.dwarf2/dw2-single-line-discriminators.c: New file.
	* gdb.dwarf2/dw2-single-line-discriminators.exp: New file.
2014-08-22 17:25:59 -07:00
Doug Evans 252a6764dd Create a typedef for record_line: record_line_ftype.
gdb/ChangeLog:

	* buildsym.h (record_line_ftype): New typedef.
	(record_line): Use it.
	* dwarf2read.c (dwarf_record_line, dwarf_finish_line): New functions.
	(dwarf_decode_lines_1): Call them.
2014-08-22 16:20:05 -07:00
Yao Qi 7c343b48b2 Copy .py files to remote host
Some gdb.python/*.exp tests fail because the .py files aren't copied
to the (remote) host.  This patch is to copy needed .py files to host.
Most of gdb.python/*.exp tests do this.

As it is still controversial to delete *.py files on host, we don't do
that in this patch.

gdb/testsuite:

2014-08-22  Yao Qi  <yao@codesourcery.com>

	* gdb.python/py-finish-breakpoint.exp: Copy .py file to host.
	* gdb.python/py-finish-breakpoint2.exp: Likewise.
	* gdb.python/python.exp: Likewise.  Use .py file on the host
	instead of the build.
2014-08-22 13:44:18 +08:00
Yao Qi 510db0520b Remove workaround to libbabeltrace 1.1.0 issue
When GDB uses recent version of babeltrace, such as 1.2.x, we'll see
such error emitted from babeltrace library,

 (gdb) target ctf .../gdb/testsuite/gdb.trace/actions.ctf
 [error] Invalid CTF stream: content size is smaller than packet headers.
 [error] Stream index creation error.
 [error] Open file stream error.

The problem can be reproduce out of GDB too, using babeltrace,

 $ babeltrace ./fake-packet.ctf/
 [error] Invalid CTF stream: content size is smaller than packet headers.
 [error] Stream index creation error.
 [error] Open file stream error.

Recent babeltrace library becomes more strict on CTF, and complains
about one "faked packet" GDB adds, when saving trace data in ctf
format from GDB.  babeltrace 1.1.0 has a bug that it can't read trace
data smaller than a certain size (see https://bugs.lttng.org/issues/450).
We workaround it in GDB to append some meaningless data in a faked
packet to make sure trace file is large enough (see ctf.c:ctf_end).
The babeltrace issue was fixed in 1.1.1 release.  However, babeltrace
recent release (since 1.1.2) starts to complain about such faked
packet.  Here is a table shows that whether faked packet or no faked
packet is "supported" by various babeltrace releases,

        faked packet      no faked packet
1.1.0      Yes                 No
1.1.1      Yes                 Yes
1.1.2      No                  Yes
1.2.0      No                  Yes

We decide to get rid of this workaround in GDB, and people can build GDB
with libbabeltrace >= 1.1.1.  In this way, both configure and ctf.c is
simpler.

Run gdb.trace/* tests in the following combinations:

 wo/ this pattch  1.1.0
 w/  this patch   1.1.1
 w/  this patch   1.1.2
 w/  this patch   1.2.0

No test results change.

gdb:

2014-08-22  Yao Qi  <yao@codesourcery.com>

	* ctf.c (CTF_FILE_MIN_SIZE): Remove.
	(ctf_end): Remove code.
2014-08-22 10:29:53 +08:00
Jan Kratochvil 22fd09ae99 Fix 'gcore' with exited threads
Program received signal SIGABRT, Aborted.
[...]
(gdb) gcore foobar
Couldn't get registers: No such process.
(gdb) info threads
[...]
(gdb) gcore foobar
Saved corefile foobar
(gdb)

gcore tries to access the exited thread:
[Thread 0x7ffff7fce700 (LWP 6895) exited]
ptrace(PTRACE_GETREGS, 6895, 0, 0x7fff18167dd0) = -1 ESRCH (No such process)

Without the TRY_CATCH protection testsuite FAILs for:
	gcore .../gdb/testsuite/gdb.threads/gcore-thread0.test
	Cannot find new threads: debugger service failed
	(gdb) FAIL: gdb.threads/gcore-thread.exp: save a zeroed-threads corefile
	+
	core .../gdb/testsuite/gdb.threads/gcore-thread0.test
	".../gdb/testsuite/gdb.threads/gcore-thread0.test" is not a core dump: File format not recognized
	(gdb) FAIL: gdb.threads/gcore-thread.exp: core0file: re-load generated corefile (bad file format)
Maybe the TRY_CATCH could be more inside update_thread_list().

Similar update_thread_list() call is IMO missing in procfs_make_note_section()
but I do not have where to verify that change.

gdb/ChangeLog
2014-08-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linux-tdep.c (linux_corefile_thread_callback): Ignore THREAD_EXITED.
	(linux_make_corefile_notes): call update_thread_list, protected against
	exceptions.

gdb/testsuite/ChangeLog
2014-08-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.threads/gcore-stale-thread.c: New file.
	* gdb.threads/gcore-stale-thread.exp: New file.
2014-08-21 20:36:20 +02:00
Pedro Alves 656e8868f3 infcmd.c: Remove stale TODO
This TODO has been stale for over 2 years.  In bd5635a1 (1991), we
already see the comment, when we only had a bare attach_command:

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /*
  * TODO:
  * Should save/restore the tty state since it might be that the
  * program to be debugged was started on this tty and it wants
  * the tty in some state other than what we want.  If it's running
  * on another terminal or without a terminal, then saving and
  * restoring the tty state is a harmless no-op.
  * This only needs to be done if we are attaching to a process.
  */

 /*
  * attach_command --
  * takes a program started up outside of gdb and ``attaches'' to it.
  * This stops it cold in its tracks and allows us to start tracing it.
  * For this to work, we must be able to send the process a
  * signal and we must have the same effective uid as the program.
  */
 void
 attach_command (args, from_tty)
      char *args;
      int from_tty;
 {
   target_attach (args, from_tty);
 }
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Later in b5a3d2aa (1992) target_terminal_init, etc. calls are added to
attach_command, and in 7e97eb28 (1992) we see:

+      /* If we attached to the process, we might or might not be sharing
+        a terminal.  Avoid printing error msg if we are unable to set our
+        terminal's process group to his process group ID.  */
+      if (!attach_flag) {
+       OOPSY ("ioctl TIOCSPGRP");

Clearly the TODO has been stale for a long while.

I considered preserving the text elsewhere, but then thought the
comments in inflow.c already have all the necessary info.

gdb/ChangeLog:

	* infcmd.c (attach_command): Remove comment.
2014-08-21 17:09:24 +01:00
Pedro Alves a8454a7c5a Remove useless gcore command detection
Checking whether the gcore command is included in the GDB build as
proxy for checking whether core dumping is supported by the target is
useless, as gcore.o has been in COMMON_OBS since git 9b4eba8e:

    2009-10-26  Michael Snyder  <msnyder@vmware.com>
                Hui Zhu  <teawater@gmail.com>

        * Makefile.in (SFILES): Add gcore.c.
        (COMMON_OBS): Add gcore.o.
        * config/alpha/alpha-linux.mh (NATDEPFILES): Delete gcore.o.
        * config/alpha/fbsd.mh (NATDEPFILES): Ditto.
	...

IOW, the command is always included in the build.

Instead, nowadays, tests bail out if actually trying to generate a
core fails with an indication the target doesn't support it.  See
gdb_gcore_cmd and callers.

Tested on x86_64 Fedora 20.

gdb/testsuite/ChangeLog:

	* gdb.base/gcore-buffer-overflow.exp: Remove "help gcore" test.
	* gdb.base/gcore-relro-pie.exp: Likewise.
	* gdb.base/gcore-relro.exp: Likewise.
	* gdb.base/gcore.exp: Likewise.
	* gdb.base/print-symbol-loading.exp: Likewise.
	* gdb.threads/gcore-thread.exp: Likewise.
	* lib/gdb.exp (gdb_gcore_cmd): Don't expect "Undefined command".
2014-08-21 11:36:59 +01:00
Will Newton de589d04f3 gdb: Fix aarch64 native build issue caused by use of LONGEST
Recent gdb code refactor changes LONGEST from a macro to a typedef,
thus the use of it in aarch64-linux-nat.c is no longer valid.

2014-08-21  Bin Cheng  <bin.cheng@arm.com>

	* aarch64-linux-nat.c (dr_changed_t): Change the type from
	unsigned LONGEST to ULONGEST.
2014-08-21 09:38:00 +01:00
Pedro Alves 2a31c6236d Integrate PR 12649's race detector directly in the testsuite machinery
This integrates Jan Kratochvil's nice race reproducer from PR
testsuite/12649 into the testsuite infrustructure directly.

With this, one only has to do either 'make check-read1' or 'make check
READ1="1"' to preload the read1.so library into expect.

Currently only enabled for glibc/GNU systems, and if
build==host==target.

gdb/testsuite/ChangeLog:

	* Makefile.in (EXTRA_RULES, CC): New variables, get from
	configure.
	(EXPECT): Handle READ1 being set.
	(all): Depend on EXTRA_RULES.
	(check-read1, expect-read1, read1.so, read1): New rules.
	* README (Testsuite Parameters): Document the READ1 make variable.
	(Race detection): New section.
	* configure: Regenerate.
	* configure.ac: If build==host==target, and running under a
	GNU/glibc system, add read1 to the extra Makefile rules.
	(EXTRA_RULES): AC_SUBST it.
	* lib/read1.c: New file.

gdb/ChangeLog:

	* Makefile.in (check-read1): New rule.
2014-08-20 18:55:54 +01:00
Joel Brobecker d36430db79 Fix handling of typedefs to types having a data_location attribute.
Consider an array described in the debugging information as being
a typedef of an array type for which there is a DW_AT_data_location
attribute. Trying to print the value of that array currently yields
incorrect element values. For instance:

    (gdb) print foo.three_tdef
    $1 = (6293760, 0, 6293772)

The problem occurs because we check for the data_location attribute
only on the typedef type, whereas we should be checking for the
typedef's target type.  As a result, GDB erroneously thinks that
there is no data_location, and therefore starts reading the array's
content from the address of the descriptor instead of the data_location
address.

gdb/ChangeLog:

        * value.c (value_from_contents_and_address): Strip resolved_type's
        typedef layers before checking its TYPE_DATA_LOCATION.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/data-loc.exp: Add additional tests exercising
        the handling of variables declared as a typedef to an array
        which a DW_AT_data_location attribute.
2014-08-20 15:34:19 +02:00
Pedro Alves 000339af7b value.c (value_contents_bits_eq): Initialize l,h for gcc -Wall.
2014-08-20  Pedro Alves  <palves@redhat.com>

	gdb/
	* value.c (value_contents_bits_eq): Initialize l,h for gcc -Wall.
2014-08-20 11:29:15 +01:00
Yao Qi 5f52445bfb Adjust comments with example in it
We would like to wrap examples, output or code snippet in comments with
blank lines, and move */ to a new line if the comment is ended with the
example.

gdb:

2014-08-20  Yao Qi  <yao@codesourcery.com>

	* amd64-tdep.c (amd64_classify): Add a blank line after the
	example.  Move "*/" to a new line.
	* arm-tdep.c (arm_vfp_cprc_sub_candidate): Likewise.
	* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Likewise.
	* dwarf2read.c (psymtab_include_file_name): Likewise.
2014-08-20 17:40:37 +08:00
Pedro Alves 9a0dc9e369 Handle partially optimized out values similarly to unavailable values
This fixes PR symtab/14604, PR symtab/14605, and Jan's test at
https://sourceware.org/ml/gdb-patches/2014-07/msg00158.html, in a tree
with bddbbed reverted:

 2014-07-22  Pedro Alves  <palves@redhat.com>

 	* value.c (allocate_optimized_out_value): Don't mark value as
 	non-lazy.

The PRs are about variables described by the DWARF as being split over
multiple registers using DWARF piece information, but some of those
registers being marked as optimised out (not saved) by a later frame.
GDB currently incorrectly mishandles these partially-optimized-out
values.

Even though we can usually tell from the debug info whether a local or
global is optimized out, handling the case of a local living in a
register that was not saved in a frame requires fetching the variable.
GDB also needs to fetch a value to tell whether parts of it are
"<unavailable>".  Given this, it's not worth it to try to avoid
fetching lazy optimized-out values based on debug info alone.

So this patch makes GDB track which chunks of a value's contents are
optimized out like it tracks <unavailable> contents.  That is, it
makes value->optimized_out be a bit range vector instead of a boolean,
and removes the struct lval_funcs check_validity and check_any_valid
hooks.

Unlike Andrew's series which this is based on (at
https://sourceware.org/ml/gdb-patches/2013-08/msg00300.html, note some
pieces have gone in since), this doesn't merge optimized out and
unavailable contents validity/availability behind a single interface,
nor does it merge the bit range vectors themselves (at least yet).
While it may be desirable to have a single entry point that returns
existence of contents irrespective of what may make them
invalid/unavailable, several places want to treat optimized out /
unavailable / etc. differently, so each spot that potentially could
use it will need to be careful considered on case-by-case basis, and
best done as a separate change.

This fixes Jan's test, because value_available_contents_eq wasn't
considering optimized out value contents.  It does now, and because of
that it's been renamed to value_contents_eq.

A new intro comment is added to value.h describing "<optimized out>",
"<not saved>" and "<unavailable>" values.

gdb/
	PR symtab/14604
	PR symtab/14605
	* ada-lang.c (coerce_unspec_val_to_type): Use
	value_contents_copy_raw.
	* ada-valprint.c (val_print_packed_array_elements): Adjust.
	* c-valprint.c (c_val_print): Use value_bits_any_optimized_out.
	* cp-valprint.c (cp_print_value_fields): Let the common printing
	code handle optimized out values.
	(cp_print_value_fields_rtti): Use value_bits_any_optimized_out.
	* d-valprint.c (dynamic_array_type): Use
	value_bits_any_optimized_out.
	* dwarf2loc.c (entry_data_value_funcs): Remove check_validity and
	check_any_valid fields.
	(check_pieced_value_bits): Delete and inline ...
	(check_pieced_synthetic_pointer): ... here.
	(check_pieced_value_validity): Delete.
	(check_pieced_value_invalid): Delete.
	(pieced_value_funcs): Remove check_validity and check_any_valid
	fields.
	(read_pieced_value): Use mark_value_bits_optimized_out.
	(write_pieced_value): Switch to use
	mark_value_bytes_optimized_out.
	(dwarf2_evaluate_loc_desc_full): Copy the value contents instead
	of assuming the whole value is optimized out.
	* findvar.c (read_frame_register_value): Remove special handling
	of optimized out registers.
	(value_from_register): Use mark_value_bytes_optimized_out.
	* frame-unwind.c (frame_unwind_got_optimized): Use
	mark_value_bytes_optimized_out.
	* jv-valprint.c (java_value_print): Adjust.
	(java_print_value_fields): Let the common printing code handle
	optimized out values.
	* mips-tdep.c (mips_print_register): Remove special handling of
	optimized out registers.
	* opencl-lang.c (lval_func_check_validity): Delete.
	(lval_func_check_any_valid): Delete.
	(opencl_value_funcs): Remove check_validity and check_any_valid
	fields.
	* p-valprint.c (pascal_object_print_value_fields): Let the common
	printing code handle optimized out values.
	* stack.c (read_frame_arg): Remove special handling of optimized
	out values.  Fetch both VAL and ENTRYVAL before comparing
	contents.  Adjust to value_available_contents_eq rename.
	* valprint.c (valprint_check_validity)
	(val_print_scalar_formatted): Use value_bits_any_optimized_out.
	(val_print_array_elements): Adjust.
	* value.c (struct value) <optimized_out>: Now a VEC(range_s).
	(value_bits_any_optimized_out): New function.
	(value_entirely_covered_by_range_vector): New function, factored
	out from value_entirely_unavailable.
	(value_entirely_unavailable): Reimplement.
	(value_entirely_optimized_out): New function.
	(insert_into_bit_range_vector): New function, factored out from
	mark_value_bits_unavailable.
	(mark_value_bits_unavailable): Reimplement.
	(struct ranges_and_idx): New struct.
	(find_first_range_overlap_and_match): New function, factored out
	from value_available_contents_bits_eq.
	(value_available_contents_bits_eq): Rename to ...
	(value_contents_bits_eq): ... this.  Check both unavailable
	contents and optimized out contents.
	(value_available_contents_eq): Rename to ...
	(value_contents_eq): ... this.
	(allocate_value_lazy): Remove reference to the old optimized_out
	boolean.
	(allocate_optimized_out_value): Use
	mark_value_bytes_optimized_out.
	(require_not_optimized_out): Adjust to check whether the
	optimized_out vec is empty.
	(ranges_copy_adjusted): New function, factored out from
	value_contents_copy_raw.
	(value_contents_copy_raw): Also copy the optimized out ranges.
	Assert the destination ranges aren't optimized out.
	(value_contents_copy): Update comment, remove call to
	require_not_optimized_out.
	(value_contents_equal): Adjust to check whether the optimized_out
	vec is empty.
	(set_value_optimized_out, value_optimized_out_const): Delete.
	(mark_value_bytes_optimized_out, mark_value_bits_optimized_out):
	New functions.
	(value_entirely_optimized_out, value_bits_valid): Delete.
	(value_copy): Take a VEC copy of the 'optimized_out' field.
	(value_primitive_field): Remove special handling of optimized out.
	(value_fetch_lazy): Assert that lazy values have no unavailable
	regions.  Use value_bits_any_optimized_out.  Remove some special
	handling for optimized out values.
	* value.h: Add intro comment about <optimized out> and
	<unavailable>.
	(struct lval_funcs): Remove check_validity and check_any_valid
	fields.
	(set_value_optimized_out, value_optimized_out_const): Remove.
	(mark_value_bytes_optimized_out, mark_value_bits_optimized_out):
	New declarations.
	(value_bits_any_optimized_out): New declaration.
	(value_bits_valid): Delete declaration.
	(value_available_contents_eq): Rename to ...
	(value_contents_eq): ... this, and extend comments.

gdb/testsuite/
	PR symtab/14604
	PR symtab/14605
	* gdb.dwarf2/dw2-op-out-param.exp: Remove kfail branches and use
	gdb_test.
2014-08-20 00:07:40 +01:00
Jan Kratochvil 6694c4110a Fix -fsanitize=address on unreadable inferior strings
echo 'void f(char *s){}main(){f((char *)1);}'|gcc -g -x c -;../gdb ./a.out -ex 'b f' -ex r
====ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000aaccf at pc 0x96eea7 bp 0x7fff75bdbc90 sp 0x7fff75bdbc80
READ of size 1 at 0x6020000aaccf thread T0
    #0 0x96eea6 in extract_unsigned_integer .../gdb/findvar.c:108
    #1 0x9df02b in val_print_string .../gdb/valprint.c:2513
[...]
0x6020000aaccf is located 1 bytes to the left of 8-byte region [0x6020000aacd0,0x6020000aacd8)
allocated by thread T0 here:
    #0 0x7f45fad26b97 in malloc (/lib64/libasan.so.1+0x57b97)
    #1 0xdb3409 in xmalloc common/common-utils.c:45
    #2 0x9d8cf9 in read_string .../gdb/valprint.c:1845
    #3 0x9defca in val_print_string .../gdb/valprint.c:2502
[..]
====ABORTING

gdb/
2014-08-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix -fsanitize=address on unreadable inferior strings.
	* valprint.c (val_print_string): Fix access before BUFFER.
2014-08-19 22:55:10 +02:00
Pedro Alves 0718a8da7b Remove stale comment
This comment is no longer true for watchpoints since commit 31e77af2
(PR breakpoints/7143 - Watchpoint does not trigger when first set).

gdb/testsuite/

	* gdb.base/watchpoint-hw-hit-once.c (main): Update comment.
2014-08-19 18:18:31 +01:00
Simon Marchi 89a1c21a1d Convert target_structs vector to VEC
I thought that this home made implementation of a vector could be
replaced by the more standard VEC. The implementation seems to predate
the introduction of vec.h, so that would explain why it exists.

Ran make check before and after, no new failures.

gdb/ChangeLog:

2014-08-19  Simon Marchi  <simon.marchi@ericsson.com>

	* target.c (target_struct_size): Remove.
	(target_struct_allocsize): Remove.
	(DEFAULT_ALLOCSIZE): Remove.
	(target_ops_p): New typedef.
	(DEF_VEC_P (target_ops_p)): New vector type.
	(target_structs): Change type to VEC (target_ops_p).
	(add_target_with_completer): Replace "push" code by VEC_safe_push.
	(find_default_run_target): Rewrite for loop following changes to
	target_structs.
2014-08-19 11:36:31 -04:00
Joel Brobecker cb417230fb value_from_pointer: remove call to resolve_dynamic_type
The given type is expected to always be a TYPE_CODE_PTR, for which
resolve_dynamic_type does nothing.  So this patch removes this call.

gdb/ChangeLog:

        * value.c (value_from_pointer): Remove use of resolve_dynamic_type.
        Adjust code accordingly.  Adjust function description comment.
2014-08-19 15:43:19 +02:00
Yao Qi 13b448cdf7 Set breakpoint on the right line
In gdb.base/watchpoint-hw-hit-once.exp, test scans source and set
breakpoint on the line having "break-at-exit",

  gdb_breakpoint [gdb_get_line_number "break-at-exit"]

However, in watchpoint-hw-hit-once.c, there are two lines having
this key word:

  dummy = 1;	/* Stub to catch break-at-exit after WATCHEE has been hit.  */
  dummy = 2;	/* break-at-exit */

so the test sets breakpoint on the first one, while I think it is
expected to set breakpoint on the second one, as far as I can tell
from the comments in watchpoint-hw-hit-once.c:

  /* Stub lines are present as no breakpoints/watchpoint gets hit if current PC
     already stays on the line PC while entering "step"/"continue".  */

This patch is to change the source matching pattern so that test
can correctly set breakpoint on the right line.  This patch fixes
a fail we found on arm-none-eabi target.

(gdb) PASS: gdb.base/watchpoint-hw-hit-once.exp: continue
continue^M
Continuing.^M
^M
*** EXIT code 0^M
[Inferior 1 (Remote target) exited normally]^M
(gdb) FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue to break-at-exit (the program exited)

Run it again on x86_64-linux, no result changes.

gdb/testsuite:

2014-08-19  Yao Qi  <yao@codesourcery.com>

	* gdb.base/watchpoint-hw-hit-once.exp: Set breakpoint on the
	right line.
2014-08-19 21:31:36 +08:00
Yao Qi 817e0957a5 Support _Complex in hard-VFP abi
Hi,
When we pass "-mfloat-abi=hard" flag in the GDB testing, we see the
following fails,

FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/callfuncs.exp: p t_double_complex_values(dc1, dc2)
FAIL: gdb.base/callfuncs.exp: p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)
FAIL: gdb.base/callfuncs.exp: p t_long_double_complex_values(ldc1, ldc2)
FAIL: gdb.base/callfuncs.exp: p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4)
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

The hard-VFP ABI was supported by GDB overal, done by this patch
https://sourceware.org/ml/gdb-patches/2009-07/msg00686.html but
"vectors and complex types are not currently supported", mentioned in
the patch.  As a result, these tests fail.

This patch is to support _Complex types in hard-VFP abi.  As specified
in "7.1.1, Procedure Call Standard for the ARM Arch", the layout of
_Complex types is a struct, which is identical to the layout on amd64,
so I copy Mark's comments to amd64 support.

Regression tested on arm-none-eabi target.  OK to apply?

gdb:

2014-08-19  Yao Qi  <yao@codesourcery.com>

	* arm-tdep.c (arm_vfp_cprc_sub_candidate): Handle _Complex
	types.
2014-08-19 21:08:38 +08:00
Alan Modra 2974be626b Fix --diable-shared --enable-plugins build breakage
Directories that don't use libtool need to add -ldl (on most *nix
hosts) to provide dlopen for libbfd.

config/
	* plugins.m4 (AC_PLUGINS): If plugins are enabled, add -ldl to
	LIBS via AC_SEARCH_LIBS.
gdb/
	* acinclude.m4 (GDB_AC_CHECK_BFD): Don't add -ldl.
	* config.in: Regenerate.
sim/ppc/
	* configure.ac: Invoke AC_PLUGINS.
	* config.in: Regenerate.

and regen lots of configure files.
2014-08-19 21:59:56 +09:30
Gary Benson 34abf635b3 Introduce common-debug.h
This introduces common-debug.h.  This holds the functions debug_printf
and debug_vprintf, two functions that the common code can use to print
debugging messages.  Clients of the common code are expected to
implement debug_vprintf; a debug_vprintf function is written from
scratch for GDB, and gdbserver's existing debug_printf is repurposed
as debug_vprintf.

common/agent.c is changed to use debug_vprintf rather than
defining the macro DEBUG_AGENT depending on GDBSERVER.

nat/i386-dregs.c is changed to use the externally-implemented
debug_printf, rather than defining it itself.

gdb/ChangeLog:

	* common/common-debug.h: New file.
	* common/common-debug.c: Likewise.
	* debug.c: Likewise.
	* Makefile.in (SFILES): Add common/common-debug.c.
	(HFILES_NO_SRCDIR): Add common/common-debug.h.
	(COMMON_OBS): Add common-debug.o and debug.o.
	(common-debug.o): New rule.
	* common/common-defs.h: Include common-debug.h.
	* common/agent.c (debug_agent_printf): New function.
	(DEBUG_AGENT): Redefine.
	* nat/i386-dregs.c (debug_printf): Undefine.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/common-debug.c.
	(OBS): Add common-debug.o.
	(common-debug.o): New rule.
	* debug.h (debug_printf): Don't declare.
	* debug.c (debug_printf): Renamed and rewritten as...
	(debug_vprintf): New function.
2014-08-19 10:07:20 +01:00
Gary Benson f6e94d78b2 Move print-utils.h to common-defs.h
This commit moves the inclusion of print-utils.h to common-defs.h
and removes all other inclusions.

gdb/ChangeLog:

	* common/common-defs.h: Include print-utils.h.
	* utils.h: Do not include print-utils.h.

gdb/gdbserver/ChangeLog:

	* utils.h: Do not include print-utils.h.
2014-08-19 10:07:19 +01:00
Gary Benson 9239eeabe3 Introduce common-types.h
This introduces common-types.h.  This file defines various standard
types used by gdb and gdbserver.

Currently these types are conditionally defined based on GDBSERVER.
The long term goal is to remove all such tests; however, this is
difficult as currently gdb uses definitions from BFD.  In the meantime
this is still a step in the right direction.

gdb/ChangeLog:

	* common/common-types.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/common-types.h.
	* common/common-defs.h: Include common-types.h.
	* defs.h (gdb_byte, CORE_ADDR, CORE_ADDR_MAX, LONGEST)
	(ULONGEST): Remove.

gdb/gdbserver/ChangeLog:

	* server.h: Add static assertion.
	(gdb_byte, CORE_ADDR, LONGEST, ULONGEST): Remove.
2014-08-19 10:07:19 +01:00
Gary Benson ef87c8bbe7 Introduce common/errors.h
This introduces common/errors.h.  This holds some error- and warning-
related declarations that can be used by the code in common, nat and
target.  Some of the declared functions must be provided by the client
as documented by the header file comments.

gdb/ChangeLog:

	* common/errors.h: New file.
	* common/errors.c: Likewise.
	* Makefile.in (SFILES): Add common/errors.c.
	(HFILES_NO_SRCDIR): Add common/errors.h.
	(COMMON_OBS): Add errors.o.
	(errors.o): New rule.
	* common/common-defs.h: Include errors.h.
	* utils.h (perror_with_name, error, verror, warning, vwarning):
	Don't declare.
	* common/common-utils.h: (malloc_failure, internal_error):
	Likewise.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/errors.c.
	(OBS): Add errors.o.
	(IPA_OBS): Add errors-ipa.o.
	(errors.o): New rule.
	(errors-ipa.o): Likewise.
	* utils.h (perror_with_name, error, warning): Don't declare.
	* utils.c (warning): Renamed and rewritten as...
	(vwarning): New function.
	(error): Renamed and rewritten as...
	(verror): New function.
	(internal_error): Renamed and rewritten as...
	(internal_verror): New function.
2014-08-19 10:07:18 +01:00
Gary Benson 196a707b15 Ensure internal_vproblem always prints the message
While working on internal_vproblem I noticed that the error/warning
message is suppressed if problem->should_quit is internal_problem_yes
or internal_problem_no.  This behaviour seems wrong.  This commit
modifies internal_vproblem to emit the message regardless of the
user's settings.

gdb/
2014-08-19  Gary Benson  <gbenson@redhat.com>

	* utils.c (internal_vproblem): Always print the message.
2014-08-19 09:44:16 +01:00
David Blaikie 1cbf50779e boards/fission.exp: Explicitly pass -ggnu-pubnames for clang.
* boards/fission.exp: Explicitly pass -ggnu-pubnames for clang.
2014-08-18 12:07:49 -07:00
Joel Brobecker bf0fae198a gdb.dwarf2/data-loc.exp: Remove second DW_AT_upper bound in array range.
The testcase generates an assembly file where a second DW_AT_upper_bound
attribute gets generated in the array range.  This was definitely
unintentional, and I only noticed this after pushing the testcase,
when dumping one more time the DWARF data using readelf.

This patch fixes it.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/data-loc.exp: Remove second DW_AT_upper bound
        attribute in array range.
2014-08-18 19:47:12 +02:00
Doug Evans ded4fc8f9c ada-typeprint.c (print_range): Initialize lo,hi for gcc -Wall.
* ada-typeprint.c (print_range): Initialize lo,hi for gcc -Wall.
2014-08-18 10:04:18 -07:00
Joel Brobecker 3c8c5dcc98 DW_AT_data_location and DW_OP_push_object_address testcase.
This testcase allows us to test the proper processing of both
DW_AT_data_location and DW_OP_push_object_address using a hand-crafted
testcase duplicating how we expect the Ada compiler to represent
unbounded arrays.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/data-loc.c, gdb.dwarf2/data-loc.exp: New files.
2014-08-18 18:14:14 +02:00
Joel Brobecker 950c97d860 [Ada] "ptype" of array where bound value uses DW_OP_push_object_address
Consider an Ada array type where the DWARF debugging info for
at least one of the bounds involves an expression containing
a DW_OP_push_object_address operation. Trying to "ptype" that
type currently yields:

    (gdb) ptype foo.array_type
    type = array (Location address is not set.

This patch improves ada-typeprint by adding handling of the situation
where an array range type has dynamic bounds.  In that case, it prints
the array bounds using Ada's typical syntax for unbounded ranges "<>":

    (gdb) ptype array_type
    type = array (<>) of integer

gdb/ChangeLog:

        * ada-typeprint.c (type_is_full_subrange_of_target_type):
        Return 0 if TYPE is dynamic.
        (print_range): Add handling of dynamic ranges.
2014-08-18 18:13:29 +02:00
Joel Brobecker 3cdcd0ce16 Add support for DW_AT_data_location.
gdb/ChangeLog:

        * gdbtypes.h (struct main_type): Add field "data_location".
        (TYPE_DATA_LOCATION, TYPE_DATA_LOCATION_BATON)
        (TYPE_DATA_LOCATION_ADDR, TYPE_DATA_LOCATION_KIND): New macros.
        * gdbtypes.c (is_dynamic_type): Return 1 if the type has
        a dynamic data location.
        (resolve_dynamic_type): Add DW_AT_data_location handling.
        (copy_recursive, copy_type): Copy the data_location information
        when present.
        * dwarf2read.c (set_die_type): Add DW_AT_data_location handling.
        * value.c (value_from_contents_and_address): Add
        DW_AT_data_location handling.
2014-08-18 18:12:53 +02:00
Joel Brobecker 08412b0722 Add support for DW_OP_push_object_address.
gdb/ChangeLog:

        * dwarf2expr.h (struct dwarf_expr_context_funcs): Uncomment
        field "get_object_address".
        * dwarf2expr.c (execute_stack_op): Add handling for
        DW_OP_push_object_address.
        * dwarf2loc.h (dwarf2_evaluate_property): Add "address" field.
        * dwarf2loc.c (struct dwarf_expr_baton): Add field "obj_address".
        (dwarf_expr_push_dwarf_reg_entry_value): Set baton_local.obj_address.
        (dwarf_expr_get_obj_addr): New function.
        (dwarf_expr_ctx_funcs): Add get_object_address field.
        (dwarf2_evaluate_loc_desc_full): Set baton.obj_address.
        (dwarf2_locexpr_baton_eval): Add parameter "addr".  Use it.
        (dwarf2_evaluate_property): Add parameter "address".  Use it.
        (needs_get_obj_addr): New function.
        (needs_frame_ctx_funcs): Add get_object_address field.
        (dwarf2_compile_expr_to_ax): Add DW_OP_push_object_address handling.
        * gdbtypes.c (resolve_dynamic_range): Add "addr" field.  Use it.
        (resolve_dynamic_array): Likewise.
2014-08-18 18:11:28 +02:00
Joel Brobecker 84754697d2 ada_evaluate_subexp<OP_VAR_VALUE>: Avoid static fixing when possible.
Now that the OP_VAR_VALUE section of this function has been reorganized
a bit, we can fall-back on standard evaluation when static fixing is
not required. This patch does that, but being exclusive about when
static fixing has to be used, rather than doing it all the time when
noside is EVAL_AVOID_SIDE_EFFECTS.

This will pave the way for later when we want to evaluate entities
that have no GNAT encodings related to them but dynamic properties
instead. In that case, we expect the standard evaluation to resolve
those dynamic properties for us, even in no-side-effect mode.

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>:
        When noside is EVAL_AVOID_SIDE_EFFECTS, only return a statically
        fixed value for records and unions for which some GNAT encodings
        are present.
2014-08-18 17:10:39 +02:00
Joel Brobecker da5c522f5b avoid "if ... else if ... else" logic in ada-lang.c::ada_evaluate_subexp
The OP_VAR_VALUE branch in ada_evaluate_subexp is written with
multiple "if ... else if ... else if ... else ..." block. But
in practice, these blocks  all either goto out of that block of
code, or return.

This patch rewrites this code slightly by replacing the "else if"-s
by simple "if"s. This should better reflect the ideal processing
where we try to do a standard eval whenever possible, and only
do something else when the standard eval does not work. On a pratical
level, this patch makes it easier to fall through to the default
processing when none of the special situations are detected, thus
making it easier to add more handlers of those special situations;
or to remove them as they no longer become necessary!

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Slight code
        rewrite to avoid "else if" and "else" constructs.  Should be
        a no-op in practice.
2014-08-18 17:09:33 +02:00
Joel Brobecker 0d72a7c318 Fix indentation level in ada-lang.c::ada_evaluate_subexp.
I just happen to notice that a lexical block was missing one
indentation level.

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Fix identation
        of lexical block.
2014-08-18 17:08:55 +02:00
Siva Chandra e66d444669 Add new argument NOSIDE to find_overload_match.
This is a fix for PR c++/17132.
If this new argument is set to EVAL_AVOID_SIDE_EFFECTS, then the object's
memory will not be read while picking the best overload match.

gdb/

	* eval.c: Update all calls to find_overload_match.
	* valarith.c: Likewise.
	(value_user_defined_cpp_op, value_user_defined_op): New
	argument NOSIDE.  Update all callers.
	* valops.c (find_overload_match): New argument NOSIDE.
	* value.h (find_overload_match): Update signature.

gdb/testsuite

	* gdb.cp/pr17132.cc: New file.
	* gdb.cp/pr17132.exp: New file.
2014-08-15 18:28:59 -07:00
Siva Chandra 940df40812 Fix xmethod Python so that it works with Python3.
gdb/

	* python/lib/gdb/command/xmethods.py (set_xm_status1): Use the
	'items'	methods instead of 'iteritems' method on dictionaries.

gdb/testsuite/

	* gdb.python/py-xmethods.py (A_getarrayind)
	(E_method_char_worker.__call__, E_method_int_worker.__call__):
	Use 'print' with function call syntax.
	(E_method_matcher.match): Fix tab vs space indentation mixup.
2014-08-15 18:04:47 -07:00
Doug Evans 699ca60ad9 (dwarf_decode_lines_1): Move definition of adj_opcode closer to use.
* dwarf2read.c (dwarf_decode_lines_1): Move definition of adj_opcode
	closer to use.
2014-08-15 16:22:51 -07:00
Doug Evans 37780ee59e dwarf2read.c (dwarf_decode_lines_1): Add comment.
* dwarf2read.c (dwarf_decode_lines_1): Add comment.
2014-08-15 16:05:47 -07:00
Doug Evans 0ad93d4feb (dwarf_decode_lines_1): Delete local "column", unused.
* dwarf2read.c (dwarf_decode_lines_1): Delete local "column", unused.
2014-08-15 15:38:56 -07:00
Doug Evans 20d8c3722e (dwarf_decode_lines_1): Delete local basic_block, unused.
* dwarf2read.c (dwarf_decode_lines_1): Delete local basic_block,
	unused.
2014-08-15 15:24:35 -07:00
Eli Zaretskii cb039ba453 Avoid compiler warnings about incomplete parameter types.
gdb/ChangeLog:

	* dcache.h: Include target.h, to avoid compile time warnings.
2014-08-15 17:04:27 +03:00
Joel Brobecker eb7a547ad4 Add "frame.h" #include in gdbarch.h.
This include is needed because gdbarch_dummy_id needs the full
definition of struct frame_id.

gdb/ChangeLog:

        * gdbarch.sh: #include "frame.h" in gdbarch.h.  Delete "struct
        frame_info" partial declaration.
        * gdbarch.h: Regenerate.

Tested on x86_64-linux by rebuilding GDB.
2014-08-15 05:29:33 -07:00
Yao Qi ebcc6c3a7b Skip tfile.exp if unable to generate trace file
I added proc generate_tracefile in this patch
https://sourceware.org/ml/gdb-patches/2014-03/msg00591.html but
tfile.exp isn't skipped as changelog entry said:

	* gdb.trace/tfile.exp: Skip the test if generate_tracefile
	return 0.

it is a mistake I made at the last minute.  Patch below fixed it.

gdb/testsuite:

2014-08-15  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/tfile.exp: Return -1 if generate_tracefile returns
	false.
2014-08-15 08:43:44 +08:00
Yao Qi 775e0f0481 Set print symbol off in some tests
GDB in default prints the symbol associated on an address, and tests
assume that there is no symbol on address zero.  However, on bare
metal target, address may be mapped to zero and there may be a
symbol.  Then, some tests fail as below:

print const_cast<void *> (0)^M
$8 = (void *) 0x0 <_ftext>^M
(gdb) FAIL: gdb.cp/casts.exp: const_cast of 0

p acp->c1^M
$9 = (A *) 0x0 <_ftext>^M
(gdb) FAIL: gdb.cp/class2.exp: p acp->c1

This patch is to set print symbol off in these tests, like what
I did previously https://sourceware.org/ml/gdb-patches/2014-07/msg00257.html

gdb/testsuite:

2014-08-15  Yao Qi  <yao@codesourcery.com>

	* gdb.cp/casts.exp: Set print symbol off.
	* gdb.cp/class2.exp: Likewise.
	* gdb.cp/overload.exp: Likewise.
	* gdb.cp/templates.exp: Likewise.
2014-08-15 07:55:16 +08:00
Yao Qi 783cecc8b3 Remove pst from dwarf_decode_lines_1
Hi,
Parameter 'pst' of function dwarf_decode_lines_1 isn't used except
to compute decode_for_pst_p, which has been got in the caller
dwarf_decode_lines.  I wonder it would be good if we just pass
'decode_for_pst_p'.

gdb:

2014-08-15  Yao Qi  <yao@codesourcery.com>

	* dwarf2read.c (dwarf_decode_lines_1): Remove parameter 'pst'.
	Add parameter 'decode_for_pst_p'.  Callers update.
2014-08-15 07:38:19 +08:00
Yao Qi 65c749e7c0 Fix build/17104
This patch is to fix the build error when GDB is configured as:

  CFLAGS=-Wall ./configure --with-babeltrace; make

This patch adds one line of code in configure test to use local
variable 'pos'.

Note that we append -Werror to CFLAGS to catch the warning related to
assignment to scope.  See more in this thread
https://sourceware.org/ml/gdb-patches/2014-08/msg00045.html

2014-08-13  Yao Qi  <yao@codesourcery.com>

	PR build/17104
	* configure.ac: Use local variable 'pos'.
	* configure: Regenerated.
2014-08-13 17:42:57 +08:00
Doug Evans d769e349bc Delete "Loaded symbols for ..." message, it is redundant.
* solib.c (solib_read_symbols): Delete "Loaded symbols for ..."
	message, it is redundant with "Reading symbols from ..." message.

	testsuite/
	* gdb.base/print-symbol-loading.exp (test_load_core): Update.
	(test_load_shlib): Update.
2014-08-11 17:21:07 -07:00
Doug Evans 24f1235ebc linux-nat.c (linux_nat_thread_address_space): Delete dead code. 2014-08-10 21:09:29 -07:00
Yao Qi dcd2e6ef22 Fix PR remote/9053: remove dead code on query packet size
The code becomes dead as GDB evolves.  In 2003, Andrew Cagney post patch
https://sourceware.org/ml/gdb-patches/2003-10/msg00511.html to add target
read/write partial methods.  They support query buffer size when both
OFFSET and LEN is zero, and it was used in avr-tdep.c and kod.c.  Then,
Daniel added target_read_object_alloc and avr-tdep.c switches to use that
in patch https://sourceware.org/ml/gdb-patches/2006-07/msg00009.html
From then on, GDB on longer queries the buffer size, so the code
returning packet size in remote_xfer_partial became dead.

PR 17060 is duplicated of PR 9053, so I mention the latter in the
ChangeLog entry.  Rebuild GDB with this patch.  OK to apply?
I'll mark PR 17060 as duplicated once the patch is applied.

gdb:

2014-08-09  Yao Qi  <yao@codesourcery.com>

	PR remote/9053
	* remote.c (remote_xfer_partial): Remove dead code.
2014-08-09 08:50:17 +08:00