History log of /freebsd-current/lib/libproc/proc_sym.c
Revision Date Author Comments
# a2f733ab 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

lib: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# af3c7888 30-Sep-2022 Ed Schouten <ed@FreeBSD.org>

Alter the prototype of qsort_r(3) to match POSIX, which adopted the
glibc-based interface.

Unfortunately, the glibc maintainers, despite knowing the existence
of the FreeBSD qsort_r(3) interface in 2004 and refused to add the
same interface to glibc based on grounds of the lack of standardization
and portability concerns, has decided it was a good idea to introduce
their own qsort_r(3) interface in 2007 as a GNU extension with a
slightly different and incompatible interface.

With the adoption of their interface as POSIX standard, let's switch
to the same prototype, there is no need to remain incompatible.

C++ and C applications written for the historical FreeBSD interface
get source level compatibility when building in C++ mode, or when
building with a C compiler with C11 generics support, provided that
the caller passes a fifth parameter of qsort_r() that exactly matches
the historical FreeBSD comparator function pointer type and does not
redefine the historical qsort_r(3) prototype in their source code.

Symbol versioning is used to keep old binaries working.

MFC: never
Relnotes: yes
Reviewed by: cem, imp, hps, pauamma
Differential revision: https://reviews.freebsd.org/D17083


# 0bbf2702 10-Jul-2022 Xin LI <delphij@FreeBSD.org>

libproc: replace home grown crc32 with zlib implementation.

MFC after: 2 weeks
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D35766


# 9e5787d2 24-Aug-2020 Matt Macy <mmacy@FreeBSD.org>

Merge OpenZFS support in to HEAD.

The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.

I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.

Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.

Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.

Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.

Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872


# 41fc64c2 22-Jul-2019 Brooks Davis <brooks@FreeBSD.org>

Be consistent about temporary variable use in adjacent loops.

Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL


# 5aa9b11b 21-Jul-2018 Mark Johnston <markj@FreeBSD.org>

Take the mapping's segment offset into account when resolving symbols.

Reported by: Jenkins, via asomers
MFC after: 2 weeks


# 5e53a4f9 25-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

lib: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# 1bdc41d2 21-Nov-2017 Mark Johnston <markj@FreeBSD.org>

Refine symtab sorting in libproc.

Add some rules to more closely match what illumos does when an address
resolves to multiple symbols:
- prefer non-local symbols
- prefer symbols with fewer leading underscores and no leading '$'

Add some regression tests to verify these rules.


# 2c73c414 06-Sep-2017 Mark Johnston <markj@FreeBSD.org>

Avoid keeping a dangling pointer when the mappings array is resized.

Sponsored by: Dell EMC Isilon


# 3573cf33 22-May-2017 Mark Johnston <markj@FreeBSD.org>

Ensure that the mappings table is populated in proc_objname().

MFC after: 1 week
Sponsored by: Dell EMC Isilon


# 1f7967e1 04-Jan-2017 Mark Johnston <markj@FreeBSD.org>

Add a reasonable bound on the symbol table index size.


# c156354f 05-Dec-2016 Mark Johnston <markj@FreeBSD.org>

libproc: Cache symbol tables for mapped objects upon access.

Extend the file handle cache entries to include symbol tables as well. An
index is used to implement binary search by symbol value. Lookups by
name are comparatively rare and are thus still implemented with a linear
search, but support for a binary search by name would be straightforward
to add if needed.


# d42df2a4 05-Dec-2016 Mark Johnston <markj@FreeBSD.org>

libproc: Match prefixes when looking up mapped object by name.

When looking up an object by name, allow prefix matches if no direct match
is found. This allows one to, for example, match libc entry probes with:

# dtrace -n 'pid$target:libc.so::entry' -c ./foo

instead of requiring "libc.so.7" or a glob.

Also remove proc_obj2map() as it currently just duplicates the
functionality of proc_name2map(). It's supposed to take a Solaris
link-map ID as a paramter, but support for this isn't implemented and
isn't required to support DTrace's pid provider.


# 07a9c2e6 05-Dec-2016 Mark Johnston <markj@FreeBSD.org>

libproc: Cache ELF handles for loaded objects.

libproc previously created a new handle for each symbol lookup, which
gives rather egregious performance for DTrace's ustack() action. With
this change libproc will cache the libelf descriptor upon access, making
lookups much faster in the common case.


# 76c6531c 05-Dec-2016 Mark Johnston <markj@FreeBSD.org>

libproc: Improve .gnu_debuglink support.

As of r278658 libproc looks for debug files under /usr/lib/debug and will
use them if available. This change fleshes out that support a bit further:
- Check for a .gnu_debuglink section and use the file name specified
there if one is present.
- Validate external debug files with the CRC in the .gnu_debuglink
section so as to avoid using stale or corrupt debug files.
- Search for debug files in the directory containing the referencing
object or in the .debug subdirectory, as GDB does.


# b1bb30e5 05-Dec-2016 Mark Johnston <markj@FreeBSD.org>

