Page MenuHomePhabricator

elf-core: Split up parsing code into os-specific functions
ClosedPublic

Authored by labath on Nov 21 2017, 8:04 AM.

Details

Summary

We've had a single function responsible for splitting a core segment
into notes, and parsing the notes themselves, bearing in mind variations
between 4 supported OS types. This commit splits that code into 5
pieces:

  • (os-independent) code for splitting a segment into individual notes
  • per-os function for parsing the notes into thread information

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Nov 21 2017, 8:04 AM
clayborg added inline comments.Nov 21 2017, 8:36 AM
source/Plugins/Process/elf-core/ProcessElfCore.cpp
488 ↗(On Diff #123810)

Do we need to check anything after parsing a note here to ensure it parsed? Can offset end up not changing and could we get into an infinite loop here? Seems like we should do:

if (!note.Parse(segment, &offset))
  break;
763–765 ↗(On Diff #123810)

This won't cause a crash right?

source/Plugins/Process/elf-core/ProcessElfCore.h
32 ↗(On Diff #123810)

Why is this needed here? Doesn't seem to be. Can you include only in .cpp file?

labath updated this revision to Diff 123816.Nov 21 2017, 9:13 AM

Address review comments.

source/Plugins/Process/elf-core/ProcessElfCore.cpp
488 ↗(On Diff #123810)

Good point. There was no error checking in the original code, but it looks like there should be...

763–765 ↗(On Diff #123810)

Only if the caller does not do anything with the result function (and it that case, it will assert regardless of whether the function returned an error or not).

krytarowski added inline comments.Nov 21 2017, 6:14 PM
source/Plugins/Process/elf-core/ProcessElfCore.cpp
735 ↗(On Diff #123816)

Can we label it as SVR4-style (Linux, FreeBSD, Solaris)? Alternatively move it to other place in order to describe Linux and FreeBSD separately (NetBSD an OpenBSD can be skipped now).

labath added inline comments.Nov 22 2017, 3:55 AM
source/Plugins/Process/elf-core/ProcessElfCore.cpp
735 ↗(On Diff #123816)

Yeah, I was wondering what to do with that comment -- it is so vague it is nearly useless. I agree we should move the core file description to the individual OS's parsing functions. I've written a description of the linux notes. Freebsd ones seem pretty similar, but don't know enough about them to say if the description applies to them as well.

labath updated this revision to Diff 123898.Nov 22 2017, 3:56 AM

Update comments.

kettenis edited edge metadata.Nov 22 2017, 4:44 AM

Looks like a good improvement to me.

clayborg accepted this revision.Nov 22 2017, 10:09 AM
This revision is now accepted and ready to land.Nov 22 2017, 10:09 AM
krytarowski accepted this revision.Nov 22 2017, 9:28 PM
This revision was automatically updated to reflect the committed changes.