This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-remote] Use llvm::StringRef.split() and llvm::to_integer()
ClosedPublic

Authored by mgorny on Sep 25 2021, 3:33 AM.

Details

Summary

Replace the uses of StringConvert combined with hand-rolled array
splitting with llvm::StringRef.split() and llvm::to_integer().

Diff Detail

Event Timeline

mgorny requested review of this revision.Sep 25 2021, 3:33 AM
mgorny created this revision.
teemperor accepted this revision.Sep 25 2021, 2:26 PM

All the llvm::StringRef & iteration variables can just be llvm::StringRef without the reference. Also some base values got lost here (see inline comments).

Beside that this LGTM, thanks!

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
1667

Base 16 arg is lost here.

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
390

This needs to forward the base arg (there are some callers that seem to parse hex).

1464

base 16 lost here.

This revision is now accepted and ready to land.Sep 25 2021, 2:26 PM
mgorny marked 3 inline comments as done.Sep 26 2021, 2:36 AM
mgorny added inline comments.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
1667

Good catch, thanks.

mgorny marked an inline comment as not done.Sep 26 2021, 2:53 AM
mgorny added inline comments.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
1667

Actually, scratch that. The values here include 0x prefix. and apparently llvm::to_integer() handles that correctly only if base isn't specified.

Though it might be reasonable to fix llvm::to_integer() to allow matching prefix, I guess.

mgorny marked an inline comment as done.Sep 26 2021, 10:58 AM
mgorny added inline comments.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
1667

I've pinged @labath about this and he suggested just stripping the 0x prefix (and fixing the sender not to send it). I'll do the first part in this patch, and then look into updating the code and docs to rid of 0x prefix.

Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2021, 12:24 PM