libproc: Make proc_getpid() an accessor for struct proc_handle.

This allows librtld_db to fetch the PID from a handle without calling into
libproc. Together with r303531, this means that librtld_db no longer
references symbols from libproc.


# 0faaddb8 12-Mar-2015 Stanislav Sedov <stas@FreeBSD.org>

Fix debug symbols loading in libproc: 0 is a valid file descriptor.

Reported by: Chris Torek <chris.torek@gmail.com>


# eda94c07 12-Feb-2015 Rui Paulo <rpaulo@FreeBSD.org>

Teach libproc how to find debugging symbols in /usr/lib/debug.

MFC after: 1 week


# c7fa6f0b 30-Jan-2015 Mark Johnston <markj@FreeBSD.org>

Stop iterating and return if the caller-supplied callback function returns
a non-zero value.

MFC after: 1 week


# cd9c9939 24-Jan-2015 Mark Johnston <markj@FreeBSD.org>

Ensure that we don't try to demangle a symbol name if we failed to look
up the symbol. Add a test to exercise this code path.

Reviewed by: adrian


# 3f1cbdbe 23-Dec-2014 Mark Johnston <markj@FreeBSD.org>

Fix a memory leak that occured when looking up CTF info for a symbol.


# ec045490 03-Oct-2014 Mark Johnston <markj@FreeBSD.org>

Remove an incorrect and useless debug print.

X-MFC-With: r272488


# 41da933c 03-Oct-2014 Mark Johnston <markj@FreeBSD.org>

Hook up support for userland CTF support in DTrace. This required some
modifications to libproc to support fetching the CTF info for a given file.

With this change, dtrace(1) is able to resolve type info for function and
USDT probe arguments, and function return values. In particular, the args[n]
syntax should now work for referencing arguments of userland probes,
provided that the requisite CTF info is available.

The uctf tests pass if the test programs are compiled with CTF info. The
current infrastructure around the DTrace test suite doesn't support this
yet.

Differential Revision: https://reviews.freebsd.org/D891
MFC after: 1 month
Relnotes: yes
Sponsored by: EMC / Isilon Storage Division


# 540cc663 25-Sep-2014 Mark Johnston <markj@FreeBSD.org>

Factor out some of the duplicated code in the symbol lookup functions, in
preparation for adding userland CTF support to DTrace.

MFC after: 1 month
Sponsored by: EMC / Isilon Storage Division


# 24a08d30 24-Aug-2014 Mark Johnston <markj@FreeBSD.org>

Fix a bug in r265255: only return NULL if the requested map wasn't found.

Submitted by: Luke Chang-Hsien Tsai <luke.tw@gmail.com>
MFC after: 1 week


# 96ec3cdd 08-Aug-2014 Dimitry Andric <dim@FreeBSD.org>

In r268463, I misplaced a return in demangle(), causing the function to
erroneously skip symbols that were not mangled at all. Fix this by
moving the return into the preceding if block.

While here, simplify the code by letting __cxa_demangle() allocate the
needed space for the demangled symbol. This also fixes a memory leak,
which would occur whenever __cxa_demangle() failed.

Reported by: pgj
MFC after: 3 days


# 3d12a343 09-Jul-2014 Dimitry Andric <dim@FreeBSD.org>

In libproc, avoid calling __cxa_demangle(), and thus depending on either
libcxxrt or libsupc++, if WITHOUT_CXX is defined.

Noticed by: sbruno
MFC after: 1 week


# acc0eea6 02-May-2014 Mark Johnston <markj@FreeBSD.org>

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


# 1e6b3858 13-Apr-2014 Mark Johnston <markj@FreeBSD.org>

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


# fbce8e16 11-Nov-2013 Mark Johnston <markj@FreeBSD.org>

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


# 4ec6017e 28-Oct-2013 Mark Johnston <markj@FreeBSD.org>

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


# 7a514b62 27-Oct-2013 Mark Johnston <markj@FreeBSD.org>

Remove an incorrect debug printf.


# 30e81f7e 27-Oct-2013 Mark Johnston <markj@FreeBSD.org>

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.


# 7bc9877d 10-Aug-2013 Rui Paulo <rpaulo@FreeBSD.org>

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.


# 404087cc 06-Sep-2012 Rui Paulo <rpaulo@FreeBSD.org>

When calling the C++ demangler, make sure to free the returned buffer,
which might have been reallocated.

Pointed out by: stefanf


# cd906041 05-Sep-2012 Rui Paulo <rpaulo@FreeBSD.org>

Add support for demangling C++ symbols. This requires linking libproc with
libc++rt/libsupc++.

Discussed with: theraven


# 19a75aff 02-Sep-2012 Rui Paulo <rpaulo@FreeBSD.org>

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.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 4c74b245 11-Aug-2010 Rui Paulo <rpaulo@FreeBSD.org>

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


# 8eb20f36 31-Jul-2010 Rui Paulo <rpaulo@FreeBSD.org>

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


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 2c633af4 21-May-2008 John Birrell <jb@FreeBSD.org>

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.