Commit Graph

116 Commits

Author SHA1 Message Date
George V. Neville-Neil
26d121f5df When we return with an error we cannot unlock the mutex, because
it's been freed.  Protect against that, hopefully unlikely, case.

Reviewed by:	rpaulo
MFC after: 2 weeks
2012-08-01 19:27:12 +00:00
Pedro F. Giffuni
694a0093a7 Dtrace: improve handling of library paths.
Merge changes from illumos

906 dtrace depends_on pragma should search all library paths, not just the
current one

949 dtrace should only include the first instance of a library found on
its library path

Illumos Revisions:	13353:936a1e45726c
			13354:2b2c36a81512

Reference:
https://www.illumos.org/issues/906
https://www.illumos.org/issues/949

Tested by:	Fabian Keil
Obtained from:	Illumos
MFC after:	3 weeks
2012-07-17 19:57:34 +00:00
Pedro F. Giffuni
ba73774268 Use libc's strndup() instead of Dtrace's reimplementation.
Corresponds partially to OpenSolaris change:
PSARC 2010/299 GNU/Linux/BSD compatibility functions
6901783 strndup would be nice

MFC after:	2 weeks
2012-07-15 21:20:31 +00:00
Pedro F. Giffuni
b99795d637 Merge illumos commit 13455:7205f7794835
1458 D compiler fails to generate error on sizeof() an undefined struct

Reference:
https://www.illumos.org/issues/1458

Tested by:	Fabian Keil
MFC after:	3 weeks
2012-07-14 20:24:00 +00:00
Dimitry Andric
ae88a6d9ac Fix clang warning, introduced in the recent dtrace import.
MFC after:	   3 days
2012-07-03 12:08:55 +00:00
Pedro F. Giffuni
fed980b201 Safer fix for building with Clang.
error: format specifies type 'long long' but the argument
has type 'int64_t' (aka 'long')

Reported by:	Ed Maste
2012-06-28 16:44:29 +00:00
Pedro F. Giffuni
db0cb5be21 Fix build with Clang.
error: format specifies type 'long long' but the argument
has type 'int64_t' (aka 'long')

Reported by:	Ed Maste
2012-06-28 15:38:14 +00:00
Pedro F. Giffuni
675cf9154b Bring llquantize support into Dtrace.
Bryan Cantrill implemented the equivalent of semi-log graph
paper for Dtrace so llquantize will use one logarithmic and
one linear scale.

Special thanks to Mark Peek for providing fix to an
assertion and to Fabian Keill for testing the port.

Illumos Revision:	13355:15b74a2a9a9d

Reference:
https://www.illumos/issues/905

Obtained from:	Illumos
Tested by:	Fabian Keill, mp
MFC after:	4 days
2012-06-27 04:39:30 +00:00
Ryan Stone
c6024848dd Implement the D "cpu" variable, which returns curcpu. I have chosen not
to follow the example of OpenSolaris and its descendants, which implemented
cpu as an inline that took a value out of curthread.  At certain points in
the FreeBSD scheduler curthread->td_oncpu will no longer be valid (in
particukar, just before the thread gets descheduled) so instead I have
implemented this as its own built-in variable.

Sponsored by:	Sandvine Inc.
MFC after:	1 week
2012-04-26 01:07:03 +00:00
George V. Neville-Neil
72cc304aba Change SIGUSR1 to SIGTHR to properly wake up a process that is being
traced.  The use of SIGUSR1 caused traced processes (those attached to
with dtrace -p) to exit when dtrace exited.

MFC in: 1 week
2012-04-13 20:22:08 +00:00
Oleksandr Tymoshenko
51df478cba Add stub file for pid probe. It's required although pid probe is not supported
on MIPS yet
2012-03-24 05:27:39 +00:00
Dimitry Andric
edf500a77a In cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c, some
uint64_t values are snprintf'd using %llx.  On amd64, uint64_t is
typedef'd as unsigned long, so cast the values to u_longlong_t, as is
done similarly in the rest of the file.

MFC after:	1 week
2011-12-16 15:12:42 +00:00
Dimitry Andric
8ac4e8ebc3 In cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c, some
uint64_t values are snprintf'd using %llx.  On amd64, uint64_t is
typedef'd as unsigned long, so cast the values to u_longlong_t, as is
done similarly in the rest of the file.

