This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Guarantee the lifetimes of all strings returned from SBAPI
ClosedPublic

Authored by bulbazord on May 17 2023, 11:01 AM.

Details

Summary

LLDB should guarantee that the strings returned by SBAPI methods
live forever. I went through every method that returns a string and made
sure that it was added to the ConstString StringPool before returning if
it wasn't obvious that it was already doing so.
I've also updated the docs to document this behavior.

Diff Detail

Event Timeline

bulbazord created this revision.May 17 2023, 11:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 11:01 AM
bulbazord requested review of this revision.May 17 2023, 11:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 11:01 AM
mib accepted this revision.May 18 2023, 2:44 PM

LGTM with nit.

lldb/source/API/SBFunction.cpp
181

nit: This threw me off, I thought you forgot to create a ConsString but it seems that ConstString has both a AsCString and a GetCString method. It would be good to stay consistent.

This revision is now accepted and ready to land.May 18 2023, 2:44 PM
bulbazord marked an inline comment as done.May 18 2023, 2:49 PM
bulbazord added inline comments.
lldb/source/API/SBFunction.cpp
181

Yeah, maybe we should try to remove either GetCString or AsCString and be uniform everywhere. Let's plan on doing that later though.

bulbazord updated this revision to Diff 523578.May 18 2023, 3:12 PM
bulbazord marked an inline comment as done.

Update SBModule::GetUUIDString -- I slightly changed behavior. Now the behavior matches the previous implementation exactly.