summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-09-19 17:54:06 +0000
committerZachary Turner <zturner@google.com>2016-09-19 17:54:06 +0000
commitecbb0bb1690cd59da0224d7b906f968356b1265c (patch)
tree90951f44a7abb40b355e849a2e64cb09ec3ac900 /lldb/source/Plugins/Process
parent495b211a6c775e6fbc00a1e3a91786f6a880b82e (diff)
downloadbcm5719-llvm-ecbb0bb1690cd59da0224d7b906f968356b1265c.tar.gz
bcm5719-llvm-ecbb0bb1690cd59da0224d7b906f968356b1265c.zip
Fix more functions in Args to use StringRef.
This patch also marks the const char* versions as =delete to prevent their use. This has the potential to cause build breakages on some platforms which I can't compile. I have tested on Windows, Linux, and OSX. Best practices for fixing broken callsites are outlined in Args.h in a comment above the deleted function declarations. Eventually we can remove these =delete declarations, but for now they are important to make sure that all implicit conversions from const char * are manually audited to make sure that they do not invoke a conversion from nullptr. llvm-svn: 281919
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp5
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp30
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp8
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp5
4 files changed, 23 insertions, 25 deletions
diff --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index dfb60e1ddc9..e609cb96456 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -305,8 +305,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
std::string encoding_str;
if (reg_info_dict->GetValueForKeyAsString("encoding", encoding_str))
- reg_info.encoding =
- Args::StringToEncoding(encoding_str.c_str(), eEncodingUint);
+ reg_info.encoding = Args::StringToEncoding(encoding_str, eEncodingUint);
else
reg_info_dict->GetValueForKeyAsInteger("encoding", reg_info.encoding,
eEncodingUint);
@@ -337,7 +336,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
std::string generic_str;
if (reg_info_dict->GetValueForKeyAsString("generic", generic_str))
reg_info.kinds[lldb::eRegisterKindGeneric] =
- Args::StringToGenericRegister(generic_str.c_str());
+ Args::StringToGenericRegister(generic_str);
else
reg_info_dict->GetValueForKeyAsInteger(
"generic", reg_info.kinds[lldb::eRegisterKindGeneric],
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index ef3e75bbf09..14c64f2e514 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1067,31 +1067,31 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
char arg_cstr[PATH_MAX];
// Start args with "debugserver /file/path -r --"
- debugserver_args.AppendArgument(debugserver_path);
+ debugserver_args.AppendArgument(llvm::StringRef(debugserver_path));
#if !defined(__APPLE__)
// First argument to lldb-server must be mode in which to run.
- debugserver_args.AppendArgument("gdbserver");
+ debugserver_args.AppendArgument(llvm::StringRef("gdbserver"));
#endif
// If a url is supplied then use it
if (url)
- debugserver_args.AppendArgument(url);
+ debugserver_args.AppendArgument(llvm::StringRef(url));
if (pass_comm_fd >= 0) {
StreamString fd_arg;
fd_arg.Printf("--fd=%i", pass_comm_fd);
- debugserver_args.AppendArgument(fd_arg.GetData());
+ debugserver_args.AppendArgument(fd_arg.GetString());
// Send "pass_comm_fd" down to the inferior so it can use it to
// communicate back with this process
launch_info.AppendDuplicateFileAction(pass_comm_fd, pass_comm_fd);
}
// use native registers, not the GDB registers
- debugserver_args.AppendArgument("--native-regs");
+ debugserver_args.AppendArgument(llvm::StringRef("--native-regs"));
if (launch_info.GetLaunchInSeparateProcessGroup()) {
- debugserver_args.AppendArgument("--setsid");
+ debugserver_args.AppendArgument(llvm::StringRef("--setsid"));
}
llvm::SmallString<PATH_MAX> named_pipe_path;
@@ -1137,8 +1137,8 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
return error;
}
int write_fd = socket_pipe.GetWriteFileDescriptor();
- debugserver_args.AppendArgument("--pipe");
- debugserver_args.AppendArgument(llvm::to_string(write_fd).c_str());
+ debugserver_args.AppendArgument(llvm::StringRef("--pipe"));
+ debugserver_args.AppendArgument(llvm::to_string(write_fd));
launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor());
#endif
} else {
@@ -1164,8 +1164,8 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
// Send the host and port down that debugserver and specify an option
// so that it connects back to the port we are listening to in this
// process
- debugserver_args.AppendArgument("--reverse-connect");
- debugserver_args.AppendArgument(port_cstr);
+ debugserver_args.AppendArgument(llvm::StringRef("--reverse-connect"));
+ debugserver_args.AppendArgument(llvm::StringRef(port_cstr));
if (port)
*port = port_;
} else {
@@ -1182,7 +1182,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
if (env_debugserver_log_file) {
::snprintf(arg_cstr, sizeof(arg_cstr), "--log-file=%s",
env_debugserver_log_file);
- debugserver_args.AppendArgument(arg_cstr);
+ debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
}
#if defined(__APPLE__)
@@ -1199,7 +1199,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
if (env_debugserver_log_channels) {
::snprintf(arg_cstr, sizeof(arg_cstr), "--log-channels=%s",
env_debugserver_log_channels);
- debugserver_args.AppendArgument(arg_cstr);
+ debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
}
#endif
@@ -1215,7 +1215,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
has_env_var = extra_arg != nullptr;
if (has_env_var) {
- debugserver_args.AppendArgument(extra_arg);
+ debugserver_args.AppendArgument(llvm::StringRef(extra_arg));
if (log)
log->Printf("GDBRemoteCommunication::%s adding env var %s contents "
"to stub command line (%s)",
@@ -1224,7 +1224,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
} while (has_env_var);
if (inferior_args && inferior_args->GetArgumentCount() > 0) {
- debugserver_args.AppendArgument("--");
+ debugserver_args.AppendArgument(llvm::StringRef("--"));
debugserver_args.AppendArguments(*inferior_args);
}
@@ -1232,7 +1232,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
StringList env;
if (Host::GetEnvironment(env)) {
for (size_t i = 0; i < env.GetSize(); ++i)
- launch_info.GetEnvironmentEntries().AppendArgument(env[i].c_str());
+ launch_info.GetEnvironmentEntries().AppendArgument(env[i]);
}
// Close STDIN, STDOUT and STDERR.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 0d7ca3c53e4..9dfb47d1a76 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -946,7 +946,8 @@ GDBRemoteCommunicationServerCommon::Handle_QEnvironment(
packet.SetFilePos(::strlen("QEnvironment:"));
const uint32_t bytes_left = packet.GetBytesLeft();
if (bytes_left > 0) {
- m_process_launch_info.GetEnvironmentEntries().AppendArgument(packet.Peek());
+ m_process_launch_info.GetEnvironmentEntries().AppendArgument(
+ llvm::StringRef::withNullAsEmpty(packet.Peek()));
return SendOKResponse();
}
return SendErrorResponse(12);
@@ -960,7 +961,7 @@ GDBRemoteCommunicationServerCommon::Handle_QEnvironmentHexEncoded(
if (bytes_left > 0) {
std::string str;
packet.GetHexByteString(str);
- m_process_launch_info.GetEnvironmentEntries().AppendArgument(str.c_str());
+ m_process_launch_info.GetEnvironmentEntries().AppendArgument(str);
return SendOKResponse();
}
return SendErrorResponse(12);
@@ -1032,8 +1033,7 @@ GDBRemoteCommunicationServerCommon::Handle_A(StringExtractorGDBRemote &packet) {
if (arg_idx == 0)
m_process_launch_info.GetExecutableFile().SetFile(arg.c_str(),
false);
- m_process_launch_info.GetArguments().AppendArgument(
- arg.c_str());
+ m_process_launch_info.GetArguments().AppendArgument(arg);
if (log)
log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"",
__FUNCTION__, actual_arg_index, arg.c_str());
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 504aa4f29e2..4230601d993 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4158,8 +4158,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
alt_name.SetString(value);
} else if (name == "encoding") {
encoding_set = true;
- reg_info.encoding =
- Args::StringToEncoding(value.data(), eEncodingUint);
+ reg_info.encoding = Args::StringToEncoding(value, eEncodingUint);
} else if (name == "format") {
format_set = true;
Format format = eFormatInvalid;
@@ -4198,7 +4197,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
StringConvert::ToUInt32(value.data(), LLDB_INVALID_REGNUM, 0);
} else if (name == "generic") {
reg_info.kinds[eRegisterKindGeneric] =
- Args::StringToGenericRegister(value.data());
+ Args::StringToGenericRegister(value);
} else if (name == "value_regnums") {
SplitCommaSeparatedRegisterNumberString(value, value_regs, 0);
} else if (name == "invalidate_regnums") {
OpenPOWER on IntegriCloud