Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit e87a90d

Browse files
committed
Merging r324251:
------------------------------------------------------------------------ r324251 | kamil | 2018-02-05 18:12:23 +0100 (Mon, 05 Feb 2018) | 14 lines Sync PlatformNetBSD.cpp with Linux Summary: Various changes in logging from log->Printf() to generic LLDB_LOG(). Sponsored by <The NetBSD Foundation> Reviewers: labath, joerg Reviewed By: labath Subscribers: llvm-commits, lldb-commits Differential Revision: https://reviews.llvm.org/D42912 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/lldb/branches/release_60@324326 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 19e7bfe commit e87a90d

File tree

1 file changed

+26
-88
lines changed

1 file changed

+26
-88
lines changed

source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp

Lines changed: 26 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,9 @@ static uint32_t g_initialize_count = 0;
4545

4646
PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
4747
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
48-
if (log) {
49-
const char *arch_name;
50-
if (arch && arch->GetArchitectureName())
51-
arch_name = arch->GetArchitectureName();
52-
else
53-
arch_name = "<null>";
54-
55-
const char *triple_cstr =
56-
arch ? arch->GetTriple().getTriple().c_str() : "<null>";
57-
58-
log->Printf("PlatformNetBSD::%s(force=%s, arch={%s,%s})", __FUNCTION__,
59-
force ? "true" : "false", arch_name, triple_cstr);
60-
}
48+
LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
49+
arch ? arch->GetArchitectureName() : "<null>",
50+
arch ? arch->GetTriple().getTriple() : "<null>");
6151

6252
bool create = force;
6353
if (create == false && arch && arch->IsValid()) {
@@ -72,18 +62,10 @@ PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
7262
}
7363
}
7464

65+
LLDB_LOG(log, "create = {0}", create);
7566
if (create) {
76-
if (log)
77-
log->Printf("PlatformNetBSD::%s() creating remote-netbsd platform",
78-
__FUNCTION__);
7967
return PlatformSP(new PlatformNetBSD(false));
8068
}
81-
82-
if (log)
83-
log->Printf(
84-
"PlatformNetBSD::%s() aborting creation of remote-netbsd platform",
85-
__FUNCTION__);
86-
8769
return PlatformSP();
8870
}
8971

@@ -258,19 +240,15 @@ bool PlatformNetBSD::CanDebugProcess() {
258240
}
259241

