MCPcopy Create free account
hub / github.com/Vector35/debugger / main

Function main

cli/main.cpp:321–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319
320
321int main(int argc, const char* argv[])
322{
323 Log::SetupAnsi();
324 LogToStdout(WarningLog);
325
326 if (argc != 2 && argc != 4)
327 {
328 Log::print<Log::Error>("usage: {} <debuggee_path>\n", argv[0]);
329 Log::print<Log::Error>("usage: {} <debuggee_path> --attach <debuggee_pid>\n", argv[0]);
330 Log::print<Log::Error>("usage: {} <debuggee_path> --connect <host:port>\n", argv[0]);
331 return 0;
332 }
333
334 Log::SetupAnsi();
335
336 SetBundledPluginDirectory(GetBundledPluginDirectory());
337 InitPlugins();
338
339 const char* fname = argv[1];
340 if (!is_file(fname))
341 {
342 cerr << "Error: " << fname << " is not a regular file" << endl;
343 exit(-1);
344 }
345
346 SetBundledPluginDirectory(GetBundledPluginDirectory());
347 InitPlugins();
348
349 Ref<BinaryData> bd = BinaryData::CreateFromFilename(new FileMetadata(argv[1]), argv[1]);
350 if (!bd)
351 {
352 fprintf(stderr, "Could not open input file.\n");
353 return -1;
354 }
355 Ref<BinaryView> bv;
356 for (auto type : BinaryViewType::GetViewTypes())
357 {
358 if (type->IsTypeValidForData(bd) && type->GetName() != "Raw")
359 {
360 bv = type->Create(bd);
361 break;
362 }
363 }
364
365 if (!bv || bv->GetTypeName() == "Raw")
366 {
367 fprintf(stderr, "Input file does not appear to be an executable\n");
368 return -1;
369 }
370
371 bv->UpdateAnalysisAndWait();
372
373 DbgRef<DebuggerController> debugger = DebuggerController::GetController(bv);
374 if (!debugger)
375 LogError("Failed to create a debugger for the BinaryView\n");
376
377 if (argc == 2)
378 {

Callers

nothing calls this directly

Calls 15

SetupAnsiFunction · 0.85
is_fileFunction · 0.85
StyleClass · 0.85
printFunction · 0.85
RegisterDisplayFunction · 0.85
DisasmDisplayFunction · 0.85
PrintStopReasonFunction · 0.85
IsTypeValidForDataMethod · 0.80
GetNameMethod · 0.80
detachMethod · 0.80
sizeMethod · 0.80
CreateMethod · 0.45

Tested by

no test coverage detected