Commit Graph

36 Commits

Author SHA1 Message Date
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Mark Johnston
92f92525d1 If the traced process stops because it received a signal, libproc needs
to ensure that the signal is forwarded when proc_continue() is called.

MFC after:	3 weeks
2014-05-04 03:34:32 +00:00
Mark Johnston
acc0eea6b0 Allow "a.out" as an alias for the executable if no other matching entries
are found. This improves compatibility with Solaris' libproc and fixes a
number of failing DTrace tests that rely on this feature.

MFC after:	3 weeks
2014-05-03 04:44:03 +00:00
Mark Johnston
1e6b385830 Fix some off-by-one errors. The kve_end and rdl_eaddr fields contain the
first address after the end of the map entry and should therefore be
excluded.

MFC after:	2 weeks
2014-04-14 00:24:04 +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
Warner Losh
40b86d77c7 The proper way to request no man pages currently is NO_MAN=xxx. Use it
in preference to the user WITHOUT_MAN knob, which should never be set
in normal src Makefiles.
2014-04-05 17:54:36 +00:00
Mark Johnston
fbce8e1683 Consistently add the relocation offset only when the ELF type is not
ET_EXEC. This fixes several problems with the DTrace pid provider not
being able to match probes.

Reviewed by:	rpaulo
MFC after:	2 weeks
2013-11-11 16:57:57 +00:00
Mark Johnston
813b26945c Modify the libproc breakpoint add/remove functions to stop the target
process if it has not already been stopped, since this is required for
ptrace(2) to work.

libdtrace does not seem to stop target processes before trying to remove
their breakpoints, so we were previously failing to remove the breakpoint
on r_debug_state() in rtld. This was causing processes to die with SIGTRAP
if they called dlopen(3) after dtrace(1) had detached.

Reported by:	symbolics@gmx.com
Reviewed by:	rpaulo
MFC after:	1 month
2013-11-05 03:23:54 +00:00
Mark Johnston
4ec6017e0b Fix an off-by-one error when checking whether a given address is within
the extent of a symbol.

Submitted by:	Prashanth Kumar <pra_udupi@yahoo.co.in>
Reviewed by:	rpaulo
MFC after:	1 week
2013-10-29 03:52:05 +00:00
Mark Johnston
fb15925c14 Revert r257248 and fix the problem in a way that doesn't violate style(9).
Suggested by:	jmg
2013-10-29 03:12:31 +00:00
Mark Johnston
2e14fd4313 Fix the build with gcc. 2013-10-28 12:42:27 +00:00
Mark Johnston
7a514b6277 Remove an incorrect debug printf. 2013-10-28 01:41:59 +00:00
Mark Johnston
30e81f7e3b Clean up the debug printing in libproc a bit. In particular:
* Don't print any error messages to stderr unless DEBUG is defined.
* Add a DPRINTFX macro for use when errno isn't set.
* Print the error string from libelf when appropriate.
2013-10-27 20:39:10 +00:00
Mark Johnston
25aecfbb23 Fix the libproc build when DEBUG is defined. 2013-10-17 03:39:21 +00:00
Rui Paulo
7bc9877d20 Fix the return value when we found a symbol in .dynstr. This nasty bug was
preventing a lot of symbol lookups in dtruss -s, for example.
2013-08-10 07:39:15 +00:00
John Baldwin
4e67575ec9 - Compute the correct size to reallocate when doubling the size of the
array of loaded objects to avoid a buffer overrun.
- Use reallocf() to avoid leaking memory if the realloc() fails.

PR:		kern/175648
Submitted by:	yuri@rawbw.com (1)
MFC after:	1 week
2013-01-28 15:48:31 +00:00
Sergey Kandaurov
322f22f7b5 Fix libproc test case to work with clang premature optimization
observed with -O2 (used by default).
Avoid function inlining for t1_bkpt_t on which we set a breakpoint.
Otherwise the address of the function is never called thus the
breakpoint never triggers.

Reported by:	zont
Reviewed by:	rpaulo
2012-12-26 05:11:48 +00:00
Justin Hibbits
c757049235 Implement DTrace for PowerPC. This includes both 32-bit and 64-bit.
There is one known issue:  Some probes will display an error message along the
lines of:  "Invalid address (0)"

