2009-07-03 04:56:39 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef FILE_SOURCE_CODE_H
|
|
|
|
#define FILE_SOURCE_CODE_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
|
|
|
#include "Array.h"
|
2009-07-03 04:56:39 +04:00
|
|
|
#include "SourceCode.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
|
|
|
class LocatableFile;
|
2009-07-03 04:56:39 +04:00
|
|
|
class SourceFile;
|
|
|
|
|
|
|
|
|
|
|
|
class FileSourceCode : public SourceCode {
|
|
|
|
public:
|
* 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
|
|
|
FileSourceCode(LocatableFile* file,
|
|
|
|
SourceFile* sourceFile);
|
2009-07-03 04:56:39 +04:00
|
|
|
virtual ~FileSourceCode();
|
|
|
|
|
|
|
|
status_t Init();
|
* 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
|
|
|
status_t AddSourceLocation(
|
|
|
|
const SourceLocation& location);
|
2009-07-03 04:56:39 +04:00
|
|
|
|
|
|
|
virtual int32 CountLines() const;
|
|
|
|
virtual const char* LineAt(int32 index) 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
|
|
|
virtual bool GetStatementLocationRange(
|
|
|
|
const SourceLocation& location,
|
|
|
|
SourceLocation& _start,
|
|
|
|
SourceLocation& _end) const;
|
2009-07-03 04:56: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
|
|
|
virtual LocatableFile* GetSourceFile() const;
|
2009-07-03 04:56: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
|
|
|
virtual status_t GetStatementAtLocation(
|
|
|
|
const SourceLocation& location,
|
|
|
|
Statement*& _statement);
|
2009-07-03 04:56:39 +04:00
|
|
|
|
|
|
|
private:
|
* 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
|
|
|
int32 _FindSourceLocationIndex(
|
|
|
|
const SourceLocation& location,
|
|
|
|
bool& _foundMatch) const;
|
2009-07-03 04:56:39 +04:00
|
|
|
|
|
|
|
private:
|
* 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
|
|
|
LocatableFile* fFile;
|
|
|
|
SourceFile* fSourceFile;
|
|
|
|
Array<SourceLocation> fSourceLocations;
|
2009-07-03 04:56:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FILE_BASED_SOURCE_CODE_H
|