17406 Commits

Author SHA1 Message Date
Earl Chew
d387566dd7 Support Linux syscall 434 pidfd_open 2023-04-14 23:06:48 +02:00
Paul Floyd
1e42338863 regtest: add new multi option to cmdline2 help output expecteds 2023-04-14 08:15:40 +02:00
Alexandra Petlanova Hajkova
0432ce486d vgdb: implement the extended-remote protocol
Executing vgdb --multi makes vgdb talk the gdb extended-remote
protocol. This means that the gdb run command is supported and
vgdb will start up the program under valgrind. Which means you
don't need to run gdb and valgrind from different terminals.
Also vgdb keeps being connected to gdb after valgrind exits. So
you can easily rerun the program with the same breakpoints in
place.

vgdb now implements a minimal gdbserver that just recognizes
a few extended-remote protocol packets. Once it starts up valgrind
it sets up noack and qsupported then it will forward packets
between gdb and valgrind gdbserver. After valgrind shutsdown it
resumes handling gdb packets itself.

https://bugs.kde.org/show_bug.cgi?id=434057

Co-authored-by: Mark Wielaard <mark@klomp.org>
2023-04-14 00:08:53 +02:00
Paul Floyd
0ae17c117e FreeBSD: auxv changes for FreeBSD 13.2 2023-04-13 22:45:46 +02:00
Paul Floyd
b66f25877c FreeBSD: Helgrind suppression for std::__1::__thread_local_data on FreeBSD 13.2 2023-04-13 22:10:56 +02:00
Paul Floyd
ec1049b5d1 regtest: update filter_stanza so that sized_aligned_new_delete_args works on 32bit platforms 2023-04-13 22:06:34 +02:00
Nicholas Nethercote
57dbcacfdb Make --cache-sim=no the default for Cachegrind.
Also, don't print cache simulation details in the `desc:` line when the
cache simulation is disabled.

Docs changes are yet to come.
2023-04-12 11:08:15 +10:00
Nicholas Nethercote
8765b3358f Overhaul cg_annotate output.
Most notable, the "Function summary" section, which printed one CC for each
`file:function` combination, has been replaced by two sections, "File:function
summary" and "Function:file summary".

These new sections both feature "deep CCs", which have an "outer CC" for the
file (or function), and one or more "inner CCs" for the paired functions (or
files).

Here is a file:function example, which helps show which files have a lot of
events, even if those events are spread across a lot of functions.
```
> 12,427,830 (5.4%, 26.3%)  /home/njn/moz/gecko-dev/js/src/ds/LifoAlloc.h:
   6,107,862 (2.7%)           js::frontend::ParseNodeVerifier::visit(js::frontend::ParseNode*)
   3,685,203 (1.6%)           js::detail::BumpChunk::setBump(unsigned char*)
   1,640,591 (0.7%)           js::LifoAlloc::alloc(unsigned long)
     711,008 (0.3%)           js::detail::BumpChunk::assertInvariants()
```
And here is a function:file example, which shows how heavy inlining can result
in a machine code function being derived from source code from multiple files:
```
>  1,343,736 (0.6%, 35.6%)  js::gc::TenuredCell::isMarkedGray() const:
     651,108 (0.3%)           /home/njn/moz/gecko-dev/js/src/d64/dist/include/js/HeapAPI.h
     292,672 (0.1%)           /home/njn/moz/gecko-dev/js/src/gc/Cell.h
     254,854 (0.1%)           /home/njn/moz/gecko-dev/js/src/gc/Heap.h
```
Previously these patterns were very hard to find, and it was easy to overlook a
hot piece of code because its counts were spread across multiple non-adjacent
entries. I have already found these changes very useful for profiling Rust
code.

Also, cumulative percentages on the outer CCs (e.g. the 26.3% and 35.6% in the
example) tell you what fraction of all events are covered by the entries so
far, something I've wanted for a long time.

Some other, related changes:
- Column event headers are now padded with `_`, e.g. `Ir__________`. This makes
  the column/event mapping clearer.
- The "Cachegrind profile" section is now called "Metadata", which is
  shorter and clearer.
- A few minor test tweaks, beyond those required for the output changes.
- I converted some doc comments to normal comments. Not standard Python, but
  nicer to read, and there are no public APIs here.
- Roughly 2x speedups to `cg_annotate` and smaller improvements for `cg_diff`
  and `cg_merge`, due to the following.
  - Change the `Cc` class to a type alias for `list[int]`, to avoid the class
    overhead (sigh).
  - Process event count lines in a single split, instead of a regex
    match + split.
  - Add the `add_cc_to_ccs` function, which does multiple CC additions in a
    single function call.
  - Better handling of dicts while reading input, minimizing lookups.
  - Pre-computing the missing CC string for each CcPrinter, instead of
    regenerating it each time.
