Commit Graph

2726 Commits

Author SHA1 Message Date
8e101624bc libsysprof: add mmap variant for elfparser 2023-05-19 10:35:31 -07:00
322a6253ba libsysprof-analyze: add note about container breakouts 2023-05-19 10:25:13 -07:00
1a9e11baef libsysprof-analyze: start on namespace translation 2023-05-19 10:23:48 -07:00
90519fe830 libsysprof-analyze: rename :id to :fs-spec to match fstab
This is the description of the field in fstab(5) so we want to match that
so it's a bit more clear what we're keying off of when translating to a
mount device we can access on the host.
2023-05-19 10:17:03 -07:00
9e2ddae05c libsysprof-analyze: make string functions recognize NULL 2023-05-19 10:13:01 -07:00
e1da2d4f70 libsysprof-analyze: use GRefString for SysprofMountDevice
We will end up creating a lot of these, and it's nice to at least be able
to share the strings even if we can't always share the objects themselves.
2023-05-19 10:11:48 -07:00
aaa12307f2 libsysprof-analyze: fix name of property 2023-05-19 10:06:51 -07:00
63168656a5 libsysprof-analyze: add get_relative_path helper
This acts somewhat like g_file_get_relative_path() in that if it is not a
subdirectory of the parent, NULL is returned. Otherwise the relative path
is returned. We can just dive into the substring instead of copying which
is a bonus point.
2023-05-19 10:02:20 -07:00
7db4540f9a libsysprof-analyze: rename mount-path to mount-point
We want to be consistent with SysprofMount in naming.
2023-05-19 10:01:02 -07:00
d448519c29 libsysprof-analyze: prefix private API with _ 2023-05-18 16:23:12 -07:00
5c1802d77f libsysprof-analyze: add scaffolding for ELF loading 2023-05-18 15:44:36 -07:00
685f9e8bab libsysprof-analyze: add scaffolding for translate API 2023-05-18 15:44:20 -07:00
978bfc5680 libsysprof-analyze: add tool to test elf loader 2023-05-18 13:11:44 -07:00
ed19b3d2b6 libsysprof-analyze: add missing SysprofElfLoader ctor 2023-05-18 13:11:08 -07:00
da58a52bf3 libsysprof-analyze: give access to SysprofElf filename 2023-05-18 13:10:51 -07:00
487e88c8f0 libsysprof-analyze: add private getter for process info 2023-05-18 13:10:30 -07:00
19c5a21ac0 libsysprof-analyze: give shape to ELF loading APIs
We need to separate a number of concerns here, such as debug-dirs within
the process namespace vs global debug-dirs (external symbols on a developer
workstation vs IoT/Laptop/VM/alternate-device).

That means we need to be able to resolve paths via the mount namespace of
the process as it was seen in the capture file.

Additionally, we need to follow .gnu_debuglink section headers so that we
can associate the version with symbols with the ELF that is loaded from
the processes SysprofAddressLayout.
2023-05-18 12:00:25 -07:00
6ad94c59bf libsysprof-analyze: add strv helpers 2023-05-18 11:49:21 -07:00
6d86d55d61 libsysprof-analyze: give address in file/function
This at least gives more visibility into what location of the file is
being executed. That way you can separate different parts of the file
rather than one giant "this file" so long as we could unwind successfully.
2023-05-16 12:43:33 -07:00
09b8c1f737 libsysprof-analyze: leave some notes on elf symbolizing 2023-05-15 16:49:40 -07:00
287c7feca2 libsysprof-analyze: add test to analyze address layout 2023-05-15 15:26:27 -07:00
b786edd848 libsysprof-analyze: print mmap information 2023-05-15 15:20:52 -07:00
140bc1d384 libsysprof-analyze: add scaffolding for elf symbol resolver 2023-05-15 15:03:25 -07:00
d415f29a15 libsysprof-analyze: allow disabling bundled symbolizer 2023-05-15 14:52:59 -07:00
64a886eea8 libsysprof-analyze: handle NULL process info
This can happen for "process 0" for example, or anything that was
recorded for a pid which did not get a SysprofCaptureProcess frame.
2023-05-15 14:33:41 -07:00
22828daad1 libsysprof-anzlyze: deduplicate and sort kernel address ranges
Turns out we do need this, and we cannot trust kallsyms all that much even
from duplicated entries on immediate next lines.
2023-05-15 14:31:18 -07:00
65318afa51 libsysprof-analyze: use define for final address range 2023-05-15 14:30:29 -07:00
a90b9a2fc7 libsysprof-analyze: use separate cache for kernel symbols
Additionally this reduces some GHashTable lookup costs by doing it once
for the process-info per-traceable rather than one per instruction pointer
per traceable.
2023-05-15 14:30:06 -07:00
909228174e libsysprof-analyze: use mapped file from file chunk 2023-05-15 13:51:22 -07:00
131d9fba29 libsysprof-analyze: implement kallsyms symbolizer
This does a simple binary search across the parsed kallsyms using the
addresses we've parsed. We need to be sure we've created the array properly
so that our bounds checking will prevent infinite loops in the tight
binary search loop.
2023-05-15 13:32:34 -07:00
525b30a42f libsysprof-analyze: give symbolizer access to address context
The kallsym symbol resolver will need this to short-circuit unless we're
within a kernel address context.
2023-05-15 13:07:48 -07:00
14e5cf06a5 libsysprof-analyzer: include kallsym symbolizer in default
Generally we're capturing Linux systems, and even if not, the capture may
contain embedded Linux symbols if on a secondary system.
2023-05-15 13:04:28 -07:00
c6135ac538 libsysprof-analyze: parse embedded /proc/kallsyms.gz
This is useful so that even if we do not get __symbols__ in the capture
file we can decode symbols from the target machine.
2023-05-15 13:03:46 -07:00
fa55594e23 libsysprof-analyze: make return type GRefString 2023-05-15 12:46:46 -07:00
11f0531591 libsysprof: include gzip'd /proc/kallsyms in capture
Compressed, this adds about 2.5mb to the capture file for the contents of
the kallsyms. However, that is useful so that we can decode kernel symbols
after the fact without relying on __symbols__ to be tacked on by the
recording machine.
2023-05-15 12:15:08 -07:00
580889f8cb libsysprof-analyze: short-circuit when address > max
This adds an O(1) check at the head of the lookup to avoid looking at
every RB_RIGHT() in the tree when address falls beyond the upper bound of
the interval tree.
2023-05-15 11:20:44 -07:00
00ecc41209 libsysprof-analyze: make SysprofDocumentSymbols private
This instead moves to a public API on the document to symbolize now
that we've gotten much of the necessary bits private in loading the
document. This commit ensures that we only do loading via the loader
now (and removes the incorrect use from the tests so they too go
through the loader).

