Commit Graph

376 Commits

Author SHA1 Message Date
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Warner Losh
3bdf775801 NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.
2014-04-13 05:21:56 +00:00
Andrew Turner
73279d4113 Add a new ARM TARGET_ARCH, armv6hf. This is considered experimental.
This targets the existing ARMv6 and ARMv7 SoCs that contain a VFP unit.
This is an optional coprocessors may not be present in all devices, however
it appears to be in all current SoCs we support.

armv6hf targets the VFP variant of the ARM EABI and our copy of gcc is too
old to support this. Because of this there are a number of WITH/WITHOUT
options that are unsupported and must be left as the default value. The
options and their required value are:
 * WITH_ARM_EABI
 * WITHOUT_GCC
 * WITHOUT_GNUCXX

In addition, without an external toolchain, the following need to be left
as their default:
 * WITH_CLANG
 * WITH_CLANG_IS_CC

As there is a different method of passing float and double values to
functions the ABI is incompatible with existing armv6 binaries. To use
this a full rebuild of world is required. Because no floating point values
are passed into the kernel an armv6 kernel with VFP enabled will work with
an armv6hf userland and vice versa.
2014-03-23 12:49:25 +00:00
John-Mark Gurney
d5ad10055b add support for building a cross-gdb for ARM... This isn't hooked up
to xdev yet as I don't know how to make it work properly...  It also
isn't heavily tested...

