UriParser:Parse expects that host name doesn't contain special URL symbols - ":", ";", "$",...
However, in case of adb protocol (adb://$device_serial_no:$port) it poses a problem - device serial number may contain a colon ("192.168.0.1:5555").
In order to handle this situation UriParser now supports optional [$HOSTNAME] notation - i.e. connect://localhost:5555 and connect://[localhost]:5555 should be parsed identically.
This change allows us to pass special URL symbols (like colon) as part of a hostname.
Details
- Reviewers
chaoren clayborg tberghammer
Diff Detail
Event Timeline
The implementation looks good, but I don't like the approach you try to handle the problem.
I think you do far too much work to use UriParser in a case where it isn't necessary and isn't make things easier. I think a better (and definitely simpler) solution would be to change only ConnectionFileDescriptorPosix.cpp to parse the adb addresses with a locally specified regexp or with looking for the last colon in the address and split the address to host and port based on that.
The problem that connection url goes all way down PlatformAndroid::ConnectRemote-> PlatformAndroidRemoteGDBServer::ConnectRemote->PlatformRemoteGDBServer::ConnectRemote whiles it reaches ConnectionFileDescriptorPosix::Connect. Within each ConnectRemote we call UriParser::Parse - either to verify url correctness or fetch device_id from adb url. In this case we may need to have special handling for adb protocol inside of UriParser::Parse to pass it through - I'm not very happy to bring protocol-specific knowledge to this class.
I see your point. I am still not too happy with this approach but I don't have any better idea to solve it. I am fine with committing it in in this format and we can improve it later if we find a better approach.
Rewrote the CL to make UriParser to support optional [$HOSTNAME] notation for LLDB connect URL - i.e. connect://localhost:5555 and connect://[localhost]:5555 should be parsed identically.
This change allows us to pass special URL symbols (like colon) as part of a hostname.
source/Utility/UriParser.cpp | ||
---|---|---|
14 | I think you wanted to include <string>, not <string.h> | |
67–76 | I would prefer no to remove the '[' and the ']' characters from the hostname. At the moment you don't use the hostname for the adb protocol so it isn't matter but if we consider IPv6 then having '[' and ']' around the address sounds like a good idea to me (later stages can use this information). |
source/Utility/UriParser.cpp | ||
---|---|---|
14 | I need string.h for strlen - it's required even with <string> included . | |
67–76 | Let me leave [] removal as-is since we treat hostname as device_id in case of adb and then use it for port forwarding setup - https://github.com/llvm-mirror/lldb/blob/master/source/Plugins/Platform/Android/PlatformAndroid.cpp#L199 |
source/Utility/UriParser.cpp | ||
---|---|---|
14 | The C++ way would be to #include <cstring> </driveby> |
Files:
/lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp /lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp /lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h /lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp /lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h /lldb/trunk/source/Utility/UriParser.cpp /lldb/trunk/source/Utility/UriParser.h /lldb/trunk/unittests/Utility/UriParserTest.cpp
Users:
ovyalov (Author)
I think you wanted to include <string>, not <string.h>