This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Implement ObjectFile::GetCStrFromSection
Needs ReviewPublic

Authored by augusto2112 on Feb 25 2022, 11:07 AM.

Details

Diff Detail

Event Timeline

augusto2112 requested review of this revision.Feb 25 2022, 11:07 AM
augusto2112 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2022, 11:07 AM
aprantl added inline comments.Feb 25 2022, 11:28 AM
lldb/include/lldb/Symbol/ObjectFile.h
676

Can you add a doxygen comment for the method?

677

Should we call it GetCStringFromSection, or even better ReadCStringFromSection?

lldb/source/Symbol/ObjectFile.cpp
558

The fact that it's a C string seems to be not relevant to the function. It seems to just convert a file address to a load address?

augusto2112 added inline comments.Feb 25 2022, 11:41 AM
lldb/include/lldb/Symbol/ObjectFile.h
677

I agree that ReadCStringFromSection sounds better.

lldb/source/Symbol/ObjectFile.cpp
558

What do you mean? This function calls m_data.GetCStr and returns the result.

labath added a subscriber: labath.Feb 25 2022, 11:59 AM

I don't think this implementation is sound. If you look at the implementation of ReadSectionData you'll see that there is a lot more involved in reading data from a section than just incrementing a pointer.

andcarminati added inline comments.
lldb/source/Symbol/ObjectFile.cpp
559

Wouldn't it be better to use

section->GetFileOffset()

to access m_data? As this object contains data loaded from the file.