Skip to content

Commit

Permalink
Debugger: Handle RefsReceived(), opening core files
Browse files Browse the repository at this point in the history
  • Loading branch information
weinhold committed Apr 26, 2016
1 parent b7e6e93 commit 6d5951d
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions src/apps/debugger/Debugger.cpp
Expand Up @@ -13,12 +13,14 @@
#include <new>

#include <Application.h>
#include <Entry.h>
#include <Message.h>
#include <ObjectList.h>
#include <Path.h>

#include <ArgumentVector.h>
#include <AutoDeleter.h>
#include <AutoLocker.h>
#include <ObjectList.h>

#include "CoreFile.h"
#include "CoreFileDebuggerInterface.h"
Expand Down Expand Up @@ -273,6 +275,7 @@ class Debugger : public BApplication,
virtual void MessageReceived(BMessage* message);
virtual void ReadyToRun();
virtual void ArgvReceived(int32 argc, char** argv);
virtual void RefsReceived(BMessage* message);

private:
virtual bool QuitRequested();
Expand All @@ -284,6 +287,7 @@ class Debugger : public BApplication,
private:
status_t _StartNewTeam(TargetHostInterface* interface,
const char* teamPath, const char* args);
status_t _HandleOptions(const Options& options);

private:
SettingsManager fSettingsManager;
Expand Down Expand Up @@ -466,13 +470,32 @@ Debugger::ArgvReceived(int32 argc, char** argv)
return;
}

TeamDebuggerOptions debuggerOptions;
set_debugger_options_from_options(debuggerOptions, options);
debuggerOptions.settingsManager = &fSettingsManager;
_HandleOptions(options);
}

TargetHostInterface* hostInterface
= TargetHostInterfaceRoster::Default()->ActiveInterfaceAt(0);
hostInterface->StartTeamDebugger(debuggerOptions);

void
Debugger::RefsReceived(BMessage* message)
{
// iterate through the refs and handle the files we can handle
entry_ref ref;
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
BPath path;
if (path.SetTo(&ref) != B_OK)
continue;

// check, whether this is a core file
{
ElfFile elfFile;
if (elfFile.Init(path.Path()) != B_OK || elfFile.Type() != ET_CORE)
continue;
}

// handle the core file
Options options;
options.coreFilePath = path.Path();
_HandleOptions(options);
}
}


Expand Down Expand Up @@ -549,6 +572,19 @@ Debugger::_StartNewTeam(TargetHostInterface* interface, const char* path,
}


status_t
Debugger::_HandleOptions(const Options& options)
{
TeamDebuggerOptions debuggerOptions;
set_debugger_options_from_options(debuggerOptions, options);
debuggerOptions.settingsManager = &fSettingsManager;

TargetHostInterface* hostInterface
= TargetHostInterfaceRoster::Default()->ActiveInterfaceAt(0);
return hostInterface->StartTeamDebugger(debuggerOptions);
}


// #pragma mark - CliDebugger


Expand Down

0 comments on commit 6d5951d

Please sign in to comment.