260242
// For local debugging, NetBSD will override the debug logic to use llgs-launch
261-
// rather than
262-
// lldb-launch, llgs-attach. This differs from current lldb-launch,
263-
// debugserver-attach
264-
// approach on MacOSX.
265-
lldb::ProcessSP PlatformNetBSD::DebugProcess(
266-
ProcessLaunchInfo &launch_info, Debugger &debugger,
267-
Target *target, // Can be NULL, if NULL create a new
268-
// target, else use existing one
269-
Status &error) {
243+
// rather than lldb-launch, llgs-attach. This differs from current lldb-launch,
244+
// debugserver-attach approach on MacOSX.
245+
lldb::ProcessSP
246+
PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
247+
Target *target, // Can be NULL, if NULL create a new
248+
// target, else use existing one
249+
Status &error) {
270250
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
271-
if (log)
272-
log->Printf("PlatformNetBSD::%s entered (target %p)", __FUNCTION__,
273-
static_cast<void *>(target));
251+
LLDB_LOG(log, "target {0}", target);
274252

275253
// If we're a remote host, use standard behavior from parent class.
276254
if (!IsHost())
@@ -293,61 +271,42 @@ lldb::ProcessSP PlatformNetBSD::DebugProcess(
293271

294272
// Ensure we have a target.
295273
if (target == nullptr) {
296-
if (log)
297-
log->Printf("PlatformNetBSD::%s creating new target", __FUNCTION__);
298-
274+
LLDB_LOG(log, "creating new target");
299275
TargetSP new_target_sp;
300276
error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
301277
nullptr, new_target_sp);
302278
if (error.Fail()) {
303-
if (log)
304-
log->Printf("PlatformNetBSD::%s failed to create new target: %s",
305-
__FUNCTION__, error.AsCString());
279+
LLDB_LOG(log, "failed to create new target: {0}", error);
306280
return process_sp;
307281
}
308282

309283
target = new_target_sp.get();
310284
if (!target) {
311285
error.SetErrorString("CreateTarget() returned nullptr");
312-
if (log)
313-
log->Printf("PlatformNetBSD::%s failed: %s", __FUNCTION__,
314-
error.AsCString());
286+
LLDB_LOG(log, "error: {0}", error);
315287
return process_sp;
316288
}
317-
} else {
318-
if (log)
319-
log->Printf("PlatformNetBSD::%s using provided target", __FUNCTION__);
320289
}
321290

322291
// Mark target as currently selected target.
323292
debugger.GetTargetList().SetSelectedTarget(target);
324293

325294
// Now create the gdb-remote process.
326-
if (log)
327-
log->Printf(
328-
"PlatformNetBSD::%s having target create process with gdb-remote plugin",
329-
__FUNCTION__);
295+
LLDB_LOG(log, "having target create process with gdb-remote plugin");
330296
process_sp = target->CreateProcess(
331297
launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
332298

333299
if (!process_sp) {
334300
error.SetErrorString("CreateProcess() failed for gdb-remote process");
335-
if (log)
336-
log->Printf("PlatformNetBSD::%s failed: %s", __FUNCTION__,
337-
error.AsCString());
301+
LLDB_LOG(log, "error: {0}", error);
338302
return process_sp;
339-
} else {
340-
if (log)
341-
log->Printf("PlatformNetBSD::%s successfully created process",
342-
__FUNCTION__);
343303
}
344304

305+
LLDB_LOG(log, "successfully created process");
345306
// Adjust launch for a hijacker.
346307
ListenerSP listener_sp;
347308
if (!launch_info.GetHijackListener()) {
348-
if (log)
349-
log->Printf("PlatformNetBSD::%s setting up hijacker", __FUNCTION__);
350-
309+
LLDB_LOG(log, "setting up hijacker");
351310
listener_sp =
352311
Listener::MakeListener("lldb.PlatformNetBSD.DebugProcess.hijack");
353312
launch_info.SetHijackListener(listener_sp);
@@ -356,16 +315,13 @@ lldb::ProcessSP PlatformNetBSD::DebugProcess(
356315

357316
// Log file actions.
358317
if (log) {
359-
log->Printf(
360-
"PlatformNetBSD::%s launching process with the following file actions:",
361-
__FUNCTION__);
362-
318+
LLDB_LOG(log, "launching process with the following file actions:");
363319
StreamString stream;
364320
size_t i = 0;
365321
const FileAction *file_action;
366322
while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
367323
file_action->Dump(stream);
368-
log->PutCString(stream.GetData());
324+
LLDB_LOG(log, "{0}", stream.GetData());
369325
stream.Clear();
370326
}
371327
}
@@ -378,37 +334,19 @@ lldb::ProcessSP PlatformNetBSD::DebugProcess(
378334
const StateType state = process_sp->WaitForProcessToStop(
379335
llvm::None, NULL, false, listener_sp);
380336

381-
if (state == eStateStopped) {
382-
if (log)
383-
log->Printf("PlatformNetBSD::%s pid %" PRIu64 " state %s\n",
384-
__FUNCTION__, process_sp->GetID(), StateAsCString(state));
385-
} else {
386-
if (log)
387-
log->Printf("PlatformNetBSD::%s pid %" PRIu64
388-
" state is not stopped - %s\n",
389-
__FUNCTION__, process_sp->GetID(), StateAsCString(state));
390-
}
337+
LLDB_LOG(log, "pid {0} state {0}", process_sp->GetID(), state);
391338
}
392339

393340
// Hook up process PTY if we have one (which we should for local debugging
394341
// with llgs).
395342
int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
396343
if (pty_fd != PseudoTerminal::invalid_fd) {
397344
process_sp->SetSTDIOFileDescriptor(pty_fd);
398-
if (log)
399-
log->Printf("PlatformNetBSD::%s pid %" PRIu64
400-
" hooked up STDIO pty to process",
401-
__FUNCTION__, process_sp->GetID());
402-
} else {
403-
if (log)
404-
log->Printf("PlatformNetBSD::%s pid %" PRIu64
405-
" not using process STDIO pty",
406-
__FUNCTION__, process_sp->GetID());
407-
}
345+
LLDB_LOG(log, "hooked up STDIO pty to process");
346+
} else
347+
LLDB_LOG(log, "not using process STDIO pty");
408348
} else {
409-
if (log)
410-
log->Printf("PlatformNetBSD::%s process launch failed: %s", __FUNCTION__,
411-
error.AsCString());
349+
LLDB_LOG(log, "process launch failed: {0}", error);
412350
// FIXME figure out appropriate cleanup here. Do we delete the target? Do
413351
// we delete the process? Does our caller do that?
414352
}

0 commit comments

Comments
 (0)