We check for NoSymbolizer in document symbols so that we can skip any
decoding. That keeps various use cases fast where you don't want to
waste time on symbolizing if you don't need to look at symbols.

There is plenty more we can do to batch decode symbols with some more
API changes, but that will come after we have kernel/userland decoding
integrated from this library.

We may still want to get all symbols into a single symbol cache, but
given that we have address ranges associated with them, that may not
be very useful beyond the hashtable to pid-specific cache we have now.

If symbols were shared between processes, that'd make more sense, but
we aren't doing that (albeit strings are shared between symbol
instances to reduce that overhead).
2023-05-15 10:56:09 -07:00
ed030d2c25 libsysprof-analyze: fix nick for symbol 2023-05-15 10:56:09 -07:00
0e95fd3841 libsysprof-analyze: add SysprofNoSymbolizer
A symbolizer that will never symbolize. We can use this later internally
to short-circuit various symoblization steps during loading.
2023-05-15 10:56:09 -07:00
a27f700c06 libsysprof-analyze: add scaffolding for kallsyms parsing
We will want to start embedding this content in the capture file (but
after gzipping it as it's otherwise quite large). This will get things in
place so that we can parse that .gz file into the address ranges and
decode symbols found within the capture file.
2023-05-14 18:45:03 -07:00
1bcb534e16 libsysprof-analyze: add api to get size for file 2023-05-14 18:36:29 -07:00
6429768373 libsysprof-analyze: add API to open input stream 2023-05-14 18:19:30 -07:00
3350ad61eb libsysprof-analyze: introduce SysprofDocumentLoader
and thereby make a bunch of the exposed API on SysprofDocument private.
Instead we'll push some of that to the loader but for now the tests can
keep doing what their doing using the private API.

The goal here is to not expose a SysprofDocument pointer until the document
has been loaded and symbolized via the loader API. Then we can lookup
symbols directly from the document w/o intermediary objects.
2023-05-12 15:41:48 -07:00
9f6e16e373 libsysprof-analyze: take depth from translation func 2023-05-12 14:29:16 -07:00
59044bd813 libsysprof-analyze: remove implementation debugging code 2023-05-12 14:15:18 -07:00
81c384a974 libsysprof-analyze: use interval tree for symbol cache
This uses an augmented red-black tree to create an interval tree with
non-interval lookups. That amounts to storing address ranges within the
red-black tree, but looking up by single address.
2023-05-12 14:13:40 -07:00
379db77349 libsysprof-analyze: add sys/tree.h
This pulls in the venerable sys/tree.h so that we may use it in some
upcoming cache code.
2023-05-12 14:12:33 -07:00
3a8471906f libsysprof-analyze: build static library for testing internals
Otherwise we can't test our private API which very much will need it to
ensure correctness.
2023-05-12 14:11:17 -07:00
582986f5c9 libsysprof-capture: free deduplicated array entries 2023-05-12 14:09:43 -07:00
dc99b46254 libsysprof-capture: fix leak of mapped ring buffer structure 2023-05-12 14:02:46 -07:00