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

Unified Diff: src/eh-frame.h

Issue 2023503002: Reland Implement .eh_frame writer and disassembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame-base
Patch Set: Improve disassembler, get rid of PatchProcedureBoundariesInEhFrame. Created 4 years, 6 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
Index: src/eh-frame.h
diff --git a/src/eh-frame.h b/src/eh-frame.h
index 75781acb502ee8f420e93b240e7515e6e9f7348d..800b008943be1d0c1f08d01968469617f5c43876 100644
--- a/src/eh-frame.h
+++ b/src/eh-frame.h
@@ -5,17 +5,76 @@
#ifndef V8_EH_FRAME_H_
#define V8_EH_FRAME_H_
-#include <cstdint>
+#include "src/list.h"
namespace v8 {
namespace internal {
class Code;
+struct CodeDesc;
+
+class EhFrameWriter {
+ public:
+ static const int kCIESize;
+
+ EhFrameWriter();
+
+ void AdvanceLocation(int pc_offset);
+ void DefineCFARegister(int code);
rmcilroy 2016/06/28 10:37:33 Could you use Register instead of "int code"? (and
Stefano Sanfilippo 2016/06/29 15:16:21 Yes, done. I added a RegisterToDwarfCode function
+ void DefineCFAOffset(int cfa_offset);
+ void IncreaseCFAOffset(int cfa_delta) {
+ DefineCFAOffset(cfa_offset_ + cfa_delta);
+ }
+ void DefineCFARegisterOffset(int code, int cfa_offset);
+ void SaveRegisterToStack(int code, int offset);
+ void SaveRegisterToStack(int code) { SaveRegisterToStack(code, cfa_offset_); }
+ void RegisterHasInitialValue(int code);
+
+ void Finish(int code_size);
+ void GetEhFrame(CodeDesc* desc);
+
+ int last_pc_offset() const { return last_pc_offset_; }
+ int cfa_register() const { return cfa_register_; }
+ int cfa_offset() const { return cfa_offset_; }
+
+ static void DisassembleToStream(std::ostream& stream, // NOLINT
+ const byte* start, const byte* end);
+
+ protected:
+ void WriteByte(byte value) { unwinding_info_.Add(value); }
+
+ void WriteBytes(const byte* value, int size) {
+ unwinding_info_.AddAll(Vector<byte>(const_cast<byte*>(value), size));
+ }
+
+ void WriteInt16(uint16_t value) {
+ unwinding_info_.AddAll(
+ Vector<byte>(reinterpret_cast<byte*>(&value), sizeof(value)));
+ }
+
+ void WriteInt32(uint32_t value) {
+ unwinding_info_.AddAll(
+ Vector<byte>(reinterpret_cast<byte*>(&value), sizeof(value)));
+ }
+
+ void WriteULEB128(uint32_t value);
+
+ void PatchInt32(int base_offset, uint32_t value) {
+ MemCopy(unwinding_info_.begin() + base_offset, &value, sizeof(value));
+ }
+
+ private:
+ void WriteFDEHeader();
+
+ int last_pc_offset_;
+ int cfa_register_;
+ int cfa_offset_;
+ List<byte> unwinding_info_;
+};
class EhFrameHdr final {
public:
static const int kRecordSize = 20;
- static const int kCIESize;
explicit EhFrameHdr(Code* code);

Powered by Google App Engine
This is Rietveld 408576698