vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / model / DisassembledCode.h
blob8ed734631cd1a5248e6f78e292c1ee12fe684e7b
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef DISASSEMBLED_CODE_H
6 #define DISASSEMBLED_CODE_H
9 #include <ObjectList.h>
11 #include "SourceCode.h"
14 class BString;
15 class ContiguousStatement;
18 class DisassembledCode : public SourceCode {
19 public:
20 DisassembledCode(SourceLanguage* language);
21 ~DisassembledCode();
23 virtual bool Lock();
24 virtual void Unlock();
26 virtual SourceLanguage* GetSourceLanguage() const;
28 virtual bool GetStatementLocationRange(
29 const SourceLocation& location,
30 SourceLocation& _start,
31 SourceLocation& _end) const;
33 virtual LocatableFile* GetSourceFile() const;
35 Statement* StatementAtAddress(target_addr_t address) const;
36 Statement* StatementAtLocation(
37 const SourceLocation& location) const;
38 TargetAddressRange StatementAddressRange() const;
40 // LineDataSource
41 virtual int32 CountLines() const;
42 virtual const char* LineAt(int32 index) const;
43 virtual int32 LineLengthAt(int32 index) const;
45 public:
46 bool AddCommentLine(const BString& line);
47 bool AddInstructionLine(const BString& line,
48 target_addr_t address, target_size_t size);
49 // instructions must be added in
50 // ascending address order
52 private:
53 struct Line;
55 typedef BObjectList<Line> LineList;
56 typedef BObjectList<ContiguousStatement> StatementList;
58 private:
59 bool _AddLine(const BString& line,
60 ContiguousStatement* statement);
61 static int _CompareAddressStatement(
62 const target_addr_t* address,
63 const ContiguousStatement* statement);
65 private:
66 SourceLanguage* fLanguage;
67 LineList fLines;
68 StatementList fStatements;
72 #endif // DISASSEMBLED_CODE_H