mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-26 23:09:03 -04:00

it logs the function calls, their arguments and the return values. This is not complete or polished, but I am committing it now, at the request of someone who really wants to use it, even though it's not really done. It currently does not attempt to log all the functions, just the most important ones. I will be making further adjustments to the API logging code over the next few days/weeks. (Suggestions for improvements are welcome). Update the Python build scripts to re-build the swig C++ file whenever the python-extensions.swig file is modified. Correct the help for 'log enable' command (give it the correct number & type of arguments). llvm-svn: 117349
185 lines
3.9 KiB
C++
185 lines
3.9 KiB
C++
//===-- SBModule.cpp --------------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/API/SBModule.h"
|
|
#include "lldb/API/SBAddress.h"
|
|
#include "lldb/API/SBFileSpec.h"
|
|
#include "lldb/API/SBFileSpec.h"
|
|
#include "lldb/API/SBStream.h"
|
|
#include "lldb/Core/Module.h"
|
|
#include "lldb/Core/Log.h"
|
|
#include "lldb/Core/STreamString.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
|
|
SBModule::SBModule () :
|
|
m_opaque_sp ()
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
|
|
|
|
if (log)
|
|
log->Printf ("SBModule::SBModule () ==> this = %p", this);
|
|
}
|
|
|
|
SBModule::SBModule (const lldb::ModuleSP& module_sp) :
|
|
m_opaque_sp (module_sp)
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
|
|
|
|
if (log)
|
|
log->Printf ("SBModule::SBModule (const lldb::ModuleSP &module_sp) module_sp.get() = %p ==> this = %p",
|
|
module_sp.get(), this);
|
|
}
|
|
|
|
SBModule::~SBModule ()
|
|
{
|
|
}
|
|
|
|
bool
|
|
SBModule::IsValid () const
|
|
{
|
|
return m_opaque_sp.get() != NULL;
|
|
}
|
|
|
|
SBFileSpec
|
|
SBModule::GetFileSpec () const
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
|
log->Printf ("SBModule::GetFileSpec ()");
|
|
|
|
SBFileSpec file_spec;
|
|
if (m_opaque_sp)
|
|
file_spec.SetFileSpec(m_opaque_sp->GetFileSpec());
|
|
|
|
if (log)
|
|
{
|
|
SBStream sstr;
|
|
file_spec.GetDescription (sstr);
|
|
log->Printf ("SBModule::GetFileSpec ==> SBFileSpec (this = %p, 's')", &file_spec, sstr.GetData());
|
|
}
|
|
|
|
return file_spec;
|
|
}
|
|
|
|
const uint8_t *
|
|
SBModule::GetUUIDBytes () const
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
|
log->Printf ("SBModule::GetUUIDBytes ()");
|
|
|
|
if (m_opaque_sp)
|
|
{
|
|
if (log)
|
|
{
|
|
StreamString sstr;
|
|
m_opaque_sp->GetUUID().Dump (&sstr);
|
|
log->Printf ("SBModule::GetUUIDBytes ==> '%s'", sstr.GetData());
|
|
}
|
|
return (const uint8_t *)m_opaque_sp->GetUUID().GetBytes();
|
|
}
|
|
|
|
if (log)
|
|
log->Printf ("SBModule::GetUUIDBytes ==> NULL");
|
|
return NULL;
|
|
}
|
|
|
|
|
|
bool
|
|
SBModule::operator == (const SBModule &rhs) const
|
|
{
|
|
if (m_opaque_sp)
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
SBModule::operator != (const SBModule &rhs) const
|
|
{
|
|
if (m_opaque_sp)
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
|
return false;
|
|
}
|
|
|
|
lldb::ModuleSP &
|
|
SBModule::operator *()
|
|
{
|
|
return m_opaque_sp;
|
|
}
|
|
|
|
lldb_private::Module *
|
|
SBModule::operator ->()
|
|
{
|
|
return m_opaque_sp.get();
|
|
}
|
|
|
|
const lldb_private::Module *
|
|
SBModule::operator ->() const
|
|
{
|
|
return m_opaque_sp.get();
|
|
}
|
|
|
|
lldb_private::Module *
|
|
SBModule::get()
|
|
{
|
|
return m_opaque_sp.get();
|
|
}
|
|
|
|
const lldb_private::Module *
|
|
SBModule::get() const
|
|
{
|
|
return m_opaque_sp.get();
|
|
}
|
|
|
|
|
|
void
|
|
SBModule::SetModule (const lldb::ModuleSP& module_sp)
|
|
{
|
|
m_opaque_sp = module_sp;
|
|
}
|
|
|
|
|
|
bool
|
|
SBModule::ResolveFileAddress (lldb::addr_t vm_addr, SBAddress& addr)
|
|
{
|
|
if (m_opaque_sp)
|
|
return m_opaque_sp->ResolveFileAddress (vm_addr, *addr);
|
|
|
|
addr->Clear();
|
|
return false;
|
|
}
|
|
|
|
SBSymbolContext
|
|
SBModule::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope)
|
|
{
|
|
SBSymbolContext sb_sc;
|
|
if (m_opaque_sp && addr.IsValid())
|
|
m_opaque_sp->ResolveSymbolContextForAddress (*addr, resolve_scope, *sb_sc);
|
|
return sb_sc;
|
|
}
|
|
|
|
bool
|
|
SBModule::GetDescription (SBStream &description)
|
|
{
|
|
if (m_opaque_sp)
|
|
{
|
|
description.ref();
|
|
m_opaque_sp->GetDescription (description.get());
|
|
}
|
|
else
|
|
description.Printf ("No value");
|
|
|
|
return true;
|
|
}
|