state = process->GetState();
if (process->IsAlive() && state != eStateConnected) {
- char message[1024];
+ std::string message;
if (process->GetState() == eStateAttaching)
- ::snprintf(message, sizeof(message),
- "There is a pending attach, abort it and %s?",
- m_new_process_action.c_str());
+ message =
+ llvm::formatv("There is a pending attach, abort it and {0}?",
+ m_new_process_action);
else if (process->GetShouldDetach())
- ::snprintf(message, sizeof(message),
- "There is a running process, detach from it and %s?",
- m_new_process_action.c_str());
+ message = llvm::formatv(
+ "There is a running process, detach from it and {0}?",
+ m_new_process_action);
else
- ::snprintf(message, sizeof(message),
- "There is a running process, kill it and %s?",
- m_new_process_action.c_str());
+ message =
+ llvm::formatv("There is a running process, kill it and {0}?",
+ m_new_process_action);
if (!m_interpreter.Confirm(message, true)) {
result.SetStatus(eReturnStatusFailed);
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
"{0} Communication::StartReadThread ()", this);
- char thread_name[1024];
- snprintf(thread_name, sizeof(thread_name), "<lldb.comm.%s>",
- GetBroadcasterName().AsCString());
+ const std::string thread_name =
+ llvm::formatv("<lldb.comm.{0}>", GetBroadcasterName());
m_read_thread_enabled = true;
m_read_thread_did_exit = false;
m_event_handler_thread(), m_io_handler_thread(),
m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
m_forward_listener_sp(), m_clear_once() {
- char instance_cstr[256];
- snprintf(instance_cstr, sizeof(instance_cstr), "debugger_%d", (int)GetID());
- m_instance_name.SetCString(instance_cstr);
+ m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str());
if (log_callback)
m_log_callback_stream_sp =
std::make_shared<StreamCallback>(log_callback, baton);
break;
}
- char prefix[32] = "";
+ std::string prefix;
if (bp_locs) {
uint32_t bp_count = bp_locs->NumLineEntriesWithLine(line);
if (bp_count > 0)
- ::snprintf(prefix, sizeof(prefix), "[%u] ", bp_count);
+ prefix = llvm::formatv("[{0}]", bp_count);
else
- ::snprintf(prefix, sizeof(prefix), " ");
+ prefix = " ";
}
char buffer[3];
.str());
}
- s->Printf("%s%s %-4u\t", prefix, current_line_highlight.c_str(), line);
+ s->Printf("%s%s %-4u\t", prefix.c_str(), current_line_highlight.c_str(),
+ line);
// So far we treated column 0 as a special 'no column value', but
// DisplaySourceLines starts counting columns from 0 (and no column is
bool can_create) {
ValueObjectSP synthetic_child_sp;
if (IsPointerType() || IsArrayType()) {
- char index_str[64];
- snprintf(index_str, sizeof(index_str), "[%" PRIu64 "]", (uint64_t)index);
+ std::string index_str = llvm::formatv("[{0}]", index);
ConstString index_const_str(index_str);
// Check if we have already created a synthetic array member in this valid
// object. If we have we will re-use it.
bool can_create) {
ValueObjectSP synthetic_child_sp;
if (IsScalarType()) {
- char index_str[64];
- snprintf(index_str, sizeof(index_str), "[%i-%i]", from, to);
+ std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
ConstString index_const_str(index_str);
// Check if we have already created a synthetic array member in this valid
// object. If we have we will re-use it.
ValueObjectSP synthetic_child_sp;
if (name_const_str.IsEmpty()) {
- char name_str[64];
- snprintf(name_str, sizeof(name_str), "@%i", offset);
- name_const_str.SetCString(name_str);
+ name_const_str.SetString("@" + std::to_string(offset));
}
// Check if we have already created a synthetic array member in this valid
static void AdjustForBitfieldness(ConstString &name,
uint8_t bitfield_bit_size) {
- if (name && bitfield_bit_size) {
- const char *compiler_type_name = name.AsCString();
- if (compiler_type_name) {
- std::vector<char> bitfield_type_name(strlen(compiler_type_name) + 32, 0);
- ::snprintf(&bitfield_type_name.front(), bitfield_type_name.size(),
- "%s:%u", compiler_type_name, bitfield_bit_size);
- name.SetCString(&bitfield_type_name.front());
- }
- }
+ if (name && bitfield_bit_size)
+ name.SetString(llvm::formatv("{0}:{1}", name, bitfield_bit_size).str());
}
ConstString ValueObjectChild::GetTypeName() {
if (value_type != OptionParser::eOptionalArgument)
new_args.AppendArgument(value);
else {
- char buffer[255];
- ::snprintf(buffer, sizeof(buffer), "%s%s", option.c_str(),
- value.c_str());
- new_args.AppendArgument(llvm::StringRef(buffer));
+ new_args.AppendArgument(option + value);
}
} else if (static_cast<size_t>(index) >= cmd_args.GetArgumentCount()) {
if (value_type != OptionParser::eOptionalArgument)
new_args.AppendArgument(cmd_args.GetArgumentAtIndex(index));
else {
- char buffer[255];
- ::snprintf(buffer, sizeof(buffer), "%s%s", option.c_str(),
- cmd_args.GetArgumentAtIndex(index));
- new_args.AppendArgument(buffer);
+ new_args.AppendArgument(option + cmd_args.GetArgumentAtIndex(index));
}
used[index] = true;
}