Commit Graph

1427 Commits

Author SHA1 Message Date
8353b1eb9c libsysprof-analyze: account kernel stacks to the kernel
If our entire stack was in kernel address context, inject the
"- - Kernel - -" symbol at the top of the stack trace so that accounting
gets properly assigned to the kernel. This is typical with kernel processes
such as kworker.
2023-05-25 11:16:08 -07:00
6f90a552e7 libsysprof-analyze: include final address context
We may need to know the final address context so we can inject symbols as
necessary into the top of the callgraph. We know it when generating the
symbols, so just yield it to the caller too.
2023-05-25 11:15:07 -07:00
1b0434c854 libsysprof-analyze: add private API to get the kernel symbol
We may need to inject "- - Kernel - -" in some stack traces.
2023-05-25 11:13:57 -07:00
f6ec119899 libsysprof-analyze: move definition to private header
So we can access it from other sources.
2023-05-25 11:13:32 -07:00
f79a3c6d2e libsysprof-context: skip context switches at head of trace
We can get stack traces which have a USER at the end, or KERNEL at the
end, and nothing after it. Not really useful to us.
2023-05-25 11:13:10 -07:00
81672f191b libsysprof-analyze: fix symbol name for context switch
We want the last context as we're working backwards in the stack trace.
2023-05-25 11:12:23 -07:00
9c8b3b9c25 libsysprof-analyze: add bit for context switch symbols 2023-05-25 11:11:52 -07:00
007b42a80f libsysprof-analyze: allow setting kallsyms file 2023-05-24 23:31:28 -07:00
7f192958ae libsysprof-analyze: free callgraph node tree on finalize 2023-05-24 17:29:32 -07:00
3ae108464d libsysprof-analyze: implement augmented callgraph
This creates a SysprofCallgraph object which is a GListModel of
SysprofCallgraphFrame. The SysprofCallgraphFrame is also a GListModel of
SysprofCallgraphFrame so that we can map this all into a GtkListView in
the future for tree-like visibility.

The augmentation allows for the same callgraph code to be used for multiple
scenarios such as CPU sampling as well as memory allocation tracking.

If your augmentation size is <=sizeof(void*) then you do not occur an extra
allocation and you can use the inline augmentation space.

The test-callgraph clearly shows that we still need to do the shuffling
of -- Kernel -- and -- User -- like the old callgraph code did. But that
will come soon enough.
2023-05-24 17:11:30 -07:00
5e9f745f38 libsysprof-analyze: pre-hash symbols for faster comparisons 2023-05-24 17:08:48 -07:00
ca2b008547 libsysprof-analyze: skip symbols we failed to symbolize 2023-05-24 17:08:09 -07:00
d723e41683 libsysprof-analyze: wrap processes in [] like previously 2023-05-24 17:07:52 -07:00
f12f2b760c libsysprof-analyze: add API to get symbol to represent process
And include a fallback in case we never got an actual Process frame which
will contain the cmdline for the process. We need to hold onto the fallback
too so that we can keep symbols lightweight by not having to reference them
so long as the document is alive.
2023-05-24 15:19:44 -07:00
5b00127d7d libsysprof-analyze: add API to get only samples
We'll probably want this for allocations too at some point.
2023-05-24 14:30:13 -07:00
8348f7fe2c libsysprof-analyze: start on scaffolding for callgraph API 2023-05-24 13:00:47 -07:00
b68d8225ec libsysprof-analyze: print the counter ids that were set 2023-05-24 12:53:34 -07:00
f7882d5c5f libsysprof-analyze: add vfunc for getting stack addresses
This allows us to avoid the function call overhead for each of the
instruction pointers in the stack trace. Instead let the interface handle
the decoding of the whole set.
2023-05-24 12:44:26 -07:00
059aec5a1e libsysprof-analyze: try to load .build-id debug paths
If we have a build-id, we might find it in a path like the following:

 /usr/lib/debug/.build-id/aa/aa123456789012345678901234567890

so do that lookup before we try to resolve the debuglink name.
2023-05-24 11:50:14 -07:00
4926723228 libsysprof-analyze: process lower/upper dir from overlay
In modern podman, we will get lowerdir= and upperdir= in the superblock
options which we can parse to find where things are on the host. Use that
instead of relying on overlay mounts.
2023-05-23 19:49:21 -07:00
5bf178e07b libsysprof-analyze: include mount root when translating
Additionally, if we're on a subvolume, and that subvolume matches the
prefix of the root, then skip past that. I have no idea if this is the
right thing to do, but it's what we were doing before and seems to be
able to help us get proper path resolving on Silverblue.
2023-05-23 15:39:27 -07:00
5ef6911d65 libsysprof-analyze: ignore /sysroot devices
I highly doubt this is foolproof, but this makes Silverblue more likely to
resolve the proper fstab entry when translating to paths we can access
from the host system.
2023-05-23 15:37:57 -07:00
b6f3379c2e libsysprof-analyze: ensure relative path on entry 2023-05-19 18:47:15 -07:00
15acac7e2e libsysprof-analyze: allow specifying kallsyms path
This is useful when opening an older capture which will not have embedded
the kallsyms content into the capture.
2023-05-19 17:28:11 -07:00
eb7e4c8224 libsysprof-analyze: ensure a GDataInputStream 2023-05-19 17:26:02 -07:00
b2a48fe38d libsysprof-analyze: kallsyms constructor with provided file
This allows parsing a kallsyms file that is provided by the application.
Such use could be necessary if a capture did not embed /proc/kallsyms.gz.
2023-05-23 11:03:34 -07:00
fd69b1051c libsysprof-analyze: add fallback Kernel symbols
If we fail to load a /proc/kallsyms.gz from the capture file, we can still
provide an "In Kernel+address" symbol. I prefer this to force loading the
kallsyms from the current system because that:

 1. Requires privileged access and therefore means potentially an
    authorization dialog.
 2. May not even be from the same system that the capture was recorded
    leading to incorrect symbolization.
