Add a means for the user to locate source files if they are not found
at the location specified in the debug info. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39289 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0fae873352
commit
5a13e7b045
@ -245,7 +245,7 @@ Application Debugger :
|
||||
libshared.a
|
||||
|
||||
$(TARGET_LIBSTDC++)
|
||||
be libdebug.so
|
||||
be tracker libdebug.so
|
||||
|
||||
: Debugger.rdef
|
||||
;
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -524,6 +525,15 @@ TeamDebugger::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamDebugger::SourceEntryLocateRequested(const char* sourcePath,
|
||||
const char* locatedPath)
|
||||
{
|
||||
AutoLocker<FileManager> locker(fFileManager);
|
||||
fFileManager->SourceEntryLocated(sourcePath, locatedPath);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance)
|
||||
{
|
||||
|
@ -48,6 +48,9 @@ private:
|
||||
// UserInterfaceListener
|
||||
virtual void FunctionSourceCodeRequested(
|
||||
FunctionInstance* function);
|
||||
virtual void SourceEntryLocateRequested(
|
||||
const char* sourcePath,
|
||||
const char* locatedPath);
|
||||
virtual void ImageDebugInfoRequested(Image* image);
|
||||
virtual void ValueNodeValueRequested(CpuState* cpuState,
|
||||
ValueNodeContainer* container,
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -21,6 +22,10 @@ Function::Function()
|
||||
Function::~Function()
|
||||
{
|
||||
SetSourceCode(NULL, FUNCTION_SOURCE_NOT_LOADED);
|
||||
if (FirstInstance() != NULL) {
|
||||
FirstInstance()->SourceFile()->RemoveListener(this);
|
||||
FirstInstance()->SourceFile()->ReleaseReference();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +75,12 @@ Function::RemoveListener(Listener* listener)
|
||||
void
|
||||
Function::AddInstance(FunctionInstance* instance)
|
||||
{
|
||||
bool firstInstance = fInstances.First() == NULL;
|
||||
fInstances.Add(instance);
|
||||
if (firstInstance && SourceFile() != NULL) {
|
||||
instance->SourceFile()->AcquireReference();
|
||||
instance->SourceFile()->AddListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,6 +88,10 @@ void
|
||||
Function::RemoveInstance(FunctionInstance* instance)
|
||||
{
|
||||
fInstances.Remove(instance);
|
||||
if (fInstances.First() == NULL && SourceFile() != NULL) {
|
||||
instance->SourceFile()->RemoveListener(this);
|
||||
instance->SourceFile()->ReleaseReference();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -94,6 +108,22 @@ Function::NotifySourceCodeChanged()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Function::LocatableFileChanged(LocatableFile* file)
|
||||
{
|
||||
BString locatedPath;
|
||||
BString path;
|
||||
file->GetPath(path);
|
||||
if (file->GetLocatedPath(locatedPath) && locatedPath != path) {
|
||||
SetSourceCode(NULL, FUNCTION_SOURCE_NOT_LOADED);
|
||||
for (FunctionInstanceList::Iterator it = fInstances.GetIterator();
|
||||
FunctionInstance* instance = it.Next();) {
|
||||
instance->SetSourceCode(NULL, FUNCTION_SOURCE_NOT_LOADED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Listener
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef FUNCTION_H
|
||||
@ -9,12 +10,13 @@
|
||||
#include <util/OpenHashTable.h>
|
||||
|
||||
#include "FunctionInstance.h"
|
||||
#include "LocatableFile.h"
|
||||
|
||||
|
||||
class FileSourceCode;
|
||||
|
||||
|
||||
class Function : public Referenceable {
|
||||
class Function : public Referenceable, private LocatableFile::Listener {
|
||||
public:
|
||||
class Listener;
|
||||
|
||||
@ -60,6 +62,8 @@ public:
|
||||
|
||||
void NotifySourceCodeChanged();
|
||||
|
||||
void LocatableFileChanged(LocatableFile* file);
|
||||
|
||||
private:
|
||||
typedef DoublyLinkedList<Listener> ListenerList;
|
||||
|
||||
|
@ -61,6 +61,9 @@ public:
|
||||
|
||||
virtual void FunctionSourceCodeRequested(
|
||||
FunctionInstance* function) = 0;
|
||||
virtual void SourceEntryLocateRequested(
|
||||
const char* sourcePath,
|
||||
const char* locatedPath) = 0;
|
||||
virtual void ImageDebugInfoRequested(Image* image) = 0;
|
||||
virtual void ValueNodeValueRequested(CpuState* cpuState,
|
||||
ValueNodeContainer* container,
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -9,11 +10,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Button.h>
|
||||
#include <FilePanel.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <Path.h>
|
||||
#include <StringView.h>
|
||||
#include <TabView.h>
|
||||
#include <ScrollView.h>
|
||||
#include <SplitView.h>
|
||||
@ -27,6 +32,7 @@
|
||||
#include "FileSourceCode.h"
|
||||
#include "Image.h"
|
||||
#include "ImageDebugInfo.h"
|
||||
#include "LocatableFile.h"
|
||||
#include "MessageCodes.h"
|
||||
#include "RegistersView.h"
|
||||
#include "StackTrace.h"
|
||||
@ -43,6 +49,32 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
MSG_LOCATE_SOURCE_IF_NEEDED = 'lsin'
|
||||
};
|
||||
|
||||
|
||||
class PathViewMessageFilter : public BMessageFilter {
|
||||
public:
|
||||
PathViewMessageFilter(BMessenger teamWindow)
|
||||
:
|
||||
BMessageFilter(B_MOUSE_UP),
|
||||
fTeamWindowMessenger(teamWindow)
|
||||
{
|
||||
}
|
||||
|
||||
virtual filter_result Filter(BMessage*, BHandler**)
|
||||
{
|
||||
fTeamWindowMessenger.SendMessage(MSG_LOCATE_SOURCE_IF_NEEDED);
|
||||
|
||||
return B_DISPATCH_MESSAGE;
|
||||
}
|
||||
|
||||
private:
|
||||
BMessenger fTeamWindowMessenger;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - TeamWindow
|
||||
|
||||
|
||||
@ -171,6 +203,30 @@ void
|
||||
TeamWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case B_REFS_RECEIVED:
|
||||
{
|
||||
entry_ref locatedPath;
|
||||
message->FindRef("refs", &locatedPath);
|
||||
_HandleResolveMissingSourceFile(locatedPath);
|
||||
break;
|
||||
}
|
||||
case MSG_LOCATE_SOURCE_IF_NEEDED:
|
||||
{
|
||||
if (fActiveFunction != NULL
|
||||
&& fActiveFunction->GetFunctionDebugInfo()
|
||||
->SourceFile() != NULL && fActiveSourceCode != NULL
|
||||
&& fActiveSourceCode->GetSourceFile() == NULL) {
|
||||
BFilePanel* panel = NULL;
|
||||
try {
|
||||
panel = new BFilePanel(B_OPEN_PANEL,
|
||||
new BMessenger(this));
|
||||
panel->Show();
|
||||
} catch (...) {
|
||||
delete panel;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_THREAD_RUN:
|
||||
case MSG_THREAD_STOP:
|
||||
case MSG_THREAD_STEP_OVER:
|
||||
@ -405,6 +461,9 @@ TeamWindow::_Init()
|
||||
.Add(fStepOutButton = new BButton("Step Out"))
|
||||
.AddGlue()
|
||||
.End()
|
||||
.Add(fSourcePathView = new BStringView(
|
||||
"source path",
|
||||
"Source path unavailable."), 4.0f)
|
||||
.AddSplit(B_HORIZONTAL, 3.0f)
|
||||
.Add(sourceScrollView = new BScrollView("source scroll",
|
||||
NULL, 0, true, true), 3.0f)
|
||||
@ -457,6 +516,12 @@ TeamWindow::_Init()
|
||||
fStepIntoButton->SetTarget(this);
|
||||
fStepOutButton->SetTarget(this);
|
||||
|
||||
fSourcePathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
BMessageFilter* filter = new(std::nothrow) PathViewMessageFilter(
|
||||
BMessenger(this));
|
||||
if (filter != NULL)
|
||||
fSourcePathView->AddFilter(filter);
|
||||
|
||||
// add menus and menu items
|
||||
BMenu* menu = new BMenu("File");
|
||||
fMenuBar->AddItem(menu);
|
||||
@ -908,8 +973,27 @@ TeamWindow::_HandleSourceCodeChanged()
|
||||
AutoLocker< ::Team> locker(fTeam);
|
||||
|
||||
SourceCode* sourceCode = fActiveFunction->GetFunction()->GetSourceCode();
|
||||
if (sourceCode == NULL)
|
||||
if (sourceCode == NULL) {
|
||||
sourceCode = fActiveFunction->GetSourceCode();
|
||||
|
||||
BString sourceText;
|
||||
LocatableFile* sourceFile = fActiveFunction->GetFunctionDebugInfo()
|
||||
->SourceFile();
|
||||
if (sourceFile != NULL && !sourceFile->GetLocatedPath(sourceText))
|
||||
sourceFile->GetPath(sourceText);
|
||||
|
||||
if (sourceCode != NULL && sourceCode->GetSourceFile() == NULL
|
||||
&& sourceFile != NULL) {
|
||||
sourceText.Prepend("Click to locate source file '");
|
||||
sourceText += "'";
|
||||
fSourcePathView->SetText(sourceText.String());
|
||||
} else if (sourceFile != NULL) {
|
||||
sourceText.Prepend("File: ");
|
||||
fSourcePathView->SetText(sourceText.String());
|
||||
} else
|
||||
fSourcePathView->SetText("Source file unavailable.");
|
||||
}
|
||||
|
||||
Reference<SourceCode> sourceCodeReference(sourceCode);
|
||||
|
||||
locker.Unlock();
|
||||
@ -924,3 +1008,22 @@ TeamWindow::_HandleUserBreakpointChanged(UserBreakpoint* breakpoint)
|
||||
fSourceView->UserBreakpointChanged(breakpoint);
|
||||
fBreakpointsView->UserBreakpointChanged(breakpoint);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamWindow::_HandleResolveMissingSourceFile(entry_ref& locatedPath)
|
||||
{
|
||||
if (fActiveFunction != NULL) {
|
||||
LocatableFile* sourceFile = fActiveFunction->GetFunctionDebugInfo()
|
||||
->SourceFile();
|
||||
if (sourceFile != NULL) {
|
||||
BString sourcePath;
|
||||
BString targetPath;
|
||||
sourceFile->GetPath(sourcePath);
|
||||
BPath path(&locatedPath);
|
||||
targetPath = path.Path();
|
||||
fListener->SourceEntryLocateRequested(sourcePath, targetPath);
|
||||
fListener->FunctionSourceCodeRequested(fActiveFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef TEAM_WINDOW_H
|
||||
@ -23,6 +24,7 @@
|
||||
|
||||
class BButton;
|
||||
class BMenuBar;
|
||||
class BStringView;
|
||||
class BTabView;
|
||||
class Image;
|
||||
class RegistersView;
|
||||
@ -129,6 +131,8 @@ private:
|
||||
void _HandleSourceCodeChanged();
|
||||
void _HandleUserBreakpointChanged(
|
||||
UserBreakpoint* breakpoint);
|
||||
void _HandleResolveMissingSourceFile(entry_ref&
|
||||
locatedPath);
|
||||
|
||||
private:
|
||||
::Team* fTeam;
|
||||
@ -156,6 +160,7 @@ private:
|
||||
BButton* fStepIntoButton;
|
||||
BButton* fStepOutButton;
|
||||
BMenuBar* fMenuBar;
|
||||
BStringView* fSourcePathView;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user