Bug 433506 - FreeBSD support, part 9
Summary: FreeBSD support, part 9
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-23 20:12 UTC by Paul Floyd
Modified: 2021-10-07 20:56 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
diff of several directories (1.37 MB, patch)
2021-02-23 20:12 UTC, Paul Floyd
Details
diff of cachegrind callgrind dhat exp-bb gdbserver_test massif (1.32 MB, patch)
2021-09-23 19:37 UTC, Paul Floyd
Details
freebsd9 (1.33 MB, text/plain)
2021-09-30 16:03 UTC, Mark Wielaard
Details
other directories (1.37 MB, patch)
2021-10-05 20:55 UTC, Paul Floyd
Details
other dirs (1.38 MB, patch)
2021-10-05 21:07 UTC, Paul Floyd
Details
other directories (1.38 MB, patch)
2021-10-05 21:16 UTC, Paul Floyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2021-02-23 20:12:26 UTC
Created attachment 136093 [details]
diff of several directories

The other tools with smaller diffs so all lumped together.

covers

cachegrind/
callgrind/
dhat/
exp-bbv/
gdbserver_tests/
lackey/
massif/
mpi/
none/
perf/
shared/

No libdl on FreeBSD
Adding defined(VGO_freebsd) to macroi tests
Extra filters and expecteds (some large ones!)
Different types of signals
Missing headers
Prevention of compiler optimizations

New FreeBSD none tests
Check that the auxv vector more or less gets passed to the client
Check that the OS release is correctly handled
Comment 1 Paul Floyd 2021-09-23 19:37:18 UTC
Created attachment 141841 [details]
diff of cachegrind callgrind dhat exp-bb gdbserver_test massif
Comment 2 Mark Wielaard 2021-09-30 14:54:27 UTC
This patch makes cachegrind/tests/Makefile.am executable, which I think is wrong.
The actual change looks fine though. As does the change to callgrind/main.c.

In dhat/tests/copy.c, which test for && defined(__GNUC__)?
Is mempcpy defined if __GNUC__ isn't on freebsd?

In none/tests/Makefile.am is it deliberate that resolv doesn't get any LDADD flags anymore (asking because res_search still does).

In none/tests/amd64/Makefile.am why is the dependency on $(srcdir)/gen_insn_test.pl removed for the .def.c target?

none/tests/amd64/faultstatus.c changes the type of escape from jmp_buf to sigjmp_buf. This looks correct. I am just surprised this worked before.

The none/tests/amd64/insn_ssse3.vgtest prereq change is ok too.
This probably also should always have been this way.

It is somewhat unfortunate we need none/tests/amd64/sse4-64.stdout.exp-freebsd-clang and none/tests/amd64/sse4-64.stdout.exp.freebsd, they are huge.

The ssse3_misaligned look correct.

There are a lot of extra none/tests/fdleak*exp.freebsd. It looks like freebsd doesn't provide the name of the file behind an fd. Is this a bug in the file descriptor leak checker on freebsd?

Assuming everything under none/tests/freebsd is fine.

I don't understand the none/tests/x86/gen_insn_test.pl change.
Comment 3 Mark Wielaard 2021-09-30 15:11:35 UTC
The changes in faultstatus.c make gdbserver_tests mcsignopass and mcsigpass fail because the line numbers changed. But rest of make regtest looks fine on Fedora 34 x86_64.
Comment 4 Paul Floyd 2021-09-30 15:47:28 UTC
I'll try to deal with the other things tonight.

For the change none/tests/x86/gen_insn_test.pl

See here
https://github.com/paulfloyd/freebsd_valgrind/issues/80

In short the generated code doesn't build with clang which complains about not having enough registers.
Comment 5 Mark Wielaard 2021-09-30 16:03:52 UTC
Created attachment 142035 [details]
freebsd9

