Greg Clayton c7bece56fa <rdar://problem/13069948>
Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary.

So I defined a new "lldb::offset_t" which should be used for all file offsets.

After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed.

Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections.

llvm-svn: 173463
2013-01-25 18:06:21 +00:00

125 lines
3.5 KiB
C++

//===-- DisassemblerLLVMC.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_DisassemblerLLVMC_h_
#define liblldb_DisassemblerLLVMC_h_
#include "llvm-c/Disassembler.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/Mutex.h"
class InstructionLLVMC;
class DisassemblerLLVMC : public lldb_private::Disassembler
{
public:
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
static void
Initialize();
static void
Terminate();
static const char *
GetPluginNameStatic();
static const char *
GetPluginDescriptionStatic();
static lldb_private::Disassembler *
CreateInstance(const lldb_private::ArchSpec &arch);
DisassemblerLLVMC(const lldb_private::ArchSpec &arch);
virtual
~DisassemblerLLVMC();
size_t
DecodeInstructions (const lldb_private::Address &base_addr,
const lldb_private::DataExtractor& data,
lldb::offset_t data_offset,
size_t num_instructions,
bool append);
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
virtual const char *
GetPluginName();
virtual const char *
GetShortPluginName();
virtual uint32_t
GetPluginVersion();
protected:
friend class InstructionLLVMC;
bool
IsValid()
{
return (m_disasm_context != NULL);
}
int OpInfo(uint64_t PC,
uint64_t Offset,
uint64_t Size,
int TagType,
void *TagBug);
const char *SymbolLookup (uint64_t ReferenceValue,
uint64_t *ReferenceType,
uint64_t ReferencePC,
const char **ReferenceName);
static int OpInfoCallback (void *DisInfo,
uint64_t PC,
uint64_t Offset,
uint64_t Size,
int TagType,
void *TagBug);
static const char *SymbolLookupCallback(void *DisInfo,
uint64_t ReferenceValue,
uint64_t *ReferenceType,
uint64_t ReferencePC,
const char **ReferenceName);
void Lock(InstructionLLVMC *inst,
const lldb_private::ExecutionContext *exe_ctx)
{
m_mutex.Lock();
m_inst = inst;
m_exe_ctx = exe_ctx;
}
void Unlock()
{
m_inst = NULL;
m_exe_ctx = NULL;
m_mutex.Unlock();
}
const lldb_private::ExecutionContext *m_exe_ctx;
InstructionLLVMC *m_inst;
lldb_private::Mutex m_mutex;
::LLVMDisasmContextRef m_disasm_context;
::LLVMDisasmContextRef m_alternate_disasm_context;
};
#endif // liblldb_DisassemblerLLVM_h_