haiku/src/apps/debugger/debug_info/TeamDebugInfo.h

109 lines
2.9 KiB
C
Raw Normal View History

/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef TEAM_DEBUG_INFO_H
#define TEAM_DEBUG_INFO_H
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +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
#include <Locker.h>
#include <ObjectList.h>
#include <Referenceable.h>
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
#include <util/OpenHashTable.h>
#include "GlobalTypeLookup.h"
#include "ImageInfo.h"
#include "TeamTypeInformation.h"
class Architecture;
class DebuggerInterface;
* 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;
class FileManager;
* 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;
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 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 FunctionInstance;
class ImageDebugInfo;
class ImageInfo;
class LocatableFile;
* 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 SourceCode;
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +04:00
class SourceLocation;
class SpecificTeamDebugInfo;
class TeamDebugInfo : public GlobalTypeLookup, public TeamTypeInformation {
public:
TeamDebugInfo(
DebuggerInterface* debuggerInterface,
Architecture* architecture,
FileManager* fileManager);
~TeamDebugInfo();
status_t Init();
virtual status_t GetType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type);
virtual status_t LookupTypeByName(const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type);
status_t LoadImageDebugInfo(const ImageInfo& imageInfo,
LocatableFile* imageFile,
ImageDebugInfo*& _imageDebugInfo);
* 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
status_t LoadSourceCode(LocatableFile* file,
FileSourceCode*& _sourceCode);
// returns reference
status_t DisassembleFunction(
FunctionInstance* functionInstance,
DisassembledCode*& _sourceCode);
// returns reference
FunctionInstance* MainFunction() const
{ return fMainFunction; }
* 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
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
// team is locked
status_t AddImageDebugInfo(
ImageDebugInfo* imageDebugInfo);
void RemoveImageDebugInfo(
ImageDebugInfo* imageDebugInfo);
ImageDebugInfo* ImageDebugInfoByName(const char* name) const;
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
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +04:00
Function* FunctionAtSourceLocation(LocatableFile* file,
const SourceLocation& location) const;
Function* FunctionByID(FunctionID* functionID) const;
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +04:00
private:
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
struct FunctionHashDefinition;
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +04:00
struct SourceFileEntry;
struct SourceFileHashDefinition;
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 BObjectList<SpecificTeamDebugInfo> SpecificInfoList;
* 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
typedef BObjectList<ImageDebugInfo> ImageList;
typedef BOpenHashTable<FunctionHashDefinition> FunctionTable;
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +04:00
private:
status_t _AddFunction(Function* function);
void _RemoveFunction(Function* function);
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
BLocker fLock;
DebuggerInterface* fDebuggerInterface;
Architecture* fArchitecture;
FileManager* fFileManager;
SpecificInfoList fSpecificInfos;
* 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
ImageList fImages;
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
FunctionTable* fFunctions;
* Finished the transformation of the SourceCode interface: - Replaced StatementAtLine() by GetStatementLocationRange(), which doesn't return a statement (i.e. also target addresses), but just a range in the source code. This can also be implemented by FileSourceCode, which can therefore be used for more than one instance of a function. - Added GetStatementAtLocation() which kind of is also a replacement for StatementAtLine(), but is optional and only provided by DisassembledSourceCode. - Added GetSourceFile(), which has to be provided when GetStatementAtLocation() is not implemented. - Kicked the statement stuff out of FileSourceCode. It only knows source ranges, now. * Team: Added GetStatementAtSourceLocation(), which is the real replacement for SourceCode::StatementAtLine() in cases where a statement is actually needed. It uses SourceCode::GetStatementAtLocation(), if available and otherwise finds a function at the source location, and gets a statement for one of its instances. * TeamDebugInfo: Does now manage a source file -> functions map allowing to look up functions at source file locations. * DwarfImageDebugInfo: - Switched the path in the source code hash table key for a LocatableFile, which is cheaper to hash and to compare. - Fixed bugs where the relocation delta was ignored. - Replace a -1 in the SourceLocation column component by 0 to avoid mismatches. * SourceLocation: Changed component types from uint32 to int32. Otherwise -1 is not representable. Things mostly work as before starting the refactoring to support function instances. All is not well yet, though. E.g. we don't merge the source code information for common source files (like headers) provided by different compilation units (or even images) yet. We need to do that, since the debug info for a compilation unit only contains line number information for inline functions (in headers) that are actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 04:08:45 +04:00
SourceFileTable* fSourceFiles;
GlobalTypeCache* fTypeCache;
FunctionInstance* fMainFunction;
};
#endif // TEAM_DEBUG_INFO_H