@@ -45,19 +45,9 @@ static uint32_t g_initialize_count = 0;
45
45
46
46
PlatformSP PlatformNetBSD::CreateInstance (bool force, const ArchSpec *arch) {
47
47
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>" );
61
51
62
52
bool create = force;
63
53
if (create == false && arch && arch->IsValid ()) {
@@ -72,18 +62,10 @@ PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
72
62
}
73
63
}
74
64
65
+ LLDB_LOG (log, " create = {0}" , create);
75
66
if (create) {
76
- if (log)
77
- log->Printf (" PlatformNetBSD::%s() creating remote-netbsd platform" ,
78
- __FUNCTION__);
79
67
return PlatformSP (new PlatformNetBSD (false ));
80
68
}
81
-
82
- if (log)
83
- log->Printf (
84
- " PlatformNetBSD::%s() aborting creation of remote-netbsd platform" ,
85
- __FUNCTION__);
86
-
87
69
return PlatformSP ();
88
70
}
89
71
@@ -258,19 +240,15 @@ bool PlatformNetBSD::CanDebugProcess() {
258
240
}
259
241
260
242
// 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) {
270
250
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);
274
252
275
253
// If we're a remote host, use standard behavior from parent class.
276
254
if (!IsHost ())
@@ -293,61 +271,42 @@ lldb::ProcessSP PlatformNetBSD::DebugProcess(
293
271
294
272
// Ensure we have a target.
295
273
if (target == nullptr ) {
296
- if (log)
297
- log->Printf (" PlatformNetBSD::%s creating new target" , __FUNCTION__);
298
-
274
+ LLDB_LOG (log, " creating new target" );
299
275
TargetSP new_target_sp;
300
276
error = debugger.GetTargetList ().CreateTarget (debugger, " " , " " , false ,
301
277
nullptr , new_target_sp);
302
278
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);
306
280
return process_sp;
307
281
}
308
282
309
283
target = new_target_sp.get ();
310
284
if (!target) {
311
285
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);
315
287
return process_sp;
316
288
}
317
- } else {
318
- if (log)
319
- log->Printf (" PlatformNetBSD::%s using provided target" , __FUNCTION__);
320
289
}
321
290
322
291
// Mark target as currently selected target.
323
292
debugger.GetTargetList ().SetSelectedTarget (target);
324
293
325
294
// 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" );
330
296
process_sp = target->CreateProcess (
331
297
launch_info.GetListenerForProcess (debugger), " gdb-remote" , nullptr );
332
298
333
299
if (!process_sp) {
334
300
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);
338
302
return process_sp;
339
- } else {
340
- if (log)
341
- log->Printf (" PlatformNetBSD::%s successfully created process" ,
342
- __FUNCTION__);
343
303
}
344
304
305
+ LLDB_LOG (log, " successfully created process" );
345
306
// Adjust launch for a hijacker.
346
307
ListenerSP listener_sp;
347
308
if (!launch_info.GetHijackListener ()) {
348
- if (log)
349
- log->Printf (" PlatformNetBSD::%s setting up hijacker" , __FUNCTION__);
350
-
309
+ LLDB_LOG (log, " setting up hijacker" );
351
310
listener_sp =
352
311
Listener::MakeListener (" lldb.PlatformNetBSD.DebugProcess.hijack" );
353
312
launch_info.SetHijackListener (listener_sp);
@@ -356,16 +315,13 @@ lldb::ProcessSP PlatformNetBSD::DebugProcess(
356
315
357
316
// Log file actions.
358
317
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:" );
363
319
StreamString stream;
364
320
size_t i = 0 ;
365
321
const FileAction *file_action;
366
322
while ((file_action = launch_info.GetFileActionAtIndex (i++)) != nullptr ) {
367
323
file_action->Dump (stream);
368
- log-> PutCString ( stream.GetData ());
324
+ LLDB_LOG (log, " {0} " , stream.GetData ());
369
325
stream.Clear ();
370
326
}
371
327
}
@@ -378,37 +334,19 @@ lldb::ProcessSP PlatformNetBSD::DebugProcess(
378
334
const StateType state = process_sp->WaitForProcessToStop (
379
335
llvm::None, NULL , false , listener_sp);
380
336
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);
391
338
}
392
339
393
340
// Hook up process PTY if we have one (which we should for local debugging
394
341
// with llgs).
395
342
int pty_fd = launch_info.GetPTY ().ReleaseMasterFileDescriptor ();
396
343
if (pty_fd != PseudoTerminal::invalid_fd) {
397
344
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" );
408
348
} 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);
412
350
// FIXME figure out appropriate cleanup here. Do we delete the target? Do
413
351
// we delete the process? Does our caller do that?
414
352
}
0 commit comments