2023-04-11 09:58:43 +10:00
Paul Floyd
ab6d3928a5 regtest: warning cleanup
All for clang and mostly Apple clang
There are still numerous deprecated warnings on macOS 10.13
(sem* functions, syscall, sbrk, i386, PIEi, OSSpinLocki, swapcontext, getcontext)
2023-04-10 10:33:54 +02:00
Nicholas Nethercote
81c7be88b2 Improve pylintrc.
- Move it to `auxprogs/`, alongside `pybuild.sh`.
- Disable the annoying design lints, instead of just modifying the
  values (which often requires modifying them again later).
2023-04-06 09:29:08 +10:00
Paul Floyd
1db98dbdb1 Callgrind: make scripts independent of perl installation path 2023-04-04 08:32:36 +02:00
Paul Floyd
4e3439f28d Another minor README change
There's only one exp- and seven tools now (not counting
none and lackey).
2023-04-04 08:23:15 +02:00
Nicholas Nethercote
004ba8c0da cg_annotate: Remove support for user-annotated files.
They're of little use, and removing them opens the possibility of adding
`cg_merge`'s profile-merging functionality into `cg_annotate` itself.
2023-04-04 12:12:48 +10:00
Nicholas Nethercote
3d0d7a1924 Some tiny README fixes. 2023-04-04 08:06:41 +10:00
Paul Floyd
0641a27ffb Darwin regtest: update strchr filter 2023-04-02 15:28:21 +02:00
Paul Floyd
b32875d20c Darwin: more suppressions for Darwin 17, and another strchr wrapper 2023-04-02 15:22:54 +02:00
Paul Floyd
28a164761f Darwin: missed removing a couple of delete wrappers 2023-04-02 14:05:40 +02:00
Paul Floyd
e27f24c165 Darwin and FreeBSD: new / delete wrappers
A few typos in the FreeBSD soname wrappers
Many missing Darwin wrappers
And no need to repeat that GNU mangling is used
2023-04-02 13:43:14 +02:00
Paul Floyd
421693f432 Darwin: add support for setting errno from alloc wrappers 2023-04-02 11:06:18 +02:00
Paul Floyd
708d0eb6b4 Regtest: fixes for callgrind tests referring to cachegrind reference files
cachegrind/tests/cgout-test was renamed to ann1.cgout but the
two tests in callgrind that use it weren't updated.
2023-04-02 10:12:17 +02:00
Mark Wielaard
03e36bc36e Commit access and try branches 2023-04-01 23:58:20 +02:00
Paul Floyd
3f4052623c Darwin: try to improve posix_memalign / zone_memalign wrapper
It still doesn't set errno though.
2023-04-01 22:28:36 +02:00
Paul Floyd
e105ce0d8f Darwin regtest: another test using aligned_alloc
I added this test because I wanted to check the behaviour of
aligned_alloc on current macOS, but Valgrind doesn't support it
yet.
2023-04-01 21:11:58 +02:00
Paul Floyd
abf513febd Darwin regtest: fix building on older OS versions
aligned_alloc was added to macOS 10.15 and 10.13 is the latest
that we support.
2023-04-01 20:55:22 +02:00
Paul Floyd
81e51f9469 MUSL regtest: fix a comple of build problems building regression tests on Alpine 2023-03-31 13:39:34 +02:00
Paul Floyd
37edf8fbda Regtest: fix a couple of unused variable warnings
Copy & paste leftovers
2023-03-31 13:17:10 +02:00
Paul Floyd
78d0dc51c0 Remove source file added to EXTRA_DIST in error 2023-03-31 12:41:40 +02:00
Paul Floyd
3c0405a63d Add missing entries to cachegrind EXTRA_DIST 2023-03-31 12:09:45 +02:00
Mark Wielaard
f32cc294e3 Propagate memory allocation failure to out_of_memory_NORETURN
Provide the user with a hint of what caused an out of memory error.
And explain that some memory policies, like selinux deny_execmem
might cause Permission denied errors.