MFC after:	1 week
2011-12-16 15:04:47 +00:00
Dimitry Andric
6d9bf0940c In cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c, the
dt_popc() function assumes that either _ILP32 or _LP64 is defined,
otherwise it has no suitable implementation.

However, the _ILP32 and _LP64 macros come from isa_defs.h, which is not
included in this file.  Add the include now, to get the macros defined.

MFC after:	1 week
2011-12-15 23:06:46 +00:00
Dimitry Andric
8b6b79ce0a In cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c, use the
correct printf format for a key_t (aka long).

MFC after:	1 week
2011-12-15 22:46:04 +00:00
Dimitry Andric
bb15ca603f In cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c, use the
correct printf format for an unsigned long.

MFC after:	1 week
2011-12-15 22:37:33 +00:00
Dimitry Andric
a2f16036af Cast away a clang alignment warning in drti.c's fixsymbol() function.
This code only runs on i386 and amd64, so there should be no problems if
buf + sec->dofs_offset is not aligned (which is unlikely anyway).

MFC after:	1 week
2011-12-15 22:10:27 +00:00
Simon L. B. Nielsen
86f222bbfe Do not use #warning to warn about missing implementation of dt_popc(),
but just have a comment that this is broken.

This is just a bandaid until somebody can fix this correctly.  The code
is just a broken as it was before r223262 - now buildworld just doesn't
fail.

Tested by:	i386 + amd64 buildworld
With hat:	benl co-mentor
2011-06-19 12:52:50 +00:00
Ben Laurie
5f301949ef Fix clang warnings.
Approved by:	philip (mentor)
2011-06-18 13:56:33 +00:00
Rui Paulo
7879263397 Give a chance to the target binary to run the ctors by waiting until it
has reached main(). This allows plockstat to work.

Sponsored by:	The FreeBSD Foundation
2010-09-12 15:59:14 +00:00
Rui Paulo
dba0ac63fb Disable debug by default.
Sponsored by:	The FreeBSD Foundation
2010-09-11 10:16:15 +00:00
Rui Paulo
acac60bbfe Don't try to map the USDT probes. This is necessary because there is no
__SUNW_dof symbol present in FreeBSD binaries.

Sponsored by:	The FreeBSD Foundation
2010-09-10 12:16:24 +00:00
Rui Paulo
37c380fbb5 Don't clobber an existing target object file when doing the DTrace
linking process. This is needed because we change the source object
files and the second this dtrace -G is run, no probes will be found.
This hack allows us to build postgres with DTrace probes enabled. I'll
try to find a way to fix this without needing this hack.

Sponsored by:	The FreeBSD Foundation
2010-09-09 11:10:15 +00:00
Rui Paulo
8f7264f0e3 Include <sys/sdt.h> on a generated header.
Sponsored by:	The FreeBSD Foundation
2010-09-01 11:27:09 +00:00
Rui Paulo
0f2bd1e89d Add libdtrace support for tracing userland programs.
Summary of changes:
* Implement a compatibility shim between Solaris libproc and our
libproc and remove several ifdefs because of this.
* Port the drti to FreeBSD.
* Implement the missing DOODAD sections
* Link with libproc and librtld_db
* Support for ustack, jstack and uregs (by sson@)
* Misc bugfixing

When writing the SUWN_dof section, we had to resort to building the ELF
file layout by "hand". This is the job of libelf, but our libelf doesn't
support this yet. When libelf is fixed, we can remove the code under
#ifdef BROKEN_LIBELF.

Sponsored by:	The FreeBSD Foundation
2010-08-21 11:50:53 +00:00
Rui Paulo
afba0b6e9e Fix another mismerge: bring back the definition of DT_MUTEX_HELD(). 2010-08-02 17:31:48 +00:00
Rui Paulo
31a396ad47 Fix the result of a mismerge. MUTEX_HELD should be DT_MUTEX_HELD() and
Plmid() is not supposed to be called.
2010-08-02 17:20:59 +00:00
Rui Paulo
1670a1c2a4 MFV OpenSolaris DTrace userland bits. 2010-08-02 13:40:53 +00:00
Rui Paulo
1e634b7b65 proc_wait() was replaced by proc_wstatus(). Right now this call is
useless because userland support is not working on HEAD, but this makes
libdtrace compile again.

