Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(28)

Delta Between Two Patch Sets: lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp

Issue 91042: Implement LLVM JIT side of GDB JIT debugging interface (Closed) SVN Base: http://llvm.org/svn/llvm-project/llvm/trunk/
Left Patch Set: Move the object files off disk and into memory. Created 3 months, 2 weeks ago
Right Patch Set: Synced with TOT. Created 2 months, 2 weeks ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 //===-- JITDebugRegisterer.cpp - Register debug symbols for JIT -----------===// 1 //===-- JITDebugRegisterer.cpp - Register debug symbols for JIT -----------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file defines a JITDebugRegisterer object that is used by the JIT to 10 // This file defines a JITDebugRegisterer object that is used by the JIT to
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 // Add this single function to the symbol table, so the debugger prints the 100 // Add this single function to the symbol table, so the debugger prints the
101 // name instead of '???'. We give the symbol default global visibility. 101 // name instead of '???'. We give the symbol default global visibility.
102 ELFSym *FnSym = ELFSym::getGV(F, 102 ELFSym *FnSym = ELFSym::getGV(F,
103 ELFSym::STB_GLOBAL, 103 ELFSym::STB_GLOBAL,
104 ELFSym::STT_FUNC, 104 ELFSym::STT_FUNC,
105 ELFSym::STV_DEFAULT); 105 ELFSym::STV_DEFAULT);
106 FnSym->SectionIdx = Text.SectionIdx; 106 FnSym->SectionIdx = Text.SectionIdx;
107 FnSym->Size = I.FnEnd - I.FnStart; 107 FnSym->Size = I.FnEnd - I.FnStart;
108 FnSym->Value = 0; // Offset from start of section. 108 FnSym->Value = 0; // Offset from start of section.
109 // TODO(rnk): Until bruno fixes the ELFWriter to not leak the ELFSym objects,
110 // we will leak this pointer.
111 EW.SymbolList.push_back(FnSym); 109 EW.SymbolList.push_back(FnSym);
112 110
113 EW.doFinalization(M); 111 EW.doFinalization(M);
114 O.flush(); 112 O.flush();
115 113
116 // When trying to debug this code, it's awfully helpful to write the object 114 // When trying to debug this code, it's awfully helpful to write the object
117 // file to disk. 115 // file to disk.
118 //std::string Filename; 116 std::string Filename;
119 //raw_string_ostream O2(Filename); 117 raw_string_ostream O2(Filename);
120 //O2 << "/tmp/llvm_function_" << I.FnStart << "_" << F->getNameStr() << ".o"; 118 O2 << "/tmp/llvm_function_" << I.FnStart << "_" << F->getNameStr() << ".o";
121 //O2.flush(); 119 O2.flush();
122 //std::string Errors; 120 std::string Errors;
123 //raw_fd_ostream O3(Filename.c_str(), /*Binary=*/true, /*Forced=*/true, 121 raw_fd_ostream O3(Filename.c_str(), Errors);
124 // Errors); 122 O3 << Buffer;
125 //O3 << Buffer; 123 O3.close();
126 //O3.close();
127 124
128 return Buffer; 125 return Buffer;
129 } 126 }
130 127
131 void JITDebugRegisterer::RegisterFunction(const Function *F, DebugInfo &I) { 128 void JITDebugRegisterer::RegisterFunction(const Function *F, DebugInfo &I) {
129 // TODO: Support non-ELF platforms.
130 if (!TM.getELFWriterInfo())
131 return;
132
132 std::string Buffer = MakeELF(F, I); 133 std::string Buffer = MakeELF(F, I);
133 134
134 jit_code_entry *JITCodeEntry = new jit_code_entry(); 135 jit_code_entry *JITCodeEntry = new jit_code_entry();
135 JITCodeEntry->symfile_addr = Buffer.c_str(); 136 JITCodeEntry->symfile_addr = Buffer.c_str();
136 JITCodeEntry->symfile_size = Buffer.size(); 137 JITCodeEntry->symfile_size = Buffer.size();
137 138
138 // Add a mapping from F to the entry and buffer, so we can delete this 139 // Add a mapping from F to the entry and buffer, so we can delete this
139 // info later. 140 // info later.
140 FnMap[F] = std::make_pair<std::string, jit_code_entry*>(Buffer, JITCodeEntry); 141 FnMap[F] = std::make_pair<std::string, jit_code_entry*>(Buffer, JITCodeEntry);
141 142
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 __jit_debug_descriptor.relevant_entry = JITCodeEntry; 184 __jit_debug_descriptor.relevant_entry = JITCodeEntry;
184 __jit_debug_register_code(); 185 __jit_debug_register_code();
185 } 186 }
186 187
187 // Free the ELF file in memory. 188 // Free the ELF file in memory.
188 std::string &Buffer = I->second.first; 189 std::string &Buffer = I->second.first;
189 Buffer.clear(); 190 Buffer.clear();
190 } 191 }
191 192
192 void JITDebugRegisterer::UnregisterFunction(const Function *F) { 193 void JITDebugRegisterer::UnregisterFunction(const Function *F) {
194 // TODO: Support non-ELF platforms.
195 if (!TM.getELFWriterInfo())
196 return;
197
193 RegisteredFunctionsMap::iterator I = FnMap.find(F); 198 RegisteredFunctionsMap::iterator I = FnMap.find(F);
194 if (I == FnMap.end()) return; 199 if (I == FnMap.end()) return;
195 UnregisterFunctionInternal(I); 200 UnregisterFunctionInternal(I);
196 FnMap.erase(I); 201 FnMap.erase(I);
197 } 202 }
198 203
199 } // end namespace llvm 204 } // end namespace llvm
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497