2009-07-08 00:47:39 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
2010-11-04 00:52:39 +03:00
|
|
|
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
2009-07-08 00:47:39 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef FUNCTION_H
|
|
|
|
#define FUNCTION_H
|
|
|
|
|
|
|
|
#include <util/DoublyLinkedList.h>
|
|
|
|
#include <util/OpenHashTable.h>
|
|
|
|
|
|
|
|
#include "FunctionInstance.h"
|
2010-11-04 00:52:39 +03:00
|
|
|
#include "LocatableFile.h"
|
2009-07-08 00:47:39 +04:00
|
|
|
|
|
|
|
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
class FileSourceCode;
|
2009-07-08 00:47:39 +04:00
|
|
|
|
|
|
|
|
2010-12-16 16:50:30 +03:00
|
|
|
class Function : public BReferenceable, private LocatableFile::Listener {
|
2009-07-08 00:47:39 +04:00
|
|
|
public:
|
|
|
|
class Listener;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Function();
|
|
|
|
~Function();
|
|
|
|
|
2009-07-19 03:52:16 +04:00
|
|
|
// team must be locked to access the instances
|
2009-07-08 00:47:39 +04:00
|
|
|
FunctionInstance* FirstInstance() const
|
|
|
|
{ return fInstances.Head(); }
|
|
|
|
FunctionInstance* LastInstance() const
|
|
|
|
{ return fInstances.Tail(); }
|
|
|
|
const FunctionInstanceList& Instances() const
|
|
|
|
{ return fInstances; }
|
|
|
|
|
|
|
|
const BString& Name() const
|
|
|
|
{ return FirstInstance()->Name(); }
|
|
|
|
const BString& PrettyName() const
|
|
|
|
{ return FirstInstance()->PrettyName(); }
|
|
|
|
LocatableFile* SourceFile() const
|
|
|
|
{ return FirstInstance()->SourceFile(); }
|
|
|
|
SourceLocation GetSourceLocation() const
|
|
|
|
{ return FirstInstance()
|
|
|
|
->GetSourceLocation(); }
|
|
|
|
|
2009-07-19 03:52:16 +04:00
|
|
|
FunctionID* GetFunctionID() const
|
|
|
|
{ return FirstInstance()->GetFunctionID(); }
|
|
|
|
// returns a reference
|
|
|
|
|
2009-07-08 00:47:39 +04:00
|
|
|
// mutable attributes follow (locking required)
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
FileSourceCode* GetSourceCode() const { return fSourceCode; }
|
2009-07-08 00:47:39 +04:00
|
|
|
function_source_state SourceCodeState() const
|
|
|
|
{ return fSourceCodeState; }
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
void SetSourceCode(FileSourceCode* source,
|
2009-07-08 00:47:39 +04:00
|
|
|
function_source_state state);
|
|
|
|
|
|
|
|
void AddListener(Listener* listener);
|
|
|
|
void RemoveListener(Listener* listener);
|
|
|
|
|
|
|
|
// package private
|
|
|
|
void AddInstance(FunctionInstance* instance);
|
|
|
|
void RemoveInstance(FunctionInstance* instance);
|
|
|
|
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
void NotifySourceCodeChanged();
|
|
|
|
|
2010-11-04 00:52:39 +03:00
|
|
|
void LocatableFileChanged(LocatableFile* file);
|
|
|
|
|
2009-07-08 00:47:39 +04:00
|
|
|
private:
|
|
|
|
typedef DoublyLinkedList<Listener> ListenerList;
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionInstanceList fInstances;
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
FileSourceCode* fSourceCode;
|
2009-07-08 00:47:39 +04:00
|
|
|
function_source_state fSourceCodeState;
|
|
|
|
ListenerList fListeners;
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
int32 fNotificationsDisabled;
|
2009-07-27 04:39:12 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// BOpenHashTable support
|
|
|
|
Function* fNext;
|
2009-07-08 00:47:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Function::Listener : public DoublyLinkedListLinkImpl<Listener> {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
|
|
|
virtual void FunctionSourceCodeChanged(Function* function);
|
|
|
|
// called with lock held
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FUNCTION_H
|