|
12 | 12 | #include "llvm/ADT/StringRef.h"
|
13 | 13 | #include "llvm/BinaryFormat/XCOFF.h"
|
14 | 14 | #include "llvm/MC/MCDisassembler/MCSymbolizer.h"
|
| 15 | +#include "llvm/Support/Error.h" |
15 | 16 | #include <cstdint>
|
16 | 17 | #include <memory>
|
17 | 18 | #include <vector>
|
@@ -139,28 +140,26 @@ class MCDisassembler {
|
139 | 140 | /// start of a symbol, or the entire symbol.
|
140 | 141 | /// This is used for example by WebAssembly to decode preludes.
|
141 | 142 | ///
|
142 |
| - /// Base implementation returns std::nullopt. So all targets by default ignore |
143 |
| - /// to treat symbols separately. |
| 143 | + /// Base implementation returns false. So all targets by default decline to |
| 144 | + /// treat symbols separately. |
144 | 145 | ///
|
145 | 146 | /// \param Symbol - The symbol.
|
146 | 147 | /// \param Size - The number of bytes consumed.
|
147 | 148 | /// \param Address - The address, in the memory space of region, of the first
|
148 | 149 | /// byte of the symbol.
|
149 | 150 | /// \param Bytes - A reference to the actual bytes at the symbol location.
|
150 |
| - /// \param CStream - The stream to print comments and annotations on. |
151 |
| - /// \return - MCDisassembler::Success if bytes are decoded |
152 |
| - /// successfully. Size must hold the number of bytes that |
153 |
| - /// were decoded. |
154 |
| - /// - MCDisassembler::Fail if the bytes are invalid. Size |
155 |
| - /// must hold the number of bytes that were decoded before |
156 |
| - /// failing. The target must print nothing. This can be |
157 |
| - /// done by buffering the output if needed. |
158 |
| - /// - std::nullopt if the target doesn't want to handle the |
159 |
| - /// symbol separately. Value of Size is ignored in this |
160 |
| - /// case. |
161 |
| - virtual std::optional<DecodeStatus> |
162 |
| - onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes, |
163 |
| - uint64_t Address, raw_ostream &CStream) const; |
| 151 | + /// \return - True if this symbol triggered some target specific |
| 152 | + /// disassembly for this symbol. Size must be set with the |
| 153 | + /// number of bytes consumed. |
| 154 | + /// - Error if this symbol triggered some target specific |
| 155 | + /// disassembly for this symbol, but an error was found with |
| 156 | + /// it. Size must be set with the number of bytes consumed. |
| 157 | + /// - False if the target doesn't want to handle the symbol |
| 158 | + /// separately. The value of Size is ignored in this case, |
| 159 | + /// and Err must not be set. |
| 160 | + virtual Expected<bool> onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, |
| 161 | + ArrayRef<uint8_t> Bytes, |
| 162 | + uint64_t Address) const; |
164 | 163 | // TODO:
|
165 | 164 | // Implement similar hooks that can be used at other points during
|
166 | 165 | // disassembly. Something along the following lines:
|
|
0 commit comments