Commit Graph

94 Commits

Author SHA1 Message Date
ab12f6a18a tools: don't resolve unless requested
It can be way to slow to be useful for quick things.
2023-06-27 13:39:06 -07:00
5b929b8d5d libsysprof-analyze: add callgraph flags for thread-ids
This allows you to set a flag to show the thread id of what was recorded.

Use this to help disassociate similar threads in a process to figure out
which thread is consuming a majority of the Total time of that process.
2023-06-14 15:11:56 -07:00
3a94170b0a libsysprof-capture: add frame type for tracing
This is like sample but has an "enter/exit" flag with it. This can be
useful when you want to provide tracing instead of sampling. We use a
different frame type so that we can denote that this isn't traditional
sampling, and the flag can be used to find the next exit for the current
enter for calculating durations.

The entire stack trace is provided to make things easier on tools
which may want to deal with indirect functions that were not instrumented
but can be unwound. That may allow for tooling to give the user some
insight that it's not *just* this function entering, but some functions
before it were entered too.

This also adds a SysprofTracer instrument which will preload a
libsysprof-tracer-6.so into the process providing the
__cyg_profile_func_enter() and __cyg_profile_func_leave() hooks.
2023-06-13 12:41:50 -07:00
81eafb9232 tools: track function declaration change 2023-06-13 12:34:40 -07:00
434cc6ba22 tools: give some feedback about callgraph type 2023-06-06 16:48:50 -07:00
f3ab23ed18 tools: allow showing basic callgraph for memory
The columns aren't all that useful, but it is to show that augmentation
will work for these things too.
2023-06-06 16:45:51 -07:00
3fb1a15eec tools: toggle row on space 2023-06-05 16:56:18 -07:00
06a2a1a211 tools: test expand/collapse with GtkEventControllerKey
This ensures that we can maintain our expand/collapse keybindings that we
have with GtkTreeView using GtkListView.
2023-06-05 15:15:35 -07:00
eaee76e49f tools: use data-table class 2023-05-25 13:36:40 -07:00
a9e14be37e tools: column sorting by default 2023-05-25 13:18:26 -07:00
b5ce671e23 tools: start on callgraph example using columnview
This just serves as a prototyping ground so that we can have a callgraph
view widget in the future based on these principles. It also shows some
areas that still need work, such as sorting within the tree and fixing the
text offset calculation for ELF symbols.
2023-05-25 12:16:18 -07:00
da3e04df04 tools: include counter type in dump 2023-05-22 16:51:44 -07:00
0e799deee4 tools: include tid in sample 2023-05-03 12:22:08 -07:00
5c06845e86 tools: add helper to rewrite a PID
This is mostly useful when troubleshooting PIDs in container namespaces
that don't match the host.
2023-02-20 21:04:21 -08:00
d0e63f8573 tools: symbolize callstacks with dump
This can be useful so we don't have to use other tools to try to figure
out what is already right in there.
2023-02-20 20:08:45 -08:00
d7d073505c sysprof-dump: print allocation call stacks 2023-02-20 19:46:22 -08:00
ceab63f694 sysprof-agent: improve messaging a bit 2022-09-21 17:18:29 -07:00
c03c964ec2 agent: add --decode command line option
This requests that symbols are decoded at the end of the capture.
2022-09-04 00:22:39 -07:00
749dfbd57e tools: make sysprof-cli statically linked
We don't need to dynamically link against libsysprof for sysprof-cli as
we can do the same thing that sysprof-agent does. In fact, we can probably
even make sysprof-cli wrap sysprof-agent in the future (or be the same
binary that looks at it's argv[0]).
2022-08-17 15:07:47 -07:00
475e513b7f tools/sysprof-cli: cleanup header includes
Fixes double inclusion of <signal.h> as well.
2022-08-01 10:15:56 -07:00
1a8a9adc97 tools/sysprof-agent: handle SIGINT like we do for sysprof-cli
This just forces the profiler to exit, but lets subsequent ^C usage to
actually exit the program.
2022-08-01 10:15:36 -07:00
2f325fbf54 tools/sysprof-agent: set cwd to . unless --directory specified 2022-08-01 10:04:59 -07:00
c3035efd52 tools: add -Dagent=true option
This also builds the agent statically with libsysprof_static_dep since
we'd need that to avoid installing libsysprof when that isn't wanted.
It also ensures the LD_PRELOAD libraries are installed for use by the
agent.
2022-07-21 18:35:35 -07:00
dc829087d4 tools: add sysprof-agent
This is a program that can be communicated with over private D-Bus using
pipes to control a process. It is useful in an automated fashion from
tooling such as Builder.

This allows, when installed into SDKs like GNOMEs, to profile from inside
the container rather than from the outside. Such is useful when you need
to ensure you have access to LD_PRELOAD/etc within the context.
2022-07-21 18:28:18 -07:00
757d36ae8e Cleanup the build a bit
Makes the Meson build a little bit better and cleans up some of the
formatting.
2022-05-25 14:07:02 -05:00
c75391e681 tools/sysprof-cli: always inherit stdin
Fixes #76
2022-04-01 12:57:30 -07:00
14139232d5 capture: rename PidRoot to Overlay and add src/dst
Really what we want to deal with here is tracking an overlay that we may
need to be able to decode after the fact (in case processes exit or we
need to do post-processing symbol resolution).

For the podman case, that is $some_path mapped to root (/), generally
speaking. For flatpak though, that would have two mappings, one for
/app and another for /usr (possibly more).
2021-02-25 13:43:09 -08:00
4758fb42ce capture: add pid-root frame type
While I'm not thrilled to add new frame types for every sort of thing, I
think having this will be relatively useful so we can improve decoding
operations.

This adds SysprofCapturePidRoot which lets us specify a root directory
on the host system for which is the real root (/) of the PID. This can
be useful when reconstructing overlays for containers and you need to
direct access to alternate roots.

The layer gives us some ability to try to deal with overlayfs, albeit at
a very rudimentary level. In most cases I anticipate we just deal with
the main root and ignore overlays until necessary.
2021-02-24 17:56:37 -08:00
7ca4acc30d sysprof-cli: always create governor source
But also disable it unless we're on Linux.
2021-02-24 11:59:34 -08:00
bd73d534d0 tools: feature test various sources behind __linux__ 2020-11-16 14:58:09 -08:00
04eacbcfe2 build: make polkit optional again for sysprof-cli 2020-11-16 14:57:04 -08:00
9405c960cc tools: load proper speedtrack library
Fixes #51
2020-10-15 13:38:37 -07:00
620f1f0ff0 build: fix build warnigns with Clang 2020-08-14 12:57:50 -07:00
5311f9d80a sysprof-dump: include <errno.h> where appropriate 2020-08-08 10:52:16 -04:00
e8790bc3d6 build: Add more Meson options for disabling parts of the build
This is all aimed at making it so that sysprof can be built as a
subproject within GLib, with only `libsysprof-capture-4.a` being
produced as output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
e03b54fca5 build: Only run gdbus-codegen if building components which need it
This is to avoid running `gdbus-codegen` when building sysprof as a
subproject underneath libglib, as by that point in the GLib build
process, `gdbus-codegen` is not yet available.

The interfaces generated by these `gdbus-codegen` invocations are only
needed for `sysprofd` and libsysprof, not for the libraries like
`libsysprof-capture`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
3c7b76c6ba build: Move Meson dependency() calls to where they’re used
This avoids making the project depend on all its dependencies, some of
which are optional, when being built as a Meson subproject.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
45c8c95706 libsysprof-capture: Drop GError usage from SysprofCaptureWriter
Use `errno` instead, which is icky, but given that all of the failure
modes are from POSIX I/O functions, it’s at least in keeping with them.

This is a major API break.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
e19d70bca0 libsysprof-capture: Drop GError usage from SysprofCaptureReader
Use `errno` instead, which is icky, but given that all of the failure
modes are from POSIX I/O functions, it’s at least in keeping with them.

This is a major API break.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
6a45f020f7 libsysprof-capture: Add SysprofCaptureJitmapIter to replace GHashTable
Change `sysprof_capture_reader_read_jitmap()` to return a `const
SysprofCaptureJitmap *` (like the other `read` functions), and add a new
`SysprofCaptureJitmapIter` type to allow easy iteration over the jitmap.

This allows a use of `GHashTable` to be removed from the API. It breaks
the libsysprof-capture API and ABI.

All the callers iterate over the jitmap rather than looking up elements
by key. If that functionality is needed in future, additional API can be
added to allow it on `SysprofCaptureJitmap`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
75b69d0a89 libsysprof-capture: Rewrite list_files() to avoid GHashTable/GPtrArray
This changes its API and ABI: it now returns an allocated array of const
strings, rather than an allocated array of allocated strings.

The call sites in the source tree have been adjusted accordingly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
5636bbf4f0 libsysprof-capture: Use stdbool instead of gboolean
Another step towards dropping GLib as a dependency of
libsysprof-capture.

Unlike the previous commit which replaced GLib integer types with the
bitwise equivalent C standard types, `stdbool` is potentially a different
width from `gboolean`, so this is an ABI break.

It therefore involves some changes to callback functions in the tests
and tools, and in libsysprof.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
d2047fb557 libsysprof-capture: Move autocleanup definitions to libsysprof
In preparation for dropping the GLib dependency from libsysprof-capture,
move the autocleanup definitions up to libsysprof. Add a new header for
them.

This is slightly awkward in the tools, which depend on
libsysprof-capture but not libsysprof. Rather than make them depend on
libsysprof (which might be disabled at configure time), include the
`sysprof-capture-autocleanups.h` file between source directories.
`SYSPROF_COMPILATION` needs to be defined for this to work.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
3eb0f3e964 sysprof-dump: Move error handling up to avoid a NULL pointer dereference
`reader` can be `NULL`, but the `NULL` check was done after potentially
dereferencing it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
30e5685655 tools: Add missing dependency on glib-2.0
It has previously been implicitly pulled in by libsysprof-capture, but
that will change in future.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
03906a84c6 tools: add --no-throttle sysprof-cli option
This allows disabling the CPU governer by switching to "performance".
2020-03-18 11:16:00 -07:00
014b696dc0 Merge branch 'wip/jojnar/litsuf' into 'master'
Fix -Werror=literal-suffix

See merge request GNOME/sysprof!25
2020-03-16 03:33:18 +00:00
89f656013a tools: add --speedtrack command line option 2020-03-15 16:00:22 -07:00
9393078d7b Fix -Werror=literal-suffix
When trying to build gjs with --werror, I get the following error:

	In file included from /nix/store/snc19nr462570ssx03v455p164vyz15s-sysprof-3.36.0-dev/include/sysprof-3/sysprof-capture-condition.h:59,
	                 from /nix/store/snc19nr462570ssx03v455p164vyz15s-sysprof-3.36.0-dev/include/sysprof-3/sysprof-capture.h:66,
	                 from ../gjs/profiler.cpp:53:
	/nix/store/snc19nr462570ssx03v455p164vyz15s-sysprof-3.36.0-dev/include/sysprof-3/sysprof-capture-types.h:76:40: error: invalid suffix on literal; C++11 requires a space between literal and string macro [-Werror=literal-suffix]
	   76 | #define SYSPROF_CAPTURE_ADDRESS_FORMAT "0x%016"G_GINT64_MODIFIER"x"
	      |                                        ^
	cc1plus: all warnings being treated as errors
2020-03-15 22:07:49 +01:00
98f6dc6642 tools: add --env=VAR=VALUE command line option 2020-02-21 12:40:55 -08:00