blob: 1bc8866975ba062c91adc3d1f1a2456ad55f67e7 [file] [log] [blame]
Sean Callanan65dafa82010-08-27 01:01:44 +00001//===-- ClangExpressionParser.cpp -------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Expression/ClangExpressionParser.h"
11
12#include "lldb/Core/ArchSpec.h"
13#include "lldb/Core/DataBufferHeap.h"
14#include "lldb/Core/Disassembler.h"
15#include "lldb/Core/Stream.h"
Sean Callananf18d91c2010-09-01 00:58:00 +000016#include "lldb/Core/StreamString.h"
Sean Callanan65dafa82010-08-27 01:01:44 +000017#include "lldb/Expression/ClangASTSource.h"
18#include "lldb/Expression/ClangExpression.h"
Sean Callananf18d91c2010-09-01 00:58:00 +000019#include "lldb/Expression/IRDynamicChecks.h"
Sean Callanan65dafa82010-08-27 01:01:44 +000020#include "lldb/Expression/IRForTarget.h"
21#include "lldb/Expression/IRToDWARF.h"
22#include "lldb/Expression/RecordingMemoryManager.h"
23#include "lldb/Target/ExecutionContext.h"
24#include "lldb/Target/Process.h"
25#include "lldb/Target/Target.h"
26
27#include "clang/AST/ASTContext.h"
28#include "clang/AST/ExternalASTSource.h"
29#include "clang/Basic/FileManager.h"
30#include "clang/Basic/TargetInfo.h"
31#include "clang/Basic/Version.h"
32#include "clang/Checker/FrontendActions.h"
33#include "clang/CodeGen/CodeGenAction.h"
34#include "clang/CodeGen/ModuleBuilder.h"
35#include "clang/Driver/CC1Options.h"
36#include "clang/Driver/OptTable.h"
37#include "clang/Frontend/CompilerInstance.h"
38#include "clang/Frontend/CompilerInvocation.h"
39#include "clang/Frontend/FrontendActions.h"
40#include "clang/Frontend/FrontendDiagnostic.h"
41#include "clang/Frontend/FrontendPluginRegistry.h"
42#include "clang/Frontend/TextDiagnosticBuffer.h"
43#include "clang/Frontend/TextDiagnosticPrinter.h"
44#include "clang/Frontend/VerifyDiagnosticsClient.h"
45#include "clang/Lex/Preprocessor.h"
46#include "clang/Rewrite/FrontendActions.h"
47#include "clang/Sema/ParseAST.h"
48#include "clang/Sema/SemaConsumer.h"
49
50#include "llvm/ADT/StringRef.h"
51#include "llvm/ExecutionEngine/ExecutionEngine.h"
52#include "llvm/ExecutionEngine/JIT.h"
53#include "llvm/Module.h"
54#include "llvm/LLVMContext.h"
55#include "llvm/Support/ErrorHandling.h"
56#include "llvm/Support/MemoryBuffer.h"
57#include "llvm/System/DynamicLibrary.h"
58#include "llvm/System/Host.h"
59#include "llvm/System/Signals.h"
60#include "llvm/Target/TargetRegistry.h"
61#include "llvm/Target/TargetSelect.h"
62
63using namespace clang;
64using namespace llvm;
65using namespace lldb_private;
66
67//===----------------------------------------------------------------------===//
68// Utility Methods for Clang
69//===----------------------------------------------------------------------===//
70
71std::string GetBuiltinIncludePath(const char *Argv0) {
72 llvm::sys::Path P =
73 llvm::sys::Path::GetMainExecutable(Argv0,
74 (void*)(intptr_t) GetBuiltinIncludePath);
75
76 if (!P.isEmpty()) {
77 P.eraseComponent(); // Remove /clang from foo/bin/clang
78 P.eraseComponent(); // Remove /bin from foo/bin
79
80 // Get foo/lib/clang/<version>/include
81 P.appendComponent("lib");
82 P.appendComponent("clang");
83 P.appendComponent(CLANG_VERSION_STRING);
84 P.appendComponent("include");
85 }
86
87 return P.str();
88}
89
90
91//===----------------------------------------------------------------------===//
92// Main driver for Clang
93//===----------------------------------------------------------------------===//
94
95static void LLVMErrorHandler(void *UserData, const std::string &Message) {
96 Diagnostic &Diags = *static_cast<Diagnostic*>(UserData);
97
98 Diags.Report(diag::err_fe_error_backend) << Message;
99
100 // We cannot recover from llvm errors.
101 exit(1);
102}
103
104static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
105 using namespace clang::frontend;
106
107 switch (CI.getFrontendOpts().ProgramAction) {
108 default:
109 llvm_unreachable("Invalid program action!");
110
111 case ASTDump: return new ASTDumpAction();
112 case ASTPrint: return new ASTPrintAction();
113 case ASTPrintXML: return new ASTPrintXMLAction();
114 case ASTView: return new ASTViewAction();
115 case BoostCon: return new BoostConAction();
116 case DumpRawTokens: return new DumpRawTokensAction();
117 case DumpTokens: return new DumpTokensAction();
118 case EmitAssembly: return new EmitAssemblyAction();
119 case EmitBC: return new EmitBCAction();
120 case EmitHTML: return new HTMLPrintAction();
121 case EmitLLVM: return new EmitLLVMAction();
122 case EmitLLVMOnly: return new EmitLLVMOnlyAction();
123 case EmitCodeGenOnly: return new EmitCodeGenOnlyAction();
124 case EmitObj: return new EmitObjAction();
125 case FixIt: return new FixItAction();
126 case GeneratePCH: return new GeneratePCHAction();
127 case GeneratePTH: return new GeneratePTHAction();
128 case InheritanceView: return new InheritanceViewAction();
129 case InitOnly: return new InitOnlyAction();
130 case ParseSyntaxOnly: return new SyntaxOnlyAction();
131
132 case PluginAction: {
133 for (FrontendPluginRegistry::iterator it =
134 FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end();
135 it != ie; ++it) {
136 if (it->getName() == CI.getFrontendOpts().ActionName) {
137 llvm::OwningPtr<PluginASTAction> P(it->instantiate());
138 if (!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs))
139 return 0;
140 return P.take();
141 }
142 }
143
144 CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name)
145 << CI.getFrontendOpts().ActionName;
146 return 0;
147 }
148
149 case PrintDeclContext: return new DeclContextPrintAction();
150 case PrintPreamble: return new PrintPreambleAction();
151 case PrintPreprocessedInput: return new PrintPreprocessedAction();
152 case RewriteMacros: return new RewriteMacrosAction();
153 case RewriteObjC: return new RewriteObjCAction();
154 case RewriteTest: return new RewriteTestAction();
155 case RunAnalysis: return new AnalysisAction();
156 case RunPreprocessorOnly: return new PreprocessOnlyAction();
157 }
158}
159
160static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
161 // Create the underlying action.
162 FrontendAction *Act = CreateFrontendBaseAction(CI);
163 if (!Act)
164 return 0;
165
166 // If there are any AST files to merge, create a frontend action
167 // adaptor to perform the merge.
168 if (!CI.getFrontendOpts().ASTMergeFiles.empty())
169 Act = new ASTMergeAction(Act, &CI.getFrontendOpts().ASTMergeFiles[0],
170 CI.getFrontendOpts().ASTMergeFiles.size());
171
172 return Act;
173}
174
175//===----------------------------------------------------------------------===//
176// Implementation of ClangExpressionParser
177//===----------------------------------------------------------------------===//
178
179ClangExpressionParser::ClangExpressionParser(const char *target_triple,
180 ClangExpression &expr) :
181 m_expr(expr),
182 m_target_triple (),
183 m_compiler (),
184 m_code_generator (NULL),
185 m_execution_engine (),
186 m_jitted_functions ()
187{
188 // Initialize targets first, so that --version shows registered targets.
189 static struct InitializeLLVM {
190 InitializeLLVM() {
191 llvm::InitializeAllTargets();
192 llvm::InitializeAllAsmPrinters();
193 }
194 } InitializeLLVM;
195
196 if (target_triple && target_triple[0])
197 m_target_triple = target_triple;
198 else
199 m_target_triple = llvm::sys::getHostTriple();
200
201 // 1. Create a new compiler instance.
202 m_compiler.reset(new CompilerInstance());
203 m_compiler->setLLVMContext(new LLVMContext());
204
205 // 2. Set options.
206
207 // Parse expressions as Objective C++ regardless of context.
208 // Our hook into Clang's lookup mechanism only works in C++.
209 m_compiler->getLangOpts().CPlusPlus = true;
210 m_compiler->getLangOpts().ObjC1 = true;
211 m_compiler->getLangOpts().ThreadsafeStatics = false;
212 m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access
213 m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name
214
215 // Set CodeGen options
216 m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
217 m_compiler->getCodeGenOpts().InstrumentFunctions = false;
218
219 // Disable some warnings.
220 m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
221
222 // Set the target triple.
223 m_compiler->getTargetOpts().Triple = m_target_triple;
224
225 // 3. Set up various important bits of infrastructure.
226 m_compiler->createDiagnostics(0, 0);
227
228 // Create the target instance.
229 m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
230 m_compiler->getTargetOpts()));
231
232 assert (m_compiler->hasTarget());
233
234 // Inform the target of the language options
235 //
236 // FIXME: We shouldn't need to do this, the target should be immutable once
237 // created. This complexity should be lifted elsewhere.
238 m_compiler->getTarget().setForcedLangOptions(m_compiler->getLangOpts());
239
240 // 4. Set up the diagnostic buffer for reporting errors
241
242 m_diagnostic_buffer.reset(new clang::TextDiagnosticBuffer);
243 m_compiler->getDiagnostics().setClient(m_diagnostic_buffer.get());
244
245 // 5. Set up the source management objects inside the compiler
246
247 if (!m_compiler->hasSourceManager())
248 m_compiler->createSourceManager();
249
250 m_compiler->createFileManager();
251 m_compiler->createPreprocessor();
252
253 // 6. Most of this we get from the CompilerInstance, but we
254 // also want to give the context an ExternalASTSource.
255 SelectorTable selector_table;
256 m_builtin_context.reset(new Builtin::Context(m_compiler->getTarget()));
257
258 std::auto_ptr<clang::ASTContext> ast_context(new ASTContext(m_compiler->getLangOpts(),
259 m_compiler->getSourceManager(),
260 m_compiler->getTarget(),
261 m_compiler->getPreprocessor().getIdentifierTable(),
262 selector_table,
263 *m_builtin_context.get(),
264 0));
265
266 ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
267
268 if (decl_map)
269 {
270 OwningPtr<clang::ExternalASTSource> ast_source(new ClangASTSource(*ast_context, *decl_map));
271 ast_context->setExternalSource(ast_source);
272 }
273
274 m_compiler->setASTContext(ast_context.release());
275
276 std::string module_name("___clang_module");
277
278 m_code_generator.reset(CreateLLVMCodeGen(m_compiler->getDiagnostics(),
279 module_name,
280 m_compiler->getCodeGenOpts(),
281 m_compiler->getLLVMContext()));
282}
283
284ClangExpressionParser::~ClangExpressionParser()
285{
286}
287
288unsigned
289ClangExpressionParser::Parse (Stream &stream)
290{
291 m_diagnostic_buffer->FlushDiagnostics (m_compiler->getDiagnostics());
292
293 MemoryBuffer *memory_buffer = MemoryBuffer::getMemBufferCopy(m_expr.Text(), __FUNCTION__);
294 FileID memory_buffer_file_id = m_compiler->getSourceManager().createMainFileIDForMemBuffer (memory_buffer);
295
296 m_diagnostic_buffer->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
297
298 ASTConsumer *ast_transformer = m_expr.ASTTransformer(m_code_generator.get());
299
300 if (ast_transformer)
301 ParseAST(m_compiler->getPreprocessor(), ast_transformer, m_compiler->getASTContext());
302 else
303 ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());
304
305 m_diagnostic_buffer->EndSourceFile();
306
307 TextDiagnosticBuffer::const_iterator diag_iterator;
308
309 int num_errors = 0;
310
311 for (diag_iterator = m_diagnostic_buffer->warn_begin();
312 diag_iterator != m_diagnostic_buffer->warn_end();
313 ++diag_iterator)
314 stream.Printf("warning: %s\n", (*diag_iterator).second.c_str());
315
316 num_errors = 0;
317
318 for (diag_iterator = m_diagnostic_buffer->err_begin();
319 diag_iterator != m_diagnostic_buffer->err_end();
320 ++diag_iterator)
321 {
322 num_errors++;
323 stream.Printf("error: %s\n", (*diag_iterator).second.c_str());
324 }
325
326 return num_errors;
327}
328
329Error
330ClangExpressionParser::MakeDWARF ()
331{
332 Error err;
333
334 llvm::Module *module = m_code_generator->GetModule();
335
336 if (!module)
337 {
338 err.SetErrorToGenericError();
339 err.SetErrorString("IR doesn't contain a module");
340 return err;
341 }
342
343 ClangExpressionVariableStore *local_variables = m_expr.LocalVariables();
344 ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
345
346 if (!local_variables)
347 {
348 err.SetErrorToGenericError();
349 err.SetErrorString("Can't convert an expression without a VariableList to DWARF");
350 return err;
351 }
352
353 if (!decl_map)
354 {
355 err.SetErrorToGenericError();
356 err.SetErrorString("Can't convert an expression without a DeclMap to DWARF");
357 return err;
358 }
359
360 IRToDWARF ir_to_dwarf(*local_variables, decl_map, m_expr.DwarfOpcodeStream());
361
362 if (!ir_to_dwarf.runOnModule(*module))
363 {
364 err.SetErrorToGenericError();
365 err.SetErrorString("Couldn't convert the expression to DWARF");
366 return err;
367 }
368
369 err.Clear();
370 return err;
371}
372
373Error
Sean Callanan830a9032010-08-27 23:31:21 +0000374ClangExpressionParser::MakeJIT (lldb::addr_t &func_addr,
375 lldb::addr_t &func_end,
376 ExecutionContext &exe_ctx)
Sean Callanan65dafa82010-08-27 01:01:44 +0000377{
378 Error err;
379
380 llvm::Module *module = m_code_generator->ReleaseModule();
381
382 if (!module)
383 {
384 err.SetErrorToGenericError();
385 err.SetErrorString("IR doesn't contain a module");
386 return err;
387 }
388
389 ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL
390
391 if (decl_map)
392 {
393 std::string target_error;
394
395 const llvm::Target *target = llvm::TargetRegistry::lookupTarget(m_target_triple, target_error);
396
397 if (!target)
398 {
399 err.SetErrorToGenericError();
400 err.SetErrorStringWithFormat("Couldn't find a target for %s", m_target_triple.c_str());
401 return err;
402 }
403
404 std::auto_ptr<llvm::TargetMachine> target_machine(target->createTargetMachine(m_target_triple, ""));
405
406 IRForTarget ir_for_target(decl_map, target_machine->getTargetData(), m_expr.FunctionName());
407
408 if (!ir_for_target.runOnModule(*module))
409 {
410 err.SetErrorToGenericError();
411 err.SetErrorString("Couldn't convert the expression to DWARF");
412 return err;
413 }
Sean Callananf18d91c2010-09-01 00:58:00 +0000414
415 IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), m_expr.FunctionName());
416
417 if (!ir_dynamic_checks.runOnModule(*module))
418 {
419 err.SetErrorToGenericError();
420 err.SetErrorString("Couldn't add dynamic checks to the expression");
421 return err;
422 }
Sean Callanan65dafa82010-08-27 01:01:44 +0000423 }
424
425 m_jit_mm = new RecordingMemoryManager();
426
427 std::string error_string;
428
429 m_execution_engine.reset(llvm::ExecutionEngine::createJIT (module,
430 &error_string,
431 m_jit_mm,
432 CodeGenOpt::Default,
433 true,
434 CodeModel::Small));
435
436 if (!m_execution_engine.get())
437 {
438 err.SetErrorToGenericError();
439 err.SetErrorStringWithFormat("Couldn't JIT the function: %s", error_string.c_str());
440 return err;
441 }
442
443 m_execution_engine->DisableLazyCompilation();
444
445 llvm::Function *function = module->getFunction (m_expr.FunctionName());
446
447 // We don't actually need the function pointer here, this just forces it to get resolved.
448
449 void *fun_ptr = m_execution_engine->getPointerToFunction(function);
450
451 // Errors usually cause failures in the JIT, but if we're lucky we get here.
452
453 if (!fun_ptr)
454 {
455 err.SetErrorToGenericError();
456 err.SetErrorString("Couldn't JIT the function");
457 return err;
458 }
459
460 m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(m_expr.FunctionName(), (lldb::addr_t)fun_ptr));
461
462 ExecutionContext &exc_context(exe_ctx);
463
464 if (exc_context.process == NULL)
465 {
466 err.SetErrorToGenericError();
467 err.SetErrorString("Couldn't write the JIT compiled code into the target because there is no target");
468 return err;
469 }
470
471 // Look over the regions allocated for the function compiled. The JIT
472 // tries to allocate the functions & stubs close together, so we should try to
473 // write them that way too...
474 // For now I only write functions with no stubs, globals, exception tables,
475 // etc. So I only need to write the functions.
476
477 size_t alloc_size = 0;
478
479 std::map<uint8_t *, uint8_t *>::iterator fun_pos = m_jit_mm->m_functions.begin();
480 std::map<uint8_t *, uint8_t *>::iterator fun_end = m_jit_mm->m_functions.end();
481
482 for (; fun_pos != fun_end; ++fun_pos)
483 alloc_size += (*fun_pos).second - (*fun_pos).first;
484
485 Error alloc_error;
486 lldb::addr_t target_addr = exc_context.process->AllocateMemory (alloc_size, lldb::ePermissionsReadable|lldb::ePermissionsExecutable, alloc_error);
487
488 if (target_addr == LLDB_INVALID_ADDRESS)
489 {
490 err.SetErrorToGenericError();
491 err.SetErrorStringWithFormat("Couldn't allocate memory for the JITted function: %s", alloc_error.AsCString("unknown error"));
492 return err;
493 }
494
495 lldb::addr_t cursor = target_addr;
496
497 for (fun_pos = m_jit_mm->m_functions.begin(); fun_pos != fun_end; fun_pos++)
498 {
499 lldb::addr_t lstart = (lldb::addr_t) (*fun_pos).first;
500 lldb::addr_t lend = (lldb::addr_t) (*fun_pos).second;
501 size_t size = lend - lstart;
502
503 Error write_error;
504
505 if (exc_context.process->WriteMemory(cursor, (void *) lstart, size, write_error) != size)
506 {
507 err.SetErrorToGenericError();
508 err.SetErrorStringWithFormat("Couldn't copy JITted function into the target: %s", write_error.AsCString("unknown error"));
509 return err;
510 }
511
512 m_jit_mm->AddToLocalToRemoteMap (lstart, size, cursor);
513 cursor += size;
514 }
515
516 std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
517
518 for (pos = m_jitted_functions.begin(); pos != end; pos++)
519 {
520 (*pos).m_remote_addr = m_jit_mm->GetRemoteAddressForLocal ((*pos).m_local_addr);
521
522 if (!(*pos).m_name.compare(m_expr.FunctionName()))
Sean Callanan830a9032010-08-27 23:31:21 +0000523 {
524 func_end = m_jit_mm->GetRemoteRangeForLocal ((*pos).m_local_addr).second;
Sean Callanan65dafa82010-08-27 01:01:44 +0000525 func_addr = (*pos).m_remote_addr;
Sean Callanan830a9032010-08-27 23:31:21 +0000526 }
Sean Callanan65dafa82010-08-27 01:01:44 +0000527 }
528
529 err.Clear();
530 return err;
531}
532
533Error
534ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx)
535{
536 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
537
538 const char *name = m_expr.FunctionName();
539
540 Error ret;
541
542 ret.Clear();
543
544 lldb::addr_t func_local_addr = LLDB_INVALID_ADDRESS;
545 lldb::addr_t func_remote_addr = LLDB_INVALID_ADDRESS;
546
547 std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
548
549 for (pos = m_jitted_functions.begin(); pos < end; pos++)
550 {
551 if (strcmp(pos->m_name.c_str(), name) == 0)
552 {
553 func_local_addr = pos->m_local_addr;
554 func_remote_addr = pos->m_remote_addr;
555 }
556 }
557
558 if (func_local_addr == LLDB_INVALID_ADDRESS)
559 {
560 ret.SetErrorToGenericError();
561 ret.SetErrorStringWithFormat("Couldn't find function %s for disassembly", name);
562 return ret;
563 }
564
565 if(log)
566 log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
567
568 std::pair <lldb::addr_t, lldb::addr_t> func_range;
569
570 func_range = m_jit_mm->GetRemoteRangeForLocal(func_local_addr);
571
572 if (func_range.first == 0 && func_range.second == 0)
573 {
574 ret.SetErrorToGenericError();
575 ret.SetErrorStringWithFormat("Couldn't find code range for function %s", name);
576 return ret;
577 }
578
579 if(log)
580 log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second);
581
582 if (!exe_ctx.target)
583 {
584 ret.SetErrorToGenericError();
585 ret.SetErrorString("Couldn't find the target");
586 }
587
588 lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_remote_addr, 0));
589
590 Error err;
591 exe_ctx.process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
592
593 if (!err.Success())
594 {
595 ret.SetErrorToGenericError();
596 ret.SetErrorStringWithFormat("Couldn't read from process: %s", err.AsCString("unknown error"));
597 return ret;
598 }
599
600 ArchSpec arch(exe_ctx.target->GetArchitecture());
601
602 Disassembler *disassembler = Disassembler::FindPlugin(arch);
603
604 if (disassembler == NULL)
605 {
606 ret.SetErrorToGenericError();
607 ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.AsCString());
608 return ret;
609 }
610
611 if (!exe_ctx.process)
612 {
613 ret.SetErrorToGenericError();
614 ret.SetErrorString("Couldn't find the process");
615 return ret;
616 }
617
618 DataExtractor extractor(buffer_sp,
619 exe_ctx.process->GetByteOrder(),
620 exe_ctx.target->GetArchitecture().GetAddressByteSize());
621
622 if(log)
623 {
624 log->Printf("Function data has contents:");
625 extractor.PutToLog (log,
626 0,
627 extractor.GetByteSize(),
628 func_remote_addr,
629 16,
630 DataExtractor::TypeUInt8);
631 }
632
633 disassembler->DecodeInstructions(extractor, 0, UINT32_MAX);
634
635 Disassembler::InstructionList &instruction_list = disassembler->GetInstructionList();
636
637 uint32_t bytes_offset = 0;
638
639 for (uint32_t instruction_index = 0, num_instructions = instruction_list.GetSize();
640 instruction_index < num_instructions;
641 ++instruction_index)
642 {
643 Disassembler::Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index);
644 Address addr(NULL, func_remote_addr + bytes_offset);
645 instruction->Dump (&stream,
646 &addr,
647 &extractor,
648 bytes_offset,
649 exe_ctx,
650 true);
651 stream.PutChar('\n');
652 bytes_offset += instruction->GetByteSize();
653 }
654
655 return ret;
656}