1 // Copyright 2010 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_GDB_JIT_H_ 6 #define V8_GDB_JIT_H_ 7 8 #include "src/allocation.h" 9 10 // 11 // Basic implementation of GDB JIT Interface client. 12 // GBD JIT Interface is supported in GDB 7.0 and above. 13 // Currently on x64 and ia32 architectures and Linux OS are supported. 14 // 15 16 #ifdef ENABLE_GDB_JIT_INTERFACE 17 #include "src/v8.h" 18 #include "src/factory.h" 19 20 namespace v8 { 21 namespace internal { 22 23 class CompilationInfo; 24 25 #define CODE_TAGS_LIST(V) \ 26 V(LOAD_IC) \ 27 V(KEYED_LOAD_IC) \ 28 V(STORE_IC) \ 29 V(KEYED_STORE_IC) \ 30 V(STUB) \ 31 V(BUILTIN) \ 32 V(SCRIPT) \ 33 V(EVAL) \ 34 V(FUNCTION) 35 36 class GDBJITLineInfo : public Malloced { 37 public: 38 GDBJITLineInfo() 39 : pc_info_(10) { } 40 41 void SetPosition(intptr_t pc, int pos, bool is_statement) { 42 AddPCInfo(PCInfo(pc, pos, is_statement)); 43 } 44 45 struct PCInfo { 46 PCInfo(intptr_t pc, int pos, bool is_statement) 47 : pc_(pc), pos_(pos), is_statement_(is_statement) { } 48 49 intptr_t pc_; 50 int pos_; 51 bool is_statement_; 52 }; 53 54 List<PCInfo>* pc_info() { 55 return &pc_info_; 56 } 57 58 private: 59 void AddPCInfo(const PCInfo& pc_info) { 60 pc_info_.Add(pc_info); 61 } 62 63 List<PCInfo> pc_info_; 64 }; 65 66 67 class GDBJITInterface: public AllStatic { 68 public: 69 enum CodeTag { 70 #define V(x) x, 71 CODE_TAGS_LIST(V) 72 #undef V 73 TAG_COUNT 74 }; 75 76 static const char* Tag2String(CodeTag tag) { 77 switch (tag) { 78 #define V(x) case x: return #x; 79 CODE_TAGS_LIST(V) 80 #undef V 81 default: 82 return NULL; 83 } 84 } 85 86 static void AddCode(const char* name, 87 Code* code, 88 CodeTag tag, 89 Script* script, 90 CompilationInfo* info); 91 92 static void AddCode(Handle<Name> name, 93 Handle<Script> script, 94 Handle<Code> code, 95 CompilationInfo* info); 96 97 static void AddCode(CodeTag tag, Name* name, Code* code); 98 99 static void AddCode(CodeTag tag, const char* name, Code* code); 100 101 static void AddCode(CodeTag tag, Code* code); 102 103 static void RemoveCode(Code* code); 104 105 static void RemoveCodeRange(Address start, Address end); 106 107 static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info); 108 }; 109 110 #define GDBJIT(action) GDBJITInterface::action 111 112 } } // namespace v8::internal 113 #else 114 #define GDBJIT(action) ((void) 0) 115 #endif 116 117 #endif 118