Page MenuHomePhabricator

[lldb-vscode] Follow up of D99989 - store some strings more safely

Authored by wallace on Apr 22 2021, 9:27 PM.



As a follow up of, I'm now
storing std::string instead of char *. I know it might never break as char *,
but if it does, chasing that bug might be dauting.

Diff Detail

Event Timeline

wallace requested review of this revision.Apr 22 2021, 9:27 PM
wallace created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 9:27 PM
JDevlieghere added inline comments.Apr 23 2021, 8:45 AM

Have you considered an`llvm::StringMap`, it should be more performant.

TIL. I'll give it a try

wallace added inline comments.Apr 23 2021, 10:28 AM

I've been reading and it seems that it's not more performant speed-wise. I imagine it's more performance space-wise, but here I mostly care about time.

clayborg requested changes to this revision.Apr 26 2021, 3:28 PM
clayborg added inline comments.

This will crash if "variable.GetName()" return nullptr. We should check and only add if not nullptr

This revision now requires changes to proceed.Apr 26 2021, 3:28 PM
wallace updated this revision to Diff 341017.Apr 27 2021, 4:06 PM

now checking if the strings gotten from the API are null or not

wallace added inline comments.Apr 27 2021, 8:50 PM
925 ↗(On Diff #341017)

i had to change this because std::string(nullptr) throws on my machine

shafik added a subscriber: shafik.Apr 28 2021, 1:28 PM
shafik added inline comments.
925 ↗(On Diff #341017)

Yes, the std::string constructor taking a const CharT* expects a null terminated C-string.

clayborg accepted this revision.Apr 28 2021, 4:35 PM
This revision is now accepted and ready to land.Apr 28 2021, 4:35 PM
wallace closed this revision.Apr 29 2021, 6:46 PM