diff options
| author | Jason Molenda <jmolenda@apple.com> | 2012-10-10 21:37:00 +0000 |
|---|---|---|
| committer | Jason Molenda <jmolenda@apple.com> | 2012-10-10 21:37:00 +0000 |
| commit | 64dc7798a465ae0acf7b23117f7199d51d3a050a (patch) | |
| tree | 107490d69fbd6eb10647dfbb9a345120a434abbb /lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp | |
| parent | 17418964f8133a7200ab708338c5faefae36da6d (diff) | |
| download | bcm5719-llvm-64dc7798a465ae0acf7b23117f7199d51d3a050a.tar.gz bcm5719-llvm-64dc7798a465ae0acf7b23117f7199d51d3a050a.zip | |
Move the scratch buffer allocation for x86 instructions from being allocated each instruction,
to once in the AssemblyParse_x86 ctor.
an instruction
llvm-svn: 165662
Diffstat (limited to 'lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp')
| -rw-r--r-- | lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp index 4094ccf6670..6ff3c522524 100644 --- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp +++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp @@ -161,6 +161,7 @@ private: int m_cpu; ArchSpec m_arch; ::LLVMDisasmContextRef m_disasm_context; + uint8_t *m_opcode_data; DISALLOW_COPY_AND_ASSIGN (AssemblyParse_x86); }; @@ -177,7 +178,8 @@ AssemblyParse_x86::AssemblyParse_x86 (const ExecutionContext &exe_ctx, int cpu, m_lldb_fp_regnum (LLDB_INVALID_REGNUM), m_wordsize (-1), m_cpu(cpu), - m_arch(arch) + m_arch(arch), + m_opcode_data(NULL) { int *initialized_flag = NULL; if (cpu == k_i386) @@ -247,10 +249,13 @@ AssemblyParse_x86::AssemblyParse_x86 (const ExecutionContext &exe_ctx, int cpu, /*TagType=*/1, NULL, NULL); + m_opcode_data = (uint8_t *) malloc (m_arch.GetMaximumOpcodeByteSize()); } AssemblyParse_x86::~AssemblyParse_x86 () { + if (m_opcode_data) + free (m_opcode_data); ::LLVMDisasmDispose(m_disasm_context); } @@ -474,8 +479,7 @@ AssemblyParse_x86::instruction_length (Address addr, int &length) if (!addr.IsValid()) return false; - uint8_t *opcode_data = (uint8_t *) malloc (max_op_byte_size); - if (opcode_data == NULL) + if (m_opcode_data == NULL) { return false; } @@ -483,23 +487,21 @@ AssemblyParse_x86::instruction_length (Address addr, int &length) const bool prefer_file_cache = true; Error error; Target *target = m_exe_ctx.GetTargetPtr(); - if (target->ReadMemory (addr, prefer_file_cache, opcode_data, max_op_byte_size, error) == -1) + if (target->ReadMemory (addr, prefer_file_cache, m_opcode_data, max_op_byte_size, error) == -1) { - free (opcode_data); return false; } char out_string[512]; const addr_t pc = addr.GetFileAddress(); const size_t inst_size = ::LLVMDisasmInstruction (m_disasm_context, - opcode_data, + m_opcode_data, max_op_byte_size, pc, // PC value out_string, sizeof(out_string)); length = inst_size; - free (opcode_data); return true; } |