Sponsored by:	The FreeBSD Foundation
2010-07-31 17:23:37 +00:00
Rui Paulo
f28bde1aea Update to the new proc_detach() function.
Sponsored by:	The FreeBSD Foundation
2010-07-31 17:10:55 +00:00
Andriy Gapon
556cb98d95 dtrace: 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.
Also, unlike OpenSolaris, the sections are not collapsed into just .text,
.data and .bss by module loaders, so we need to take additional care
about other sections.

Note that in-kernel symbol-to-address mapping worked just fine, e.g. fbt
provider could correctly find the functions, etc.  It's only in userland
that the mapping in both direction worked incorrectly, e.g. in stack()
output addresses of functions in kernel modules were not translated to
their names.

Reviewed by:	rpaulo
MFC after:	3 weeks
2010-07-23 17:32:47 +00:00
Rui Paulo
7aa3838467 Merge from vendor: libdtrace MD parts needed by fasttrap.
Sponsored by:	The FreeBSD Foundation
2010-07-17 18:31:31 +00:00
Marcel Moolenaar
33ae3dfefd Unbreak platforms with char unsigned by default. Oddly enough, GCC isn't
satisfied with a simple cast to int in the check against EOF, so the fix
is a bit involved by actually having to go through a temporary variable.
2010-06-20 00:34:06 +00:00
Alexander Kabaev
283bcf71ad Do not allow EOF token to be put back into input buffer.
This reimplements previous change from r20930 in more generic way.

MFC after:	1 week
2010-06-18 16:07:24 +00:00
Alexander Kabaev
e9bc68ba9c In dtrace lexer, do not unput token if it is EOF.
This is harmless with OpenSolaris fex and yacc, but with FreeBSD
causes '\xff' symbol to be physically put into input buffer, causing
subsequent syntax error.

MFC after: 1 week
2010-06-11 04:38:14 +00:00
John Baldwin
1149b79dac Correct the sense of the "use32" terenary operator so that it uses
'lib32' for 32-bit binaries on amd64 and 'lib' for 64-bit binaries.
Remove an #ifdef __i386__ that defined use32 to the wrong value on
i386 to workaround the bug in the terenary operator.

MFC after:	1 month
2009-01-16 22:16:54 +00:00
Craig Rodrigues
56b3556343 Merge latest DTrace changes from Perforce.
Approved by:	jb
2008-11-05 19:35:09 +00:00
Warner Losh
d80d601555 Mips doesn't have a long double that's different in size from double. 2008-09-18 19:54:02 +00:00
John Birrell
187379693c * Handle the different ioctl design.
* Add a couple of FreeBSD action extensions.
2008-04-26 05:09:19 +00:00
John Birrell
41ec19c071 Make this file compile cleanly. 2008-04-26 05:07:54 +00:00
John Birrell
2c981f99ef Leave out some header files. 2008-04-26 05:07:07 +00:00
John Birrell
2693feb411 * Handle building on FreeBSD for i386 and amd64.
* Add stubs for the other FreeBSD arches.
* Make the file compile cleanly.
2008-04-26 05:05:48 +00:00
John Birrell
5fe26f7c08 * Make this file compile cleanly.
* Add FreeBSD constructor/destructor definitions.
2008-04-26 05:03:22 +00:00
John Birrell
fb24b944be * Add FreeBSD action extensions.
* Get the kernel module file name rather than hard-coding it like on Solaris.
* Use FreeBSD's process library API.
* Handle FreeBSD's different lock types.
* Get the list of loaded providers via a syscall.
2008-04-26 05:01:29 +00:00
John Birrell
132df6e9ab * Handle the different ioctl design.
* Make this file compile cleanly.
2008-04-26 04:57:45 +00:00
John Birrell
5ec5669275 There is a lot of commented out code here which applies to future work
for userland tracing.