I tested this with both a simple dtrace probe and dtruss on a few different
binaries on 32-bit.  I only compiled 64-bit, did not run it, but I don't expect
problems without the modules loaded.  Volunteers are welcome.

MFC after:	1 month
2012-11-07 23:45:09 +00:00
Rui Paulo
404087cc06 When calling the C++ demangler, make sure to free the returned buffer,
which might have been reallocated.

Pointed out by:	stefanf
2012-09-07 02:38:07 +00:00
Rui Paulo
cd906041ea Add support for demangling C++ symbols. This requires linking libproc with
libc++rt/libsupc++.

Discussed with:	theraven
2012-09-06 03:19:48 +00:00
Rui Paulo
202f1c2c8d Fix test cases to work with the latest version of the API. 2012-09-06 01:24:18 +00:00
Rui Paulo
19a75aff51 Make sure we visit both symbol sections even if one of them doesn't
exist. This makes it possible to dtrace some C++ programs like devd.
2012-09-02 18:14:01 +00:00
Oleksandr Tymoshenko
f2242861f8 Make libproc compilable for MIPS 2012-03-23 23:07:02 +00:00
Andriy Gapon
a8375da0d3 fix a serious bug in libproc's proc_attach
proc_attach always frees any struct proc_handle data
that it allocates, but that is supposed to be done
only in error conditions.

PR:		bin/158431
Approved by:	re (kib)
MFC after:	1 week
2011-08-03 09:55:59 +00:00
Kevin Lo
faeece5e24 Fix a memory leak on the error condition
Reviewed by:	rpaulo
2010-12-14 15:14:08 +00:00
Rui Paulo
320807de5e Ignore EINTR when calling waitpid. 2010-09-18 23:38:21 +00:00
Rui Paulo
4c74b2455d Several fixes for libproc:
o return the correct status in proc_wstatus()
o proc_read takes a void *
o correctly allocate the objs structure array

Sponsored by:	The FreeBSD Foundation
2010-08-11 17:33:26 +00:00
Rui Paulo
fe0c8f8973 Revert SHLIB_MAJOR to 2.
As discussed with kan@, since DTrace is the only consumer of libproc
right now, there's no need for a major shlib bump.
2010-07-31 17:14:54 +00:00
Rui Paulo
295790277a Bump the shared library major version due to ABI conflicts.
Sponsored by:	The FreeBSD Foundation
2010-07-31 16:11:11 +00:00
Rui Paulo
8eb20f364f New version of libproc. Changes are:
* breakpoint setup support
* register query
* symbol to address mapping and vice-versa
* more misc utility functions based on their Solaris counterpart

Also, I've written some test cases.

Sponsored by:	The FreeBSD Foundation
2010-07-31 16:10:20 +00:00
Ruslan Ermilov
13c89dbfa7 Removed redundant -I. from CFLAGS and "yes" from WITHOUT_MAN. 2010-02-25 22:16:30 +00:00
Ed Schouten
daaf575910 Build lib/ with WARNS=6 by default.
Similar to libexec/, do the same with lib/. Make WARNS=6 the norm and
lower it when needed.

I'm setting WARNS?=0 for secure/. It seems secure/ includes the
Makefile.inc provided by lib/. I'm not going to touch that directory.
Most of the code there is contributed anyway.
2010-01-02 09:58:07 +00:00
Ken Smith
3ca3047aee Bump the version of all non-symbol-versioned shared libraries in
preparation for 8.0-RELEASE.  Add the previous version of those
libraries to ObsoleteFiles.inc and bump __FreeBSD_Version.

Reviewed by:    kib
Approved by:    re (rwatson)
2009-07-19 17:25:24 +00:00
Craig Rodrigues
820e067933 Merge latest DTrace changes from Perforce.
Update libproc API to reflect new changes.

Approved by:	jb
2008-11-05 19:35:43 +00:00
John Birrell
2acd18806c Add the Makefile for the process library which was missed in the previous
commit.
2008-05-22 02:10:14 +00:00
John Birrell
2c633af461 Add a process library with some stubs that the DTrace client needs.
These will be fleshed out as part of the DTrace userland tracing
development.

For now, the kernel tracing part of DTrace requires minimal functionality
for this library.

The API for this library is deliberately different from the libproc in
OpenSolaris due to licensing restrictions.
2008-05-22 02:09:21 +00:00