Add an err argument to out_of_memory_NORETURN. And change
am_shadow_alloc to return a SysRes (all three callers were already
checking for errors and calling out_of_memory_NORETURN).
2023-03-31 01:31:25 +02:00
Nicholas Nethercote
2d97182f0d cg_annotate: use <unspecified> for an unspecified filename.
Users shouldn't ever see this, but it's useful to distinguish this
malformed data file case from the missing symbol case (which is still
shown as `???`).
2023-03-29 09:15:56 +11:00
Nicholas Nethercote
6436be0a3f cg_annotate.in: fix a small bug in the printing of past-the-end lines. 2023-03-28 17:22:42 +11:00
Nicholas Nethercote
ca44cbbd7b Fix some problems in cachegrind/tests/Makefile.am. 2023-03-28 16:30:01 +11:00
Nicholas Nethercote
e95328b12c Simpler and more consistent cachegrind/tests/*.vgtest files.
- Always use `python3`, never `python`.
- Avoid unnecessary `../cachegrind/` in paths.
2023-03-28 15:44:34 +11:00
Nicholas Nethercote
551874920f Rewrite cg_merge in Python.
It's currently written in C, but `cg_annotate` and `cg_diff` are written in
Python. It's better to have them all in the same language.

The good news is that the Python code is 4.5x shorter than the C code.
The bad news is that the Python code is roughly 3x slower than the C
code. But `cg_merge` isn't used that often, so I think it's a reasonable
trade-off.
2023-03-28 14:54:27 +11:00
Nicholas Nethercote
8a75eecbad Rewrite cg_diff in Python.
For all the same reasons I rewrote `cg_annotate` in Python.

The commit also moves the Python "build" steps into
`auxprogs/pybuild.sh`, for easy sharing.

Finally, it very slightly tweaks the whitespace in the output of
`cg_annotate`.
2023-03-28 14:54:25 +11:00
Nicholas Nethercote
29d1f00e20 Rename ann-diff test as ann-diff1.
To make room for another test.
2023-03-27 11:03:45 +11:00
Nicholas Nethercote
3f1bbe12fe Make section formatting more consistent.
- Every section now has a heading with the long `----` lines above and
  below.
- Event names are always shown below that heading, rather than within
  it.
- Each Unreadable file now gets its own section, much like files that
  lack any data.
2023-03-27 09:01:38 +11:00
Nicholas Nethercote
d7081e936e Rename a bunch of cg_annotate test files.
For more consistency.
2023-03-27 08:52:28 +11:00
Paul Floyd
c7e01d28b4 Solaris: improve syscall trace for sysfs
More than just fix the format warning
2023-03-26 18:21:42 +02:00
Paul Floyd
5fd3b8947e Regtest: put back a glibc version ofr memalign_args test
I forgot that glibc aligned_alloc really is memalign, which
changes the callstack.
2023-03-26 17:05:25 +02:00
Paul Floyd
95ac41bc58 Regtest: add a filter for aligned alloc uninit args tests
These tests generate a varying number of errors per argument
depending on the platform and compiler.

The filter just prints the first unique error stanza which
allows 8 expecteds to be removed.
2023-03-26 16:37:56 +02:00
Paul Floyd
6bbe320a1a Solaris: format warnings in syswrap functions 2023-03-26 10:48:08 +02:00
Paul Floyd
3eaac58827 Regtest: clean aligned alloc tests on FreeBSD x86
Add a filter for size_t (unsigned long on 64bit platforms and unsigned
int on 32bit ones).

Add another expected for x86.
2023-03-25 19:52:41 +01:00
Nicholas Nethercote
179fc84ba7 Add more annotated/unannotated lines at the end.
This way, all CCs are categorised, which is useful for understanding
why thing were/weren't annotated.
2023-03-23 13:20:44 +11:00
Nicholas Nethercote
05d01cd681 Change Threshold: to Thresholds:.
Because all the thresholds other than the first one were always 100, due
to historical reasons.
2023-03-23 13:00:17 +11:00
Nicholas Nethercote
3f8494c8a4 Just use one decimal place for all percentages.
Simpler, shorter, and good enough in practice.
2023-03-23 13:00:17 +11:00
Nicholas Nethercote
b8a90ee968 Improve formatting of percentage columns.
Currently their width is mostly hard-wired in a quick and dirty fashion.
This commit does them properly, so:
- all columns are always the right width, even ones with really large
  percentages
- things like `( 1.00%)` are now `(1.00%)`
- any percentages that would involve a division by zero now show as
  `(n/a)` rather than `( 0.00%)`
2023-03-23 13:00:17 +11:00
Nicholas Nethercote
e9e7b663fb Make cg_annotate work with Python 3.9, by avoiding TypeAlias. 2023-03-23 09:50:21 +11:00
Paul Floyd
bb35cd572f Make cg_annotate independent of python3 install location 2023-03-22 20:43:30 +01:00
Mark Wielaard
3bb907290a cachegrind/tests/Makefile.am EXTRA_DIST add ann3.{{post,stderr}.exp,vgtest} 2023-03-22 11:41:53 +01:00