Commit Graph

41 Commits

Author SHA1 Message Date
Marcel Moolenaar
3f6558c489 Allow building a cross libkvm by setting TARGET_ARCH. The library so
produced will be called libkvm-${ARCH} instead of libkvm. This allows
installing it alongside the native version.
For symbol lookups, use ps_pglobal_lookup() instead of __fdnlist()
when building a cross libkvm. It is assumed that the cross tool that
uses the cross libkvm also provides an implementation for this
proc_services function.

Note that this commit does not change any of the architecture-specific
code for cross-compilation.
2013-12-28 23:01:57 +00:00
Jilles Tjoelker
7b05a79942 libkvm: Make second /dev/null file descriptor close-on-exec as well.
MFC after:	1 week
2013-05-04 11:45:48 +00:00
Jilles Tjoelker
76dce67f0f libkvm: Use O_CLOEXEC instead of separate fcntl(F_SETFD) call.
MFC after:	1 week
2013-05-04 09:47:51 +00:00
Ulrich Spörlein
948db0b9e9 libkvm: fix logic inversion introduced with last commit
Reported by:	Brandon Gooch <jamesbrandongooch@gmail.com>
Pointy hat to:	uqs
2011-02-02 17:01:26 +00:00
Ulrich Spörlein
c10970dd7d libkvm code janitoring
- make WARNS=6 clean for archs w/o strict alignment requirments
- add const, ANSIfy, remove unused vars, cast types for comparison
- thanks to differing definitions of VM_MIN_ADDRESS across our archs, we
  need to trick the compiler to not complain about signedness. We could
  either fix VM_MIN_ADDRESS to always be a simple integer or make the
  check conditional on $ARCH.

Closes PRs:	kern/42386, kern/83364
Reviewed by:	bde
2011-01-23 11:08:28 +00:00
Dimitry Andric
5f67450d3a Similar to sys/net/vnet.h, define the linker set name for sys/sys/pcpu.h
as a macro, and use it instead of literal strings.
2010-11-14 20:14:25 +00:00
Robert Watson
ccd8bad0bb A first cut at teaching libkvm how to deal with dynamic per-CPU storage
(DPCPU):

A new API, kvm_dpcpu_setcpu(3), selects the active CPU for the purposes
of DPCPU.  Calls to kvm_nlist(3) will automatically translate DPCPU
symbols and return a pointer to the current CPU's version of the data.
Consumers needing to read the same symbol on several CPUs will invoke a
series of setcpu/nlist calls, one per CPU of interest.

This addition makes it possible for tools like netstat(1) to query the
values of DPCPU variables during crashdump analysis, and is based on
similar code handling virtualized global variables.

MFC after:	1 week
Sponsored by:	Juniper Networks, Inc.
2010-03-01 00:27:55 +00:00
Bjoern A. Zeeb
7cf8b4b933 Make libkvm work on live systems and crashdumps with and
without VIMAGE virtualization in the kernel.

If we cannot resolve a symbol try to see if we can find it with
prefix of the virtualized subsystem, currently only "vnet_entry"
by identifying either the vnet of the current process for a
live system or the vnet of proc0 (or of dumptid if compiled
in a non-default way).

The way this is done currently allows us to only touch libkvm
but no single application. Once we are going to virtualize more
subsystems we will have to review this decision for better scaling.

Submitted by:	rwatson (initial version of kvm_vnet.c, lots of ideas)
Reviewed by:	rwatson
Approved by:	re (kib)
2009-07-23 21:12:21 +00:00
Xin LI
01c56ef230 Reduce code duplication: use calloc() intead of malloc()
and memset afterward.
2008-10-17 20:11:28 +00:00
Xin LI
8b8ffe64e9 Plug memory leaks that is observed when argbuf or argspc is used in the
context.

Submitted by:	Michal Vranek <michal.vranek seznam cz>
PR:		bin/118380
MFC after:	1 month
2008-01-12 00:54:47 +00:00
Hidetoshi Shimokawa
d7dc9f7649 Re-enable raw dump format support on i386 and amd64 for /dev/fwmem. 2007-06-15 11:35:11 +00:00
Warner Losh
67e405315d Remove the advertising clause. UCB did this some time ago, but these
files were never updated to reflect that.

MFC After: 2 days
2007-01-08 17:35:36 +00:00
Wojciech A. Koszek
6e6dfbf26e Don't forget to set internal error message in kvm_nlist().
Approved by:	cognet (mentor)
2006-09-20 12:09:21 +00:00
Christian S.J. Peron
65efc5ee23 Validate that the supplied file is not empty before trying mmap(2) it
and access the pages associated with it.

Submitted by:	Wojciech A. Koszek
PR:		bin/91411
MFC after:	1 week
2006-01-15 20:30:13 +00:00
Peter Wemm
e55a0cd805 Support crash dumps > 4GB in size on 32 bit platforms. _kvm_kvatop()
returned an lseek offset in a "u_long *" value, which can't express >4GB
offsets on 32 bit machines (eg: PAE).  Change to "off_t *" for all.

Support ELF crashdumps on i386 and amd64.

Support PAE crashdumps on i386.  This is done by auto-detecting the
presence of the IdlePDPT which means that PAE is active.

I used Marcel's _kvm_pa2off strategy and ELF header reader for ELF support
on amd64.  Paul Saab ported the amd64 changes to i386 and we implemented
the PAE support from there.

Note that gdb6 in the src tree uses whatever libkvm supports.  If you want
to debug an old crash dump, you might want to keep an old libkvm.so handy
and use LD_PRELOAD or the like.  This does not detect the old raw dump
format.