Patch that removes executable but from Makefile.am and adjusts the gdb_server test exp file. Tested on fedora 34 x86_64
Comment 6 Paul Floyd 2021-09-30 19:08:18 UTC
(In reply to Mark Wielaard from comment #2)
> This patch makes cachegrind/tests/Makefile.am executable, which I think is
> wrong.

Done.

> In dhat/tests/copy.c, which test for && defined(__GNUC__)?
> Is mempcpy defined if __GNUC__ isn't on freebsd?

I think that it is not defined at all (it's nowhere in /usr/include), but clang has it as a builtin.

> In none/tests/Makefile.am is it deliberate that resolv doesn't get any LDADD
> flags anymore (asking because res_search still does).

Looks like a copy/paste error. Fixed.

> In none/tests/amd64/Makefile.am why is the dependency on
> $(srcdir)/gen_insn_test.pl removed for the .def.c target?

It wasn't there for x86. I'll put it back and add it to x86.
 
> It is somewhat unfortunate we need
> none/tests/amd64/sse4-64.stdout.exp-freebsd-clang and
> none/tests/amd64/sse4-64.stdout.exp.freebsd, they are huge.

Huge and largely the same. Haven't spent time analyzing these small differences, it just seems that each compiler/platform has to deviate a tiny bit.

> There are a lot of extra none/tests/fdleak*exp.freebsd. It looks like
> freebsd doesn't provide the name of the file behind an fd. Is this a bug in
> the file descriptor leak checker on freebsd?

I just tried fdleak_open without the freebsd expected and it passes. I remember spending some time debugging this and it seemed as though the KDE wm was passing an open socket to processes to be able to tell when they exit (maybe, I never realy understood what was happening).

I'll check the others and update as necessary.
Comment 7 Ed Maste 2021-09-30 20:33:03 UTC
(In reply to Paul Floyd from comment #6)
> (In reply to Mark Wielaard from comment #2)
> > This patch makes cachegrind/tests/Makefile.am executable, which I think is
> > wrong.
> 
> Done.
> 
> > In dhat/tests/copy.c, which test for && defined(__GNUC__)?
> > Is mempcpy defined if __GNUC__ isn't on freebsd?
> 
> I think that it is not defined at all (it's nowhere in /usr/include), but
> clang has it as a builtin.

__GNUC__ is a Clang built-in:

$ cc -x c -dM -E /dev/null | grep GNUC
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__ 4

mempcpy was added in:

commit ee37f64cf875255338f917a9da76c643cf59786c
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Wed Jul 14 18:41:36 2021 +0300

    libc: add mempcpy(3) and wmempcpy(3)
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D31180

Testing (defined(VGO_freebsd) && defined(__GNUC__)) seems a bit strange - probably the right thing to do is just drop the __GNUC__ condition now, and then also remove VGO_freebsd in several months, when all supported FreeBSD branches have mempcpy.
Comment 8 Paul Floyd 2021-09-30 21:15:50 UTC
> Testing (defined(VGO_freebsd) && defined(__GNUC__)) seems a bit strange -
> probably the right thing to do is just drop the __GNUC__ condition now, and
> then also remove VGO_freebsd in several months, when all supported FreeBSD
> branches have mempcpy.

mempcpy doesn't seem very portable. I've already fixed this testcase on Solaris and macOS (which don't have it available).

My FreeBSD commit message was 

    Strangely GCC and clang do different things.

I'll try to remember to update this, but it's only a regtest so not that important.
Comment 9 Ed Maste 2021-09-30 23:15:09 UTC
(In reply to Paul Floyd from comment #8)
>
> I'll try to remember to update this, but it's only a regtest so not that
> important.

Indeed, this is not a high priority and could be dealt with well in the future.
Comment 10 Paul Floyd 2021-10-05 20:55:00 UTC
Created attachment 142189 [details]
other directories

missing shared and mpi directories
Comment 11 Paul Floyd 2021-10-05 21:07:03 UTC
Created attachment 142193 [details]
other dirs

added mpi and shared
Comment 12 Paul Floyd 2021-10-05 21:16:21 UTC
Created attachment 142195 [details]
other directories

Removed a couple of diff files
Comment 13 Paul Floyd 2021-10-07 20:56:14 UTC
Code committed with
commit 53dd9bd255d7add6f5a502ec9cd4895d3ed21452