Page MenuHomeFreeBSD

Add extended segment support to gcore
ClosedPublic

Authored by cem on Jul 20 2016, 7:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 8:40 AM
Unknown Object (File)
Sat, Dec 7, 7:28 PM
Unknown Object (File)
Nov 18 2024, 9:20 AM
Unknown Object (File)
Nov 2 2024, 5:52 AM
Unknown Object (File)
Nov 2 2024, 5:52 AM
Unknown Object (File)
Nov 2 2024, 5:52 AM
Unknown Object (File)
Nov 2 2024, 5:52 AM
Unknown Object (File)
Nov 2 2024, 5:43 AM
Subscribers

Details

Summary

Follow-up to D7255, requested by jhb.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 4549
Build 4601: arc lint + arc unit

Event Timeline

cem retitled this revision from to Add extended segment support to gcore.
cem updated this object.
cem edited the test plan for this revision. (Show Details)
cem added reviewers: jhb, emaste, markj.

Please ignore the tests/ changes. arc doesn't support independent diffs in the same SVN tree very well.

emaste edited edge metadata.

LGTM as long as you've tested it.

This revision is now accepted and ready to land.Jul 20 2016, 7:25 PM

LGTM as long as you've tested it.

About that... maybe my world is out of date, but I can't even build gcore:

CURRENT.svn/usr.bin/gcore/elfcore.c:617:10: error: no member named 'pr_pid' in 'struct prpsinfo'
        psinfo->pr_pid = pid;
        ~~~~~~  ^
usr.bin/gcore/elfcore.c
484

This doesn't seem correct in the new case as 'hdr' isn't updated. Probably the assignment of 'phdr' needs to move into the branches above? The 'if' can use this, and the 'else' would it put it after the end of the 'shdr'.

Just hack your previous test program to add a 'getchar()' or some such so it pauses so you can run gcore against it to test it. (That's what I end up doing to test gcore).

usr.bin/gcore/elfcore.c
484

Not sure what you mean. hdr isn't updated in the kernel dump either. The segments are actually located before the sections in the dump (in both kernel and gcore). More correct would be phdr = hdr + ehdr->e_phoff but e_phoff is sizeof(Elf_Edhr) so that's fine.

Just hack your previous test program to add a 'getchar()' or some such so it pauses so you can run gcore against it to test it. (That's what I end up doing to test gcore).

Or even better have the helper take a command-line argument to either abort itself, or wait.

Yes, pr_pid was added to gcore in HEAD this past week. It requires a newer /sys/sys/procfs.h. You can just copy that header to /usr/include/sys to build a gcore binary.

usr.bin/gcore/elfcore.c
484

Ah, I inferred the relative location from the fact that you moved it. I guess it's fine to move it, but it is "noise" in the diff, per se. Changing it to 'e_phoff' is fine with me though if you wish.

In D7265#151151, @jhb wrote:

Yes, pr_pid was added to gcore in HEAD this past week. It requires a newer /sys/sys/procfs.h. You can just copy that header to /usr/include/sys to build a gcore binary.

Thanks.

usr.bin/gcore/elfcore.c
484

Right. I've changed it to e_phoff locally, but am waiting to push the new diff until I can test it.

cem edited edge metadata.

Minor change: replace hardcoded phdr offset with e_phoff (though e_phoff
remains unchanged).

I've tested this and confirmed gcore emits the special section when the number
of r/w segments exceeds 65535. Caveat, gcore appears to interpret whether or
not to dump a section differently from the kernel. So to repro, I doubled the
count in the helper program.

This revision now requires review to proceed.Jul 20 2016, 9:42 PM
This revision was automatically updated to reflect the committed changes.

Hmm. They really should be dumping the same set of segments. What is the difference you see?