2023-05-23 10:57:26 -07:00
c3f67eb988 libsysprof-analyze: allow specifying external debug dirs from test 2023-05-23 10:47:42 -07:00
bc482f628b libsysprof-analyze: bridge debug dirs to ELF loader 2023-05-23 10:44:03 -07:00
f2a7aa94a2 libsysprof-analyze: add support for external debug dirs
The ELF loader can use a set of external debug dirs which will be used to
resolve .gnu_debuglink symbols.
2023-05-23 10:35:33 -07:00
e8eaae3eca libsysprof-analyze: process SysprofElfLoader:debug-dirs
This needs to process the debug-dirs as if they're within the mount
namespace of the target process.

We still need to do external-debug-dirs, but that will be slightly
difference as it does not need further translation.
2023-05-23 10:24:32 -07:00
ab29afd2b1 libsysprof-analyze: add overlay mountinfo parsing test
This just ensures that we can parse the contents of the superblock options
that we get for "overlay" mounts via toolbox/podman. These still need to
be handled from SysprofMountNamespace when translating though.

Additionally, this stuff seems very brittle for parsing, unless it is
getting escaped somewhere I'm missing currently.
2023-05-22 21:13:08 -07:00
44b1297a1b libsysprof-analyze: remove duplicates in address layout
And use a GPtrArray for them instead of gsequence, as it makes it nicer
to remove duplicates using a bitset.
2023-05-22 20:52:10 -07:00
e38eae7aa7 libsysprof-analyze: sanitize address ranges
That way we are clamped to what the mapping actually provides. This only
seems to get messed up with glibc, but not clear why and it's barely off
so perhaps it has some special mapping tricks it does.

I still notice some non-reproducible runs, but that appears to be related
to duplicate address mapping entries for [stack] which we need to clear
up by removing the duplicate (short) entry.
2023-05-22 20:06:12 -07:00
5cc55117c3 libsysprof-analyze: check cached ELF for build-id/file-inode
Just because it's cached doesn't mean we should just trust it. It could
have gotten added to the cache previously even though we didn't match.
2023-05-22 19:53:38 -07:00
839695dcd1 libsysprof-analyze: fix SysprofElf:build-id property 2023-05-22 19:49:27 -07:00
a32e82e70c libsysprof-analyze: add jitmap symbol cache test 2023-05-22 19:24:01 -07:00
59a6f852a0 libsysprof-analyze: always ignore jitmap from elf symbolizer 2023-05-22 19:05:41 -07:00
05d5bc6c77 libsysprof-analyze: fix format to match other use 2023-05-22 19:05:25 -07:00
04797587e6 libsysprof-analyze: sort overlays before non-overlays
We still need to support mounts that do not include overlay frames, but
this fixes some of the cases for captures we already generate.
2023-05-22 18:56:30 -07:00
26d81f0737 libsysprof-analyze: print more elf loading information 2023-05-22 18:55:59 -07:00
47538244f3 libsysprof-analyze: actually walk through paths 2023-05-22 18:55:42 -07:00
1469e8691a libsysprof-analyze: treat overlay as SysprofMount
This creates a synthesized SysprofMount for the overlays so that we can
process them as we walk the other mounts.
2023-05-22 18:39:00 -07:00
754e5df789 libsysprof: only record process from perf, not threads
Otherwise we'll get additional SysprofCaptureProcess frames that relate
to the threads instead of just the processes.
2023-05-22 18:35:35 -07:00
c2c4495e3c libsysprof-analyze: add --silent option for test
This allows testing loading without the print overhead.
2023-05-22 17:16:48 -07:00
309f60e263 libsysprof-analyze: read double value for counter 2023-05-22 17:10:10 -07:00
7c31a45f7d libsysprof-analyze: include number of values in counter info 2023-05-22 17:09:54 -07:00
40e9e32030 libsysprof-analyze: cleanup ctrset value retrieval 2023-05-22 17:09:37 -07:00
da3e04df04 tools: include counter type in dump 2023-05-22 16:51:44 -07:00
816d0bf33f libsysprof-analyze: warn in invalid type 2023-05-22 16:51:31 -07:00