This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

As a follow up of https://reviews.llvm.org/D99989#inline-953343, 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
lldb/tools/lldb-vscode/lldb-vscode.cpp
2934

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
lldb/tools/lldb-vscode/lldb-vscode.cpp
2934

I've been reading https://llvm.org/devmtg/2014-04/PDFs/LightningTalks/data_structure_llvm.pdf 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.
lldb/tools/lldb-vscode/lldb-vscode.cpp
2939

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
lldb/tools/lldb-vscode/JSONUtils.cpp
925

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.
lldb/tools/lldb-vscode/JSONUtils.cpp
925

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