For now we need the basic functions to be in place so that DTrace can
be used for kernel tracing.
2008-04-26 04:56:46 +00:00
John Birrell
84098f48c6 Leave out a header file. 2008-04-26 04:54:58 +00:00
John Birrell
cccc7d47c0 Merge FreeBSD include file changes with some code that should have come
in on the vendor branch.
2008-04-26 04:53:24 +00:00
John Birrell
bbda5851ce * Use FreeBSD's process library instead of the Solaris one.
* There are a few placeholders in here for which there isn't libproc
  support code yet. This is relevent to userland tracing. This set of
  commits is designed to get kernel tracing up and running, with the
  userland stuff to follow later.
2008-04-26 04:51:45 +00:00
John Birrell
d46d190310 Leave out the hook that Solaris has into it's rtld. 2008-04-26 04:49:02 +00:00
John Birrell
f5a736457d * Add a couple of action definitions for FreeBSD extensions.
* Handle the different ioctl design.
* Add support for the get and set error location.
* Add support for freopen().
2008-04-26 04:47:16 +00:00
John Birrell
cd14ec8113 * Handle the different ioctl design.
* Make the file compile cleanly.
2008-04-26 04:44:34 +00:00
John Birrell
768c574fc0 There are many places in libdtrace where errno can be set. When an
error is returned all the way back to the dtrace app, it's hard to
figure out where that error came from.

Add a couple of functions to get and set the error location which can
be optionally compiled into the library.
2008-04-26 04:43:19 +00:00
John Birrell
79673c5671 Add some error definitions for FreeBSD action extensions. 2008-04-26 04:40:38 +00:00
John Birrell
f1e56186ea * Make this file compile cleanly.
* Use FreeBSD's kld syscalls to get kernel module information instead
  of using an object file system like Solaris uses.
2008-04-26 04:39:26 +00:00
John Birrell
d9ce014461 * Handle the different ioctl design.
* Use FreeBSD's process library API.
* Make the file compile cleanly.
2008-04-26 04:37:01 +00:00
John Birrell
40de299f6b Just leave out a few includes to compile this on FreeBSD. 2008-04-26 04:34:50 +00:00
John Birrell
b29602e4d8 * Get the maximum number of CPUs via a sysctl.
* Handle the different ioctl design.
* Support the freopen() changes.
* Use functions in FreeBSD's process library rather than the CDDL
  library that Solaris has which sits on top of their process file
  system and is therefore unsuitable for use on FreeBSD. The libproc
  API for FreeBSD is deliberately different to that on Solaris because
  Sun wouldn't release the libproc.h header under a BSD license.
2008-04-26 04:33:15 +00:00
John Birrell
51e031e870 * Define YY_INPUT for flex since input() can't be re-defined.
* On FreeBSD define both LITTLE_ENDIAN and BIG_ENDIAN and then set the
  BYTE_ORDER to the one we are using. On Solaris they define one or
  the other but not both. For us to keep using FreeBSD header files,
  we need to use endian definitions the same way we do in pure BSD
  code.
2008-04-26 04:26:23 +00:00
John Birrell
df5c121dfe Handle the different level of indirection between ioctl on SYSV vs BSD. 2008-04-26 04:20:11 +00:00
John Birrell
29f89dfce7 freopen() on FreeBSD behaves differently to the Solaris one. 2008-04-26 04:18:35 +00:00
John Birrell
1cbe5a9868 * Use a portable POSIX timed wait.
* Handle the different ioctl format.
2008-04-26 04:16:17 +00:00
John Birrell
a76c5ce792 * Fix a function prototype.
* Allow for the different level of indirection between SYSV's ioctl and BSD's.
* Map a couple of sysconf definitions to one that FreeBSD has.
2008-04-26 04:13:23 +00:00
John Birrell
abb532f661 'echo' behaviour differs between SYSV and BSD. 2008-04-26 04:03:58 +00:00
John Birrell
20594ebf90 This commit was generated by cvs2svn to compensate for changes in r178528,
which included commits to RCS files with non-trunk default branches.
2008-04-26 00:54:52 +00:00
John Birrell
6ff6d951ad This commit was generated by cvs2svn to compensate for changes in r178479,
which included commits to RCS files with non-trunk default branches.
2008-04-25 09:04:09 +00:00