Approved by: re
2005-06-29 22:39:41 +00:00
Stefan Farfeleder
1a5ff9285a Avoid assignments to cast expressions.
Reviewed by:	md5
Approved by:	das (mentor)
2004-06-08 13:08:19 +00:00
Hidetoshi Shimokawa
7928124aa5 Allow to specify a character special device as a core file.
This enable us to use /dev/fwmem* as a core file.
e.g.
	ps -M /dev/fwmem0.0 -N kernel.debug
	dmesg -M /dev/fwmem0.0 -N kernel.debug
	gdb -k -c /dev/fwmem0.0 kernel.debug
You need to set target EUI64 in hw.firewire.fwmem.eui64_hi/lo before
opening the device. On the target arch, (PCI) bus address must be
equivalent to physical address.
(We cannot use this for sparc64 because of IOMMU.)

No objection in: -audit
2003-10-29 14:02:16 +00:00
Poul-Henning Kamp
8d2fd95bc8 Remove unnecssary <vm/swap_pager.h> includes.
These were probably not cleaned up back in whatever murky past these
files were split into separate files.
2003-07-31 21:44:31 +00:00
Jacques Vidrine
f76b74d6d7 In kvm_openfiles/kvm_open, mark the file descriptors as close-on-exec.
Applications can not do this themselves, as the descriptors are hidden
behind the opaque `kvm_t' type.
2002-09-11 16:41:39 +00:00
Alfred Perlstein
a82bbc730e Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
2002-05-28 17:03:12 +00:00
David E. O'Brien
69160b1eb7 Remove __P() usage. 2002-03-21 23:54:04 +00:00
David E. O'Brien
be04b6d190 Remove 'register' keyword. 2002-03-21 23:39:28 +00:00
Ruslan Ermilov
fe42e96eff Finish cleanup in kvm.c revisions 1.10 and 1.11 -- mark sf (swapfile)
argument to kvm_open() and kvm_openfiles() as unused.

BSD didn't read swap since kvm.c CSRG revision 5.21 (u-area is pageable
under new VM.  no need to read from swap.)

The old !NEWVM code was removed in CSRG revision 5.23 (~ten years ago).
2002-01-22 10:07:03 +00:00
Bruce Evans
6eabd84580 Compensate for "Compensate for header dethreading" by backing it out. 2001-10-10 17:48:44 +00:00
Matthew Dillon
e67f5b9fca Implement __FBSDID() 2001-09-16 21:35:07 +00:00
Mark Murray
82633431b3 Compensate for header dethreading. 2001-05-01 09:24:15 +00:00
Kris Kennaway
ba3c0383aa Limit the amount of data copied to the error buffer to _POSIX2_LINE_MAX.
This is the documented size which the user-provided buffer must be.
2000-08-04 09:23:07 +00:00
Jacques Vidrine
91a594d823 Change the return value of kvm_read/kvm_write to be -1 on error, to
match the documented interface.

Previously it returned 0 on error.

PR:		bin/10511
2000-03-31 15:04:25 +00:00
David E. O'Brien
b787589098 -Wall, which caught a real bug where buflen wasn't being set properly. 2000-03-27 00:33:45 +00:00
Peter Wemm
c4a7cdb3b6 Use kldsym(2) to lookup symbol values. This avoids the kvm_mkdb juggling
and is module aware.  Yes, this means that kvm_nlist(3) will find symbols
in loaded modules.  The emulation of the nlist struct is pretty crude but
seems to work well enough for all the users in the tree that I found.
1999-12-27 07:14:58 +00:00
Peter Wemm
8771870c76 Delete the sf (swapfile) arg to an internal function that used to point to
/dev/drum but has not been used for a LONG time.
Add $FreeBSD$
1999-10-11 05:01:17 +00:00
Bruce Evans
480bc7e108 Don't open the swap file. The open descriptor for it hasn't been used
for over 5 years since we switched to using procfs for kvm_uread().
This cleanup was motivated by recent breakage of the default swap file
(/dev/drum) when swapon() has not been called.
1999-08-25 03:01:54 +00:00
Poul-Henning Kamp
35e6b695d6 Allow /dev/null as path for the "/dev/mem" file, and assume that people
know what they're doing if they do that.  This will allow ps to use
the kvm_proc.c bits without having access to /dev/mem.

Fix kvm_proc.c to not need /dev/mem for access to argv/envp
1998-06-30 21:29:44 +00:00
Andrey A. Chernov
d7b100f932 kvm_malloc:
When malloc fails. don't try to memset NULL pointer, it cause core dump
Replace malloc+memset with calloc, theoretically it can do some
optimization of zeroing process internally
Improve error diagnostic
1996-11-11 08:28:47 +00:00
Peter Wemm
a52219bb33 phkmalloc strikes again! :-) Another use of un-cleared returns from
malloc squashed...
1995-12-09 04:45:50 +00:00
Rodney W. Grimes
6c06b4e2aa Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
Bruce Evans
64f14011a8 Fix previous fix to agree with the man page - don't report errors in
kvm_open() if errstr is NULL.
1995-02-25 16:44:01 +00:00
Poul-Henning Kamp
12eaa3d55d Remove some unused variables and fix two blatant core dump triggers. 1995-02-24 08:15:27 +00:00
Garrett Wollman
4be4929c2b Get rid of _PATH_UNIX completely; use getbootfile(3) instead.
DANGER WILL ROBINSON!
_PATH_UNIX is currently defined as the literal string "don't use this".
I am of two minds about this myself, but wanted to get something into the
tree as quickly as possible.
1994-09-24 00:08:43 +00:00
David Greenman
b3bfc7199e Converted 'vmunix' to 'kernel'. 1994-08-05 09:14:37 +00:00
Rodney W. Grimes
58f0484fa2 BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00