Reviewed by:	silence on -arm
2014-02-12 02:08:42 +00:00
Marcel Moolenaar
2d34114497 When building a cross-kgdb, suppress the registration of the
standard core target by declaring coreops_suppress_target with
initializer. This is also happening for non-cross kgdb, by
virtue of having fbsd-threads.c in libgdb and having it do the
exact same thing. Since fbsd-threads.c is not included in in
libgdb when building a cross debugger, we ended up with more
than 1 core file targets (the standard gdb core file target and
kgdb's libkvm based core file target) and this behaves the same
as not having a core target at all.
2014-01-13 19:08:25 +00:00
Marcel Moolenaar
03197d0ab0 When building a cross kgdb, link against the appropriate cross libkvm.
Provide an implementation of ps_pglobal_lookup() for use by the cross
libkvm.
2013-12-28 23:31:22 +00:00
Simon J. Gerraty
34b33809b7 Updated dependencies 2013-10-13 00:24:00 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Ed Maste
73adaf3810 Fold in frame-unwind patch
After moving to svn there's no need to avoid pulling files off a vendor
branch.
2013-06-17 18:34:34 +00:00
Ed Maste
42f8c5b580 Add a new knob WITH_DEBUG_FILES to control the building of standalone
debug files for userland programs and libraries.  The "-g" debug flag
is automatically applied when WITH_DEBUG_FILES is set.

The debug files are now named ${prog}.debug and ${shlib}.debug for
consistency with other systems and documentation.  In addition they are
installed under /usr/lib/debug, to simplify the process of installing
them if needed after a crash.  Users of bsd.{prog,lib}.mk outside of the
base system place the standalone debug files in a .debug subdirectory.
GDB automatically searches both of these directories for standalone
debug files.

Thanks to everyone who contributed changes, review, and testing during
development.
2013-06-07 21:40:02 +00:00
Warner Losh
3d8e9c1283 Fix mips64 and mipsn32 bilds by using proper register names. 2013-04-25 04:53:01 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Will Andrews
5cabf7777e KGDB: Accept KLD symbol files with the ".symbols" extension.
Submitted by:	gibbs
Approved by:	ken (mentor)
Sponsored by:	Spectra Logic
MFC after:	1 month
2013-03-28 17:07:02 +00:00
Will Andrews
c89d0ca50b KGDB: Allow modules to be loaded from the specified kernel's directory.
When looking up the absolute path for a kld, call find_kld_path() first.
This enables locating the module in a different directory than the one
stored in kernel memory.

With this change, kgdb can now be run on a kernel & vmcore whose associated
modules are located in the same directory as the kernel.  This makes
independent triaging of problems much easier.

This change also does not break the normal kgdb use case where no arguments
are specified; in that case kgdb loads the running kernel and its modules.

Reviewed by:	adrian
Approved by:	ken (mentor)
Sponsored by:	Spectra Logic
MFC after:	1 month
2013-03-28 17:04:59 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Adrian Chadd
bab63de286 kgdb enhancements!
* document the kgdb -b flag
* better verify what's valid with -b
* add more comprehensive command line help

PR:		kern/175743
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2013-02-19 02:09:18 +00:00
Marcel Moolenaar
d7aa5f02d0 In kthr.c, obtain the address of the PCB for threads that were running
on a core, when the core was stopped, by calling kgdb_trgt_core_pcb().
This has 2 advantages:
1.  We don't need to include a machine-specific header anymore and as
    such kthr.c is truly machine independent. This allows the code to
    be used in a cross-debugger.
2.  We don't need to lookup stoppcbs in generic code when it's an
    inherently target-spicific symbol. It does not exist for ia64.

Implement kgdb_trgt_core_pcb() for all architectures, except ia64, by
calling a common function called kgdb_trgt_stop_pcb(). This function
differs from kgdb_trgt_core_pcb() in that it gets the size of the PCB
structure as an argument and as such remains machine independent.

On ia64 the PCB for stopped cores is in the PCPU structure itself.
This for better scaling. The implementation of kgdb_trgt_core_pcb()
for ia64 uses the cpuid_to_pcpu[] array to to obtain the address of
the PCB structure.
2013-02-17 02:15:19 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Adrian Chadd
23dbd4334a Add command-line support to kgdb to allow the baudrate to be set.
This allows a remote session to be specified with '-r' as well as a
non-default baudrate setting using '-b'.

TODO: add to the kgdb manpage.

MFC after:	2 weeks
2013-01-21 01:46:36 +00:00
Simon J. Gerraty
7cd2dcf076 Updated/new Makefile.depend 2012-11-08 21:24:17 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Andreas Tobler
8a1f9d1cf5 Fix typo. Not a win in terms of functionality but in terms of completeness. 2012-08-19 19:17:54 +00:00
Oleksandr Tymoshenko
4da573d910 Merging of projects/armv6, part 3
r238211:
Support TARGET_ARCH=armv6 and TARGET_ARCH=armv6eb

This adds a new TARGET_ARCH for building on ARM
processors that support the ARMv6K multiprocessor
extensions.  In particular, these processors have
better support for TLS and mutex operations.

This mostly touches a lot of Makefiles to extend
existing patterns for inferring CPUARCH from ARCH.
It also configures:
 * GCC to default to arm1176jz-s
 * GCC to predefine __FreeBSD_ARCH_armv6__
 * gas to default to ARM_ARCH_V6K
 * uname -p to return 'armv6'
 * make so that MACHINE_ARCH defaults to 'armv6'
It also changes a number of headers to use
the compiler __ARM_ARCH_XXX__ macros to configure
processor-specific support routines.

Submitted by:	Tim Kientzle <kientzle@freebsd.org>
2012-08-15 03:21:56 +00:00
David Xu
f8ad51d5e2 Print key value, an index, otherwise we don't know which key is allocated. 2012-05-21 03:06:31 +00:00
Glen Barber
2fccbf04cc General mdoc(7) and typo fixes.
PR:		167696
Submitted by:	Nobuyuki Koganemaru (kogane!jp.freebsd.org)
MFC after:	3 days
2012-05-10 02:07:00 +00:00
Marcel Moolenaar
f502124c06 Allow building a powerpc cross-kgdb. 2012-04-27 20:16:20 +00:00
Juli Mallett
84db023ec1 Assume a big-endian default on MIPS and drop the "eb" suffix from MACHINE_ARCH.
This makes our naming scheme more closely match other systems and the
expectations of much third-party software.  MIPS builds which are little-endian
should require and exhibit no changes.  Big-endian TARGET_ARCHes must be
changed:
	From:		To:
	mipseb		mips
	mipsn32eb	mipsn32
	mips64eb	mips64

An entry has been added to UPDATING and some foot-shooting protection (complete
with warnings which should become errors in the near future) to the top-level
base system Makefile.
2012-03-29 02:54:35 +00:00
Juli Mallett
07257b7e1c Note two shortcomings of GDB on MIPS that should be addressed. 2012-03-13 04:50:41 +00:00
Konstantin Belousov
f1c8f19055 Adopt to new layout of struct pcb.
MFC after:	1 month
2012-01-21 17:50:14 +00:00
Robert Watson
f68dd1eefc Add missing -w to kgdb(1)'s usage().
Sponsored by:	Adara Networks, Inc.
MFC after:	3 days
2012-01-04 21:26:47 +00:00
Olivier Houchard
84f3091bc2 Do not include <sys/ptrace.h> if we're building a cross-debugger, ptrace isn't
used anyway, and it breaks the build, since sys/ptrace.h now includes
<machine/reg.h>

Approved by:	re
2011-08-26 15:24:54 +00:00
John Baldwin
6dfd657c01 Walk the zombproc list as well as the allproc list when enumerating threads
and processes in a kernel image.  This allows examination of threads that
have exited or are in the late stages of exiting.

Tested by:	avg
Approved by:	re (kib)
MFC after:	1 week
2011-08-19 21:28:40 +00:00
Marius Strobl
39c5320dad Compile fbsd-threads.c. Amongst others this is necessary for a working
kgdb(1).

Reviewed by:	marcel
Approved by:	re (kib)
MFC after:	1 week
2011-08-06 17:53:45 +00:00
Attilio Rao
1de471dfee Revert r222363, as bde@ pointed out the initial solution was far more
correct.
2011-05-31 20:59:53 +00:00
Attilio Rao
d361ed4b1c Style fix: cast to size_t rather than u_long when comparing to sizeof()
rets.

Requested by:	kib
2011-05-27 16:01:51 +00:00
Attilio Rao
71a19bdc64 Commit the support for removing cpumask_t and replacing it directly with
cpuset_t objects.
That is going to offer the underlying support for a simple bump of
MAXCPU and then support for number of cpus > 32 (as it is today).

Right now, cpumask_t is an int, 32 bits on all our supported architecture.
cpumask_t on the other side is implemented as an array of longs, and
easilly extendible by definition.

The architectures touched by this commit are the following:
- amd64
- i386
- pc98
- arm
- ia64
- XEN

while the others are still missing.
Userland is believed to be fully converted with the changes contained
here.

Some technical notes:
- This commit may be considered an ABI nop for all the architectures
  different from amd64 and ia64 (and sparc64 in the future)
- per-cpu members, which are now converted to cpuset_t, needs to be
  accessed avoiding migration, because the size of cpuset_t should be
  considered unknown
- size of cpuset_t objects is different from kernel and userland (this is
  primirally done in order to leave some more space in userland to cope
  with KBI extensions). If you need to access kernel cpuset_t from the
  userland please refer to example in this patch on how to do that
  correctly (kgdb may be a good source, for example).
- Support for other architectures is going to be added soon
- Only MAXCPU for amd64 is bumped now

The patch has been tested by sbruno and Nicholas Esborn on opteron
4 x 12 pack CPUs. More testing on big SMP is expected to came soon.
pluknet tested the patch with his 8-ways on both amd64 and i386.

Tested by:	pluknet, sbruno, gianni, Nicholas Esborn
Reviewed by:	jeff, jhb, sbruno
2011-05-05 14:39:14 +00:00
Konstantin Belousov
57c3423c39 Print the raw value of si_code, that is esp. useful for undecoded values.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2011-03-26 21:12:53 +00:00
Dimitry Andric
ce8fb93178 Merge binutils 2.17.50 to head. This brings a number of improvements to
x86 CPU support, better support for powerpc64, some new directives, and
many other things.  Bump __FreeBSD_version, and add a note to UPDATING.

Thanks to the many people that have helped to test this.

Obtained from:	projects/binutils-2.17
2011-02-18 20:54:12 +00:00
Ed Maste
89db1db777 Use string literal format strings to quiet clang warnings. 2011-01-23 14:08:59 +00:00
Warner Losh
cd2ae2532f Retire TARGET_ABI.
Implement MACHINE_ARCH=mips64e[lb] to build N64 images.  This replaces
MACHINE_ARCH=mipse[lb] TARGET_ABI=n64.

MACHINE_ARCH=mipsn32e[lb] has been added, but currently requires
WITHOUT_CDDL due to atomic issues in libzfs.  I've not investigated
this much, but implemented this to preserve as much of the TARGET_ABI
functionality that I could.  Since its presence doesn't affect the
working cases, I've kept it in for now.

Added mips64e[lb] to make universe, so more kernels build.

And I think this (finally) closes the curtain on the tbemd tree.
2011-01-07 20:26:33 +00:00
Dimitry Andric
a35d3535ee Sync: merge r215464 through r215708 from ^/head. 2010-11-22 20:52:18 +00:00
Attilio Rao
7f08176ee8 Add the ability for GDB to printout the thread name along with other
thread specific informations.

In order to do that, and in order to avoid KBI breakage with existing
infrastructure the following semantic is implemented:
- For live programs, a new member to the PT_LWPINFO is added (pl_tdname)
- For cores, a new ELF note is added (NT_THRMISC) that can be used for
  storing thread specific, miscellaneous, informations. Right now it is
  just popluated with a thread name.

GDB, then, retrieves the correct informations from the corefile via the
BFD interface, as it groks the ELF notes and create appropriate
pseudo-sections.

Sponsored by:	Sandvine Incorporated
Tested by:	gianni
Discussed with:	dim, kan, kib
MFC after:	2 weeks
2010-11-22 14:42:13 +00:00
Dimitry Andric
29d0dcddab Sync: merge r215273 through r215318 from ^/head. 2010-11-14 20:47:30 +00:00
Yoshihiro Takahashi
c482218be3 Add missing '/'. 2010-11-14 11:09:16 +00:00
Warner Losh
5fb4617bc9 We need to add powerpc64->powerpc translations (I knew I hated copying
this code in the first place).

Also MACHINE_ARCH powerpc is 32-bit, not MACHINE_CPUARCH == powerpc.

Submitted by:	nathanw
2010-11-14 01:52:19 +00:00
Dimitry Andric
1170f3d12e Sync: merge r214895 through r215140 from ^/head. 2010-11-11 20:52:24 +00:00
Warner Losh
e8dce5b9b3 Complete the integration of tbemd branch into head.
TARGET_BIG_ENDIAN is now completely dead, except where it was
originally supposed to be used (internally in the toolchain building).

TARGET_ARCH has changed in three cases:
(1) Little endian mips has changed to mipsel.
(2) Big endian mips has changed to mipseb.
(3) Big endian arm has changed to armeb.

Some additional changes are needed to make 'make universe' work on arm
and mips after this change, so those are commented out for now.

UPDATING information will be forthcoming.  Any remaining rough edges
will be hammered out in -current.
2010-11-10 06:39:49 +00:00
Oleksandr Tymoshenko
ce9346c8a4 Fix cross-debugger build 2010-11-07 23:23:48 +00:00
Oleksandr Tymoshenko
c8f6c2ae32 Fix initialization order:_initialize_svr4_solib should
be called before _initialize_thread_db
2010-11-07 23:22:22 +00:00
Oleksandr Tymoshenko
94b78d528f - Use proper constant for accessing PCB intead of hardcoded numbers
- Minor clean-up
2010-11-07 20:56:41 +00:00
Oleksandr Tymoshenko
a815718baf Link threads support to the build 2010-11-07 20:53:19 +00:00
Dimitry Andric
4e41c4ad7e Fix warnings in fbsd-threads.c. 2010-11-01 20:17:15 +00:00
Dimitry Andric
e9071af4e8 For stuff under gnu/usr.bin/gdb, search contrib/binutils/include before
contrib/gdb/include, since that contains newer versions of the same
files.
2010-11-01 20:09:54 +00:00
Ed Maste
d290883447 Move test for zero bufp or size before rseq and wseq calculation. This
avoids spinning in an infinite loop for some (possibly corrupt?) core
files at work.
2010-09-22 19:41:01 +00:00
Warner Losh
25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Will Andrews
4be3feb212 Fix buildworld -DNO_CLEAN when using with Perforce, which marks files as
read-only by default, meaning files copied can't be overwritten next time.

Reviewed by:	imp
Approved by:	ken (mentor)
2010-08-12 20:46:49 +00:00
John Baldwin
68819dae55 Change kgdb_lookup() to resolve symbols via GDB instead of via libkvm(3). 2010-08-04 21:02:04 +00:00
Jung-uk Kim
03b2888ea1 Give kgdb(1) a chance to take a look at FPU state. 2010-08-02 17:40:25 +00:00
Andriy Gapon
7996bf419b kgdb: correctly map sections to addresses in elf object modules (amd64)
Unlike for modules with dso type, in elf object modules all the sections
have virtual address of zero.  So, it is insufficient to add module base
address to section virtual address (as recorded in section header) to
get section address in kernel memory.
Instead, we should apply the same calculations that are performed by
kernel loaders (in boot code and in kernel) when they lay out sections
in memory.

Discussed with:	jhb, np
MFC after:	3 weeks
2010-07-23 17:21:23 +00:00
Nathan Whitehorn
2cf64c8006 Teach our toolchain how to generate 64-bit PowerPC binaries. This fixes
a variety of bugs in binutils related to handling of 64-bit PPC ELF,
provides a GCC configuration for 64-bit PowerPC on FreeBSD, and
associated build systems tweaks.

Obtained from:	projects/ppc64
2010-07-10 02:29:22 +00:00
Konstantin Belousov
46d44c29db For "thread signal" command, print some information from siginfo when
available.

Suggested by:	davidxu
MFC after:	2 weeks
2010-07-04 12:09:30 +00:00
Warner Losh
d578fbb66e Make this directory more regular. Since it is one we control, use the
freebsd-based names for filenames.  This allows us to eliminate
almost all of the uses of ${MACHINE_ARCH} here to do special things, and
instead we use it to include filenames.  This makes new architectures easier
to support.
2010-04-14 20:31:06 +00:00
Ulrich Spörlein
aa12cea2cc mdoc: order prologue macros consistently by Dd/Dt/Os
Although groff_mdoc(7) gives another impression, this is the ordering
most widely used and also required by mdocml/mandoc.

Reviewed by:	ru
Approved by:	philip, ed (mentors)
2010-04-14 19:08:06 +00:00
Warner Losh
b29d0c6134 Simplify how we select which architectures to add gdbserver for. If
the MD files exist, compile it, otherwise omit it.
2010-04-12 23:35:58 +00:00
Marcel Moolenaar
2a4510e122 Allow building a cross-kgdb for ia64. 2010-03-26 19:41:40 +00:00
Marcel Moolenaar
10da4aa601 Handle cross-builds for gdbserver. 2010-03-26 19:40:53 +00:00
Warner Losh
ae84e39b61 Fix typo in comment 2010-03-19 05:40:47 +00:00
Jung-uk Kim
bdcf2df5c2 Initial gdbserver support for amd64. 2010-02-25 21:29:00 +00:00
Randall Stewart
7e1f32462d These contain JC's patch to get gdb sort of working
on mips. Its not fully done yet but its a start.

Obtained from: JC - c.jayachandran@gmail.com

M    gnu/usr.bin/gdb/kgdb/trgt_mips.c
M    gnu/usr.bin/gdb/arch/mips/init.c
M    gnu/usr.bin/gdb/arch/mips/Makefile
M    gnu/usr.bin/Makefile
M    contrib/gdb/gdb/mips-tdep.h
2010-02-20 17:29:27 +00:00
Marcel Moolenaar
f6c3201d66 Compile fbsd-threads.c. Threading & TLS support is working just fine. 2010-02-16 16:38:57 +00:00
Andriy Gapon
c12959b335 kgdb: initialize n_type field of nlist entry for kvm_nlist call
kvm_nlist skips lookup for entries that have n_type != N_UNDF.
N_UNDF happens to be zero, so n_type typically has a correct
value by accident, but not always.
Note: jhb has a patch that replaces kvm_nlist use with direct
gdb parsing.

MFC after:	5 days
X-MFC-Note:	unless jhb commits kvm_nlist => kgdb_parse change
2010-02-13 11:47:04 +00:00
Rafal Jaworowski
ab8b490a63 Initial gdbserver support for PowerPC.
Obtained from:	Juniper Networks, Semihalf
2009-02-23 18:22:49 +00:00
Rafal Jaworowski
c7b4433263 Initial gdbserver support for ARM.
Obtained from:	Juniper Networks, Semihalf
2008-11-17 16:32:57 +00:00
David E. O'Brien
ee81baecd8 Document what the sed trick is for.
Remove an embedded <TAB>, and use same style for both files.
2008-10-16 18:09:27 +00:00
John Baldwin
27f38446be Oops, initialize sections and sections_end to NULL.
Submitted by:	Navdeep Parhar
MFC after:	1 week
2008-10-02 20:42:10 +00:00
Konstantin Belousov
42003afced Differentiate between interrupt frames, trap interrupt frames and timer
frame in the kgdb, to allow it to properly backtrace over the interrupt
stacks.

Noted and reviewed by:	tegge
Tested by:	pho
MFC after:	1 week
2008-09-27 15:58:37 +00:00
John Baldwin
59c47d99be Use existing GDB routines for parsing the section table of klds in
the 'add-kld' command instead of doing it more by hand.

MFC after:	1 week
2008-09-25 19:32:03 +00:00
Marcel Moolenaar
93898f2b2d Widen psaddr_t from uintptr_t to uint64_t. This results in an
ABI change on ILP32 platforms and relating to events.  However
it's harmless on little-endian ILP32 platforms in the sense
that it doesn't cause breakages.  Old ILP32 thread libraries
write a 32-bit th_p and new thread libraries write a 64-bit
th_p.  But due to the fact that we have an unused 32-bit data
field right after th_p and that field is always initialized to
zero, little-endian ILP32 machines effectively have a valid
64-bit th_p by accident. Likewise for new thread libraries and
old libthread_db: little endian ILP32 is unaffected.

At this time we don't support big-endian threaded applications
in GDB, so the breakage for the ILP32 case goes unnoticed.
2008-09-14 16:52:42 +00:00
Olivier Houchard
7aab344dc1 Unbreak the arm build, by spelling LIBSRCS correctly. 2008-08-02 12:33:39 +00:00
Olivier Houchard
21fb986f16 Do not build fbsd-threads.c if we're building a cross-debugger.
MFC after:	3 days
2008-08-02 01:21:04 +00:00
John Baldwin
ad335b4edf Catch up to recentish kgdb changes:
- Use ptid_get_pid() rather than ptid_get_tid() (part of the changes to
  let 'tid' work for remote kgdb).
- Add a stub kgdb_trgt_new_objfile() hook.

Silence from:	obrien, mips@
2008-06-18 14:23:28 +00:00
David E. O'Brien
486b0cc401 Add Juniper's copyright. 2008-05-20 22:58:47 +00:00
David E. O'Brien
aa4a28bd31 MIPS arch target kgdb(1) support.
Obtained from: Juniper Networks.
2008-05-20 22:54:42 +00:00
John Baldwin
084bc6a480 Trim unneeded header. 2008-05-09 19:00:40 +00:00
John Baldwin
53df73db45 - Change how the vmcore target maps FreeBSD thread IDs to GDB ptids. We
now only use the TID and ignore the PID and use pid_to_ptid() to build a
  ptid treating the TID as a PID.  The benefit of this is that the vmcore
  target now uses the same scheme as GDB's remote targets.  As a result,
  the 'tid' command now works for remote targets (however, it only accepts
  TIDs and not addresses of 'struct thread' objects).
- Use gdb_thread_select() to do the actual thread switch for the 'tid' and
  'proc' commands.  This now gives the same UI feedback when switching
  threads as the GDB 'thread' command rather than providing no visual
  output at all.

MFC after:	1 week
2008-05-01 20:36:48 +00:00
John Baldwin
3461a0f244 Rework how kgdb manages kernel and vmcore files to be a bit more gdb-ish
so that kgdb can be used more like a normal gdb:
- Load the kernel via the standard 'exec' target and allow it to be changed
  via the 'file' command.
  - Instead of explicitly loading the kernel file as the mail symbol file
    during startup, just pass it to gdb_main() as the executable file.
  - Change the kld support (via shared libraries) to cache the address of
    the linker_files and linker_kernel_file variables in addition to the
    offsets of various members in 'struct linker_file'.
  - When a new symbol file is loaded, recompute the addresses and offsets
    used by the kld support code.
  - When a new symbol file is loaded, recalculate the ofs_fix variable to
    account for the different ways a trapframe can be passed to trap
    frame handlers in i386.  This is done by adding a MD
    kgdb_trgt_new_objfile() hook that is empty on all but i386.
  - Don't use the directory name of the kernel specified on the command
    line to find kernel modules in the kld support code.  Instead,
    extract the filename of the current executable via exec_bfd.  Now
    the 'kernel' variable is private to main.c again.
  - Make the 'add-kld' command explicitly fail if no executable is loaded.
- Make the support for vmcores a real core-dump target that opens the
  kernel and vmcore on open and closes the kvm connection when closed, etc.
  - The 'core' command can now be used to select a vmcore to use, either
    a crash dump file or /dev/mem for live debugging.
  - The 'detach' command can be used to detach from a vmcore w/o attaching
    to a new one.
  - kgdb no longer explicitly opens a core dump during startup and no longer
    has to use an atexit() hook to close the kvm connection on shutdown.
  - Symbols for kld's are automatically loaded anytime a core is opened.
    Also, the unread portion of dmesg is dumped just as it was done on kgdb
    startup previously.
- Don't require either a remote target or core dump if a kernel is specified.
  You can now just run 'kgdb kernel' similar to running gdb on an executable
  and later connect to a remote target or core dump.
- Use a more relaxed way to verify remote targets specified via -r.
  Instead of explicitly allowing a few non-file target specifications,
  just assume that if stat() on the arg and on "/dev/" + arg both fail
  that is some non-file target and pass it to gdb.
- Don't use a custom interpreter.  The existing kgdb_init() hook and the
  target_new_objfile() hook give us sufficient hooks during startup to
  setup kgdb-specific behavior now.
- Always add the 'proc', 'tid', and 'add-kld' commands on startup and not
  just if we have a core dump.  Currently the 'proc' and 'tid' commands do
  not work for remote targets (I will fix at least 'tid' in the next round
  of changes though).  However, the 'add-kld' command works fine for
  loading symbols for a kernel module on a remote target.
- Always setup the 'kld' shared library target operations instead of just
  if we have a core dump.  Although symbols for kernel modules are not
  automatically loaded when connecting to a remote target, you can do
  'info sharedlibrary' after connecting to the remote target and kgdb will
  find all the modules.  You can then use the 'sharedlibrary' command to
  load symbols from the module files.
- Change kthr_init() to free the existing list of kthr objects before
  generating a new one.  This allows it to be invoked multiple times
  w/o leaking memory.

MFC after:	1 week
2008-04-29 20:32:45 +00:00
John Baldwin
624e4d168d - Add a global variable 'fbsdcoreops_suppress_target' that can be set to
force the FreeBSD multithreaded core target to not register any target
  for handling core dumps.  This is analogous to the
  'coreops_suppress_target' variable that GDB provides for suppressing the
  default core dump target.  KGDB will use this new variable so it can
  provide its own core dump target that uses libkvm to work with vmcore
  files.
- Adjust the long name and documentation of the FreeBSD multithreaded core
  dump target so it better matches what GDB's core dump target uses.

MFC after:	1 week
Reviewed by:	davidxu, marcel
2008-04-29 17:47:25 +00:00
John Baldwin
34f36b232b Use kgdb_parse() instead of libkvm(3) to read the first instruction from
"calltrap" to see which method is used to pass trap frames.  This seg
faulted on remote gdb connections (where libkvm isn't used).

MFC after:	3 days
2008-04-28 18:27:19 +00:00
John Baldwin
064e8b005f Remove the 'add_kld_command' arg from load_kld(). It is always true since
the auto-loading of kld's switched to hooking into gdb's shared library
support.

MFC after:	1 week
2008-04-28 15:26:11 +00:00
Warner Losh
2fd1934152 FreeBSD/mips gdb build suspport. From the mips2-jnpr branch. 2008-04-26 12:22:46 +00:00
John Baldwin
36cc36a0ec Change kgdb_parse() to use wrapped versions of parse_expression() and
evaluate_expression() so that any errors are caught and cause the function
to return to 0.  Otherwise the errors posted an exception (via longjmp())
that aborted the current operation.  This fixes the kld handling for
older kernels (6.x and 7.x) that don't have the full pathname stored in
the kernel linker.

MFC after:	3 days
2008-03-29 17:46:03 +00:00
John Baldwin
ec922be302 Initialize the head pointer in kld_current_sos() to NULL to avoid returning
a junk pointer and possibly causing a seg fault if we don't have any
non-kernel klds (or are unable to walk the list due to core / kernel
mismatch).

MFC after:	1 week
2008-03-29 03:48:06 +00:00
John Baldwin
af6e49e963 Remove a stale prototype I missed when converting the kld support over to
hooking into gdb's shared library infrastructure.
2008-02-25 22:04:07 +00:00
John Baldwin
2369087a60 - Rework the kld support to hook into GDB's shared library support.
kgdb(8) now treats kld's as shared libraries relative to the kernel
  "binary".  Thus, you can use 'info sharedlibrary' to list the kld's
  along with 'sharedlibrary' and 'nosharedlibrary' to manage symbol
  loading and unloading.  Note that there isn't an easy way to force GDB
  to use a specific path for a shared library.  However, you can use
  'nosharedlibrary' to unload all the klds and then use 'sharedlibrary'
  to load specific klds where it gets the kld correct and use
  'add-kld' for the kld's where the default open behavior doesn't work.
  klds opened via 'sharedlibrary' (and during startup) do have their
  sections listed in 'info files'.
- Change the 'add-kld' command to use filename completion to complete its
  argument.
2008-01-29 23:44:34 +00:00
John Baldwin
d6022a04c5 Don't close the kernel bfd object during startup. Instead, leave it open
and build a section table from the kernel file so that 'info files' output
for kgdb now matches the usage of gdb on a regular file with the exception
that we don't list sections for memory in the crash dump.
2008-01-29 23:37:59 +00:00
John Baldwin
c989eb07bb Use target_read_memory() and extract_unsigned_integer() instead of direct
KVM access to read kernel pointers.
2008-01-29 23:36:42 +00:00
John Baldwin
a4d5f8a2b7 Don't look for "foo.ko.symbols" files. GDB is smart enough to open the
".symbols" file automatically when you tell it to load "foo.ko" because of
the debug link.
2008-01-29 23:36:10 +00:00