mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-20 03:55:48 -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
230 lines
5.6 KiB
C++
230 lines
5.6 KiB
C++
//===-- SBLineEntry.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/SBLineEntry.h"
|
|
#include "lldb/API/SBStream.h"
|
|
#include "lldb/Symbol/LineEntry.h"
|
|
#include "lldb/Core/Log.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
|
|
SBLineEntry::SBLineEntry () :
|
|
m_opaque_ap ()
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::SBLineEntry () ==> this = %p", this);
|
|
}
|
|
|
|
SBLineEntry::SBLineEntry (const SBLineEntry &rhs) :
|
|
m_opaque_ap ()
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
|
|
|
|
if (rhs.IsValid())
|
|
{
|
|
m_opaque_ap.reset (new lldb_private::LineEntry (*rhs));
|
|
}
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::SBLineEntry (const SBLineEntry &rhs) rhs.m_opaque_ap.get() = %p ==> this = %p ",
|
|
(rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
|
|
m_opaque_ap ()
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
|
|
|
|
if (lldb_object_ptr)
|
|
m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr));
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) lldb_object_ptr = %p"
|
|
" ==> this = %p (m_opaque_ap.get() = %p)", lldb_object_ptr, this, m_opaque_ap.get());
|
|
}
|
|
|
|
const SBLineEntry &
|
|
SBLineEntry::operator = (const SBLineEntry &rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{
|
|
if (rhs.IsValid())
|
|
m_opaque_ap.reset (new lldb_private::LineEntry(*rhs));
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void
|
|
SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
|
|
{
|
|
if (m_opaque_ap.get())
|
|
(*m_opaque_ap.get()) = lldb_object_ref;
|
|
else
|
|
m_opaque_ap.reset (new lldb_private::LineEntry (lldb_object_ref));
|
|
}
|
|
|
|
|
|
SBLineEntry::~SBLineEntry ()
|
|
{
|
|
}
|
|
|
|
|
|
SBAddress
|
|
SBLineEntry::GetStartAddress () const
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::GetStartAddress ()");
|
|
|
|
SBAddress sb_address;
|
|
if (m_opaque_ap.get())
|
|
sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
|
|
|
|
if (log)
|
|
{
|
|
SBStream sstr;
|
|
sb_address.GetDescription (sstr);
|
|
log->Printf ("SBLineEntry::GetStartAddress ==> SBAddress (this = %p, (%s)", &sb_address, sstr.GetData());
|
|
}
|
|
|
|
return sb_address;
|
|
}
|
|
|
|
SBAddress
|
|
SBLineEntry::GetEndAddress () const
|
|
{
|
|
SBAddress sb_address;
|
|
if (m_opaque_ap.get())
|
|
{
|
|
sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
|
|
sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize());
|
|
}
|
|
return sb_address;
|
|
}
|
|
|
|
bool
|
|
SBLineEntry::IsValid () const
|
|
{
|
|
return m_opaque_ap.get() != NULL;
|
|
}
|
|
|
|
|
|
SBFileSpec
|
|
SBLineEntry::GetFileSpec () const
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::GetFileSpec ()");
|
|
|
|
SBFileSpec sb_file_spec;
|
|
if (m_opaque_ap.get() && m_opaque_ap->file)
|
|
sb_file_spec.SetFileSpec(m_opaque_ap->file);
|
|
|
|
if (log)
|
|
{
|
|
SBStream sstr;
|
|
sb_file_spec.GetDescription (sstr);
|
|
log->Printf ("SBLineEntry::GetFileSpec ==> SBFileSpec (this = %p, '%s'", &sb_file_spec, sstr.GetData());
|
|
}
|
|
|
|
return sb_file_spec;
|
|
}
|
|
|
|
uint32_t
|
|
SBLineEntry::GetLine () const
|
|
{
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::GetLine ()");
|
|
|
|
uint32_t line = 0;
|
|
if (m_opaque_ap.get())
|
|
line = m_opaque_ap->line;
|
|
|
|
if (log)
|
|
log->Printf ("SBLineEntry::GetLine ==> %d", line);
|
|
|
|
return line;
|
|
}
|
|
|
|
|
|
uint32_t
|
|
SBLineEntry::GetColumn () const
|
|
{
|
|
if (m_opaque_ap.get())
|
|
return m_opaque_ap->column;
|
|
return 0;
|
|
}
|
|
|
|
bool
|
|
SBLineEntry::operator == (const SBLineEntry &rhs) const
|
|
{
|
|
lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
|
|
lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0;
|
|
|
|
return lhs_ptr == rhs_ptr;
|
|
}
|
|
|
|
bool
|
|
SBLineEntry::operator != (const SBLineEntry &rhs) const
|
|
{
|
|
lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
|
|
lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0;
|
|
|
|
return lhs_ptr != rhs_ptr;
|
|
}
|
|
|
|
const lldb_private::LineEntry *
|
|
SBLineEntry::operator->() const
|
|
{
|
|
return m_opaque_ap.get();
|
|
}
|
|
|
|
const lldb_private::LineEntry &
|
|
SBLineEntry::operator*() const
|
|
{
|
|
return *m_opaque_ap;
|
|
}
|
|
|
|
bool
|
|
SBLineEntry::GetDescription (SBStream &description)
|
|
{
|
|
if (m_opaque_ap.get())
|
|
{
|
|
// Line entry: File, line x {, column y}: Addresses: <start_addr> - <end_addr>
|
|
char file_path[PATH_MAX*2];
|
|
m_opaque_ap->file.GetPath (file_path, sizeof (file_path));
|
|
description.Printf ("Line entry: %s, line %d", file_path, GetLine());
|
|
if (GetColumn() > 0)
|
|
description.Printf (", column %d", GetColumn());
|
|
description.Printf (": Addresses: 0x%p - 0x%p", GetStartAddress().GetFileAddress() ,
|
|
GetEndAddress().GetFileAddress());
|
|
}
|
|
else
|
|
description.Printf ("No value");
|
|
|
|
return true;
|
|
}
|