haiku/headers/private/debugger/debug_info/FunctionInstance.h

85 lines
2.3 KiB
C
Raw Normal View History

Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
2016-11-23 07:06:09 +03:00
* Copyright 2016, Rene Gollent, rene@gollent.com.
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
* Distributed under the terms of the MIT License.
*/
#ifndef FUNCTION_INSTANCE_H
#define FUNCTION_INSTANCE_H
#include <util/DoublyLinkedList.h>
#include "FunctionDebugInfo.h"
* 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
enum function_source_state {
FUNCTION_SOURCE_NOT_LOADED,
FUNCTION_SOURCE_LOADING,
FUNCTION_SOURCE_LOADED,
2016-11-23 07:06:09 +03:00
FUNCTION_SOURCE_UNAVAILABLE,
FUNCTION_SOURCE_SUPPRESSED
* 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 DisassembledCode;
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
class Function;
class FunctionDebugInfo;
* Worker: - Made Job Referenceable. - Turned JobKey into an abstract base class to add flexibility. The new SimpleJobKey is a subclass with the former functionality. * TeamWindow: Removed the TeamWindow* parameter from the listener hooks. The TeamDebugger knows anyway. * Added IDs to Variable, Function, and FunctionInstance. The latter two generate the ID on the fly, Variable stores it. * SpecificImageDebugInfo::CreateFrame(): Changed FunctionDebugInfo* debug parameter to FunctionInstance* to provide more info (the function ID). * DwarfInterfaceFactory/DwarfImageDebugInfo: - Added class DwarfFunctionParameterID, an ID class implementation for function parameters and set the IDs on the parameter objects. - Retrieve the size of a type (i.e. the size of its objects) and store it in DwarfType. - If a parameter's ValueLocation doesn't have a size, set that of the respective type. - Map the register indicies in the parameters' ValueLocations from DWARF to our indices. * Added class TypeComponentPath for identifying subcomponents in types. * Added class StackFrameValues, a container associating variables and their subcomponents with values. * StackFrame does now have a StackFrameValues object for parameters and local variables and a mechanism to notify listeners when values have been retrieved. * Added GetStackFrameValueJob to retrieve variable values. Lots of functionality is missing yet. Most notably it doesn't retrieves values for subcomponents. * Wired everything to trigger loading of variable values and getting notified when done. * VariablesView: Added a value column. This is all very basic and has to be done differently, but at least values for the parameters can be seen already. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31636 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-19 03:52:16 +04:00
class FunctionID;
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
class ImageDebugInfo;
class FunctionInstance : public BReferenceable,
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
public DoublyLinkedListLinkImpl<FunctionInstance> {
public:
FunctionInstance(ImageDebugInfo* imageDebugInfo,
FunctionDebugInfo* functionDebugInfo);
~FunctionInstance();
ImageDebugInfo* GetImageDebugInfo() const
{ return fImageDebugInfo; }
Function* GetFunction() const
{ return fFunction; }
FunctionDebugInfo* GetFunctionDebugInfo() const
{ return fFunctionDebugInfo; }
target_addr_t Address() const
{ return fFunctionDebugInfo->Address(); }
target_size_t Size() const
{ return fFunctionDebugInfo->Size(); }
const BString& Name() const
{ return fFunctionDebugInfo->Name(); }
const BString& PrettyName() const
{ return fFunctionDebugInfo->PrettyName(); }
LocatableFile* SourceFile() const
{ return fFunctionDebugInfo->SourceFile(); }
SourceLocation GetSourceLocation() const
{ return fFunctionDebugInfo
->SourceStartLocation(); }
* Worker: - Made Job Referenceable. - Turned JobKey into an abstract base class to add flexibility. The new SimpleJobKey is a subclass with the former functionality. * TeamWindow: Removed the TeamWindow* parameter from the listener hooks. The TeamDebugger knows anyway. * Added IDs to Variable, Function, and FunctionInstance. The latter two generate the ID on the fly, Variable stores it. * SpecificImageDebugInfo::CreateFrame(): Changed FunctionDebugInfo* debug parameter to FunctionInstance* to provide more info (the function ID). * DwarfInterfaceFactory/DwarfImageDebugInfo: - Added class DwarfFunctionParameterID, an ID class implementation for function parameters and set the IDs on the parameter objects. - Retrieve the size of a type (i.e. the size of its objects) and store it in DwarfType. - If a parameter's ValueLocation doesn't have a size, set that of the respective type. - Map the register indicies in the parameters' ValueLocations from DWARF to our indices. * Added class TypeComponentPath for identifying subcomponents in types. * Added class StackFrameValues, a container associating variables and their subcomponents with values. * StackFrame does now have a StackFrameValues object for parameters and local variables and a mechanism to notify listeners when values have been retrieved. * Added GetStackFrameValueJob to retrieve variable values. Lots of functionality is missing yet. Most notably it doesn't retrieves values for subcomponents. * Wired everything to trigger loading of variable values and getting notified when done. * VariablesView: Added a value column. This is all very basic and has to be done differently, but at least values for the parameters can be seen already. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31636 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-19 03:52:16 +04:00
FunctionID* GetFunctionID() const;
// returns a reference
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
void SetFunction(Function* function);
// package private
* 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
// mutable attributes follow (locking required)
DisassembledCode* GetSourceCode() const
{ return fSourceCode; }
function_source_state SourceCodeState() const
{ return fSourceCodeState; }
void SetSourceCode(DisassembledCode* source,
function_source_state state);
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
private:
ImageDebugInfo* fImageDebugInfo;
Function* fFunction;
FunctionDebugInfo* fFunctionDebugInfo;
* 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
DisassembledCode* fSourceCode;
function_source_state fSourceCodeState;
Very much work in progress, not in a particularly working state. Haiku munged a good part of the source tree, so I rather get those changes into the repository before continuing. The general aim of the work is to deal with multiple instances of the same function, e.g. inlined or non-inlined inline functions or those weird duplicates gcc (4 at least) seems to be generating for no apparent reason. * Added classes FunctionInstance (wrapping FunctionDebugInfo) and Function. FunctionInstance represents a physical instance of a function (e.g. inlined function at a particular address). A Function collects all FunctionInstances referring to the same source code location. * Moved the SourceCode property from FunctionDebugInfo to Function accordingly. * Since SourceCode is no longer associated with a concrete function instance, several methods dealing with statements have been removed and the functionality has been provided through other means (e.g. TeamDebugModel or SpecificImageDebugModel). This part is not yet completed. * Introduced UserBreakpoint and UserBreakpointInstance. The user sets a breakpoint at a source code location, which is represented by a UserBreakpoint. Since that source location can be mapped to one address per instance of the respective function, UserBreakpoint has a UserBreakpointInstance per such function instance, which in turn refers to a Breakpoint (an actual breakpoint at an address). * Adjusted Breakpoint, BreakpointManager, and TeamDebugger accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 00:47:39 +04:00
};
typedef DoublyLinkedList<FunctionInstance> FunctionInstanceList;
#endif // FUNCTION_INSTANCE_H