Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1028)

Unified Diff: courgette/disassembler.h

Issue 1676683002: [Courgette] Clean up Disassembler; fix ELF Memory leaks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | courgette/disassembler.cc » ('j') | courgette/image_utils.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/disassembler.h
diff --git a/courgette/disassembler.h b/courgette/disassembler.h
index e833cfa1315114255c728219ee86a31967acc5cc..73a52809d7f7bb7ae16fd7d546786a454b8f49cb 100644
--- a/courgette/disassembler.h
+++ b/courgette/disassembler.h
@@ -16,33 +16,35 @@ namespace courgette {
class AssemblyProgram;
-class Disassembler {
+class Disassembler : public AddressTranslator {
huangs 2016/02/05 21:19:05 Going against "composition over inheritance", but
public:
virtual ~Disassembler();
- virtual ExecutableType kind() { return EXE_UNKNOWN; }
+ // AddressTranslator interfaces.
+ virtual RVA FileOffsetToRVA(FileOffset file_offset) const override = 0;
+ virtual FileOffset RVAToFileOffset(RVA rva) const override = 0;
+ const uint8_t* FileOffsetToPointer(FileOffset file_offset) const override;
+ const uint8_t* RVAToPointer(RVA rva) const override;
- // ok() may always be called but returns 'true' only after ParseHeader
- // succeeds.
- bool ok() const { return failure_reason_ == NULL; }
+ virtual ExecutableType kind() const = 0;
- // Returns 'true' if the buffer appears to be a valid executable of the
- // expected type. It is not required that this be called before Disassemble.
+ // Returns true if the buffer appears to be a valid executable of the expected
+ // type, and false otherwise. This need not be called before Disassemble().
virtual bool ParseHeader() = 0;
// Disassembles the item passed to the factory method into the output
// parameter 'program'.
virtual bool Disassemble(AssemblyProgram* program) = 0;
- // Returns the length of the source executable. May reduce after ParseHeader.
+ // ok() may always be called but returns 'true' only after ParseHeader
+ // succeeds.
+ bool ok() const { return failure_reason_ == nullptr; }
+
+ // Returns the length of the image. May reduce after ParseHeader.
size_t length() const { return length_; }
const uint8_t* start() const { return start_; }
const uint8_t* end() const { return end_; }
- // Returns a pointer into the memory copy of the file format.
- // FileOffsetToPointer(0) returns a pointer to the start of the file format.
- const uint8_t* OffsetToPointer(size_t offset) const;
-
protected:
Disassembler(const void* start, size_t length);
« no previous file with comments | « no previous file | courgette/disassembler.cc » ('j') | courgette/image_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698