This is an archive of the discontinued LLVM Phabricator instance.

Fix a bug in linux core file handling
ClosedPublic

Authored by labath on Apr 1 2016, 9:06 AM.

Details

Summary

There was a bug in linux core file handling, where if there was a running process with the same
process id as the id in the core file, the core file debugging would fail, as we would pull some
pieces of information (ProcessInfo structure) from the running process instead of the core file.
I fix this by routing the ProcessInfo requests through the Process class and overriding it in
ProcessElfCore to return correct data.

A (slightly convoluted) test is included.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 52379.Apr 1 2016, 9:06 AM
labath retitled this revision from to Fix a bug in linux core file handling.
labath updated this object.
labath added reviewers: clayborg, zturner.
labath added a subscriber: lldb-commits.
zturner edited edge metadata.Apr 1 2016, 9:09 AM
zturner added a subscriber: zturner.

What if you are simultaneously debugging 2 processes with the same pid?
Does this fail?

clayborg requested changes to this revision.Apr 1 2016, 10:00 AM
clayborg edited edge metadata.

See inlined comments.

source/Plugins/Process/elf-core/ProcessElfCore.cpp
644–647 ↗(On Diff #52379)

Can the ELF core really not figure out what its executable is? Shouldn't it be filling in info.m_executable by calling info.SetExecutableFile(...)?

source/Target/Process.cpp
6487 ↗(On Diff #52379)

We should probably be extra safe here and do:

PlatformSP platform_sp = GetTarget().GetPlatform();
if (platform_sp)
    return platform_sp->GetProcessInfo(GetID(), info);
else
    return false;
This revision now requires changes to proceed.Apr 1 2016, 10:00 AM
labath updated this revision to Diff 52572.Apr 4 2016, 9:54 AM
labath edited edge metadata.

Address review comments.

labath marked an inline comment as done.Apr 4 2016, 9:57 AM

I have also added a test which loads two core files with the same pid. (Based on very little experimentation) everything seems to be working ok for that case.

source/Plugins/Process/elf-core/ProcessElfCore.cpp
644–647 ↗(On Diff #52572)

It get's parsed and set as the main target module in DoLoadCore, so I load the info from there.

clayborg accepted this revision.Apr 4 2016, 10:04 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Apr 4 2016, 10:04 AM
This revision was automatically updated to reflect the committed changes.