Initial checkin of lldb code from internal Apple repo.

llvm-svn: 105619
This commit is contained in:
Chris Lattner 2010-06-08 16:52:24 +00:00
parent 312c4c799d
commit 30fdc8d841
790 changed files with 216273 additions and 0 deletions

View File

@ -0,0 +1,47 @@
On MacOSX lldb needs to be code signed. The Debug and Release builds
are set to code sign using a code signing certificate named
lldb_codesign.
If you don't have one yet you will need to:
- Launch /Applications/Utilities/Keychain Access.app
- In Keychain Access select the "login" keychain in the "Keychains"
list in the upper left hand corner of the window.
- Select the following menu item:
Keychain Access->Certificate Assistant->Create a Certificate...
- Set the following settings
Name = lldb_codesign
Identity Type = Self Signed Root
Certificate Type = Code Signing
- Click Continue
- Click Continue
- Click Done
- Click on the "My Certificates"
- Double click on your new lldb_codesign certificate
- Turn down the "Trust" disclosure triangle
Change:
When using this certificate: Always Trust
- Enter your login password to confirm and make it trusted
The next steps are necessary on SnowLeopard, but are probably because of a bug
how Keychain Access makes certificates (the steps above used to be enougnk
in Leopard.)
- Option-drag the new lldb_codesign certificate from the login keychain to
the System keychain in the Keychains pane of the main Keychain Access window
to make a copy of this certificate in the System keychain. You'll have to
authorize a few more times, set it to be "Always trusted" when asked.
- Switch to the System keychain, and drag the copy of lldb_codesign you just
made there onto the desktop.
- Switch to Terminal, and run the following:
sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer
That should do it.

View File

@ -0,0 +1,47 @@
On MacOSX lldb needs to be code signed. The Debug and Release builds
are set to code sign using a code signing certificate named
lldb_codesign.
If you don't have one yet you will need to:
- Launch /Applications/Utilities/Keychain Access.app
- In Keychain Access select the "login" keychain in the "Keychains"
list in the upper left hand corner of the window.
- Select the following menu item:
Keychain Access->Certificate Assistant->Create a Certificate...
- Set the following settings
Name = lldb_codesign
Identity Type = Self Signed Root
Certificate Type = Code Signing
- Click Continue
- Click Continue
- Click Done
- Click on the "My Certificates"
- Double click on your new lldb_codesign certificate
- Turn down the "Trust" disclosure triangle
Change:
When using this certificate: Always Trust
- Enter your login password to confirm and make it trusted
The next steps are necessary on SnowLeopard, but are probably because of a bug
how Keychain Access makes certificates (the steps above used to be enougnk
in Leopard.)
- Option-drag the new lldb_codesign certificate from the login keychain to
the System keychain in the Keychains pane of the main Keychain Access window
to make a copy of this certificate in the System keychain. You'll have to
authorize a few more times, set it to be "Always trusted" when asked.
- Switch to the System keychain, and drag the copy of lldb_codesign you just
made there onto the desktop.
- Switch to Terminal, and run the following:
sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer
That should do it.

View File

@ -0,0 +1,49 @@
//===-- LLDB.h --------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_LLDB_h_
#define LLDB_LLDB_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include <LLDB/SBDefines.h>
#include <LLDB/SBAddress.h>
#include <LLDB/SBBlock.h>
#include <LLDB/SBBreakpoint.h>
#include <LLDB/SBBreakpointLocation.h>
#include <LLDB/SBBroadcaster.h>
#include <LLDB/SBCommandContext.h>
#include <LLDB/SBCommandInterpreter.h>
#include <LLDB/SBCommandReturnObject.h>
#include <LLDB/SBCommunication.h>
#include <LLDB/SBCompileUnit.h>
#include <LLDB/SBDebugger.h>
#include <LLDB/SBError.h>
#include <LLDB/SBEvent.h>
#include <LLDB/SBFileSpec.h>
#include <LLDB/SBFrame.h>
#include <LLDB/SBFunction.h>
#include <LLDB/SBHostOS.h>
#include <LLDB/SBInputReader.h>
#include <LLDB/SBLineEntry.h>
#include <LLDB/SBListener.h>
#include <LLDB/SBModule.h>
#include <LLDB/SBProcess.h>
#include <LLDB/SBSourceManager.h>
#include <LLDB/SBSymbol.h>
#include <LLDB/SBSymbolContext.h>
#include <LLDB/SBTarget.h>
#include <LLDB/SBThread.h>
#include <LLDB/SBType.h>
#include <LLDB/SBValue.h>
#include <LLDB/SBValueList.h>
#endif // LLDB_LLDB_h_

View File

@ -0,0 +1,75 @@
//===-- SBAddress.h ---------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBAddress_h_
#define LLDB_SBAddress_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBAddress
{
public:
SBAddress ();
SBAddress (const lldb::SBAddress &rhs);
~SBAddress ();
#ifndef SWIG
const SBAddress &
operator = (const SBAddress &rhs);
#endif
bool
IsValid () const;
addr_t
GetFileAddress () const;
addr_t
GetLoadAddress (const lldb::SBProcess &process) const;
bool
OffsetAddress (addr_t offset);
protected:
friend class SBFrame;
friend class SBLineEntry;
friend class SBSymbolContext;
friend class SBThread;
#ifndef SWIG
const lldb_private::Address *
operator->() const;
const lldb_private::Address &
operator*() const;
#endif
SBAddress (const lldb_private::Address *lldb_object_ptr);
void
SetAddress (const lldb_private::Address *lldb_object_ptr);
private:
std::auto_ptr<lldb_private::Address> m_lldb_object_ap;
};
} // namespace lldb
#endif // LLDB_SBAddress_h_

View File

@ -0,0 +1,44 @@
//===-- SBBlock.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBBlock_h_
#define LLDB_SBBlock_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBBlock
{
public:
SBBlock ();
~SBBlock ();
bool
IsValid () const;
void
AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list);
private:
friend class SBFrame;
friend class SBSymbolContext;
SBBlock (lldb_private::Block *lldb_object_ptr);
lldb_private::Block *m_lldb_object_ptr;
};
} // namespace lldb
#endif // LLDB_SBBlock_h_

View File

@ -0,0 +1,129 @@
//===-- SBBreakpoint.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBBreakpoint_h_
#define LLDB_SBBreakpoint_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBBreakpoint
{
public:
typedef bool (*BreakpointHitCallback) (void *baton,
SBProcess &process,
SBThread &thread,
lldb::SBBreakpointLocation &location);
SBBreakpoint ();
SBBreakpoint (const lldb::SBBreakpoint& rhs);
~SBBreakpoint();
#ifndef SWIG
const SBBreakpoint &
operator = (const SBBreakpoint& rhs);
#endif
break_id_t
GetID () const;
bool
IsValid() const;
void
Dump (FILE *f);
void
ClearAllBreakpointSites ();
lldb::SBBreakpointLocation
FindLocationByAddress (lldb::addr_t vm_addr);
lldb::break_id_t
FindLocationIDByAddress (lldb::addr_t vm_addr);
lldb::SBBreakpointLocation
FindLocationByID (lldb::break_id_t bp_loc_id);
lldb::SBBreakpointLocation
GetLocationAtIndex (uint32_t index);
void
ListLocations (FILE *, const char *description_level = "full");
void
SetEnabled (bool enable);
bool
IsEnabled ();
void
SetIgnoreCount (int32_t count);
int32_t
GetIgnoreCount () const;
void
SetThreadID (lldb::tid_t sb_thread_id);
lldb::tid_t
GetThreadID ();
void
SetCallback (BreakpointHitCallback callback, void *baton);
size_t
GetNumResolvedLocations() const;
size_t
GetNumLocations() const;
void
GetDescription (FILE *, const char *description_level, bool describe_locations = false);
private:
friend class SBBreakpointLocation;
friend class SBTarget;
SBBreakpoint (const lldb::BreakpointSP &bp_sp);
#ifndef SWIG
lldb_private::Breakpoint *
operator->() const;
lldb_private::Breakpoint *
get() const;
lldb::BreakpointSP &
operator *();
const lldb::BreakpointSP &
operator *() const;
#endif
static bool
PrivateBreakpointHitCallback (void *baton,
lldb_private::StoppointCallbackContext *context,
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
lldb::BreakpointSP m_break_sp;
};
} // namespace lldb
#endif // LLDB_SBBreakpoint_h_

View File

@ -0,0 +1,73 @@
//===-- SBBreakpointLocation.h ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBBreakpointLocation_h_
#define LLDB_SBBreakpointLocation_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBBreakpoint.h>
namespace lldb {
class SBBreakpointLocation
{
public:
SBBreakpointLocation ();
~SBBreakpointLocation ();
bool
IsValid() const;
lldb::addr_t
GetLoadAddress ();
void
SetEnabled(bool enabled);
bool
IsEnabled ();
int32_t
GetIgnoreCount ();
void
SetIgnoreCount (int32_t n);
void
SetThreadID (lldb::tid_t thread_id);
lldb::tid_t
GetThreadID ();
bool
IsResolved ();
void
GetDescription (FILE *f, const char *description_level);
SBBreakpoint
GetBreakpoint ();
private:
friend class SBBreakpoint;
SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp);
void
SetLocation (const lldb::BreakpointLocationSP &break_loc_sp);
lldb::BreakpointLocationSP m_break_loc_sp;
};
} // namespace lldb
#endif // LLDB_SBBreakpointLocation_h_

View File

@ -0,0 +1,83 @@
//===-- SBBroadcaster.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBBroadcaster_h_
#define LLDB_SBBroadcaster_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBBroadcaster
{
public:
SBBroadcaster ();
SBBroadcaster (const char *name);
~SBBroadcaster();
bool
IsValid () const;
void
BroadcastEventByType (uint32_t event_type, bool unique = false);
void
BroadcastEvent (const lldb::SBEvent &event, bool unique = false);
void
AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events);
uint32_t
AddListener (const lldb::SBListener &listener, uint32_t event_mask);
const char *
GetName ();
bool
EventTypeHasListeners (uint32_t event_type);
bool
RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
#ifndef SWIG
bool
operator == (const lldb::SBBroadcaster &rhs) const;
bool
operator != (const lldb::SBBroadcaster &rhs) const;
#endif
protected:
friend class SBCommandInterpreter;
friend class SBCommunication;
friend class SBEvent;
friend class SBListener;
friend class SBProcess;
friend class SBTarget;
SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns);
lldb_private::Broadcaster *
GetLLDBObjectPtr () const;
void
SetLLDBObjectPtr (lldb_private::Broadcaster *broadcaster, bool owns);
private:
lldb_private::Broadcaster *m_lldb_object;
bool m_lldb_object_owned;
};
} // namespace lldb
#endif // LLDB_SBBroadcaster_h_

View File

@ -0,0 +1,36 @@
//===-- SBCommandContext.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBCommandContext_h_
#define LLDB_SBCommandContext_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBCommandContext
{
public:
SBCommandContext (lldb_private::CommandContext *lldb_object);
~SBCommandContext ();
bool
IsValid () const;
private:
lldb_private::CommandContext *m_lldb_object;
};
} // namespace lldb
#endif // LLDB_SBCommandContext_h_

View File

@ -0,0 +1,105 @@
//===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBCommandInterpreter_h_
#define LLDB_SBCommandInterpreter_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBCommandInterpreter
{
public:
enum
{
eBroadcastBitThreadShouldExit = (1 << 0),
eBroadcastBitResetPrompt = (1 << 1),
eBroadcastBitQuitCommandReceived = (1 << 2) // User entered quit
};
~SBCommandInterpreter ();
bool
CommandExists (const char *cmd);
bool
AliasExists (const char *cmd);
bool
UserCommandExists (const char *cmd);
lldb::SBBroadcaster
GetBroadcaster ();
const char **
GetEnvironmentVariables ();
bool
HasCommands ();
bool
HasAliases ();
bool
HasUserCommands ();
bool
HasAliasOptions ();
bool
HasInterpreterVariables ();
lldb::SBProcess
GetProcess ();
ssize_t
WriteToScriptInterpreter (const char *src);
ssize_t
WriteToScriptInterpreter (const char *src, size_t src_len);
void
SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
void
SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
lldb::ReturnStatus
HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
int
HandleCompletion (const char *current_line,
const char *cursor,
const char *last_char,
int match_start_point,
int max_return_elements,
SBStringList &matches);
protected:
lldb_private::CommandInterpreter &
GetLLDBObjectRef ();
lldb_private::CommandInterpreter *
GetLLDBObjectPtr ();
private:
friend class SBDebugger;
SBCommandInterpreter (lldb_private::CommandInterpreter &interpreter_ptr); // Access using SBDebugger::GetSharedInstance().GetCommandInterpreter();
lldb_private::CommandInterpreter &m_interpreter;
};
} // namespace lldb
#endif // LLDB_SBCommandInterpreter_h_

View File

@ -0,0 +1,80 @@
//===-- SBCommandReturnObject.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBCommandReturnObject_h_
#define LLDB_SBCommandReturnObject_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBCommandReturnObject
{
public:
SBCommandReturnObject ();
~SBCommandReturnObject ();
bool
IsValid() const;
const char *
GetOutput ();
const char *
GetError ();
size_t
PutOutput (FILE *fh);
size_t
GetOutputSize ();
size_t
GetErrorSize ();
size_t
PutError (FILE *fh);
void
Clear();
lldb::ReturnStatus
GetStatus();
bool
Succeeded ();
bool
HasResult ();
void
AppendMessage (const char *message);
protected:
friend class SBCommandInterpreter;
friend class SBOptions;
lldb_private::CommandReturnObject *
GetLLDBObjectPtr();
lldb_private::CommandReturnObject &
GetLLDBObjectRef();
void
SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr);
private:
std::auto_ptr<lldb_private::CommandReturnObject> m_return_object_ap;
};
} // namespace lldb
#endif // LLDB_SBCommandReturnObject_h_

View File

@ -0,0 +1,97 @@
//===-- SBCommunication.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBCommunication_h_
#define LLDB_SBCommunication_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBError.h>
namespace lldb {
class SBCommunication
{
public:
enum {
eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost.
eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available.
eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread.
eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet.
eAllEventBits = 0xffffffff
};
typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
SBCommunication ();
SBCommunication (const char * broadcaster_name);
~SBCommunication ();
lldb::SBBroadcaster
GetBroadcaster ();
lldb::ConnectionStatus
AdoptFileDesriptor (int fd, bool owns_fd);
lldb::ConnectionStatus
CheckIfBytesAvailable ();
lldb::ConnectionStatus
WaitForBytesAvailableInfinite ();
lldb::ConnectionStatus
WaitForBytesAvailableWithTimeout (uint32_t timeout_usec);
lldb::ConnectionStatus
Connect (const char *url);
lldb::ConnectionStatus
Disconnect ();
bool
IsConnected () const;
size_t
Read (void *dst,
size_t dst_len,
uint32_t timeout_usec,
lldb::ConnectionStatus &status);
size_t
Write (const void *src,
size_t src_len,
lldb::ConnectionStatus &status);
bool
ReadThreadStart ();
bool
ReadThreadStop ();
bool
ReadThreadIsRunning ();
bool
SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
void *callback_baton);
private:
// void
// CreateIfNeeded ();
lldb_private::Communication *m_lldb_object;
bool m_lldb_object_owned;
};
} // namespace lldb
#endif // LLDB_SBCommunication_h_

View File

@ -0,0 +1,75 @@
//===-- SBCompileUnit.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBCompileUnit_h_
#define LLDB_SBCompileUnit_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBFileSpec.h>
namespace lldb {
class SBCompileUnit
{
public:
SBCompileUnit ();
~SBCompileUnit ();
bool
IsValid () const;
lldb::SBFileSpec
GetFileSpec () const;
uint32_t
GetNumLineEntries () const;
lldb::SBLineEntry
GetLineEntryAtIndex (uint32_t idx) const;
uint32_t
FindLineEntryIndex (uint32_t start_idx,
uint32_t line,
lldb::SBFileSpec *inline_file_spec) const;
#ifndef SWIG
bool
operator == (const lldb::SBCompileUnit &rhs) const;
bool
operator != (const lldb::SBCompileUnit &rhs) const;
#endif
private:
friend class SBFrame;
friend class SBSymbolContext;
SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr);
#ifndef SWIG
const lldb_private::CompileUnit *
operator->() const;
const lldb_private::CompileUnit &
operator*() const;
#endif
lldb_private::CompileUnit *m_lldb_object_ptr;
};
} // namespace lldb
#endif // LLDB_SBCompileUnit_h_

View File

@ -0,0 +1,148 @@
//===-- SBDebugger.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBDebugger_h_
#define LLDB_SBDebugger_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBDebugger
{
public:
static void
Initialize();
static void
Terminate();
static void
SetAsync (bool b);
static void
SetInputFile (const char *tty_name); // DEPRECATED: will be removed in next submission
static void
SetOutputFile (const char *tty_name); // DEPRECATED: will be removed in next submission
static void
SetErrorFile (const char *tty_name); // DEPRECATED: will be removed in next submission
static void
SetInputFileHandle (FILE *f, bool transfer_ownership);
static void
SetOutputFileHandle (FILE *f, bool transfer_ownership);
static void
SetErrorFileHandle (FILE *f, bool transfer_ownership);
static FILE *
GetInputFileHandle ();
static FILE *
GetOutputFileHandle ();
static FILE *
GetErrorFileHandle ();
static lldb::SBCommandInterpreter
GetCommandInterpreter ();
static void
HandleCommand (const char *command);
static lldb::SBListener
GetListener ();
static void
HandleProcessEvent (const lldb::SBProcess &process,
const lldb::SBEvent &event,
FILE *out,
FILE *err);
static lldb::SBTarget
CreateTargetWithFileAndTargetTriple (const char *filename,
const char *target_triple);
static lldb::SBTarget
CreateTargetWithFileAndArch (const char *filename,
const char *archname);
static lldb::SBTarget
CreateTarget (const char *filename);
static lldb::SBTarget
GetTargetAtIndex (uint32_t idx);
static lldb::SBTarget
FindTargetWithProcessID (pid_t pid);
static lldb::SBTarget
FindTargetWithFileAndArch (const char *filename,
const char *arch);
static uint32_t
GetNumTargets ();
static lldb::SBTarget
GetCurrentTarget ();
static void
UpdateCurrentThread (lldb::SBProcess &process);
static void
ReportCurrentLocation (FILE *out = stdout,
FILE *err = stderr);
static lldb::SBSourceManager &
GetSourceManager ();
static bool
GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
static bool
SetDefaultArchitecture (const char *arch_name);
static lldb::ScriptLanguage
GetScriptingLanguage (const char *script_language_name);
static const char *
GetVersionString ();
static const char *
StateAsCString (lldb::StateType state);
static bool
StateIsRunningState (lldb::StateType state);
static bool
StateIsStoppedState (lldb::StateType state);
static void
DispatchInput (void *baton, const void *data, size_t data_len);
static void
PushInputReader (lldb::SBInputReader &reader);
private:
#ifndef SWIG
friend class SBProcess;
static lldb::SBTarget
FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP);
#endif
}; // class SBDebugger
} // namespace lldb
#endif // LLDB_SBDebugger_h_

View File

@ -0,0 +1,62 @@
//===-- SBDefines.h ---------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBDefines_h_
#define LLDB_SBDefines_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include <LLDB/lldb-defines.h>
#include <LLDB/lldb-enumerations.h>
#include <LLDB/lldb-forward.h>
#include <LLDB/lldb-forward-rtti.h>
#include <LLDB/lldb-types.h>
// Forward Declarations
namespace lldb {
class SBAddress;
class SBBlock;
class SBBreakpoint;
class SBBreakpointLocation;
class SBBroadcaster;
class SBCommandContext;
class SBCommandInterpreter;
class SBCommandReturnObject;
class SBCommunication;
class SBCompileUnit;
class SBDebugger;
class SBError;
class SBEvent;
class SBEventList;
class SBFileSpec;
class SBFrame;
class SBFunction;
class SBHostOS;
class SBInputReader;
class SBInstruction;
class SBLineEntry;
class SBListener;
class SBModule;
class SBProcess;
class SBSourceManager;
class SBSymbol;
class SBSymbolContext;
class SBStringList;
class SBTarget;
class SBThread;
class SBValue;
}
#endif // LLDB_SBDefines_h_

View File

@ -0,0 +1,102 @@
//===-- SBError.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBError_h_
#define LLDB_SBError_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBError {
public:
SBError ();
SBError (const SBError &rhs);
~SBError();
#ifndef SWIG
const SBError &
operator =(const SBError &rhs);
#endif
const char *
GetCString () const;
void
Clear ();
bool
Fail () const;
bool
Success () const;
uint32_t
GetError () const;
lldb::ErrorType
GetType () const;
void
SetError (uint32_t err, lldb::ErrorType type);
void
SetErrorToErrno ();
void
SetErrorToGenericError ();
void
SetErrorString (const char *err_str);
int
SetErrorStringWithFormat (const char *format, ...);
bool
IsValid () const;
protected:
friend class SBArguments;
friend class SBCommunication;
friend class SBHostOS;
friend class SBInputReader;
friend class SBProcess;
#ifndef SWIG
lldb_private::Error *
get();
lldb_private::Error *
operator->();
const lldb_private::Error &
operator*() const;
#endif
void
SetError (const lldb_private::Error &lldb_error);
private:
std::auto_ptr<lldb_private::Error> m_lldb_object_ap;
void
CreateIfNeeded ();
};
} // namespace lldb
#endif // LLDB_SBError_h_

View File

@ -0,0 +1,89 @@
//===-- SBEvent.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBEvent_h_
#define LLDB_SBEvent_h_
#include <vector>
#include <LLDB/SBDefines.h>
namespace lldb {
class SBBroadcaster;
class SBEvent
{
public:
SBEvent();
// Make an event that contains a C string.
SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len);
~SBEvent();
bool
IsValid() const;
void
Dump (FILE *f) const;
const char *
GetDataFlavor ();
uint32_t
GetType () const;
lldb::SBBroadcaster
GetBroadcaster () const;
bool
BroadcasterMatchesPtr (const lldb::SBBroadcaster *broadcaster);
bool
BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster);
void
Clear();
static const char *
GetCStringFromEvent (const lldb::SBEvent &event);
protected:
friend class SBListener;
friend class SBBroadcaster;
friend class SBDebugger;
friend class SBProcess;
SBEvent (lldb::EventSP &event_sp);
lldb::EventSP &
GetSharedPtr () const;
void
SetEventSP (lldb::EventSP &event_sp);
void
SetLLDBObjectPtr (lldb_private::Event* event);
lldb_private::Event *
GetLLDBObjectPtr ();
const lldb_private::Event *
GetLLDBObjectPtr () const;
private:
mutable lldb::EventSP m_event_sp;
mutable lldb_private::Event *m_lldb_object;
};
} // namespace lldb
#endif // LLDB_SBEvent_h_

View File

@ -0,0 +1,83 @@
//===-- SBFileSpec.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBFileSpec_h_
#define LLDB_SBFileSpec_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBFileSpec
{
public:
SBFileSpec ();
SBFileSpec (const lldb::SBFileSpec &rhs);
SBFileSpec (const char *path);
~SBFileSpec ();
#ifndef SWIG
const SBFileSpec &
operator = (const lldb::SBFileSpec &rhs);
#endif
bool
IsValid() const;
bool
Exists () const;
const char *
GetFileName() const;
const char *
GetDirectory() const;
uint32_t
GetPath (char *dst_path, size_t dst_len) const;
static int
ResolvePath (const char *src_path, char *dst_path, size_t dst_len);
private:
friend class SBLineEntry;
friend class SBCompileUnit;
friend class SBHostOS;
friend class SBModule;
friend class SBSourceManager;
friend class SBTarget;
void
SetFileSpec (const lldb_private::FileSpec& fs);
#ifndef SWIG
const lldb_private::FileSpec *
operator->() const;
const lldb_private::FileSpec *
get() const;
const lldb_private::FileSpec &
operator*() const;
const lldb_private::FileSpec &
ref() const;
#endif
std::auto_ptr <lldb_private::FileSpec> m_lldb_object_ap;
};
} // namespace lldb
#endif // LLDB_SBFileSpec_h_

View File

@ -0,0 +1,130 @@
//===-- SBFrame.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBFrame_h_
#define LLDB_SBFrame_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBValueList.h>
namespace lldb {
class SBValue;
class SBFrame
{
public:
SBFrame ();
~SBFrame();
bool
IsValid() const;
uint32_t
GetFrameID () const;
lldb::addr_t
GetPC () const;
bool
SetPC (lldb::addr_t new_pc);
lldb::addr_t
GetSP () const;
lldb::addr_t
GetFP () const;
lldb::SBAddress
GetPCAddress () const;
lldb::SBSymbolContext
GetSymbolContext (uint32_t resolve_scope) const;
lldb::SBModule
GetModule () const;
lldb::SBCompileUnit
GetCompileUnit () const;
lldb::SBFunction
GetFunction () const;
lldb::SBBlock
GetBlock () const;
lldb::SBLineEntry
GetLineEntry () const;
lldb::SBThread
GetThread () const;
const char *
Disassemble () const;
void
Clear();
#ifndef SWIG
bool
operator == (const lldb::SBFrame &rhs) const;
bool
operator != (const lldb::SBFrame &rhs) const;
#endif
lldb::SBValueList
GetVariables (bool arguments,
bool locals,
bool statics,
bool in_scope_only);
lldb::SBValueList
GetRegisters ();
lldb::SBValue
LookupVar (const char *var_name);
lldb::SBValue
LookupVarInScope (const char *var_name, const char *scope);
protected:
friend class SBValue;
lldb_private::StackFrame *
GetLLDBObjectPtr ();
private:
friend class SBThread;
#ifndef SWIG
lldb_private::StackFrame *
operator->() const;
// Mimic shared pointer...
lldb_private::StackFrame *
get() const;
#endif
SBFrame (const lldb::StackFrameSP &lldb_object_sp);
void
SetFrame (const lldb::StackFrameSP &lldb_object_sp);
lldb::StackFrameSP m_lldb_object_sp;
};
} // namespace lldb
#endif // LLDB_SBFrame_h_

View File

@ -0,0 +1,55 @@
//===-- SBFunction.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBFunction_h_
#define LLDB_SBFunction_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBFunction
{
public:
SBFunction ();
~SBFunction ();
bool
IsValid () const;
const char *
GetName() const;
const char *
GetMangledName () const;
#ifndef SWIG
bool
operator == (const lldb::SBFunction &rhs) const;
bool
operator != (const lldb::SBFunction &rhs) const;
#endif
private:
friend class SBFrame;
friend class SBSymbolContext;
SBFunction (lldb_private::Function *lldb_object_ptr);
lldb_private::Function *m_lldb_object_ptr;
};
} // namespace lldb
#endif // LLDB_SBFunction_h_

View File

@ -0,0 +1,54 @@
//===-- SBHostOS.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBHostOS_h_
#define LLDB_SBHostOS_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBFileSpec.h>
namespace lldb {
class SBHostOS
{
public:
static lldb::SBFileSpec
GetProgramFileSpec ();
static void
ThreadCreated (const char *name);
static lldb::thread_t
ThreadCreate (const char *name,
void *(*thread_function)(void *),
void *thread_arg,
lldb::SBError *err);
static bool
ThreadCancel (lldb::thread_t thread,
lldb::SBError *err);
static bool
ThreadDetach (lldb::thread_t thread,
lldb::SBError *err);
static bool
ThreadJoin (lldb::thread_t thread,
void **result,
lldb::SBError *err);
private:
};
} // namespace lldb
#endif // LLDB_SBHostOS_h_

View File

@ -0,0 +1,100 @@
//===-- SBInputReader.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBInputReader_h_
#define LLDB_SBInputReader_h_
#include <LLDB/SBDefines.h>
#include <termios.h>
namespace lldb {
class SBInputReader
{
public:
typedef size_t (*Callback) (void *baton,
SBInputReader *reader,
InputReaderAction notification,
const char *bytes,
size_t bytes_len);
SBInputReader ();
SBInputReader (const lldb::InputReaderSP &reader_sp);
SBInputReader (const lldb::SBInputReader &rhs);
~SBInputReader ();
SBError
Initialize (Callback callback,
void *callback_baton,
lldb::InputReaderGranularity granularity,
const char *end_token,
const char *prompt,
bool echo);
bool
IsValid () const;
#ifndef SWIG
const SBInputReader &
operator = (const lldb::SBInputReader &rhs);
#endif
bool
IsActive () const;
bool
IsDone () const;
void
SetIsDone (bool value);
InputReaderGranularity
GetGranularity ();
protected:
friend class SBDebugger;
#ifndef SWIG
lldb_private::InputReader *
operator->() const;
lldb::InputReaderSP &
operator *();
const lldb::InputReaderSP &
operator *() const;
#endif
lldb_private::InputReader *
get() const;
private:
static size_t
PrivateCallback (void *baton,
lldb_private::InputReader *reader,
lldb::InputReaderAction notification,
const char *bytes,
size_t bytes_len);
lldb::InputReaderSP m_reader_sp;
Callback m_callback_function;
void *m_callback_baton;
};
} // namespace lldb
#endif // LLDB_SBInputReader_h_

View File

@ -0,0 +1,57 @@
//===-- SBInstruction.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBInstruction_h_
#define LLDB_SBInstruction_h_
#include <LLDB/SBDefines.h>
// There's a lot to be fixed here, but need to wait for underlying insn implementation
// to be revised & settle down first.
//class lldb_private::Disassembler::Instruction;
namespace lldb {
class SBInstruction
{
public:
//SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn);
SBInstruction ();
~SBInstruction ();
//bool
//IsValid();
//size_t
//GetByteSize ();
//void
//SetByteSize (size_t byte_size);
//bool
//DoesBranch ();
void
Print (FILE *out);
private:
//lldb_private::Disassembler::Instruction::SharedPtr m_lldb_object_sp;
};
} // namespace lldb
#endif // LLDB_SBInstruction_h_

View File

@ -0,0 +1,53 @@
//===-- SBInstructionList.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBInstructionList_h_
#define LLDB_SBInstructionList_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBInstructionList
{
public:
SBInstructionList ();
~SBInstructionList ();
size_t
GetSize ();
lldb::SBInstruction
GetInstructionAtIndex (uint32_t idx);
void
Clear ();
void
AppendInstruction (lldb::SBInstruction inst);
void
Print (FILE *out);
private:
// If we have an instruction list, it will need to be backed by an
// lldb_private class that contains the list, we can't inherit from
// std::vector here...
//std::vector <SBInstruction> m_insn_list;
};
} // namespace lldb
#endif // LLDB_SBInstructionList_h_

View File

@ -0,0 +1,88 @@
//===-- SBLineEntry.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBLineEntry_h_
#define LLDB_SBLineEntry_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBAddress.h>
#include <LLDB/SBFileSpec.h>
namespace lldb {
class SBLineEntry
{
public:
SBLineEntry ();
SBLineEntry (const lldb::SBLineEntry &rhs);
~SBLineEntry ();
#ifndef SWIG
const lldb::SBLineEntry &
operator = (const lldb::SBLineEntry &rhs);
#endif
lldb::SBAddress
GetStartAddress () const;
lldb::SBAddress
GetEndAddress () const;
bool
IsValid () const;
lldb::SBFileSpec
GetFileSpec () const;
uint32_t
GetLine () const;
uint32_t
GetColumn () const;
#ifndef SWIG
bool
operator == (const lldb::SBLineEntry &rhs) const;
bool
operator != (const lldb::SBLineEntry &rhs) const;
#endif
private:
friend class SBCompileUnit;
friend class SBFrame;
friend class SBSymbolContext;
#ifndef SWIG
const lldb_private::LineEntry *
operator->() const;
const lldb_private::LineEntry &
operator*() const;
#endif
SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr);
void
SetLineEntry (const lldb_private::LineEntry &lldb_object_ref);
std::auto_ptr<lldb_private::LineEntry> m_lldb_object_ap;
};
} // namespace lldb
#endif // LLDB_SBLineEntry_h_

View File

@ -0,0 +1,119 @@
//===-- SBListener.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBListener_h_
#define LLDB_SBListener_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBListener
{
public:
friend class SBBroadcaster;
friend class SBCommandInterpreter;
friend class SBDebugger;
friend class SBTarget;
SBListener (const char *name);
SBListener (lldb_private::Listener &listener);
SBListener ();
~SBListener ();
void
AddEvent (const lldb::SBEvent &event);
void
Clear ();
bool
IsValid () const;
uint32_t
StartListeningForEvents (const lldb::SBBroadcaster& broadcaster,
uint32_t event_mask);
bool
StopListeningForEvents (const lldb::SBBroadcaster& broadcaster,
uint32_t event_mask);
// Returns true if an event was recieved, false if we timed out.
bool
WaitForEvent (uint32_t num_seconds,
lldb::SBEvent &event);
bool
WaitForEventForBroadcaster (uint32_t num_seconds,
const lldb::SBBroadcaster &broadcaster,
lldb::SBEvent &sb_event);
bool
WaitForEventForBroadcasterWithType (uint32_t num_seconds,
const lldb::SBBroadcaster &broadcaster,
uint32_t event_type_mask,
lldb::SBEvent &sb_event);
bool
PeekAtNextEvent (lldb::SBEvent &sb_event);
bool
PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster,
lldb::SBEvent &sb_event);
bool
PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster,
uint32_t event_type_mask,
lldb::SBEvent &sb_event);
bool
GetNextEvent (lldb::SBEvent &sb_event);
bool
GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster,
lldb::SBEvent &sb_event);
bool
GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster,
uint32_t event_type_mask,
lldb::SBEvent &sb_event);
bool
HandleBroadcastEvent (const lldb::SBEvent &event);
private:
#ifndef SWIG
lldb_private::Listener *
operator->() const;
lldb_private::Listener *
get() const;
lldb_private::Listener &
operator *();
const lldb_private::Listener &
operator *() const;
#endif
lldb_private::Listener *m_lldb_object_ptr;
bool m_lldb_object_ptr_owned;
};
} // namespace lldb
#endif // LLDB_SBListener_h_

View File

@ -0,0 +1,79 @@
//===-- SBModule.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBModule_h_
#define LLDB_SBModule_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBModule
{
public:
SBModule ();
~SBModule ();
bool
IsValid () const;
lldb::SBFileSpec
GetFileSpec () const;
const uint8_t *
GetUUIDBytes () const;
#ifndef SWIG
bool
operator == (const lldb::SBModule &rhs) const;
bool
operator != (const lldb::SBModule &rhs) const;
#endif
private:
friend class SBSymbolContext;
friend class SBTarget;
friend class SBFrame;
explicit SBModule (const lldb::ModuleSP& module_sp);
void
SetModule (const lldb::ModuleSP& module_sp);
#ifndef SWIG
lldb::ModuleSP &
operator *();
lldb_private::Module *
operator ->();
const lldb_private::Module *
operator ->() const;
lldb_private::Module *
get();
const lldb_private::Module *
get() const;
#endif
lldb::ModuleSP m_lldb_object_sp;
};
} // namespace lldb
#endif // LLDB_SBModule_h_

View File

@ -0,0 +1,195 @@
//===-- SBProcess.h ---------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBProcess_h_
#define LLDB_SBProcess_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBError.h>
#include <LLDB/SBTarget.h>
namespace lldb {
class SBEvent;
class SBProcess
{
public:
//------------------------------------------------------------------
/// Broadcaster event bits definitions.
//------------------------------------------------------------------
enum
{
eBroadcastBitStateChanged = (1 << 0),
eBroadcastBitInterrupt = (1 << 1),
eBroadcastBitSTDOUT = (1 << 2),
eBroadcastBitSTDERR = (1 << 3),
};
SBProcess ();
SBProcess (const lldb::SBProcess& rhs);
~SBProcess();
void
Clear ();
bool
IsValid() const;
lldb::SBTarget
GetTarget() const;
size_t
PutSTDIN (const char *src, size_t src_len);
size_t
GetSTDOUT (char *dst, size_t dst_len) const;
size_t
GetSTDERR (char *dst, size_t dst_len) const;
void
ReportCurrentState (const lldb::SBEvent &event, FILE *out) const;
void
AppendCurrentStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
//------------------------------------------------------------------
// Thread related functions
//------------------------------------------------------------------
uint32_t
GetNumThreads ();
lldb::SBThread
GetThreadAtIndex (size_t index);
lldb::SBThread
GetThreadByID (lldb::tid_t sb_thread_id);
lldb::SBThread
GetCurrentThread () const;
bool
SetCurrentThread (const lldb::SBThread &thread);
bool
SetCurrentThreadByID (uint32_t tid);
//------------------------------------------------------------------
// Stepping related functions
//------------------------------------------------------------------
lldb::StateType
GetState ();
int
GetExitStatus ();
const char *
GetExitDescription ();
lldb::pid_t
GetProcessID ();
uint32_t
GetAddressByteSize() const;
SBError
Destroy ();
void
DisplayThreadsInfo (FILE *out = NULL, FILE *err = NULL, bool only_threads_with_stop_reason = true);
void
ListThreads ();
bool
WaitUntilProcessHasStopped (lldb::SBCommandReturnObject &result);
lldb::pid_t
AttachByPID (lldb::pid_t pid); // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t)
SBError
Attach (lldb::pid_t pid);
SBError
AttachByName (const char *name, bool wait_for_launch);
SBError
Continue ();
SBError
Stop ();
SBError
Kill ();
SBError
Detach ();
SBError
Signal (int signal);
void
Backtrace (bool all_threads = false, uint32_t num_frames = 0);
size_t
ReadMemory (addr_t addr, void *buf, size_t size, SBError &error);
size_t
WriteMemory (addr_t addr, const void *buf, size_t size, SBError &error);
// Events
static lldb::StateType
GetStateFromEvent (const lldb::SBEvent &event);
static bool
GetRestartedFromEvent (const lldb::SBEvent &event);
static lldb::SBProcess
GetProcessFromEvent (const lldb::SBEvent &event);
lldb::SBBroadcaster
GetBroadcaster () const;
protected:
friend class SBAddress;
friend class SBBreakpoint;
friend class SBBreakpointLocation;
friend class SBCommandInterpreter;
friend class SBDebugger;
friend class SBTarget;
friend class SBThread;
friend class SBValue;
#ifndef SWIG
lldb_private::Process *
operator->() const;
// Mimic shared pointer...
lldb_private::Process *
get() const;
#endif
SBProcess (const lldb::ProcessSP &process_sp);
void
SetProcess (const lldb::ProcessSP &process_sp);
lldb::ProcessSP m_lldb_object_sp;
};
} // namespace lldb
#endif // LLDB_SBProcess_h_

View File

@ -0,0 +1,47 @@
//===-- SBSourceManager.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBSourceManager_h_
#define LLDB_SBSourceManager_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBSourceManager
{
public:
~SBSourceManager();
size_t
DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file,
uint32_t line,
uint32_t context_before,
uint32_t context_after,
const char* current_line_cstr,
FILE *f);
protected:
friend class SBCommandInterpreter;
friend class SBDebugger;
SBSourceManager(lldb_private::SourceManager &source_manager);
lldb_private::SourceManager &
GetLLDBManager ();
private:
lldb_private::SourceManager &m_source_manager;
};
} // namespace lldb
#endif // LLDB_SBSourceManager_h_

View File

@ -0,0 +1,72 @@
//===-- SBStringList.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBStringList_h_
#define LLDB_SBStringList_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBStringList
{
public:
SBStringList ();
SBStringList (const lldb_private::StringList *lldb_strings);
SBStringList (const lldb::SBStringList &rhs);
~SBStringList ();
bool
IsValid() const;
void
AppendString (const char *str);
void
AppendList (const char **strv, int strc);
void
AppendList (lldb::SBStringList strings);
uint32_t
GetSize () const;
const char *
GetStringAtIndex (size_t idx);
void
Clear ();
#ifndef SWIG
const lldb_private::StringList *
operator->() const;
const lldb_private::StringList &
operator*() const;
const lldb::SBStringList &
operator = (const lldb::SBStringList &rhs);
#endif
private:
std::auto_ptr<lldb_private::StringList> m_lldb_object_ap;
};
} // namespace lldb
#endif // LLDB_SBStringList_h_

View File

@ -0,0 +1,55 @@
//===-- SBSymbol.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBSymbol_h_
#define LLDB_SBSymbol_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBSymbol
{
public:
SBSymbol ();
~SBSymbol ();
bool
IsValid () const;
const char *
GetName() const;
const char *
GetMangledName () const;
#ifndef SWIG
bool
operator == (const lldb::SBSymbol &rhs) const;
bool
operator != (const lldb::SBSymbol &rhs) const;
#endif
private:
friend class SBSymbolContext;
SBSymbol (lldb_private::Symbol *lldb_object_ptr);
lldb_private::Symbol *m_lldb_object_ptr;
};
} // namespace lldb
#endif // LLDB_SBSymbol_h_

View File

@ -0,0 +1,73 @@
//===-- SBSymbolContext.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBSymbolContext_h_
#define LLDB_SBSymbolContext_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBBlock.h>
#include <LLDB/SBCompileUnit.h>
#include <LLDB/SBFunction.h>
#include <LLDB/SBLineEntry.h>
#include <LLDB/SBModule.h>
#include <LLDB/SBSymbol.h>
namespace lldb {
class SBSymbolContext
{
public:
SBSymbolContext ();
SBSymbolContext (const lldb::SBSymbolContext& rhs);
~SBSymbolContext ();
bool
IsValid () const;
#ifndef SWIG
const lldb::SBSymbolContext &
operator = (const lldb::SBSymbolContext &rhs);
#endif
SBModule GetModule ();
SBCompileUnit GetCompileUnit ();
SBFunction GetFunction ();
SBBlock GetBlock ();
SBLineEntry GetLineEntry ();
SBSymbol GetSymbol ();
protected:
friend class SBFrame;
friend class SBThread;
#ifndef SWIG
lldb_private::SymbolContext*
operator->() const;
#endif
lldb_private::SymbolContext *
GetLLDBObjectPtr() const;
SBSymbolContext (const lldb_private::SymbolContext *sc_ptr);
void
SetSymbolContext (const lldb_private::SymbolContext *sc_ptr);
private:
std::auto_ptr<lldb_private::SymbolContext> m_lldb_object_ap;
};
} // namespace lldb
#endif // LLDB_SBSymbolContext_h_

View File

@ -0,0 +1,167 @@
//===-- SBTarget.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBTarget_h_
#define LLDB_SBTarget_h_
#include <LLDB/SBDefines.h>
#include <LLDB/SBBroadcaster.h>
#include <LLDB/SBFileSpec.h>
namespace lldb {
class SBBreakpoint;
class SBTarget
{
public:
//------------------------------------------------------------------
// Broadcaster bits.
//------------------------------------------------------------------
enum
{
eBroadcastBitBreakpointChanged = (1 << 0),
eBroadcastBitModulesLoaded = (1 << 1),
eBroadcastBitModulesUnloaded = (1 << 2)
};
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
SBTarget (const lldb::SBTarget& rhs);
SBTarget (); // Required for SWIG.
//------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------
~SBTarget();
const lldb::SBTarget&
Assign (const lldb::SBTarget& rhs);
bool
IsValid() const;
lldb::SBProcess
GetProcess ();
lldb::SBProcess
CreateProcess ();
lldb::SBProcess
LaunchProcess (char const **argv,
char const **envp,
const char *tty,
bool stop_at_entry);
lldb::SBFileSpec
GetExecutable ();
uint32_t
GetNumModules () const;
lldb::SBModule
GetModuleAtIndex (uint32_t idx);
lldb::SBModule
FindModule (const lldb::SBFileSpec &file_spec);
bool
DeleteTargetFromList (lldb_private::TargetList *list);
bool
MakeCurrentTarget ();
lldb::SBBreakpoint
BreakpointCreateByLocation (const char *file, uint32_t line);
lldb::SBBreakpoint
BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
lldb::SBBreakpoint
BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
lldb::SBBreakpoint
BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
lldb::SBBreakpoint
BreakpointCreateByAddress (addr_t address);
bool
BreakpointDelete (break_id_t break_id);
void
ListAllBreakpoints ();
lldb::SBBreakpoint
FindBreakpointByID (break_id_t break_id);
bool
EnableAllBreakpoints ();
bool
DisableAllBreakpoints ();
bool
DeleteAllBreakpoints ();
lldb::SBBroadcaster
GetBroadcaster () const;
//void
//Disassemble ();
void
Disassemble (lldb::addr_t file_address_start, lldb::addr_t file_address_end = LLDB_INVALID_ADDRESS,
const char *module_name = NULL);
void
Disassemble (const char *function_name, const char *module_name = NULL);
#ifndef SWIG
bool
operator == (const lldb::SBTarget &rhs) const;
bool
operator != (const lldb::SBTarget &rhs) const;
#endif
protected:
friend class SBDebugger;
friend class SBProcess;
//------------------------------------------------------------------
// Constructors are private, use static Target::Create function to
// create an instance of this class.
//------------------------------------------------------------------
SBTarget (const lldb::TargetSP& target_sp);
void
SetLLBDTarget (const lldb::TargetSP& target_sp);
lldb_private::Target *
GetLLDBObjectPtr();
const lldb_private::Target *
GetLLDBObjectPtr() const;
private:
//------------------------------------------------------------------
// For Target only
//------------------------------------------------------------------
lldb::TargetSP m_target_sp;
};
} // namespace lldb
#endif // LLDB_SBTarget_h_

View File

@ -0,0 +1,152 @@
//===-- SBThread.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBThread_h_
#define LLDB_SBThread_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBFrame;
class SBThread
{
public:
SBThread ();
SBThread (const lldb::SBThread &thread);
~SBThread();
bool
IsValid() const;
lldb::StopReason
GetStopReason();
size_t
GetStopDescription (char *dst, size_t dst_len);
lldb::tid_t
GetThreadID () const;
uint32_t
GetIndexID () const;
const char *
GetName () const;
const char *
GetQueueName() const;
void
DisplayFramesForCurrentContext (FILE *out,
FILE *err,
uint32_t first_frame,
uint32_t num_frames,
bool show_frame_info,
uint32_t num_frames_with_source,
uint32_t source_lines_before = 3,
uint32_t source_lines_after = 3);
bool
DisplaySingleFrameForCurrentContext (FILE *out,
FILE *err,
lldb::SBFrame &frame,
bool show_frame_info,
bool show_source,
uint32_t source_lines_after,
uint32_t source_lines_before);
void
StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
void
StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
void
StepOut ();
void
StepInstruction(bool step_over);
void
RunToAddress (lldb::addr_t addr);
void
Backtrace (uint32_t num_frames = 0);
uint32_t
GetNumFrames ();
lldb::SBFrame
GetFrameAtIndex (uint32_t idx);
lldb::SBProcess
GetProcess ();
#ifndef SWIG
const lldb::SBThread &
operator = (const lldb::SBThread &rhs);
bool
operator == (const lldb::SBThread &rhs) const;
bool
operator != (const lldb::SBThread &rhs) const;
#endif
protected:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
friend class SBFrame;
friend class SBProcess;
friend class SBDebugger;
friend class SBValue;
lldb_private::Thread *
GetLLDBObjectPtr ();
#ifndef SWIG
const lldb_private::Thread *
operator->() const;
const lldb_private::Thread &
operator*() const;
lldb_private::Thread *
operator->();
lldb_private::Thread &
operator*();
#endif
SBThread (const lldb::ThreadSP& lldb_object_sp);
void
SetThread (const lldb::ThreadSP& lldb_object_sp);
private:
//------------------------------------------------------------------
// Classes that inherit from Thread can see and modify these
//------------------------------------------------------------------
lldb::ThreadSP m_lldb_object_sp;
};
} // namespace lldb
#endif // LLDB_SBThread_h_

View File

@ -0,0 +1,31 @@
//===-- SBType.h ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBType_h_
#define LLDB_SBType_h_
#include <LLDB/SBDefines.h>
namespace lldb {
class SBType
{
public:
static bool
IsPointerType (void *opaque_type);
private:
};
} // namespace lldb
#endif // LLDB_SBType_h_

View File

@ -0,0 +1,126 @@
//===-- SBValue.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBValue_h_
#define LLDB_SBValue_h_
#include <LLDB/SBDefines.h>
class lldb_private::Variable;
class lldb_private::ValueObject;
class lldb_private::ExecutionContext;
namespace lldb {
class SBValue
{
public:
SBValue ();
~SBValue ();
bool
IsValid() const;
void
Print (FILE *out_file, lldb::SBFrame *frame, bool print_type, bool print_value);
const char *
GetName();
const char *
GetTypeName ();
size_t
GetByteSize ();
bool
IsInScope (const lldb::SBFrame &frame);
const char *
GetValue (const lldb::SBFrame &frame);
bool
GetValueDidChange ();
const char *
GetSummary (const lldb::SBFrame &frame);
const char *
GetLocation (const lldb::SBFrame &frame);
bool
SetValueFromCString (const lldb::SBFrame &frame, const char *value_str);
lldb::SBValue
GetChildAtIndex (uint32_t idx);
// Matches children of this object only and will match base classes and
// member names if this is a clang typed object.
uint32_t
GetIndexOfChildWithName (const char *name);
// Matches child members of this object and child members of any base
// classes.
lldb::SBValue
GetChildMemberWithName (const char *name);
uint32_t
GetNumChildren ();
bool
ValueIsStale ();
void *
GetOpaqueType();
//void
//DumpType ();
lldb::SBValue
Dereference ();
bool
TypeIsPtrType ();
protected:
friend class SBValueList;
friend class SBFrame;
SBValue (const lldb::ValueObjectSP &value_sp);
#ifndef SWIG
// Mimic shared pointer...
lldb_private::ValueObject *
get() const;
lldb_private::ValueObject *
operator->() const;
lldb::ValueObjectSP &
operator*();
const lldb::ValueObjectSP &
operator*() const;
#endif
private:
lldb_private::ExecutionContext
GetCurrentExecutionContext ();
lldb::ValueObjectSP m_lldb_object_sp;
};
} // namespace lldb
#endif // LLDB_SBValue_h_

View File

@ -0,0 +1,79 @@
//===-- SBValueList.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBValueList_h_
#define LLDB_SBValueList_h_
#include <LLDB/SBDefines.h>
class lldb_private::ValueObjectList;
namespace lldb {
class SBValueList
{
public:
SBValueList ();
SBValueList (const lldb::SBValueList &rhs);
~SBValueList();
bool
IsValid() const;
void
Append (const lldb::SBValue &val_obj);
uint32_t
GetSize() const;
lldb::SBValue
GetValueAtIndex (uint32_t idx) const;
lldb::SBValue
FindValueObjectByUID (lldb::user_id_t uid);
#ifndef SWIG
const lldb::SBValueList &
operator = (const lldb::SBValueList &rhs);
lldb_private::ValueObjectList *
operator -> ();
lldb_private::ValueObjectList &
operator* ();
const lldb_private::ValueObjectList *
operator -> () const;
const lldb_private::ValueObjectList &
operator* () const;
#endif
private:
friend class SBFrame;
SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr);
void
Append (lldb::ValueObjectSP& val_obj_sp);
void
CreateIfNeeded ();
std::auto_ptr<lldb_private::ValueObjectList> m_lldb_object_ap;
};
} // namespace lldb
#endif // LLDB_SBValueList_h_

View File

@ -0,0 +1,511 @@
//===-- Breakpoint.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_Breakpoint_h_
#define liblldb_Breakpoint_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocationList.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Breakpoint/Stoppoint.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/StringList.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h"
/// @brief Class that manages logical breakpoint setting.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// A breakpoint has four main parts, a filter, a resolver, the list of breakpoint
/// locations that have been determined for the filter/resolver pair, and finally
/// a set of options for the breakpoint.
///
/// \b Filter:
/// This is an object derived from SearchFilter. It manages the search
/// for breakpoint location matches through the symbols in the module list of the target
/// that owns it. It also filters out locations based on whatever logic it wants.
///
/// \b Resolver:
/// This is an object derived from BreakpointResolver. It provides a
/// callback to the filter that will find breakpoint locations. How it does this is
/// determined by what kind of resolver it is.
///
/// The Breakpoint class also provides constructors for the common breakpoint cases
/// which make the appropriate filter and resolver for you.
///
/// \b Location List:
/// This stores the breakpoint locations that have been determined
/// to date. For a given breakpoint, there will be only one location with a given
/// address. Adding a location at an already taken address will just return the location
/// already at that address. Locations can be looked up by ID, or by address.
///
/// \b Options:
/// This includes:
/// \b Enabled/Disabled
/// \b Ignore Count
/// \b Callback
/// \b Condition
/// Note, these options can be set on the breakpoint, and they can also be set on the
/// individual locations. The options set on the breakpoint take precedence over the
/// options set on the individual location.
/// So for instance disabling the breakpoint will cause NONE of the locations to get hit.
/// But if the breakpoint is enabled, then the location's enabled state will be checked
/// to determine whether to insert that breakpoint location.
/// Similarly, if the breakpoint condition says "stop", we won't check the location's condition.
/// But if the breakpoint condition says "continue", then we will check the location for whether
/// to actually stop or not.
/// One subtle point worth observing here is that you don't actually stop at a Breakpoint, you
/// always stop at one of its locations. So the "should stop" tests are done by the location,
/// not by the breakpoint.
//----------------------------------------------------------------------
class Breakpoint:
public Stoppoint
{
public:
static const ConstString &
GetEventIdentifier ();
//------------------------------------------------------------------
/// An enum specifying the match style for breakpoint settings. At
/// present only used for function name style breakpoints.
//------------------------------------------------------------------
typedef enum
{
Exact,
Regexp,
Glob
} MatchType;
class BreakpointEventData :
public EventData
{
public:
static const ConstString &
GetFlavorString ();
virtual const ConstString &
GetFlavor () const;
enum EventSubType
{
eBreakpointInvalidType = (1 << 0),
eBreakpointAdded = (1 << 1),
eBreakpointRemoved = (1 << 2),
eBreakpointLocationsAdded = (1 << 3),
eBreakpointLocationsRemoved = (1 << 4),
eBreakpointLocationResolved = (1 << 5)
};
BreakpointEventData (EventSubType sub_type,
lldb::BreakpointSP &new_breakpoint_sp);
virtual
~BreakpointEventData();
EventSubType
GetSubType () const;
lldb::BreakpointSP &
GetBreakpoint ();
virtual void
Dump (Stream *s) const;
static BreakpointEventData *
GetEventDataFromEvent (const lldb::EventSP &event_sp);
static EventSubType
GetSubTypeFromEvent (const lldb::EventSP &event_sp);
static lldb::BreakpointSP
GetBreakpointFromEvent (const lldb::EventSP &event_sp);
private:
EventSubType m_sub_type;
lldb::BreakpointSP m_new_breakpoint_sp;
BreakpointLocationCollection m_locations;
DISALLOW_COPY_AND_ASSIGN (BreakpointEventData);
};
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is not virtual since there should be no reason to subclass
/// breakpoints. The varieties of breakpoints are specified instead by
/// providing different resolvers & filters.
//------------------------------------------------------------------
~Breakpoint();
//------------------------------------------------------------------
// Methods
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Tell whether this breakpoint is an "internal" breakpoint.
/// @return
/// Returns \b true if this is an internal breakpoint, \b false otherwise.
//------------------------------------------------------------------
bool
IsInternal () const;
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
void
Dump (Stream *s);
//------------------------------------------------------------------
// The next set of methods provide ways to tell the breakpoint to update
// it's location list - usually done when modules appear or disappear.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Tell this breakpoint to clear all its breakpoint sites. Done
/// when the process holding the breakpoint sites is destroyed.
//------------------------------------------------------------------
void
ClearAllBreakpointSites ();
//------------------------------------------------------------------
/// Tell this breakpoint to scan it's target's module list and resolve any
/// new locations that match the breakpoint's specifications.
//------------------------------------------------------------------
void
ResolveBreakpoint ();
//------------------------------------------------------------------
/// Tell this breakpoint to scan a given module list and resolve any
/// new locations that match the breakpoint's specifications.
///
/// @param[in] changedModules
/// The list of modules to look in for new locations.
//------------------------------------------------------------------
void
ResolveBreakpointInModules (ModuleList &changedModules);
//------------------------------------------------------------------
/// Like ResolveBreakpointInModules, but allows for "unload" events, in
/// which case we will remove any locations that are in modules that got
/// unloaded.
///
/// @param[in] changedModules
/// The list of modules to look in for new locations.
/// @param[in] load_event
/// If \b true then the modules were loaded, if \b false, unloaded.
//------------------------------------------------------------------
void
ModulesChanged (ModuleList &changedModules,
bool load_event);
//------------------------------------------------------------------
// The next set of methods provide access to the breakpoint locations
// for this breakpoint.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Add a location to the breakpoint's location list. This is only meant
/// to be called by the breakpoint's resolver. FIXME: how do I ensure that?
///
/// @param[in] addr
/// The Address specifying the new location.
/// @param[out] new_location
/// Set to \b true if a new location was created, to \b false if there
/// already was a location at this Address.
/// @return
/// Returns a pointer to the new location.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
AddLocation (Address &addr,
bool *new_location = NULL);
//------------------------------------------------------------------
/// Find a breakpoint location by Address.
///
/// @param[in] addr
/// The Address specifying the location.
/// @return
/// Returns a shared pointer to the location at \a addr. The pointer
/// in the shared pointer will be NULL if there is no location at that address.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
FindLocationByAddress (Address &addr);
//------------------------------------------------------------------
/// Find a breakpoint location ID by Address.
///
/// @param[in] addr
/// The Address specifying the location.
/// @return
/// Returns the UID of the location at \a addr, or \b LLDB_INVALID_ID if
/// there is no breakpoint location at that address.
//------------------------------------------------------------------
lldb::break_id_t
FindLocationIDByAddress (Address &addr);
//------------------------------------------------------------------
/// Find a breakpoint location for a given breakpoint location ID.
///
/// @param[in] bp_loc_id
/// The ID specifying the location.
/// @return
/// Returns a shared pointer to the location with ID \a bp_loc_id. The pointer
/// in the shared pointer will be NULL if there is no location with that ID.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
FindLocationByID (lldb::break_id_t bp_loc_id);
//------------------------------------------------------------------
/// Get breakpoint locations by index.
///
/// @param[in] index
/// The location index.
///
/// @return
/// Returns a shared pointer to the location with index \a
/// index. The shared pointer might contain NULL if \a index is
/// greater than then number of actual locations.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
GetLocationAtIndex (uint32_t index);
const lldb::BreakpointSP
GetSP ();
//------------------------------------------------------------------
// The next section deals with various breakpoint options.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// If \a enable is \b true, enable the breakpoint, if \b false disable it.
//------------------------------------------------------------------
void
SetEnabled (bool enable);
//------------------------------------------------------------------
/// Check the Enable/Disable state.
/// @return
/// \b true if the breakpoint is enabled, \b false if disabled.
//------------------------------------------------------------------
bool
IsEnabled ();
//------------------------------------------------------------------
/// Set the breakpoint to ignore the next \a count breakpoint hits.
/// @param[in] count
/// The number of breakpoint hits to ignore.
//------------------------------------------------------------------
void
SetIgnoreCount (int32_t count);
//------------------------------------------------------------------
/// Return the current Ignore Count.
/// @return
/// The number of breakpoint hits to be ignored.
//------------------------------------------------------------------
int32_t
GetIgnoreCount () const;
//------------------------------------------------------------------
/// Set the valid thread to be checked when the breakpoint is hit.
/// @param[in] thread_id
/// If this thread hits the breakpoint, we stop, otherwise not.
//------------------------------------------------------------------
void
SetThreadID (lldb::tid_t thread_id);
//------------------------------------------------------------------
/// Return the current stop thread value.
/// @return
/// The thread id for which the breakpoint hit will stop, LLDB_INVALID_THREAD_ID for all threads.
//------------------------------------------------------------------
lldb::tid_t
GetThreadID ();
//------------------------------------------------------------------
/// Set the callback action invoked when the breakpoint is hit. The callback
/// Will return a bool indicating whether the target should stop at this breakpoint or not.
/// @param[in] callback
/// The method that will get called when the breakpoint is hit.
/// @param[in] baton
/// A void * pointer that will get passed back to the callback function.
//------------------------------------------------------------------
void
SetCallback (BreakpointHitCallback callback,
void *baton,
bool is_synchronous = false);
void
SetCallback (BreakpointHitCallback callback,
const lldb::BatonSP &callback_baton_sp,
bool is_synchronous = false);
void
ClearCallback ();
//------------------------------------------------------------------
/// Set the condition expression to be checked when the breakpoint is hit.
/// @param[in] expression
/// The method that will get called when the breakpoint is hit.
//------------------------------------------------------------------
void
SetCondition (void *expression);
//------------------------------------------------------------------
// The next section are various utility functions.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Return the number of breakpoint locations that have resolved to
/// actual breakpoint sites.
///
/// @return
/// The number locations resolved breakpoint sites.
//------------------------------------------------------------------
size_t
GetNumResolvedLocations() const;
//------------------------------------------------------------------
/// Return the number of breakpoint locations.
///
/// @return
/// The number breakpoint locations.
//------------------------------------------------------------------
size_t
GetNumLocations() const;
//------------------------------------------------------------------
/// Put a description of this breakpoint into the stream \a s.
///
/// @param[in] s
/// Stream into which to dump the description.
///
/// @param[in] level
/// The description level that indicates the detail level to
/// provide.
///
/// @see lldb::DescriptionLevel
//------------------------------------------------------------------
void
GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations = false);
//------------------------------------------------------------------
/// Accessor for the breakpoint Target.
/// @return
/// This breakpoint's Target.
//------------------------------------------------------------------
Target &
GetTarget ();
const Target &
GetTarget () const;
void
GetResolverDescription (Stream *s);
void
GetFilterDescription (Stream *s);
//------------------------------------------------------------------
/// Returns the BreakpointOptions structure set at the breakpoint level.
///
/// Meant to be used by the BreakpointLocation class.
///
/// @return
/// A pointer to this breakpoint's BreakpointOptions.
//------------------------------------------------------------------
BreakpointOptions *
GetOptions ();
protected:
friend class Target;
friend class BreakpointLocation; // To call InvokeCallback
//------------------------------------------------------------------
/// Constructors and Destructors
/// Only the Target can make a breakpoint, and it owns the breakpoint lifespans.
/// The constructor takes a filter and a resolver. Up in Target there are convenience
/// variants that make breakpoints for some common cases.
//------------------------------------------------------------------
// This is the generic constructor
Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp);
//------------------------------------------------------------------
// Protected Methods
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Invoke the callback action when the breakpoint is hit.
///
/// Meant to be used by the BreakpointLocation class.
///
/// @param[in] context
/// Described the breakpoint event.
///
/// @param[in] bp_loc_id
/// Which breakpoint location hit this breakpoint.
///
/// @return
/// \b true if the target should stop at this breakpoint and \b false not.
//------------------------------------------------------------------
bool
InvokeCallback (StoppointCallbackContext *context,
lldb::break_id_t bp_loc_id);
protected:
//------------------------------------------------------------------
/// Returns the shared pointer that this breakpoint holds for the
/// breakpoint location passed in as \a bp_loc_ptr. Passing in a
/// breakpoint location that doesn't belong to this breakpoint will
/// cause an assert.
///
/// Meant to be used by the BreakpointLocation::GetSP() function.
///
/// @return
/// A copy of the shared pointer for the given location.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
GetLocationSP (BreakpointLocation *bp_loc_ptr);
private:
//------------------------------------------------------------------
// For Breakpoint only
//------------------------------------------------------------------
Target &m_target; // The target that holds this breakpoint.
lldb::SearchFilterSP m_filter_sp; // The filter that constrains the breakpoint's domain.
lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint.
BreakpointOptions m_options; // Settable breakpoint options
BreakpointLocationList m_locations; // The list of locations currently found for this breakpoint.
DISALLOW_COPY_AND_ASSIGN(Breakpoint);
};
} // namespace lldb_private
#endif // liblldb_Breakpoint_h_

View File

@ -0,0 +1,117 @@
//===-- BreakpointID.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_BreakpointID_h_
#define liblldb_BreakpointID_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
// class BreakpointID
//----------------------------------------------------------------------
class BreakpointID
{
public:
BreakpointID (lldb::break_id_t bp_id = LLDB_INVALID_BREAK_ID,
lldb::break_id_t loc_id = LLDB_INVALID_BREAK_ID);
virtual
~BreakpointID ();
lldb::break_id_t
GetBreakpointID ()
{
return m_break_id;
}
lldb::break_id_t
GetLocationID ()
{
return m_location_id;
}
void
SetID (lldb::break_id_t bp_id, lldb::break_id_t loc_id)
{
m_break_id = bp_id;
m_location_id = loc_id;
}
void
SetBreakpointID (lldb::break_id_t bp_id)
{
m_break_id = bp_id;
}
void
SetBreakpointLocationID (lldb::break_id_t loc_id)
{
m_location_id = loc_id;
}
void
GetDescription (Stream *s, lldb::DescriptionLevel level);
static bool
IsRangeIdentifier (const char *str);
static bool
IsValidIDExpression (const char *str);
static const char *g_range_specifiers[];
//------------------------------------------------------------------
/// Takes an input string containing the description of a breakpoint or breakpoint and location
/// and returns the breakpoint ID and the breakpoint location id.
///
/// @param[in] input
/// A string containing JUST the breakpoint description.
/// @param[out] break_id
/// This is the break id.
/// @param[out] break_loc_id
/// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no location was specified.
/// @return
/// \b true if the call was able to extract a breakpoint location from the string. \b false otherwise.
//------------------------------------------------------------------
static bool
ParseCanonicalReference (const char *input, lldb::break_id_t *break_id, lldb::break_id_t *break_loc_id);
//------------------------------------------------------------------
/// Takes a breakpoint ID and the breakpoint location id and returns
/// a string containing the canonical description for the breakpoint
/// or breakpoint location.
///
/// @param[out] break_id
/// This is the break id.
///
/// @param[out] break_loc_id
/// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no
/// location is to be specified.
//------------------------------------------------------------------
static void
GetCanonicalReference (Stream *s, lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
protected:
lldb::break_id_t m_break_id;
lldb::break_id_t m_location_id;
};
} // namespace lldb_private
#endif // liblldb_BreakpointID_h_

View File

@ -0,0 +1,82 @@
//===-- BreakpointIDList.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_BreakpointIDList_h_
#define liblldb_BreakpointIDList_h_
// C Includes
// C++ Includes
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/BreakpointID.h"
namespace lldb_private {
//----------------------------------------------------------------------
// class BreakpointIDList
//----------------------------------------------------------------------
class BreakpointIDList
{
public:
typedef std::vector<BreakpointID> BreakpointIDArray;
BreakpointIDList ();
virtual
~BreakpointIDList ();
int
Size();
BreakpointID &
GetBreakpointIDAtIndex (int index);
bool
RemoveBreakpointIDAtIndex (int index);
void
Clear();
bool
AddBreakpointID (BreakpointID bp_id);
bool
AddBreakpointID (const char *bp_id);
bool
FindBreakpointID (BreakpointID &bp_id, int *position);
bool
FindBreakpointID (const char *bp_id, int *position);
void
InsertStringArray (const char **string_array, int array_size, CommandReturnObject &result);
static bool
StringContainsIDRangeExpression (const char *in_string, int *range_start_len, int *range_end_pos);
static void
FindAndReplaceIDRanges (Args &old_args, Target *target, CommandReturnObject &result, Args &new_args);
private:
BreakpointIDArray m_breakpoint_ids;
BreakpointID m_invalid_id;
DISALLOW_COPY_AND_ASSIGN(BreakpointIDList);
};
} // namespace lldb_private
#endif // liblldb_BreakpointIDList_h_

View File

@ -0,0 +1,177 @@
//===-- BreakpointList.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_BreakpointList_h_
#define liblldb_BreakpointList_h_
// C Includes
// C++ Includes
#include <list>
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h"
/// @brief This class manages a list of breakpoints.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// Allows adding and removing breakpoints and find by ID and index.
//----------------------------------------------------------------------
class BreakpointList
{
public:
BreakpointList (bool is_internal);
~BreakpointList();
//------------------------------------------------------------------
/// Add the breakpoint \a bp_sp to the list.
///
/// @param[in] bp_sp
/// Shared pointer to the breakpoint that will get added to the list.
///
/// @result
/// Returns breakpoint id.
//------------------------------------------------------------------
virtual lldb::break_id_t
Add (lldb::BreakpointSP& bp_sp);
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint with id \a breakID.
///
/// @param[in] breakID
/// The breakpoint ID to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointSP
FindBreakpointByID (lldb::break_id_t breakID);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint with id \a breakID. Const version.
///
/// @param[in] breakID
/// The breakpoint ID to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointSP
FindBreakpointByID (lldb::break_id_t breakID) const;
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint with index \a i.
///
/// @param[in] i
/// The breakpoint index to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointSP
GetBreakpointByIndex (uint32_t i);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint with index \a i, const version
///
/// @param[in] i
/// The breakpoint index to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointSP
GetBreakpointByIndex (uint32_t i) const;
//------------------------------------------------------------------
/// Returns the number of elements in this breakpoint list.
///
/// @result
/// The number of elements.
//------------------------------------------------------------------
size_t
GetSize() const { return m_breakpoints.size(); }
//------------------------------------------------------------------
/// Removes the breakpoint given by \b breakID from this list.
///
/// @param[in] breakID
/// The breakpoint index to remove.
///
/// @result
/// \b true if the breakpoint \a breakID was in the list.
//------------------------------------------------------------------
bool
Remove (lldb::break_id_t breakID);
void
SetEnabledAll (bool enabled);
//------------------------------------------------------------------
/// Removes all the breakpoints from this list.
//------------------------------------------------------------------
void
RemoveAll ();
//------------------------------------------------------------------
/// Tell all the breakpoints to update themselves due to a change in the
/// modules in \a module_list. \a added says whether the module was loaded
/// or unloaded.
///
/// @param[in] module_list
/// The module list that has changed.
///
/// @param[in] added
/// \b true if the modules are loaded, \b false if unloaded.
//------------------------------------------------------------------
void
UpdateBreakpoints (ModuleList &module_list, bool added);
void
ClearAllBreakpointSites ();
protected:
typedef std::list<lldb::BreakpointSP> bp_collection;
bp_collection::iterator
GetBreakpointIDIterator(lldb::break_id_t breakID);
bp_collection::const_iterator
GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
mutable Mutex m_mutex;
bp_collection m_breakpoints; // The breakpoint list, currently a list.
lldb::break_id_t m_next_break_id;
bool m_is_internal;
private:
DISALLOW_COPY_AND_ASSIGN (BreakpointList);
};
} // namespace lldb_private
#endif // liblldb_BreakpointList_h_

View File

@ -0,0 +1,354 @@
//===-- BreakpointLocation.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_BreakpointLocation_h_
#define liblldb_BreakpointLocation_h_
// C Includes
// C++ Includes
#include <list>
#include <memory>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Target/Process.h"
#include "lldb/Core/StringList.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointLocation BreakpointLocation.h "lldb/Breakpoint/BreakpointLocation.h"
/// @brief Class that manages one unique (by address) instance of a logical breakpoint.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// A breakpoint location is defined by the breakpoint that produces it,
/// and the address that resulted in this particular instantiation.
/// Each breakpoint location also may have a breakpoint site if its
/// address has been loaded into the program.
/// Finally it has a settable options object.
///
/// FIXME: Should we also store some fingerprint for the location, so
/// we can map one location to the "equivalent location" on rerun? This
/// would be useful if you've set options on the locations.
//----------------------------------------------------------------------
class BreakpointLocation : public StoppointLocation
{
public:
~BreakpointLocation ();
//------------------------------------------------------------------
/// Gets the load address for this breakpoint location
/// @return
/// Returns breakpoint location load address, \b
/// LLDB_INVALID_ADDRESS if not yet set.
//------------------------------------------------------------------
lldb::addr_t
GetLoadAddress ();
//------------------------------------------------------------------
/// Gets the Address for this breakpoint location
/// @return
/// Returns breakpoint location Address.
//------------------------------------------------------------------
Address &
GetAddress ();
//------------------------------------------------------------------
/// Gets the Breakpoint that created this breakpoint location
/// @return
/// Returns the owning breakpoint.
//------------------------------------------------------------------
Breakpoint &
GetBreakpoint ();
//------------------------------------------------------------------
/// Determines whether we should stop due to a hit at this
/// breakpoint location.
///
/// Side Effects: This may evaluate the breakpoint condition, and
/// run the callback. So this command may do a considerable amount
/// of work.
///
/// @return
/// \b true if this breakpoint location thinks we should stop,
/// \b false otherwise.
//------------------------------------------------------------------
bool
ShouldStop (StoppointCallbackContext *context);
//------------------------------------------------------------------
// The next section deals with various breakpoint options.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// If \a enable is \b true, enable the breakpoint, if \b false
/// disable it.
//------------------------------------------------------------------
void
SetEnabled(bool enabled);
//------------------------------------------------------------------
/// Check the Enable/Disable state.
///
/// @return
/// \b true if the breakpoint is enabled, \b false if disabled.
//------------------------------------------------------------------
bool
IsEnabled ();
//------------------------------------------------------------------
/// Return the current Ignore Count.
///
/// @return
/// The number of breakpoint hits to be ignored.
//------------------------------------------------------------------
int32_t
GetIgnoreCount ();
//------------------------------------------------------------------
/// Set the breakpoint to ignore the next \a count breakpoint hits.
///
/// @param[in] count
/// The number of breakpoint hits to ignore.
//------------------------------------------------------------------
void
SetIgnoreCount (int32_t n);
//------------------------------------------------------------------
/// Set the callback action invoked when the breakpoint is hit.
///
/// The callback will return a bool indicating whether the target
/// should stop at this breakpoint or not.
///
/// @param[in] callback
/// The method that will get called when the breakpoint is hit.
///
/// @param[in] callback_baton_sp
/// A shared pointer to a Baton that provides the void * needed
/// for the callback.
///
/// @see lldb_private::Baton
//------------------------------------------------------------------
void
SetCallback (BreakpointHitCallback callback,
const lldb::BatonSP &callback_baton_sp,
bool is_synchronous);
void
SetCallback (BreakpointHitCallback callback,
void *baton,
bool is_synchronous);
void
ClearCallback ();
//------------------------------------------------------------------
/// Set the condition expression to be checked when the breakpoint is hit.
///
/// @param[in] expression
/// The method that will get called when the breakpoint is hit.
//------------------------------------------------------------------
void
SetCondition (void *condition);
//------------------------------------------------------------------
/// Set the valid thread to be checked when the breakpoint is hit.
///
/// @param[in] thread_id
/// If this thread hits the breakpoint, we stop, otherwise not.
//------------------------------------------------------------------
void
SetThreadID (lldb::tid_t thread_id);
//------------------------------------------------------------------
/// Return the current stop thread value.
///
/// @return
/// The thread id for which the breakpoint hit will stop,
/// LLDB_INVALID_THREAD_ID for all threads.
//------------------------------------------------------------------
lldb::tid_t
GetThreadID ();
//------------------------------------------------------------------
// The next section deals with this location's breakpoint sites.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Try to resolve the breakpoint site for this location.
///
/// @return
/// \b true if we were successful at setting a breakpoint site,
/// \b false otherwise.
//------------------------------------------------------------------
bool
ResolveBreakpointSite ();
//------------------------------------------------------------------
/// Clear this breakpoint location's breakpoint site - for instance
/// when disabling the breakpoint.
///
/// @return
/// \b true if there was a breakpoint site to be cleared, \b false
/// otherwise.
//------------------------------------------------------------------
bool
ClearBreakpointSite ();
//------------------------------------------------------------------
/// Return whether this breakpoint location has a breakpoint site.
/// @return
/// \b true if there was a breakpoint site for this breakpoint
/// location, \b false otherwise.
//------------------------------------------------------------------
bool
IsResolved () const;
//------------------------------------------------------------------
// The next section are generic report functions.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Print a description of this breakpoint location to the stream
/// \a s.
///
/// @param[in] s
/// The stream to which to print the description.
///
/// @param[in] level
/// The description level that indicates the detail level to
/// provide.
///
/// @see lldb::DescriptionLevel
//------------------------------------------------------------------
void
GetDescription (Stream *s, lldb::DescriptionLevel level);
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// Use this to set location specific breakpoint options.
///
/// It will create a copy of the containing breakpoint's options if
/// that hasn't been done already
///
/// @return
/// A pointer to the breakpoint options.
//------------------------------------------------------------------
BreakpointOptions *
GetLocationOptions ();
//------------------------------------------------------------------
/// Use this to access location specific breakpoint options.
///
/// @return
/// A pointer to the containing breakpoint's options if this
/// location doesn't have its own copy.
//------------------------------------------------------------------
BreakpointOptions *
GetOptionsNoCopy ();
protected:
friend class Breakpoint;
friend class CommandObjectBreakpointCommandAdd;
friend class Process;
//------------------------------------------------------------------
/// Invoke the callback action when the breakpoint is hit.
///
/// Meant to be used by the BreakpointLocation class.
///
/// @param[in] context
/// Described the breakpoint event.
///
/// @param[in] bp_loc_id
/// Which breakpoint location hit this breakpoint.
///
/// @return
/// \b true if the target should stop at this breakpoint and \b
/// false not.
//------------------------------------------------------------------
bool
InvokeCallback (StoppointCallbackContext *context);
//------------------------------------------------------------------
/// Set the breakpoint site for this location to \a bp_site_sp.
///
/// @param[in] bp_site_sp
/// The breakpoint site we are setting for this location.
///
/// @return
/// \b true if we were successful at setting the breakpoint site,
/// \b false otherwise.
//------------------------------------------------------------------
bool
SetBreakpointSite (lldb::BreakpointSiteSP& bp_site_sp);
private:
//------------------------------------------------------------------
// Constructors and Destructors
//
// Only the Breakpoint can make breakpoint locations, and it owns
// them.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Constructor.
///
/// @param[in] owner
/// A back pointer to the breakpoint that owns this location.
///
/// @param[in] addr
/// The Address defining this location.
///
/// @param[in] tid
/// The thread for which this breakpoint location is valid, or
/// LLDB_INVALID_THREAD_ID if it is valid for all threads.
///
/// @param[in] hardware
/// \b true if a hardware breakpoint is requested.
//------------------------------------------------------------------
BreakpointLocation (lldb::break_id_t bid,
Breakpoint &owner,
Address &addr,
lldb::tid_t tid = LLDB_INVALID_THREAD_ID,
bool hardware = false);
//------------------------------------------------------------------
// Data members:
//------------------------------------------------------------------
Address m_address; ///< The address defining this location.
Breakpoint &m_owner; ///< The breakpoint that produced this object.
std::auto_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, NULL if we're using our breakpoint's options.
lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.)
DISALLOW_COPY_AND_ASSIGN (BreakpointLocation);
};
} // namespace lldb_private
#endif // liblldb_BreakpointLocation_h_

View File

@ -0,0 +1,187 @@
//===-- BreakpointLocationCollection.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_BreakpointLocationCollection_h_
#define liblldb_BreakpointLocationCollection_h_
// C Includes
// C++ Includes
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
class BreakpointLocationCollection
{
public:
BreakpointLocationCollection();
~BreakpointLocationCollection();
//------------------------------------------------------------------
/// Add the breakpoint \a bp_loc_sp to the list.
///
/// @param[in] bp_sp
/// Shared pointer to the breakpoint location that will get added
/// to the list.
///
/// @result
/// Returns breakpoint location id.
//------------------------------------------------------------------
void
Add (const lldb::BreakpointLocationSP& bp_loc_sp);
//------------------------------------------------------------------
/// Removes the breakpoint location given by \b breakID from this
/// list.
///
/// @param[in] break_id
/// The breakpoint index to remove.
///
/// @param[in] break_loc_id
/// The breakpoint location index in break_id to remove.
///
/// @result
/// \b true if the breakpoint was in the list.
//------------------------------------------------------------------
bool
Remove (lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with id \a
/// breakID.
///
/// @param[in] break_id
/// The breakpoint ID to seek for.
///
/// @param[in] break_loc_id
/// The breakpoint location ID in \a break_id to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
FindByIDPair (lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with id \a
/// breakID, const version.
///
/// @param[in] breakID
/// The breakpoint location ID to seek for.
///
/// @param[in] break_loc_id
/// The breakpoint location ID in \a break_id to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
FindByIDPair (lldb::user_id_t break_id, lldb::user_id_t break_loc_id) const;
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with index
/// \a i.
///
/// @param[in] i
/// The breakpoint location index to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
GetByIndex (uint32_t i);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with index
/// \a i, const version.
///
/// @param[in] i
/// The breakpoint location index to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
GetByIndex (uint32_t i) const;
//------------------------------------------------------------------
/// Returns the number of elements in this breakpoint location list.
///
/// @result
/// The number of elements.
//------------------------------------------------------------------
size_t
GetSize() const { return m_break_loc_collection.size(); }
//------------------------------------------------------------------
/// Enquires of all the breakpoint locations in this list whether
/// we should stop at a hit at \a breakID.
///
/// @param[in] context
/// This contains the information about this stop.
///
/// @param[in] breakID
/// This break ID that we hit.
///
/// @return
/// \b true if we should stop, \b false otherwise.
//------------------------------------------------------------------
bool
ShouldStop (StoppointCallbackContext *context);
//------------------------------------------------------------------
/// Print a description of the breakpoint locations in this list
/// to the stream \a s.
///
/// @param[in] s
/// The stream to which to print the description.
///
/// @param[in] level
/// The description level that indicates the detail level to
/// provide.
///
/// @see lldb::DescriptionLevel
//------------------------------------------------------------------
void GetDescription (Stream *s, lldb::DescriptionLevel level);
protected:
//------------------------------------------------------------------
// Classes that inherit from BreakpointLocationCollection can see
// and modify these
//------------------------------------------------------------------
private:
//------------------------------------------------------------------
// For BreakpointLocationCollection only
//------------------------------------------------------------------
typedef std::vector<lldb::BreakpointLocationSP> collection;
collection::iterator
GetIDPairIterator(lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
collection::const_iterator
GetIDPairConstIterator(lldb::user_id_t break_id, lldb::user_id_t break_loc_id) const;
collection m_break_loc_collection;
};
} // namespace lldb_private
#endif // liblldb_BreakpointLocationCollection_h_

View File

@ -0,0 +1,285 @@
//===-- BreakpointLocationList.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_BreakpointLocationList_h_
#define liblldb_BreakpointLocationList_h_
// C Includes
// C++ Includes
#include <vector>
#include <map>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointLocationList BreakpointLocationList.h "lldb/Breakpoint/BreakpointLocationList.h"
/// @brief This class is used by Breakpoint to manage a list of breakpoint locations,
// each breakpoint location in the list
/// has a unique ID, and is unique by Address as well.
//----------------------------------------------------------------------
class BreakpointLocationList
{
// Only Breakpoints can make the location list, or add elements to it.
// This is not just some random collection of locations. Rather, the act of adding the location
// to this list sets its ID, and implicitly all the locations have the same breakpoint ID as
// well. If you need a generic container for breakpoint locations, use BreakpointLocationCollection.
friend class Breakpoint;
public:
~BreakpointLocationList();
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location at address
/// \a addr - const version.
///
/// @param[in] addr
/// The address to look for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
FindByAddress (Address &addr) const;
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with id \a
/// breakID.
///
/// @param[in] breakID
/// The breakpoint location ID to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
FindByID (lldb::user_id_t breakID);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with id
/// \a breakID, const version.
///
/// @param[in] breakID
/// The breakpoint location ID to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
FindByID (lldb::user_id_t breakID) const;
//------------------------------------------------------------------
/// Returns the breakpoint location id to the breakpoint location
/// at address \a addr.
///
/// @param[in] addr
/// The address to match.
///
/// @result
/// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
//------------------------------------------------------------------
lldb::user_id_t
FindIDByAddress (Address &addr);
//------------------------------------------------------------------
/// Returns a breakpoint location list of the breakpoint locations
/// in the module \a module. This list is allocated, and owned by
/// the caller.
///
/// @param[in] module
/// The module to seek in.
///
/// @param[in]
/// A breakpoint collection that gets any breakpoint locations
/// that match \a module appended to.
///
/// @result
/// The number of matches
//------------------------------------------------------------------
size_t
FindInModule (Module *module,
BreakpointLocationCollection& bp_loc_list);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with
/// index \a i.
///
/// @param[in] i
/// The breakpoint location index to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
GetByIndex (uint32_t i);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint location with index
/// \a i, const version.
///
/// @param[in] i
/// The breakpoint location index to seek for.
///
/// @result
/// A shared pointer to the breakpoint. May contain a NULL
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
GetByIndex (uint32_t i) const;
//------------------------------------------------------------------
/// Removes all the locations in this list from their breakpoint site
/// owners list.
//------------------------------------------------------------------
void
ClearAllBreakpointSites ();
//------------------------------------------------------------------
/// Tells all the breakopint locations in this list to attempt to
/// resolve any possible breakpoint sites.
//------------------------------------------------------------------
void
ResolveAllBreakpointSites ();
//------------------------------------------------------------------
/// Returns the number of breakpoint locations in this list with
/// resolved breakpoints.
///
/// @result
/// Number of qualifying breakpoint locations.
//------------------------------------------------------------------
size_t
GetNumResolvedLocations() const;
//------------------------------------------------------------------
/// Removes the breakpoint location given by \b breakID from this
/// list.
///
/// @param[in] breakID
/// The breakpoint location index to remove.
///
/// @result
/// \b true if the breakpoint \a breakID was in the list.
//------------------------------------------------------------------
bool
Remove (lldb::user_id_t breakID);
//------------------------------------------------------------------
/// Enquires of the breakpoint location in this list with ID \a
/// breakID whether we should stop.
///
/// @param[in] context
/// This contains the information about this stop.
///
/// @param[in] breakID
/// This break ID that we hit.
///
/// @return
/// \b true if we should stop, \b false otherwise.
//------------------------------------------------------------------
bool
ShouldStop (StoppointCallbackContext *context,
lldb::user_id_t breakID);
//------------------------------------------------------------------
/// Returns the number of elements in this breakpoint location list.
///
/// @result
/// The number of elements.
//------------------------------------------------------------------
size_t
GetSize() const
{
return m_locations.size();
}
//------------------------------------------------------------------
/// Print a description of the breakpoint locations in this list to
/// the stream \a s.
///
/// @param[in] s
/// The stream to which to print the description.
///
/// @param[in] level
/// The description level that indicates the detail level to
/// provide.
///
/// @see lldb::DescriptionLevel
//------------------------------------------------------------------
void
GetDescription (Stream *s,
lldb::DescriptionLevel level);
protected:
//------------------------------------------------------------------
/// This is the standard constructor.
///
/// It creates an empty breakpoint location list. It is protected
/// here because only Breakpoints are allowed to create the
/// breakpoint location list.
//------------------------------------------------------------------
BreakpointLocationList();
//------------------------------------------------------------------
/// Add the breakpoint \a bp_loc_sp to the list.
///
/// @param[in] bp_sp
/// Shared pointer to the breakpoint location that will get
/// added to the list.
///
/// @result
/// Returns breakpoint location id.
//------------------------------------------------------------------
virtual lldb::user_id_t
Add (lldb::BreakpointLocationSP& bp_loc_sp);
typedef std::vector<lldb::BreakpointLocationSP> collection;
typedef std::map<lldb_private::Address,
lldb::BreakpointLocationSP,
Address::ModulePointerAndOffsetLessThanFunctionObject> addr_map;
// The breakpoint locations are stored in their Parent Breakpoint's location list by an
// index that is unique to this list, and not across all breakpoint location lists.
// This is only set in the Breakpoint's AddLocation method.
// There is another breakpoint location list, the owner's list in the BreakpointSite,
// but that should not reset the ID. Unfortunately UserID's SetID method is public.
lldb::break_id_t
GetNextID();
collection::iterator
GetIDIterator(lldb::user_id_t breakID);
collection::const_iterator
GetIDConstIterator(lldb::user_id_t breakID) const;
collection m_locations;
addr_map m_address_to_location;
mutable Mutex m_mutex;
lldb::break_id_t m_next_id;
};
} // namespace lldb_private
#endif // liblldb_BreakpointLocationList_h_

View File

@ -0,0 +1,210 @@
//===-- BreakpointOptions.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_BreakpointOptions_h_
#define liblldb_BreakpointOptions_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Baton.h"
#include "lldb/Core/StringList.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointOptions BreakpointOptions.h "lldb/Breakpoint/BreakpointOptions.h"
/// @brief Class that manages the options on a breakpoint or breakpoint location.
//----------------------------------------------------------------------
class BreakpointOptions
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Default constructor. The breakpoint is enabled, and has no condition,
/// callback, ignore count, etc...
//------------------------------------------------------------------
BreakpointOptions();
BreakpointOptions(const BreakpointOptions& rhs);
//------------------------------------------------------------------
/// This constructor allows you to specify all the breakpoint options.
///
/// @param[in] condition
/// The expression which if it evaluates to \b true if we are to stop
///
/// @param[in] callback
/// This is the plugin for some code that gets run, returns \b true if we are to stop.
///
/// @param[in] baton
/// Client data that will get passed to the callback.
///
/// @param[in] enabled
/// Is this breakpoint enabled.
///
/// @param[in] ignore
/// How many breakpoint hits we should ignore before stopping.
///
/// @param[in] thread_id
/// Only stop if \a thread_id hits the breakpoint.
//------------------------------------------------------------------
BreakpointOptions(void *condition,
BreakpointHitCallback callback,
void *baton,
bool enabled = true,
int32_t ignore = 0,
lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
virtual ~BreakpointOptions();
//------------------------------------------------------------------
// Operators
//------------------------------------------------------------------
const BreakpointOptions&
operator=(const BreakpointOptions& rhs);
//------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------
void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
bool IsCallbackSynchronous () {
return m_callback_is_synchronous;
};
Baton *GetBaton ();
void ClearCallback ();
//------------------------------------------------------------------
// Enabled/Ignore Count
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Check the Enable/Disable state.
/// @return
/// \b true if the breakpoint is enabled, \b false if disabled.
//------------------------------------------------------------------
bool
IsEnabled () const;
//------------------------------------------------------------------
/// If \a enable is \b true, enable the breakpoint, if \b false disable it.
//------------------------------------------------------------------
void
SetEnabled (bool enabled);
void
SetIgnoreCount (int32_t n);
//------------------------------------------------------------------
/// Return the current Ignore Count.
/// @return
/// The number of breakpoint hits to be ignored.
//------------------------------------------------------------------
int32_t
GetIgnoreCount () const;
//------------------------------------------------------------------
/// Set the breakpoint to ignore the next \a count breakpoint hits.
/// @param[in] count
/// The number of breakpoint hits to ignore.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Return the current stop thread value.
/// @return
/// The thread id for which the breakpoint hit will stop,
/// LLDB_INVALID_THREAD_ID for all threads.
//------------------------------------------------------------------
lldb::tid_t
GetThreadID () const;
//------------------------------------------------------------------
/// Set the valid thread to be checked when the breakpoint is hit.
/// @param[in] thread_id
/// If this thread hits the breakpoint, we stop, otherwise not.
//------------------------------------------------------------------
void
SetThreadID (lldb::tid_t thread_id);
//------------------------------------------------------------------
/// This is the default empty callback.
/// @return
/// The thread id for which the breakpoint hit will stop,
/// LLDB_INVALID_THREAD_ID for all threads.
//------------------------------------------------------------------
static bool
NullCallback (void *baton,
StoppointCallbackContext *context,
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
struct CommandData
{
CommandData () :
user_source(),
script_source()
{
}
~CommandData ()
{
}
StringList user_source;
StringList script_source;
};
class CommandBaton : public Baton
{
public:
CommandBaton (CommandData *data) :
Baton (data)
{
}
virtual
~CommandBaton ()
{
delete ((CommandData *)m_data);
m_data = NULL;
}
virtual void
GetDescription (Stream *s, lldb::DescriptionLevel level) const;
};
protected:
//------------------------------------------------------------------
// Classes that inherit from BreakpointOptions can see and modify these
//------------------------------------------------------------------
private:
//------------------------------------------------------------------
// For BreakpointOptions only
//------------------------------------------------------------------
BreakpointHitCallback m_callback; // This is the callback function pointer
lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
bool m_callback_is_synchronous;
bool m_enabled;
int32_t m_ignore_count; // Number of times to ignore this breakpoint
lldb::tid_t m_thread_id; // Thread for which this breakpoint will take
};
} // namespace lldb_private
#endif // liblldb_BreakpointOptions_h_

View File

@ -0,0 +1,123 @@
//===-- BreakpointResolver.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_BreakpointResolver_h_
#define liblldb_BreakpointResolver_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Core/FileSpec.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/ConstString.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointResolver BreakpointResolver.h "lldb/Breakpoint/BreakpointResolver.h"
/// @brief This class works with SearchFilter to resolve logical breakpoints to their
/// of concrete breakpoint locations.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// The BreakpointResolver is a Searcher. In that protocol,
/// the SearchFilter asks the question "At what depth of the symbol context
/// descent do you want your callback to get called?" of the filter. The resolver
/// answers this question (in the GetDepth method) and provides the resolution callback.
/// Each Breakpoint has a BreakpointResolver, and it calls either ResolveBreakpoint
/// or ResolveBreakpointInModules to tell it to look for new breakpoint locations.
//----------------------------------------------------------------------
class BreakpointResolver :
public Searcher
{
public:
//------------------------------------------------------------------
/// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
/// to make sense. It can be constructed without a breakpoint, but you have to
/// call SetBreakpoint before ResolveBreakpoint.
///
/// @param[in] bkpt
/// The breakpoint that owns this resolver.
///
/// @result
/// Returns breakpoint location id.
//------------------------------------------------------------------
BreakpointResolver (Breakpoint *bkpt);
//------------------------------------------------------------------
/// The Destructor is virtual, all significant breakpoint resolvers derive
/// from this class.
//------------------------------------------------------------------
virtual
~BreakpointResolver ();
//------------------------------------------------------------------
/// This sets the breakpoint for this resolver.
///
/// @param[in] bkpt
/// The breakpoint that owns this resolver.
//------------------------------------------------------------------
void
SetBreakpoint (Breakpoint *bkpt);
//------------------------------------------------------------------
/// In response to this method the resolver scans all the modules in the breakpoint's
/// target, and adds any new locations it finds.
///
/// @param[in] filter
/// The filter that will manage the search for this resolver.
//------------------------------------------------------------------
virtual void
ResolveBreakpoint (SearchFilter &filter);
//------------------------------------------------------------------
/// In response to this method the resolver scans the modules in the module list
/// \a modules, and adds any new locations it finds.
///
/// @param[in] filter
/// The filter that will manage the search for this resolver.
//------------------------------------------------------------------
virtual void
ResolveBreakpointInModules (SearchFilter &filter,
ModuleList &modules);
//------------------------------------------------------------------
/// Prints a canonical description for the breakpoint to the stream \a s.
///
/// @param[in] s
/// Stream to which the output is copied.
//------------------------------------------------------------------
virtual void
GetDescription (Stream *s) = 0;
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
virtual void
Dump (Stream *s) const = 0;
protected:
Target *m_target; // Every resolver has a target.
Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
private:
DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
};
} // namespace lldb_private
#endif // liblldb_BreakpointResolver_h_

View File

@ -0,0 +1,68 @@
//===-- BreakpointResolverAddress.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_BreakpointResolverAddress_h_
#define liblldb_BreakpointResolverAddress_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointResolver.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointResolverAddress BreakpointResolverAddress.h "lldb/Breakpoint/BreakpointResolverAddress.h"
/// @brief This class sets breakpoints on a given Address. This breakpoint only takes
/// once, and then it won't attempt to reset itself.
//----------------------------------------------------------------------
class BreakpointResolverAddress:
public BreakpointResolver
{
public:
BreakpointResolverAddress (Breakpoint *bkpt,
const Address &addr);
virtual
~BreakpointResolverAddress ();
virtual void
ResolveBreakpoint (SearchFilter &filter);
virtual void
ResolveBreakpointInModules (SearchFilter &filter,
ModuleList &modules);
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
virtual Searcher::Depth
GetDepth ();
virtual void
GetDescription (Stream *s);
virtual void
Dump (Stream *s) const;
protected:
Address m_addr;
private:
DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
};
} // namespace lldb_private
#endif // liblldb_BreakpointResolverAddress_h_

View File

@ -0,0 +1,65 @@
//===-- BreakpointResolverFileLine.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_BreakpointResolverFileLine_h_
#define liblldb_BreakpointResolverFileLine_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointResolver.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h "lldb/Breakpoint/BreakpointResolverFileLine.h"
/// @brief This class sets breakpoints by file and line. Optionally, it will look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
class BreakpointResolverFileLine :
public BreakpointResolver
{
public:
BreakpointResolverFileLine (Breakpoint *bkpt,
const FileSpec &resolver,
uint32_t line_no,
bool check_inlines);
virtual
~BreakpointResolverFileLine ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
virtual Searcher::Depth
GetDepth ();
virtual void
GetDescription (Stream *s);
virtual void
Dump (Stream *s) const;
protected:
FileSpec m_file_spec; // This is the file spec we are looking for.
uint32_t m_line_number; // This is the line number that we are looking for.
bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
private:
DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);
};
} // namespace lldb_private
#endif // liblldb_BreakpointResolverFileLine_h_

View File

@ -0,0 +1,75 @@
//===-- BreakpointResolverName.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_BreakpointResolverName_h_
#define liblldb_BreakpointResolverName_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointResolver.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointResolverName BreakpointResolverName.h "lldb/Breakpoint/BreakpointResolverName.h"
/// @brief This class sets breakpoints on a given function name, either by exact match
/// or by regular expression.
//----------------------------------------------------------------------
class BreakpointResolverName:
public BreakpointResolver
{
public:
BreakpointResolverName (Breakpoint *bkpt,
const char *func_name,
Breakpoint::MatchType type = Breakpoint::Exact);
// Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex);
BreakpointResolverName (Breakpoint *bkpt,
const char *class_name,
const char *method,
Breakpoint::MatchType type);
virtual
~BreakpointResolverName ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
virtual Searcher::Depth
GetDepth ();
virtual void
GetDescription (Stream *s);
virtual void
Dump (Stream *s) const;
protected:
ConstString m_func_name;
ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop on methods of this class.
RegularExpression m_regex;
Breakpoint::MatchType m_match_type;
private:
DISALLOW_COPY_AND_ASSIGN(BreakpointResolverName);
};
} // namespace lldb_private
#endif // liblldb_BreakpointResolverName_h_

View File

@ -0,0 +1,258 @@
//===-- BreakpointSite.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_BreakpointSite_h_
#define liblldb_BreakpointSite_h_
// C Includes
// C++ Includes
#include <list>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointSite BreakpointSite.h "lldb/Breakpoint/BreakpointSite.h"
/// @brief Class that manages the actual breakpoint that will be inserted
/// into the running program.
///
/// The BreakpointSite class handles the physical breakpoint that is
/// actually inserted in the target program. As such, it is also the
/// one that gets hit, when the program stops. It keeps a list of all
/// BreakpointLocations that share this phsyical site. When the
/// breakpoint is hit, all the locations are informed by the breakpoint
/// site. Breakpoint sites are owned by the process.
//----------------------------------------------------------------------
class BreakpointSite : public StoppointLocation
{
public:
enum Type
{
eSoftware, // Breakpoint opcode has been written to memory and m_saved_opcode
// and m_trap_opcode contain the saved and written opcode.
eHardware, // Breakpoint site is set as a hardware breakpoint
eExternal // Breakpoint site is managed by an external debug nub or
// debug interface where memory reads trasparently will not
// display any breakpoint opcodes.
};
virtual ~BreakpointSite ();
//----------------------------------------------------------------------
// This section manages the breakpoint traps
//----------------------------------------------------------------------
//------------------------------------------------------------------
/// Returns the Opcode Bytes for this breakpoint
//------------------------------------------------------------------
uint8_t *
GetTrapOpcodeBytes ();
//------------------------------------------------------------------
/// Returns the Opcode Bytes for this breakpoint - const version
//------------------------------------------------------------------
const uint8_t *
GetTrapOpcodeBytes () const;
//------------------------------------------------------------------
/// Get the size of the trap opcode for this address
//------------------------------------------------------------------
size_t
GetTrapOpcodeMaxByteSize () const;
//------------------------------------------------------------------
/// Sets the trap opcode
//------------------------------------------------------------------
bool
SetTrapOpcode (const uint8_t *trap_opcode,
size_t trap_opcode_size);
//------------------------------------------------------------------
/// Gets the original instruction bytes that were overwritten by the trap
//------------------------------------------------------------------
uint8_t *
GetSavedOpcodeBytes ();
//------------------------------------------------------------------
/// Gets the original instruction bytes that were overwritten by the trap const version
//------------------------------------------------------------------
const uint8_t *
GetSavedOpcodeBytes () const;
//------------------------------------------------------------------
/// Says whether \a addr and size \a size intersects with the address \a intersect_addr
//------------------------------------------------------------------
bool
IntersectsRange (lldb::addr_t addr,
size_t size,
lldb::addr_t *intersect_addr,
size_t *intersect_size,
size_t *opcode_offset) const;
//------------------------------------------------------------------
/// Tells whether the current breakpoint site is enabled or not
///
/// This is a low-level enable bit for the breakpoint sites. If a
/// breakpoint site has no enabled owners, it should just get
/// removed. This enable/disable is for the low-level target code
/// to enable and disable breakpoint sites when single stepping,
/// etc.
//------------------------------------------------------------------
bool
IsEnabled () const;
//------------------------------------------------------------------
/// Sets whether the current breakpoint site is enabled or not
///
/// @param[in] enabled
/// \b true if the breakoint is enabled, \b false otherwise.
//------------------------------------------------------------------
void
SetEnabled (bool enabled);
//------------------------------------------------------------------
/// Enquires of the breakpoint locations that produced this breakpoint site whether
/// we should stop at this location.
///
/// @param[in] context
/// This contains the information about this stop.
///
/// @return
/// \b true if we should stop, \b false otherwise.
//------------------------------------------------------------------
virtual bool
ShouldStop (StoppointCallbackContext *context);
//------------------------------------------------------------------
/// Standard Dump method
///
/// @param[in] context
/// The stream to dump this output.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// The "Owners" are the breakpoint locations that share this
/// breakpoint site. The method adds the \a owner to this breakpoint
/// site's owner list.
///
/// @param[in] context
/// \a owner is the Breakpoint Location to add.
//------------------------------------------------------------------
void
AddOwner (lldb::BreakpointLocationSP &owner);
//------------------------------------------------------------------
/// This method returns the number of breakpoint locations currently
/// located at this breakpoint site.
///
/// @return
/// The number of owners.
//------------------------------------------------------------------
uint32_t
GetNumberOfOwners ();
//------------------------------------------------------------------
/// This method returns the the breakpoint location at index \a index
/// located at this breakpoint site. The owners are listed ordinally
/// from 0 to GetNumberOfOwners() - 1 so you can use this method to iterate
/// over the owners
///
/// @param[in] index
/// The index in the list of owners for which you wish the owner location.
/// @return
/// A shared pointer to the breakpoint location at that index.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
GetOwnerAtIndex (uint32_t index);
//------------------------------------------------------------------
/// Print a description of this breakpoint site to the stream \a s.
/// GetDescription tells you about the breakpoint site's owners.
/// Use BreakpointSite::Dump(Stream *) to get information about the
/// breakpoint site itself.
///
/// @param[in] s
/// The stream to which to print the description.
///
/// @param[in] level
/// The description level that indicates the detail level to
/// provide.
///
/// @see lldb::DescriptionLevel
//------------------------------------------------------------------
void
GetDescription (Stream *s,
lldb::DescriptionLevel level);
bool
IsBreakpointAtThisSite (lldb::break_id_t bp_id);
BreakpointSite::Type
GetType () const
{
return m_type;
}
void
SetType (BreakpointSite::Type type)
{
m_type = type;
}
private:
friend class Process;
//------------------------------------------------------------------
/// The method removes the owner at \a break_loc_id from this breakpoint list.
///
/// @param[in] context
/// \a break_loc_id is the Breakpoint Location to remove.
//------------------------------------------------------------------
uint32_t
RemoveOwner (lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
BreakpointSite::Type m_type;///< The type of this breakpoint site.
uint8_t m_saved_opcode[8]; ///< The saved opcode bytes if this breakpoint site uses trap opcodes.
uint8_t m_trap_opcode[8]; ///< The opcode that was used to create the breakpoint if it is a software breakpoint site.
bool m_enabled; ///< Boolean indicating if this breakpoint site enabled or not.
// Consider adding an optimization where if there is only one
// owner, we don't store a list. The usual case will be only one owner...
BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site.
static lldb::break_id_t
GetNextID();
// Only the Process can create breakpoint sites in
// Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool).
BreakpointSite (BreakpointSiteList *list,
lldb::BreakpointLocationSP& owner,
lldb::addr_t m_addr,
lldb::tid_t tid,
bool use_hardware);
DISALLOW_COPY_AND_ASSIGN(BreakpointSite);
};
} // namespace lldb_private
#endif // liblldb_BreakpointSite_h_

View File

@ -0,0 +1,217 @@
//===-- BreakpointSiteList.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_BreakpointSiteList_h_
#define liblldb_BreakpointSiteList_h_
// C Includes
// C++ Includes
#include <map>
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointSite.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class BreakpointSiteList BreakpointSiteList.h "lldb/Breakpoint/BreakpointSiteList.h"
/// @brief Class that manages lists of BreakpointSite shared pointers.
//----------------------------------------------------------------------
class BreakpointSiteList
{
// At present Process directly accesses the map of BreakpointSites so it can
// do quick lookups into the map (using GetMap).
// FIXME: Find a better interface for this.
friend class Process;
public:
//------------------------------------------------------------------
/// Default constructor makes an empty list.
//------------------------------------------------------------------
BreakpointSiteList();
//------------------------------------------------------------------
/// Destructor, currently does nothing.
//------------------------------------------------------------------
~BreakpointSiteList();
//------------------------------------------------------------------
/// Add a BreakpointSite to the list.
///
/// @param[in] bp_site_sp
/// A shared pointer to a breakpoint site being added to the list.
///
/// @return
/// The ID of the BreakpointSite in the list.
//------------------------------------------------------------------
lldb::user_id_t
Add (const lldb::BreakpointSiteSP& bp_site_sp);
//------------------------------------------------------------------
/// Standard Dump routine, doesn't do anything at present.
/// @param[in] s
/// Stream into which to dump the description.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint site at address
/// \a addr.
///
/// @param[in] addr
/// The address to look for.
///
/// @result
/// A shared pointer to the breakpoint site. May contain a NULL
/// pointer if no breakpoint site exists with a matching address.
//------------------------------------------------------------------
lldb::BreakpointSiteSP
FindByAddress (lldb::addr_t addr);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint site with id \a breakID.
///
/// @param[in] breakID
/// The breakpoint site ID to seek for.
///
/// @result
/// A shared pointer to the breakpoint site. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointSiteSP
FindByID (lldb::user_id_t breakID);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint site with id \a breakID - const version.
///
/// @param[in] breakID
/// The breakpoint site ID to seek for.
///
/// @result
/// A shared pointer to the breakpoint site. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointSiteSP
FindByID (lldb::user_id_t breakID) const;
//------------------------------------------------------------------
/// Returns the breakpoint site id to the breakpoint site at address \a addr.
///
/// @param[in] addr
/// The address to match.
///
/// @result
/// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
//------------------------------------------------------------------
lldb::user_id_t
FindIDByAddress (lldb::addr_t addr);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint site with index \a i.
///
/// @param[in] i
/// The breakpoint site index to seek for.
///
/// @result
/// A shared pointer to the breakpoint site. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointSiteSP
GetByIndex (uint32_t i);
//------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint site with index \a i - const version.
///
/// @param[in] i
/// The breakpoint site index to seek for.
///
/// @result
/// A shared pointer to the breakpoint site. May contain a NULL pointer if the
/// breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointSiteSP
GetByIndex (uint32_t i) const;
//------------------------------------------------------------------
/// Removes the breakpoint site given by \b breakID from this list.
///
/// @param[in] breakID
/// The breakpoint site index to remove.
///
/// @result
/// \b true if the breakpoint site \a breakID was in the list.
//------------------------------------------------------------------
bool
Remove (lldb::user_id_t breakID);
//------------------------------------------------------------------
/// Removes the breakpoint site at address \a addr from this list.
///
/// @param[in] addr
/// The address from which to remove a breakpoint site.
///
/// @result
/// \b true if \a addr had a breakpoint site to remove from the list.
//------------------------------------------------------------------
bool
RemoveByAddress (lldb::addr_t addr);
void
SetEnabledForAll(const bool enable, const lldb::user_id_t except_id = LLDB_INVALID_BREAK_ID);
typedef void (*BreakpointSiteSPMapFunc) (lldb::BreakpointSiteSP &bp, void *baton);
//------------------------------------------------------------------
/// Enquires of the breakpoint site on in this list with ID \a breakID whether
/// we should stop for the breakpoint or not.
///
/// @param[in] context
/// This contains the information about this stop.
///
/// @param[in] breakID
/// This break ID that we hit.
///
/// @return
/// \b true if we should stop, \b false otherwise.
//------------------------------------------------------------------
bool
ShouldStop (StoppointCallbackContext *context, lldb::user_id_t breakID);
//------------------------------------------------------------------
/// Returns the number of elements in the list.
///
/// @result
/// The number of elements.
//------------------------------------------------------------------
size_t
GetSize() const { return m_bp_site_list.size(); }
protected:
typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
collection::iterator
GetIDIterator(lldb::user_id_t breakID);
collection::const_iterator
GetIDConstIterator(lldb::user_id_t breakID) const;
// This function exposes the m_bp_site_list. I use the in Process because there
// are places there where you want to iterate over the list, and it is less efficient
// to do it by index. FIXME: Find a better way to do this.
const collection *
GetMap ();
collection m_bp_site_list; // The breakpoint site list.
};
} // namespace lldb_private
#endif // liblldb_BreakpointSiteList_h_

View File

@ -0,0 +1,63 @@
//===-- Stoppoint.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_Stoppoint_h_
#define liblldb_Stoppoint_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
namespace lldb_private {
class Stoppoint
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
Stoppoint();
virtual
~Stoppoint();
//------------------------------------------------------------------
// Methods
//------------------------------------------------------------------
virtual void
Dump (Stream *) = 0;
virtual bool
IsEnabled () = 0;
virtual void
SetEnabled (bool enable) = 0;
lldb::break_id_t
GetID () const;
void
SetID (lldb::break_id_t bid);
protected:
lldb::break_id_t m_bid;
private:
//------------------------------------------------------------------
// For Stoppoint only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Stoppoint);
};
} // namespace lldb_private
#endif // liblldb_Stoppoint_h_

View File

@ -0,0 +1,58 @@
//===-- StoppointCallbackContext.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_StoppointCallbackContext_h_
#define liblldb_StoppointCallbackContext_h_
#include "lldb/lldb-private.h"
#include "lldb/Target/ExecutionContext.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class StoppointCallbackContext StoppointCallbackContext.h "lldb/Breakpoint/StoppointCallbackContext.h"
/// @brief Class holds the information that a breakpoint callback needs to evaluate this stop.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// When we hit a breakpoint we need to package up whatever information is needed
/// to evaluate breakpoint commands and conditions. This class is the container of
/// that information.
//----------------------------------------------------------------------
class StoppointCallbackContext
{
public:
StoppointCallbackContext();
StoppointCallbackContext(Event *event, Process* process, Thread *thread = NULL, StackFrame * frame = NULL, bool synchronously = false);
//------------------------------------------------------------------
/// Clear the object's state.
///
/// Sets the event, process and thread to NULL, and the frame index to an
/// invalid value.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
Event *event; // This is the event, the callback can modify this to indicate
// the meaning of the breakpoint hit
ExecutionContext context; // This tells us where we have stopped, what thread.
bool is_synchronous; // Is the callback being executed synchronously with the breakpoint,
// or asynchronously as the event is retrieved?
};
} // namespace lldb_private
#endif // liblldb_StoppointCallbackContext_h_

View File

@ -0,0 +1,111 @@
//===-- StoppointLocation.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_StoppointLocation_h_
#define liblldb_StoppointLocation_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
// #include "lldb/Breakpoint/BreakpointOptions.h"
namespace lldb_private {
class StoppointLocation
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
StoppointLocation (lldb::break_id_t bid,
lldb::addr_t m_addr,
lldb::tid_t tid,
bool hardware);
StoppointLocation (lldb::break_id_t bid,
lldb::addr_t m_addr,
lldb::tid_t tid,
size_t size,
bool hardware);
virtual
~StoppointLocation ();
//------------------------------------------------------------------
// Operators
//------------------------------------------------------------------
//------------------------------------------------------------------
// Methods
//------------------------------------------------------------------
virtual lldb::addr_t
GetLoadAddress () const;
size_t
GetByteSize () const;
uint32_t
GetHitCount () const;
void
IncrementHitCount ();
uint32_t
GetHardwareIndex () const;
lldb::tid_t
GetThreadID() const;
bool
HardwarePreferred () const;
bool
IsHardware () const;
virtual bool
ShouldStop (StoppointCallbackContext *context);
virtual void
Dump (Stream *stream) const;
void
SetHardwareIndex (uint32_t index);
lldb::break_id_t
GetID () const;
protected:
//------------------------------------------------------------------
// Classes that inherit from StoppointLocation can see and modify these
//------------------------------------------------------------------
lldb::break_id_t m_loc_id; // Break ID
lldb::tid_t m_tid; // The thread ID if this stoppoint location is thread specific, or LLDB_INVALID_THREAD_ID if not thread specific.
lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't
// store a full Address since that's not needed for the breakpoint sites.
bool m_hw_preferred; // 1 if this point has been requested to be set using hardware (which may fail due to lack of resources)
uint32_t m_hw_index; // The hardware resource index for this breakpoint/watchpoint
uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length of the trap opcode for
// software breakpoints, or the optional length in bytes for
// hardware breakpoints, or the length of the watchpoint.
uint32_t m_hit_count; // Number of times this breakpoint has been hit
private:
//------------------------------------------------------------------
// For StoppointLocation only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
StoppointLocation(); // Disallow default constructor
};
} // namespace lldb_private
#endif // liblldb_StoppointLocation_h_

View File

@ -0,0 +1,69 @@
//===-- WatchpointLocation.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_WatchpointLocation_h_
#define liblldb_WatchpointLocation_h_
// C Includes
// C++ Includes
#include <list>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Breakpoint/StoppointLocation.h"
namespace lldb_private {
class WatchpointLocation :
public StoppointLocation
{
public:
WatchpointLocation (lldb::addr_t m_addr, lldb::tid_t tid, bool hardware);
~WatchpointLocation ();
bool
IsEnabled () const;
void
SetEnabled (uint32_t enabled);
bool WatchpointRead () const;
bool WatchpointWrite () const;
int32_t GetIgnoreCount () const;
void SetIgnoreCount (int32_t n);
void SetWatchpointType (uint32_t type);
bool BreakpointWasHit (StoppointCallbackContext *context);
bool SetCallback (WatchpointHitCallback callback, void *callback_baton);
void Dump (Stream *s) const;
private:
bool m_enabled; // Is this breakpoint enabled
uint32_t m_watch_read:1, // 1 if we stop when the watched data is read from
m_watch_write:1, // 1 if we stop when the watched data is written to
m_watch_was_read:1, // Set to 1 when watchpoint is hit for a read access
m_watch_was_written:1; // Set to 1 when watchpoint is hit for a write access
int32_t m_ignore_count; // Number of times to ignore this breakpoint
WatchpointHitCallback m_callback;
void * m_callback_baton; // Callback user data to pass to callback
static lldb::break_id_t
GetNextID();
DISALLOW_COPY_AND_ASSIGN (WatchpointLocation);
};
} // namespace lldb_private
#endif // liblldb_WatchpointLocation_h_

View File

@ -0,0 +1,425 @@
//===-- Address.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_Address_h_
#define liblldb_Address_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Symbol/SymbolContextScope.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Address Address.h "lldb/Core/Address.h"
/// @brief A section + offset based address class.
///
/// The Address class allows addresses to be relative to a section
/// that can move during runtime due to images (executables, shared
/// libraries, bundles, frameworks) being loaded at different
/// addresses than the addresses found in the object file that
/// represents them on disk. There are currently two types of addresses
/// for a section:
/// @li file addresses
/// @li load addresses
///
/// File addresses represent the virtual addresses that are in the "on
/// disk" object files. These virtual addresses are converted to be
/// relative to unique sections scoped to the object file so that
/// when/if the addresses slide when the images are loaded/unloaded
/// in memory, we can easily track these changes without having to
/// update every object (compile unit ranges, line tables, function
/// address ranges, lexical block and inlined subroutine address
/// ranges, global and static variables) each time an image is loaded or
/// unloaded.
///
/// Load addresses represent the virtual addresses where each section
/// ends up getting loaded at runtime. Before executing a program, it
/// is common for all of the load addresses to be unresolved. When a
/// DynamicLoader plug-in receives notification that shared libraries
/// have been loaded/unloaded, the load addresses of the main executable
/// and any images (shared libraries) will be resolved/unresolved. When
/// this happens, breakpoints that are in one of these sections can be
/// set/cleared.
//----------------------------------------------------------------------
class Address :
public SymbolContextScope
{
public:
//------------------------------------------------------------------
/// Dump styles allow the Address::Dump(Stream *,DumpStyle) const
/// function to display Address contents in a variety of ways.
//------------------------------------------------------------------
typedef enum {
DumpStyleInvalid, ///< Invalid dump style
DumpStyleSectionNameOffset, ///< Display as the section name + offset.
///< \code
/// // address for printf in libSystem.B.dylib as a section name + offset
/// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf
/// \endcode
DumpStyleSectionPointerOffset, ///< Display as the section pointer + offset (debug output).
///< \code
/// // address for printf in libSystem.B.dylib as a section pointer + offset
/// (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode
DumpStyleFileAddress, ///< Display as the file address (if any).
///< \code
/// // address for printf in libSystem.B.dylib as a file address
/// 0x000000000005dcff \endcode
DumpStyleModuleWithFileAddress, ///< Display as the file address with the module name prepended (if any).
///< \code
/// // address for printf in libSystem.B.dylib as a file address
/// libSystem.B.dylib[0x000000000005dcff] \endcode
DumpStyleLoadAddress, ///< Display as the load address (if resolved).
///< \code
/// // address for printf in libSystem.B.dylib as a load address
/// 0x00007fff8306bcff \endcode
DumpStyleResolvedDescription ///< Display the name that an address resolves to
} DumpStyle;
//------------------------------------------------------------------
/// Default constructor.
///
/// Initialize with a invalid section (NULL) and an invalid
/// offset (LLDB_INVALID_ADDRESS).
//------------------------------------------------------------------
Address ();
//------------------------------------------------------------------
/// Copy constructor
///
/// Makes a copy of the another Address object \a rhs.
///
/// @param[in] rhs
/// A const Address object reference to copy.
//------------------------------------------------------------------
Address (const Address& rhs);
//------------------------------------------------------------------
/// Construct with a section pointer and offset.
///
/// Initialize the address with the supplied \a section and \a
/// offset.
///
/// @param[in] section
/// A section pointer to a valid lldb::Section, or NULL if the
/// address doesn't have a section or will get resolved later.
///
/// @param[in] offset
/// The offset in bytes into \a section.
//------------------------------------------------------------------
Address (const Section* section, lldb::addr_t offset);
//------------------------------------------------------------------
/// Construct with a virtual address and section list.
///
/// Initialize and resolve the address with the supplied virtual
/// address \a file_addr.
///
/// @param[in] file_addr
/// A virtual file address.
///
/// @param[in] section_list
/// A list of sections, one of which may contain the \a file_addr.
//------------------------------------------------------------------
Address (lldb::addr_t file_addr, const SectionList * section_list);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~Address ();
//------------------------------------------------------------------
/// Assignment operator.
///
/// Copies the address value from another Address object \a rhs
/// into \a this object.
///
/// @param[in] rhs
/// A const Address object reference to copy.
///
/// @return
/// A const Address object reference to \a this.
//------------------------------------------------------------------
#ifndef SWIG
const Address&
operator= (const Address& rhs);
#endif
//------------------------------------------------------------------
/// Clear the object's state.
///
/// Sets the section to an invalid value (NULL) and an invalid
/// offset (LLDB_INVALID_ADDRESS).
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Compare two Address objects.
///
/// @param[in] lhs
/// The Left Hand Side const Address object reference.
///
/// @param[in] rhs
/// The Right Hand Side const Address object reference.
///
/// @return
/// @li -1 if lhs < rhs
/// @li 0 if lhs == rhs
/// @li 1 if lhs > rhs
//------------------------------------------------------------------
static int
CompareFileAddress (const Address& lhs, const Address& rhs);
static int
CompareLoadAddress (const Address& lhs, const Address& rhs, Process *process);
static int
CompareModulePointerAndOffset (const Address& lhs, const Address& rhs);
// For use with std::map, std::multi_map
class ModulePointerAndOffsetLessThanFunctionObject
{
public:
ModulePointerAndOffsetLessThanFunctionObject () {}
bool
operator() (const Address& a, const Address& b) const
{
return Address::CompareModulePointerAndOffset(a, b) < 0;
}
};
//------------------------------------------------------------------
/// Dump a description of this object to a Stream.
///
/// Dump a description of the contents of this object to the
/// supplied stream \a s. There are many ways to display a section
/// offset based address, and \a style lets the user choose.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
///
/// @param[in] style
/// The display style for the address.
///
/// @param[in] fallback_style
/// The display style for the address.
///
/// @return
/// Returns \b true if the address was able to be displayed.
/// File and load addresses may be unresolved and it may not be
/// possible to display a valid value, \b false will be returned
/// in such cases.
///
/// @see Address::DumpStyle
//------------------------------------------------------------------
bool
Dump (Stream *s,
ExecutionContextScope *exe_scope,
DumpStyle style,
DumpStyle fallback_style = DumpStyleInvalid) const;
//------------------------------------------------------------------
/// Dump a debug description of this object to a Stream.
///
/// Dump a debug description of the contents of this object to the
/// supplied stream \a s.
///
/// The debug description contains verbose internal state such
/// and pointer values, reference counts, etc.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//------------------------------------------------------------------
void
DumpDebug (Stream *s) const;
//------------------------------------------------------------------
/// Get the file address.
///
/// If an address comes from a file on disk that has section
/// relative addresses, then it has a virtual address that is
/// relative to unique section in the object file.
///
/// @return
/// The valid file virtual address, or LLDB_INVALID_ADDRESS if
/// the address doesn't have a file virtual address (image is
/// from memory only with no representation on disk).
//------------------------------------------------------------------
lldb::addr_t
GetFileAddress () const;
//------------------------------------------------------------------
/// Get the load address.
///
/// If an address comes from a file on disk that has section
/// relative addresses, then it has a virtual address that is
/// relative to unique section in the object file. Sections get
/// resolved at runtime by DynamicLoader plug-ins as images
/// (executables and shared libraries) get loaded/unloaded. If a
/// section is loaded, then the load address can be resolved.
///
/// @return
/// The valid load virtual address, or LLDB_INVALID_ADDRESS if
/// the address is currently not loaded.
//------------------------------------------------------------------
lldb::addr_t
GetLoadAddress (Process *process) const;
//------------------------------------------------------------------
/// Get the section relative offset value.
///
/// @return
/// The current offset, or LLDB_INVALID_ADDRESS if this address
/// doesn't contain a valid offset.
//------------------------------------------------------------------
lldb::addr_t
GetOffset () const;
//------------------------------------------------------------------
/// Check if an address is section offset.
///
/// When converting a virtual file or load address into a section
/// offset based address, we often need to know if, given a section
/// list, if the address was able to be converted to section offset.
/// This function returns true if the current value contained in
/// this object is section offset based.
///
/// @return
/// Returns \b true if the address has a valid section and
/// offset, \b false otherwise.
//------------------------------------------------------------------
bool
IsSectionOffset() const;
//------------------------------------------------------------------
/// Check if the object state is valid.
///
/// A valid Address object contains either a section pointer and
/// and offset (for section offset based addresses), or just a valid
/// offset (for absolute addresses that have no section).
///
/// @return
/// Returns \b true if the the offset is valid, \b false
/// otherwise.
//------------------------------------------------------------------
bool
IsValid() const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// @return
/// The number of bytes that this object occupies in memory.
//------------------------------------------------------------------
size_t
MemorySize () const;
//------------------------------------------------------------------
/// Resolve a file virtual address using a section list.
///
/// Given a list of sections, attempt to resolve \a addr as a
/// an offset into one of the file sections.
///
/// @return
/// Returns \b true if \a addr was able to be resolved, \b false
/// otherwise.
//------------------------------------------------------------------
bool
ResolveAddressUsingFileSections (lldb::addr_t addr, const SectionList *sections);
bool
IsLinkedAddress () const;
void
ResolveLinkedAddress ();
//------------------------------------------------------------------
/// Get accessor for the module for this address.
///
/// @return
/// Returns the Module pointer that this address is an offset
/// in, or NULL if this address doesn't belong in a module, or
/// isn't resolved yet.
//------------------------------------------------------------------
Module *
GetModule () const;
//------------------------------------------------------------------
/// Get const accessor for the section.
///
/// @return
/// Returns the const lldb::Section pointer that this address is an
/// offset in, or NULL if this address is absolute.
//------------------------------------------------------------------
const Section*
GetSection() const;
//------------------------------------------------------------------
/// Set accessor for the offset.
///
/// @param[in] offset
/// A new offset value for this object.
///
/// @return
/// Returns \b true if the offset changed, \b false otherwise.
//------------------------------------------------------------------
bool
SetOffset (lldb::addr_t offset);
//------------------------------------------------------------------
/// Set accessor for the section.
///
/// @param[in] section
/// A new lldb::Section pointer to use as the section base. Can
/// be NULL for absolute addresses that are not relative to
/// any section.
//------------------------------------------------------------------
void
SetSection (const Section* section);
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
void
CalculateSymbolContext (SymbolContext *sc);
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
void
DumpSymbolContext (Stream *s);
protected:
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
const Section* m_section; ///< The section for the address, can be NULL.
lldb::addr_t m_offset; ///< Offset into section if \a m_section != NULL, else the absolute address value.
};
//bool operator< (const Address& lhs, const Address& rhs);
//bool operator<= (const Address& lhs, const Address& rhs);
//bool operator> (const Address& lhs, const Address& rhs);
//bool operator>= (const Address& lhs, const Address& rhs);
bool operator== (const Address& lhs, const Address& rhs);
bool operator!= (const Address& lhs, const Address& rhs);
//Stream& operator << (Stream& strm, const Address& so_addr);
} // namespace lldb_private
#endif // liblldb_Address_h_

View File

@ -0,0 +1,280 @@
//===-- AddressRange.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_AddressRange_h_
#define liblldb_AddressRange_h_
#include "lldb/Core/Address.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class AddressRange AddressRange.h "lldb/Core/AddressRange.h"
/// @brief A section + offset based address range class.
//----------------------------------------------------------------------
class AddressRange
{
public:
//------------------------------------------------------------------
/// Default constructor.
///
/// Initialize with a invalid section (NULL), an invalid
/// offset (LLDB_INVALID_ADDRESS), and zero byte size.
//------------------------------------------------------------------
AddressRange ();
//------------------------------------------------------------------
/// Construct with a section pointer, offset, and byte_size.
///
/// Initialize the address with the supplied \a section, \a
/// offset and \a byte_size.
///
/// @param[in] section
/// A section pointer to a valid lldb::Section, or NULL if the
/// address doesn't have a section or will get resolved later.
///
/// @param[in] offset
/// The offset in bytes into \a section.
///
/// @param[in] byte_size
/// The size in bytes of the address range.
//------------------------------------------------------------------
AddressRange (const Section* section, lldb::addr_t offset, lldb::addr_t byte_size);
//------------------------------------------------------------------
/// Construct with a virtual address, section list and byte size.
///
/// Initialize and resolve the address with the supplied virtual
/// address \a file_addr, and byte size \a byte_size.
///
/// @param[in] file_addr
/// A virtual address.
///
/// @param[in] byte_size
/// The size in bytes of the address range.
///
/// @param[in] section_list
/// A list of sections, one of which may contain the \a vaddr.
//------------------------------------------------------------------
AddressRange (lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = NULL);
//------------------------------------------------------------------
/// Construct with a Address object address and byte size.
///
/// Initialize by copying the section offset address in \a so_addr,
/// and setting the byte size to \a byte_size.
///
/// @param[in] so_addr
/// A section offset address object.
///
/// @param[in] byte_size
/// The size in bytes of the address range.
//------------------------------------------------------------------
AddressRange (const Address& so_addr, lldb::addr_t byte_size);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual in case this class is subclassed.
//------------------------------------------------------------------
~AddressRange ();
//------------------------------------------------------------------
/// Clear the object's state.
///
/// Sets the section to an invalid value (NULL), an invalid offset
/// (LLDB_INVALID_ADDRESS) and a zero byte size.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Check if a section offset address is contained in this range.
///
/// @param[in] so_addr
/// A section offset address object reference.
///
/// @return
/// Returns \b true if \a so_addr is contained in this range,
/// \b false otherwise.
//------------------------------------------------------------------
// bool
// Contains (const Address &so_addr) const;
//------------------------------------------------------------------
/// Check if a section offset address is contained in this range.
///
/// @param[in] so_addr_ptr
/// A section offset address object pointer.
///
/// @return
/// Returns \b true if \a so_addr is contained in this range,
/// \b false otherwise.
//------------------------------------------------------------------
// bool
// Contains (const Address *so_addr_ptr) const;
//------------------------------------------------------------------
/// Check if a section offset \a so_addr when represented as a file
/// address is contained within this object's file address range.
///
/// @param[in] so_addr
/// A section offset address object reference.
///
/// @return
/// Returns \b true if both \a this and \a so_addr have
/// resolvable file address values and \a so_addr is contained
/// in the address range, \b false otherwise.
//------------------------------------------------------------------
bool
ContainsFileAddress (const Address &so_addr) const;
//------------------------------------------------------------------
/// Check if the resolved file address \a file_addr is contained
/// within this object's file address range.
///
/// @param[in] so_addr
/// A section offset address object reference.
///
/// @return
/// Returns \b true if both \a this has a resolvable file
/// address value and \a so_addr is contained in the address
/// range, \b false otherwise.
//------------------------------------------------------------------
bool
ContainsFileAddress (lldb::addr_t file_addr) const;
//------------------------------------------------------------------
/// Check if a section offset \a so_addr when represented as a load
/// address is contained within this object's load address range.
///
/// @param[in] so_addr
/// A section offset address object reference.
///
/// @return
/// Returns \b true if both \a this and \a so_addr have
/// resolvable load address values and \a so_addr is contained
/// in the address range, \b false otherwise.
//------------------------------------------------------------------
bool
ContainsLoadAddress (const Address &so_addr, Process *process) const;
//------------------------------------------------------------------
/// Check if the resolved load address \a load_addr is contained
/// within this object's load address range.
///
/// @param[in] so_addr
/// A section offset address object reference.
///
/// @return
/// Returns \b true if both \a this has a resolvable load
/// address value and \a so_addr is contained in the address
/// range, \b false otherwise.
//------------------------------------------------------------------
bool
ContainsLoadAddress (lldb::addr_t load_addr, Process *process) const;
//------------------------------------------------------------------
/// Dump a description of this object to a Stream.
///
/// Dump a description of the contents of this object to the
/// supplied stream \a s. There are many ways to display a section
/// offset based address range, and \a style lets the user choose
/// how the base address gets displayed.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
///
/// @param[in] style
/// The display style for the address.
///
/// @return
/// Returns \b true if the address was able to be displayed.
/// File and load addresses may be unresolved and it may not be
/// possible to display a valid value, \b false will be returned
/// in such cases.
///
/// @see Address::DumpStyle
//------------------------------------------------------------------
bool
Dump (Stream *s, Process *process, Address::DumpStyle style, Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const;
//------------------------------------------------------------------
/// Dump a debug description of this object to a Stream.
///
/// Dump a debug description of the contents of this object to the
/// supplied stream \a s.
///
/// The debug description contains verbose internal state such
/// and pointer values, reference counts, etc.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//------------------------------------------------------------------
void
DumpDebug (Stream *s) const;
//------------------------------------------------------------------
/// Get accessor for the base address of the range.
///
/// @return
/// A reference to the base address object.
//------------------------------------------------------------------
Address &
GetBaseAddress();
//------------------------------------------------------------------
/// Get const accessor for the base address of the range.
///
/// @return
/// A const reference to the base address object.
//------------------------------------------------------------------
const Address &
GetBaseAddress() const;
//------------------------------------------------------------------
/// Get accessor for the byte size of this range.
///
/// @return
/// The size in bytes of this address range.
//------------------------------------------------------------------
lldb::addr_t
GetByteSize () const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// @return
/// The number of bytes that this object occupies in memory.
//------------------------------------------------------------------
size_t
MemorySize () const;
//------------------------------------------------------------------
/// Set accessor for the byte size of this range.
///
/// @param[in] byte_size
/// The new size in bytes of this address range.
//------------------------------------------------------------------
void
SetByteSize (lldb::addr_t byte_size);
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
Address m_base_addr; ///< The section offset base address of this range.
lldb::addr_t m_byte_size; ///< The size in bytes of this address range.
};
//bool operator== (const AddressRange& lhs, const AddressRange& rhs);
} // namespace lldb_private
#endif // liblldb_AddressRange_h_

View File

@ -0,0 +1,90 @@
//===-- AddressResolver.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_AddressResolver_h_
#define liblldb_AddressResolver_h_
#include <vector>
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/FileSpec.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/ConstString.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h"
/// @brief This class works with SearchFilter to resolve function names and
/// source file locations to their concrete addresses.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// The AddressResolver is a Searcher. In that protocol,
/// the SearchFilter asks the question "At what depth of the symbol context
/// descent do you want your callback to get called?" of the filter. The resolver
/// answers this question (in the GetDepth method) and provides the resolution callback.
//----------------------------------------------------------------------
class AddressResolver :
public Searcher
{
public:
typedef enum
{
Exact,
Regexp,
Glob
} MatchType;
AddressResolver ();
virtual
~AddressResolver ();
virtual void
ResolveAddress (SearchFilter &filter);
virtual void
ResolveAddressInModules (SearchFilter &filter,
ModuleList &modules);
virtual void
GetDescription (Stream *s) = 0;
std::vector<AddressRange> &
GetAddressRanges ();
size_t
GetNumberOfAddresses ();
AddressRange &
GetAddressRangeAtIndex (size_t idx);
protected:
std::vector<AddressRange> m_address_ranges;
private:
DISALLOW_COPY_AND_ASSIGN(AddressResolver);
};
} // namespace lldb_private
#endif // liblldb_AddressResolver_h_

View File

@ -0,0 +1,59 @@
//===-- AddressResolverFileLine.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_AddressResolverFileLine_h_
#define liblldb_AddressResolverFileLine_h_
// Project includes
#include "lldb/Core/AddressResolver.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class AddressResolverFileLine AddressResolverFileLine.h "lldb/Core/AddressResolverFileLine.h"
/// @brief This class finds address for source file and line. Optionally, it will look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
class AddressResolverFileLine :
public AddressResolver
{
public:
AddressResolverFileLine (const FileSpec &resolver,
uint32_t line_no,
bool check_inlines);
virtual
~AddressResolverFileLine ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
virtual Searcher::Depth
GetDepth ();
virtual void
GetDescription (Stream *s);
protected:
FileSpec m_file_spec; // This is the file spec we are looking for.
uint32_t m_line_number; // This is the line number that we are looking for.
bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
private:
DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine);
};
} // namespace lldb_private
#endif // liblldb_AddressResolverFileLine_h_

View File

@ -0,0 +1,67 @@
//===-- AddressResolverName.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_AddressResolverName_h_
#define liblldb_AddressResolverName_h_
// Project includes
#include "lldb/Core/AddressResolver.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class AddressResolverName AddressResolverName.h "lldb/Core/AddressResolverName.h"
/// @brief This class finds addresses for a given function name, either by exact match
/// or by regular expression.
//----------------------------------------------------------------------
class AddressResolverName:
public AddressResolver
{
public:
AddressResolverName (const char *func_name,
AddressResolver::MatchType type = Exact);
// Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
AddressResolverName (RegularExpression &func_regex);
AddressResolverName (const char *class_name,
const char *method,
AddressResolver::MatchType type);
virtual
~AddressResolverName ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
virtual Searcher::Depth
GetDepth ();
virtual void
GetDescription (Stream *s);
protected:
ConstString m_func_name;
ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop on methods of this class.
RegularExpression m_regex;
AddressResolver::MatchType m_match_type;
private:
DISALLOW_COPY_AND_ASSIGN(AddressResolverName);
};
} // namespace lldb_private
#endif // liblldb_AddressResolverName_h_

View File

@ -0,0 +1,326 @@
//===-- ArchSpec.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_ArchSpec_h_
#define liblldb_ArchSpec_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
/// @brief An architecture specification class.
///
/// A class designed to be created from a cpu type and subtype, or a
/// string representation. Keeping all of the conversions of strings
/// to architecture enumeration values confined to this class allows
/// new architecture support to be added easily.
//----------------------------------------------------------------------
class ArchSpec
{
public:
//------------------------------------------------------------------
/// Default constructor.
///
/// Default constructor that initializes the object with invalid
/// cpu type and subtype values.
//------------------------------------------------------------------
ArchSpec ();
//------------------------------------------------------------------
/// Constructor with cpu type and subtype.
///
/// Constructor that initializes the object with supplied cpu and
/// subtypes.
//------------------------------------------------------------------
ArchSpec (uint32_t cpu, uint32_t sub);
//------------------------------------------------------------------
/// Construct with architecture name.
///
/// Constructor that initializes the object with supplied
/// architecture name. There are also predefined values in
/// Defines.h:
/// @li \c LLDB_ARCH_DEFAULT
/// The arch the current system defaults to when a program is
/// launched without any extra attributes or settings.
///
/// @li \c LLDB_ARCH_DEFAULT_32BIT
/// The 32 bit arch the current system defaults to (if any)
///
/// @li \c LLDB_ARCH_DEFAULT_32BIT
/// The 64 bit arch the current system defaults to (if any)
//------------------------------------------------------------------
ArchSpec (const char *arch_name);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual in case this class is subclassed.
//------------------------------------------------------------------
virtual
~ArchSpec ();
//------------------------------------------------------------------
/// Assignment operator.
///
/// @param[in] rhs another ArchSpec object to copy.
///
/// @return a const reference to this object
//------------------------------------------------------------------
const ArchSpec&
operator= (const ArchSpec& rhs);
//------------------------------------------------------------------
/// Get a string representation of the contained architecture.
///
/// Gets a C string representation of the current architecture.
/// If the returned string is a valid architecture name, the string
/// came from a constant string values that do not need to be freed.
/// If the returned string uses the "N.M" format, the string comes
/// from a static buffer that should be copied.
///
/// @return a NULL terminated C string that does not need to be
/// freed.
//------------------------------------------------------------------
const char *
AsCString () const;
//------------------------------------------------------------------
/// Returns a string representation of the supplied architecture.
///
/// Class function to get a C string representation given a CPU type
/// and subtype.
///
/// @param[in] cpu The cpu type of the architecture.
/// @param[in] subtype The cpu subtype of the architecture.
///
/// @return a NULL terminated C string that does not need to be
/// freed.
//------------------------------------------------------------------
static const char *
AsCString (uint32_t cpu, uint32_t subtype);
//------------------------------------------------------------------
/// Clears the object state.
///
/// Clears the object state back to a default invalid state.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Returns the size in bytes of an address of the current
/// architecture.
///
/// @return The byte size of an address of the current architecture.
//------------------------------------------------------------------
uint32_t
GetAddressByteSize () const;
//------------------------------------------------------------------
/// CPU subtype get accessor.
///
/// @return The current value of the CPU subtype.
//------------------------------------------------------------------
uint32_t
GetCPUSubtype () const;
//------------------------------------------------------------------
/// CPU type get accessor.
///
/// @return The current value of the CPU type.
//------------------------------------------------------------------
uint32_t
GetCPUType () const;
//------------------------------------------------------------------
/// Feature flags get accessor.
///
/// @return The current value of the CPU feature flags.
//------------------------------------------------------------------
uint32_t
GetFeatureFlags () const;
//------------------------------------------------------------------
/// Get register names of the current architecture.
///
/// Get register names of the current architecture given
/// a register number, and a flavor for that register number.
/// There are many different register numbering schemes used
/// on a host:
/// @li \c eRegisterKindGCC - gcc compiler register numbering
/// @li \c eRegisterKindDWARF - DWARF register numbering
///
/// @param[in] reg_num The register number to decode.
/// @param[in] flavor The flavor of the \a reg_num.
///
/// @return the name of the register as a NULL terminated C string,
/// or /c NULL if the \a reg_num is invalid for \a flavor.
/// String values that are returned do not need to be freed.
//------------------------------------------------------------------
const char *
GetRegisterName (uint32_t reg_num, uint32_t flavor) const;
//------------------------------------------------------------------
/// Get register names for a specified architecture.
///
/// Get register names of the specified architecture given
/// a register number, and a flavor for that register number.
/// There are many different register numbering schemes used
/// on a host:
///
/// @li compiler register numbers (@see eRegisterKindGCC)
/// @li DWARF register numbers (@see eRegisterKindDWARF)
///
/// @param[in] cpu The cpu type of the architecture specific
/// register
/// @param[in] subtype The cpu subtype of the architecture specific
/// register
/// @param[in] reg_num The register number to decode.
/// @param[in] flavor The flavor of the \a reg_num.
///
/// @return the name of the register as a NULL terminated C string,
/// or /c NULL if the \a reg_num is invalid for \a flavor.
/// String values that are returned do not need to be freed.
//------------------------------------------------------------------
static const char *
GetRegisterName (uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t flavor);
//------------------------------------------------------------------
/// Test if the contained architecture is valid.
///
/// @return true if the current architecture is valid, false
/// otherwise.
//------------------------------------------------------------------
bool
IsValid () const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// @return
/// The number of bytes that this object occupies in memory.
//------------------------------------------------------------------
size_t
MemorySize() const;
//------------------------------------------------------------------
/// Change the CPU type and subtype given an architecture name.
///
/// The architecture name supplied can also by one of the generic
/// system default values:
/// @li \c LLDB_ARCH_DEFAULT - The arch the current system defaults
/// to when a program is launched without any extra
/// attributes or settings.
/// @li \c LLDB_ARCH_DEFAULT_32BIT - The default host architecture
/// for 32 bit (if any).
/// @li \c LLDB_ARCH_DEFAULT_64BIT - The default host architecture
/// for 64 bit (if any).
///
/// @param[in] arch_name The name of an architecture.
///
/// @return true if \a arch_name was successfully transformed into
/// a valid cpu type and subtype.
//------------------------------------------------------------------
bool
SetArch (const char *arch_name);
bool
SetArchFromTargetTriple (const char *arch_name);
//------------------------------------------------------------------
/// Change the CPU type and subtype given new values of the cpu
/// type and subtype.
///
/// @param[in] cpu The new CPU type
/// @param[in] subtype The new CPU subtype
//------------------------------------------------------------------
void
SetArch (uint32_t cpu, uint32_t subtype);
//------------------------------------------------------------------
/// Change the CPU subtype given a new value of the CPU subtype.
///
/// @param[in] subtype The new CPU subtype.
//------------------------------------------------------------------
void
SetCPUSubtype (uint32_t subtype);
//------------------------------------------------------------------
/// Change the CPU type given a new value of the CPU type.
///
/// @param[in] cpu The new CPU type.
//------------------------------------------------------------------
void
SetCPUType (uint32_t cpu);
//------------------------------------------------------------------
/// Returns the default endianness of the architecture.
///
/// @return The endian enumeration for the default endianness of
/// the architecture.
//------------------------------------------------------------------
lldb::ByteOrder
GetDefaultEndian () const;
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
uint32_t m_cpu; ///< The cpu type of the architecture
uint32_t m_sub; ///< The cpu subtype of the architecture
};
//------------------------------------------------------------------
/// @fn bool operator== (const ArchSpec& lhs, const ArchSpec& rhs)
/// @brief Equal to operator.
///
/// Tests two ArchSpec objects to see if they are equal.
///
/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
///
/// @return true if \a lhs is equal to \a rhs
//------------------------------------------------------------------
bool operator==(const ArchSpec& lhs, const ArchSpec& rhs);
//------------------------------------------------------------------
/// @fn bool operator!= (const ArchSpec& lhs, const ArchSpec& rhs)
/// @brief Not equal to operator.
///
/// Tests two ArchSpec objects to see if they are not equal.
///
/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
///
/// @return true if \a lhs is not equal to \a rhs
//------------------------------------------------------------------
bool operator!=(const ArchSpec& lhs, const ArchSpec& rhs);
//------------------------------------------------------------------
/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs)
/// @brief Less than operator.
///
/// Tests two ArchSpec objects to see if \a lhs is less than \a
/// rhs.
///
/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
///
/// @return true if \a lhs is less than \a rhs
//------------------------------------------------------------------
bool operator< (const ArchSpec& lhs, const ArchSpec& rhs);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // #ifndef liblldb_ArchSpec_h_

View File

@ -0,0 +1,368 @@
//===-- Args.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_Command_h_
#define liblldb_Command_h_
// C Includes
#include <getopt.h>
// C++ Includes
#include <list>
#include <string>
#include <vector>
#include <utility>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Error.h"
#include "lldb/lldb-types.h"
namespace lldb_private {
typedef std::pair<std::string, std::string> OptionArgPair;
typedef std::vector<OptionArgPair> OptionArgVector;
typedef lldb::SharedPtr<OptionArgVector>::Type OptionArgVectorSP;
struct OptionArgElement
{
OptionArgElement (int defs_index, int pos, int arg_pos) :
opt_defs_index(defs_index),
opt_pos (pos),
opt_arg_pos (arg_pos)
{
}
int opt_defs_index;
int opt_pos;
int opt_arg_pos;
};
typedef std::vector<OptionArgElement> OptionElementVector;
//----------------------------------------------------------------------
/// @class Args Args.h "lldb/Core/Args.h"
/// @brief A command line argument class.
///
/// The Args class is designed to be fed a command line. The
/// command line is copied into an internal buffer and then split up
/// into arguments. Arguments are space delimited if there are no quotes
/// (single, double, or backtick quotes) surrounding the argument. Spaces
/// can be escaped using a \ character to avoid having to surround an
/// argument that contains a space with quotes.
//----------------------------------------------------------------------
class Args
{
public:
//------------------------------------------------------------------
/// Construct with an option command string.
///
/// @param[in] command
/// A NULL terminated command that will be copied and split up
/// into arguments.
///
/// @see Args::SetCommandString(const char *)
//------------------------------------------------------------------
Args (const char *command = NULL);
Args (const char *command, size_t len);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~Args();
//------------------------------------------------------------------
/// Dump all arguments to the stream \a s.
///
/// @param[in] s
/// The stream to which to dump all arguments in the argument
/// vector.
//------------------------------------------------------------------
void
Dump (Stream *s);
//------------------------------------------------------------------
/// Sets the command string contained by this object.
///
/// The command string will be copied and split up into arguments
/// that can be accessed via the accessor functions.
///
/// @param[in] command
/// A NULL terminated command that will be copied and split up
/// into arguments.
///
/// @see Args::GetArgumentCount() const
/// @see Args::GetArgumentAtIndex (size_t) const
/// @see Args::GetArgumentVector ()
/// @see Args::Shift ()
/// @see Args::Unshift (const char *)
//------------------------------------------------------------------
void
SetCommandString (const char *command);
void
SetCommandString (const char *command, size_t len);
bool
GetCommandString (std::string &command);
//------------------------------------------------------------------
/// Gets the number of arguments left in this command object.
///
/// @return
/// The number or arguments in this object.
//------------------------------------------------------------------
size_t
GetArgumentCount () const;
//------------------------------------------------------------------
/// Gets the NULL terminated C string argument pointer for the
/// argument at index \a idx.
///
/// @return
/// The NULL terminated C string argument pointer if \a idx is a
/// valid argument index, NULL otherwise.
//------------------------------------------------------------------
const char *
GetArgumentAtIndex (size_t idx) const;
char
GetArgumentQuoteCharAtIndex (size_t idx) const;
//------------------------------------------------------------------
/// Gets the argument vector.
///
/// The value returned by this function can be used by any function
/// that takes and vector. The return value is just like \a argv
/// in the standard C entry point function:
/// \code
/// int main (int argc, const char **argv);
/// \endcode
///
/// @return
/// An array of NULL terminated C string argument pointers that
/// also has a terminating NULL C string pointer
//------------------------------------------------------------------
char **
GetArgumentVector ();
//------------------------------------------------------------------
/// Gets the argument vector.
///
/// The value returned by this function can be used by any function
/// that takes and vector. The return value is just like \a argv
/// in the standard C entry point function:
/// \code
/// int main (int argc, const char **argv);
/// \endcode
///
/// @return
/// An array of NULL terminate C string argument pointers that
/// also has a terminating NULL C string pointer
//------------------------------------------------------------------
const char **
GetConstArgumentVector () const;
//------------------------------------------------------------------
/// Appends a new argument to the end of the list argument list.
///
/// @param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
///
/// @return
/// The NULL terminated C string of the copy of \a arg_cstr.
//------------------------------------------------------------------
const char *
AppendArgument (const char *arg_cstr, char quote_char = '\0');
void
AppendArguments (const Args &rhs);
//------------------------------------------------------------------
/// Insert the argument value at index \a idx to \a arg_cstr.
///
/// @param[in] idx
/// The index of where to insert the argument.
///
/// @param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
///
/// @return
/// The NULL terminated C string of the copy of \a arg_cstr.
//------------------------------------------------------------------
const char *
InsertArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char = '\0');
//------------------------------------------------------------------
/// Replaces the argument value at index \a idx to \a arg_cstr
/// if \a idx is a valid argument index.
///
/// @param[in] idx
/// The index of the argument that will have its value replaced.
///
/// @param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
///
/// @return
/// The NULL terminated C string of the copy of \a arg_cstr if
/// \a idx was a valid index, NULL otherwise.
//------------------------------------------------------------------
const char *
ReplaceArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char = '\0');
//------------------------------------------------------------------
/// Deletes the argument value at index
/// if \a idx is a valid argument index.
///
/// @param[in] idx
/// The index of the argument that will have its value replaced.
///
//------------------------------------------------------------------
void
DeleteArgumentAtIndex (size_t idx);
//------------------------------------------------------------------
/// Sets the argument vector value, optionally copying all
/// arguments into an internal buffer.
///
/// Sets the arguments to match those found in \a argv. All argument
/// strings will be copied into an internal buffers.
//
// FIXME: Handle the quote character somehow.
//------------------------------------------------------------------
void
SetArguments (int argc, const char **argv);
//------------------------------------------------------------------
/// Shifts the first argument C string value of the array off the
/// argument array.
///
/// The string value will be freed, so a copy of the string should
/// be made by calling Args::GetArgumentAtIndex (size_t) const
/// first and copying the returned value before calling
/// Args::Shift().
///
/// @see Args::GetArgumentAtIndex (size_t) const
//------------------------------------------------------------------
void
Shift ();
//------------------------------------------------------------------
/// Inserts a class owned copy of \a arg_cstr at the beginning of
/// the argument vector.
///
/// A copy \a arg_cstr will be made.
///
/// @param[in] arg_cstr
/// The argument to push on the front the the argument stack.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
///
/// @return
/// A pointer to the copy of \a arg_cstr that was made.
//------------------------------------------------------------------
const char *
Unshift (const char *arg_cstr, char quote_char = '\0');
//------------------------------------------------------------------
/// Parse the arguments in the contained arguments.
///
/// The arguments that are consumed by the argument parsing process
/// will be removed from the argument vector. The arguements that
/// get processed start at the second argument. The first argument
/// is assumed to be the command and will not be touched.
///
/// @see class Options
//------------------------------------------------------------------
Error
ParseOptions (Options &options);
// The following works almost identically to ParseOptions, except that no option is required to have arguments,
// and it builds up the option_arg_vector as it parses the options.
void
ParseAliasOptions (Options &options, CommandReturnObject &result, OptionArgVector *option_arg_vector);
void
ParseArgsForCompletion (Options &options, OptionElementVector &option_element_vector);
//------------------------------------------------------------------
// Clear the arguments.
//
// For re-setting or blanking out the list of arguments.
//------------------------------------------------------------------
void
Clear ();
static int32_t
StringToSInt32 (const char *s, int32_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static uint32_t
StringToUInt32 (const char *s, uint32_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static int64_t
StringToSInt64 (const char *s, int64_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static uint64_t
StringToUInt64 (const char *s, uint64_t fail_value = 0, int base = 0, bool *success_ptr = NULL);
static lldb::addr_t
StringToAddress (const char *s, lldb::addr_t fail_value = LLDB_INVALID_ADDRESS, bool *success_ptr = NULL);
static bool
StringToBoolean (const char *s, bool fail_value, bool *success_ptr);
static int32_t
StringToOptionEnum (const char *s, lldb::OptionEnumValueElement *enum_values, int32_t fail_value, bool *success_ptr);
static lldb::ScriptLanguage
StringToScriptLanguage (const char *s, lldb::ScriptLanguage fail_value, bool *success_ptr);
static Error
StringToFormat (const char *s, lldb::Format &format);
// This one isn't really relevant to Arguments per se, but we're using the Args as a
// general strings container, so...
void
LongestCommonPrefix (std::string &common_prefix);
protected:
//------------------------------------------------------------------
// Classes that inherit from Args can see and modify these
//------------------------------------------------------------------
typedef std::list<std::string> arg_sstr_collection;
typedef std::vector<const char *> arg_cstr_collection;
typedef std::vector<char> arg_quote_char_collection;
arg_sstr_collection m_args;
arg_cstr_collection m_argv; ///< The current argument vector.
arg_quote_char_collection m_args_quote_char;
void
UpdateArgsAfterOptionParsing ();
void
UpdateArgvFromArgs ();
};
} // namespace lldb_private
#endif // liblldb_Command_h_

View File

@ -0,0 +1,62 @@
//===-- Baton.h -------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Baton_h_
#define lldb_Baton_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-include.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Baton Baton.h "lldb/Core/Baton.h"
/// @brief A class designed to wrap callback batons so they can cleanup
/// any acquired resources
///
/// This class is designed to be used by any objects that have a
/// callback function that takes a baton where the baton might need to
/// free/delete/close itself.
///
/// The default behavior is to not free anything. Subclasses can
/// free any needed resources in their destructors.
//----------------------------------------------------------------------
class Baton
{
public:
explicit Baton(void *p) :
m_data (p)
{
}
virtual
~Baton()
{
// The default destructor for a baton does NOT attempt to clean up
// anything in m_baton
}
virtual void
GetDescription (Stream *s, lldb::DescriptionLevel level) const;
void *m_data; // Leave baton public for easy access
private:
//------------------------------------------------------------------
// For Baton only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Baton);
};
} // namespace lldb_private
#endif // lldb_Baton_h_

View File

@ -0,0 +1,194 @@
//===-- Broadcaster.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_Broadcaster_h_
#define liblldb_Broadcaster_h_
// C Includes
// C++ Includes
#include <string>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
//#include "lldb/Core/Flags.h"
#include "lldb/Core/Listener.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Broadcaster Broadcaster.h "lldb/Core/Broadcaster.h"
/// @brief An event broadcasting class.
///
/// The Broadcaster class is designed to be subclassed by objects that
/// wish to vend events in a multi-threaded environment. Broadcaster
/// objects can each vend 32 events. Each event is represented by a bit
/// in a 32 bit value and these bits can be set:
/// @see Broadcaster::SetEventBits(uint32_t)
/// or cleared:
/// @see Broadcaster::ResetEventBits(uint32_t)
/// When an event gets set the Broadcaster object will notify the
/// Listener object that is listening for the event (if there is one).
///
/// Subclasses should provide broadcast bit definitions for any events
/// they vend, typically using an enumeration:
/// \code
/// class Foo : public Broadcaster
/// {
/// public:
/// //----------------------------------------------------------
/// // Broadcaster event bits definitions.
/// //----------------------------------------------------------
/// enum
/// {
/// eBroadcastBitStateChanged = (1 << 0),
/// eBroadcastBitInterrupt = (1 << 1),
/// eBroadcastBitSTDOUT = (1 << 2),
/// eBroadcastBitSTDERR = (1 << 3)
/// };
/// \endcode
//----------------------------------------------------------------------
class Broadcaster
{
public:
//------------------------------------------------------------------
/// Construct with a broadcaster with a name.
///
/// @param[in] name
/// A NULL terminated C string that contains the name of the
/// broadcaster object.
//------------------------------------------------------------------
Broadcaster (const char *name);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class gets subclassed.
//------------------------------------------------------------------
virtual
~Broadcaster();
//------------------------------------------------------------------
/// Broadcast an event which has no associated data.
///
/// @param[in] event_type
/// The element from the enum defining this broadcaster's events
/// that is being broadcast.
///
/// @param[in] event_data
/// User event data that will be owned by the lldb::Event that
/// is created internally.
///
/// @param[in] unique
/// If true, then only add an event of this type if there isn't
/// one already in the queue.
///
//------------------------------------------------------------------
void
BroadcastEvent (lldb::EventSP &event_sp);
void
BroadcastEventIfUnique (lldb::EventSP &event_sp);
void
BroadcastEvent (uint32_t event_type, EventData *event_data = NULL);
void
BroadcastEventIfUnique (uint32_t event_type, EventData *event_data = NULL);
virtual void
AddInitialEventsToListener (Listener *listener, uint32_t requested_events);
//------------------------------------------------------------------
/// Listen for any events specified by \a event_mask.
///
/// Only one listener can listen to each event bit in a given
/// Broadcaster. Once a listener has acquired an event bit, no
/// other broadcaster will have access to it until it is
/// relinquished by the first listener that gets it. The actual
/// event bits that get acquired by \a listener may be different
/// from what is requested in \a event_mask, and to track this the
/// actual event bits that are acquired get returned.
///
/// @param[in] listener
/// The Listener object that wants to monitor the events that
/// get broadcast by this object.
///
/// @param[in] event_mask
/// A bit mask that indicates which events the listener is
/// asking to monitor.
///
/// @return
/// The actual event bits that were acquired by \a listener.
//------------------------------------------------------------------
uint32_t
AddListener (Listener* listener, uint32_t event_mask);
//------------------------------------------------------------------
/// Get the NULL terminated C string name of this Broadcaster
/// object.
///
/// @return
/// The NULL terminated C string name of this Broadcaster.
//------------------------------------------------------------------
const ConstString &
GetBroadcasterName ();
bool
EventTypeHasListeners (uint32_t event_type);
//------------------------------------------------------------------
/// Removes a Listener from this broadcasters list and frees the
/// event bits specified by \a event_mask that were previously
/// acquired by \a listener (assuming \a listener was listening to
/// this object) for other listener objects to use.
///
/// @param[in] listener
/// A Listener object that previously called AddListener.
///
/// @param[in] event_mask
/// The event bits \a listener wishes to relinquish.
///
/// @return
/// \b True if the listener was listening to this broadcaster
/// and was removed, \b false otherwise.
///
/// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
//------------------------------------------------------------------
bool
RemoveListener (Listener* listener, uint32_t event_mask = UINT32_MAX);
protected:
void
PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique);
//------------------------------------------------------------------
// Classes that inherit from Broadcaster can see and modify these
//------------------------------------------------------------------
typedef std::vector< std::pair<Listener*,uint32_t> > collection;
// Prefix the name of our member variables with "m_broadcaster_"
// since this is a class that gets subclassed.
const ConstString m_broadcaster_name; ///< The name of this broadcaster object.
collection m_broadcaster_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster.
Mutex m_broadcaster_listeners_mutex; ///< A mutex that protects \a m_broadcaster_listeners.
private:
//------------------------------------------------------------------
// For Broadcaster only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Broadcaster);
};
} // namespace lldb_private
#endif // liblldb_Broadcaster_h_

View File

@ -0,0 +1,103 @@
//===-- ClangForward.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_ClangForward_h_
#define liblldb_ClangForward_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#if defined(__cplusplus)
namespace clang
{
namespace Builtin
{
class Context;
}
class ASTContext;
class AddrLabelExpr;
class BinaryOperator;
class CodeGenerator;
class CompilerInstance;
class CXXBaseSpecifier;
class CXXBoolLiteralExpr;
class CXXFunctionalCastExpr;
class CXXNamedCastExpr;
class CXXRecordDecl;
class CXXThisExpr;
class CharacterLiteral;
class CompoundAssignOperator;
class Decl;
class DeclaratorDecl;
class DeclContext;
class DeclRefExpr;
class DeclStmt;
class Diagnostic;
class EnumDecl;
class Expr;
class ExtVectorElementExpr;
class FieldDecl;
class FloatingLiteral;
class FunctionDecl;
class GotoStmt;
class IdentifierTable;
class IntegerLiteral;
class LabelStmt;
class LangOptions;
class MemberExpr;
class NamedDecl;
class NamespaceDecl;
class NonTypeTemplateParmDecl;
class ObjCEncodeExpr;
class ObjCImplicitSetterGetterRefExpr;
class ObjCInterfaceDecl;
class ObjCIvarRefExpr;
class ObjCMessageExpr;
class ObjCMethodDecl;
class ObjCPropertyRefExpr;
class ObjCProtocolDecl;
class ObjCProtocolExpr;
class ObjCSelectorExpr;
class ObjCSuperExpr;
class ParenExpr;
class ParmVarDecl;
class PredefinedExpr;
class QualType;
class QualifiedNameType;
class RecordDecl;
class SelectorTable;
class SizeOfAlignOfExpr;
class SourceLocation;
class SourceManager;
class Stmt;
class StmtIteratorBase;
class StringLiteral;
class TagDecl;
class TargetInfo;
class TargetOptions;
class TemplateArgument;
class TemplateDecl;
class TemplateTemplateParmDecl;
class TemplateTypeParmDecl;
class TextDiagnosticBuffer;
class Type;
class TypedefDecl;
class TypesCompatibleExpr;
class UnaryOperator;
class ValueDecl;
class VarDecl;
struct PrintingPolicy;
}
#endif // #if defined(__cplusplus)
#endif // liblldb_ClangForward_h_

View File

@ -0,0 +1,401 @@
//===-- Communication.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_Communication_h_
#define liblldb_Communication_h_
// C Includes
// C++ Includes
#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Communication Communication.h "lldb/Core/Communication.h"
/// @brief An abstract communications class.
///
/// Communication is an class that handles data communication
/// between two data sources. It uses a Connection class to do the
/// real communication. This approach has a couple of advantages: it
/// allows a single instance of this class to be used even though its
/// connection can change. Connections could negotiate for different
/// connections based on abilities like starting with Bluetooth and
/// negotiating up to WiFi if available. It also allows this class to be
/// subclassed by any interfaces that don't want to give bytes but want
/// to validate and give out packets. This can be done by overriding:
///
/// AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast);
///
/// Communication inherits from Broadcaster which means it can be
/// used in conjunction with Listener to wait for multiple broadcaster
/// objects and multiple events from each of those objects.
/// Communication defines a set of pre-defined event bits (see
/// enumerations definitions that start with "eBroadcastBit" below).
///
/// There are two modes in which communications can occur:
/// @li single-threaded
/// @li multi-threaded
///
/// In single-threaded mode, all reads and writes happen synchronously
/// on the calling thread.
///
/// In multi-threaded mode, a read thread is spawned that continually
/// reads data and caches any received bytes. To start the read thread
/// clients call:
///
/// bool Communication::StartReadThread (Error *);
///
/// If true is returned a read thead has been spawned that will
/// continually execute a call to the pure virtual DoRead function:
///
/// size_t Communication::ReadFromConnection (void *, size_t, uint32_t);
///
/// When bytes are received the data gets cached in \a m_bytes and this
/// class will broadcast a \b eBroadcastBitReadThreadGotBytes event.
/// Clients that want packet based communication should override
/// AppendBytesToCache. The subclasses can choose to call the
/// built in AppendBytesToCache with the \a broadcast parameter set to
/// false. This will cause the \b eBroadcastBitReadThreadGotBytes event
/// not get broadcast, and then the subclass can post a \b
/// eBroadcastBitPacketAvailable event when a full packet of data has
/// been received.
///
/// If the connection is disconnected a \b eBroadcastBitDisconnected
/// event gets broadcast. If the read thread exits a \b
/// eBroadcastBitReadThreadDidExit event will be broadcast. Clients
/// can also post a \b eBroadcastBitReadThreadShouldExit event to this
/// object which will cause the read thread to exit.
//----------------------------------------------------------------------
class Communication : public Broadcaster
{
public:
enum {
eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost.
eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available.
eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread.
eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet.
kLoUserBroadcastBit = (1 << 16),///< Subclasses can used bits 31:16 for any needed events.
kHiUserBroadcastBit = (1 << 31),
eAllEventBits = 0xffffffff
};
typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
//------------------------------------------------------------------
/// Construct the Communication object with the specified name for
/// the Broadcaster that this object inherits from.
///
/// @param[in] broadcaster_name
/// The name of the broadcaster object. This name should be as
/// complete as possible to uniquely identify this object. The
/// broadcaster name can be updated after the connect function
/// is called.
//------------------------------------------------------------------
Communication(const char * broadcaster_name);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class gets subclassed.
//------------------------------------------------------------------
virtual
~Communication();
void
Clear ();
//------------------------------------------------------------------
/// Poll for bytes available if the communications supports it.
///
/// @param[in] timeout_usec
/// A timeout value in micro-seconds, UINT32_MAX for infinite
/// wait.
///
/// @return
/// \b True if the bytes are, or became available within the
/// timeout period, \b false otherwise.
//------------------------------------------------------------------
virtual lldb::ConnectionStatus
BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
//------------------------------------------------------------------
/// Connect using the current connection by passing \a url to its
/// connect function.
/// string.
///
/// @param[in] url
/// A string that contains all information needed by the
/// subclass to connect to another client.
///
/// @return
/// \b True if the connect succeeded, \b false otherwise. The
/// internal error object should be filled in with an
/// appropriate value based on the result of this function.
///
/// @see Error& Communication::GetError ();
/// @see bool Connection::Connect (const char *url);
//------------------------------------------------------------------
lldb::ConnectionStatus
Connect (const char *url, Error *error_ptr);
//------------------------------------------------------------------
/// Disconnect the communications connection if one is currently
/// connected.
///
/// @return
/// \b True if the disconnect succeeded, \b false otherwise. The
/// internal error object should be filled in with an
/// appropriate value based on the result of this function.
///
/// @see Error& Communication::GetError ();
/// @see bool Connection::Disconnect ();
//------------------------------------------------------------------
lldb::ConnectionStatus
Disconnect (Error *error_ptr = NULL);
//------------------------------------------------------------------
/// Check if the connection is valid.
///
/// @return
/// \b True if this object is currently connected, \b false
/// otherwise.
//------------------------------------------------------------------
bool
IsConnected () const;
bool
HasConnection () const;
//------------------------------------------------------------------
/// Read bytes from the current connection.
///
/// If no read thread is running, this function call the
/// connection's Connection::BytesAvailable(uint32_t) method to
/// wait for available data, and then call the
/// Connection::Read(void *, size_t) function to get any available
/// bytes if Connection::BytesAvailable(uint32_t) returned true.
///
/// If a read thread has been started, this function will check for
/// any cached bytes that have already been read and return any
/// currently available bytes. If no bytes are cached, it will wait
/// for the bytes to become available by listening for the \a
/// eBroadcastBitReadThreadGotBytes event. If this function consumes
/// all of the bytes in the cache, it will reset the
/// \a eBroadcastBitReadThreadGotBytes event bit.
///
/// @param[in] dst
/// A destination buffer that must be at least \a dst_len bytes
/// long.
///
/// @param[in] dst_len
/// The number of bytes to attempt to read, and also the max
/// number of bytes that can be placed into \a dst.
///
/// @param[in] timeout_usec
/// A timeout value in micro-seconds.
///
/// @return
/// The number of bytes actually read.
///
/// @see bool Connection::BytesAvailable (uint32_t);
/// @see size_t Connection::Read (void *, size_t);
//------------------------------------------------------------------
size_t
Read (void *dst,
size_t dst_len,
uint32_t timeout_usec,
lldb::ConnectionStatus &status,
Error *error_ptr);
//------------------------------------------------------------------
/// The actual write function that attempts to write to the
/// communications protocol.
///
/// Subclasses must override this function.
///
/// @param[in] src
/// A source buffer that must be at least \a src_len bytes
/// long.
///
/// @param[in] src_len
/// The number of bytes to attempt to write, and also the
/// number of bytes are currently available in \a src.
///
/// @return
/// The number of bytes actually Written.
//------------------------------------------------------------------
size_t
Write (const void *src,
size_t src_len,
lldb::ConnectionStatus &status,
Error *error_ptr);
//------------------------------------------------------------------
/// Sets the connection that it to be used by this class.
///
/// By making a communication class that uses different connections
/// it allows a single communication interface to negotiate and
/// change its connection without any interruption to the client.
/// It also allows the Communication class to be subclassed for
/// packet based communication.
///
/// @param[in] connection
/// A connection that this class will own and destroy.
///
/// @see
/// class Connection
//------------------------------------------------------------------
void
SetConnection (Connection *connection);
//------------------------------------------------------------------
/// Starts a read thread whose sole purpose it to read bytes from
/// the current connection. This function will call connection's
/// read function:
///
/// size_t Connection::Read (void *, size_t);
///
/// When bytes are read and cached, this function will call:
///
/// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
///
/// Subclasses should override this function if they wish to override
/// the default action of caching the bytes and broadcasting a \b
/// eBroadcastBitReadThreadGotBytes event.
///
/// @return
/// \b True if the read thread was successfully started, \b
/// false otherwise.
///
/// @see size_t Connection::Read (void *, size_t);
/// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
//------------------------------------------------------------------
virtual bool
StartReadThread (Error *error_ptr = NULL);
//------------------------------------------------------------------
/// Stops the read thread by cancelling it.
///
/// @return
/// \b True if the read thread was successfully canceled, \b
/// false otherwise.
//------------------------------------------------------------------
virtual bool
StopReadThread (Error *error_ptr = NULL);
//------------------------------------------------------------------
/// Checks if there is a currently running read thread.
///
/// @return
/// \b True if the read thread is running, \b false otherwise.
//------------------------------------------------------------------
bool
ReadThreadIsRunning ();
//------------------------------------------------------------------
/// The static read thread function. This function will call
/// the "DoRead" function continuously and wait for data to become
/// avaialble. When data is received it will append the available
/// data to the internal cache and broadcast a
/// \b eBroadcastBitReadThreadGotBytes event.
///
/// @param[in] comm_ptr
/// A pointer to an instance of this class.
///
/// @return
/// \b NULL.
///
/// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t);
//------------------------------------------------------------------
static lldb::thread_result_t
ReadThread (lldb::thread_arg_t comm_ptr);
void
SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
void *callback_baton);
private:
//------------------------------------------------------------------
// For Communication only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Communication);
protected:
std::auto_ptr<Connection> m_connection_ap; ///< The connection that is current in use by this communications class.
lldb::thread_t m_read_thread; ///< The read thread handle in case we need to cancel the thread.
bool m_read_thread_enabled;
std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
Mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes.
ReadThreadBytesReceived m_callback;
void *m_callback_baton;
size_t
ReadFromConnection (void *dst,
size_t dst_len,
lldb::ConnectionStatus &status,
Error *error_ptr);
//------------------------------------------------------------------
/// Append new bytes that get read from the read thread into the
/// internal object byte cache. This will cause a \b
/// eBroadcastBitReadThreadGotBytes event to be broadcast if \a
/// broadcast is true.
///
/// Subclasses can override this function in order to inspect the
/// received data and check if a packet is available.
///
/// Subclasses can also still call this function from the
/// overridden method to allow the caching to correctly happen and
/// suppress the broadcasting of the \a eBroadcastBitReadThreadGotBytes
/// event by setting \a broadcast to false.
///
/// @param[in] src
/// A source buffer that must be at least \a src_len bytes
/// long.
///
/// @param[in] src_len
/// The number of bytes to append to the cache.
//------------------------------------------------------------------
virtual void
AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast);
//------------------------------------------------------------------
/// Get any available bytes from our data cache. If this call
/// empties the data cache, the \b eBroadcastBitReadThreadGotBytes event
/// will be reset to signify no more bytes are available.
///
/// @param[in] dst
/// A destination buffer that must be at least \a dst_len bytes
/// long.
///
/// @param[in] dst_len
/// The number of bytes to attempt to read from the cache,
/// and also the max number of bytes that can be placed into
/// \a dst.
///
/// @return
/// The number of bytes extracted from the data cache.
//------------------------------------------------------------------
size_t
GetCachedBytes (void *dst, size_t dst_len);
};
} // namespace lldb_private
#endif // liblldb_Communication_h_

View File

@ -0,0 +1,176 @@
//===-- Connection.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_Connection_h_
#define liblldb_Connection_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Connection Connection.h "lldb/Core/Connection.h"
/// @brief A communication connection class.
///
/// A class that implements that actual communication functions for
/// connecting/disconnecting, reading/writing, and waiting for bytes
/// to become available from a two way communication connection.
///
/// This class is designed to only do very simple communication
/// functions. Instances can be instantiated and given to a
/// Communication class to perform communications where clients can
/// listen for broadcasts, and perform other higher level communications.
//----------------------------------------------------------------------
class Connection
{
public:
//------------------------------------------------------------------
/// Default constructor
//------------------------------------------------------------------
Connection ();
//------------------------------------------------------------------
/// Virtual destructor since this class gets subclassed and handed
/// to a Communication object.
//------------------------------------------------------------------
virtual
~Connection ();
//------------------------------------------------------------------
/// Poll for bytes available if the communications supports it.
///
/// @param[in] timeout_usec
/// A timeout value in micro-seconds.
///
/// @param[out] error
/// A reference to an error object that should be given an
/// approriate error value if this method returns false. This
/// value can be NULL if the error value should be ignored.
///
/// @return
/// \b True if the bytes are, or became available within the
/// timeout period, \b false otherwise.
//------------------------------------------------------------------
virtual lldb::ConnectionStatus
BytesAvailable (uint32_t timeout_usec, Error *error_ptr) = 0;
//------------------------------------------------------------------
/// Connect using the connect string \a url.
///
/// @param[in] url
/// A string that contains all information needed by the
/// subclass to connect to another client.
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
/// approriate error value if this method returns false. This
/// value can be NULL if the error value should be ignored.
///
/// @return
/// \b True if the connect succeeded, \b false otherwise. The
/// internal error object should be filled in with an
/// appropriate value based on the result of this function.
///
/// @see Error& Communication::GetError ();
//------------------------------------------------------------------
virtual lldb::ConnectionStatus
Connect (const char *url, Error *error_ptr) = 0;
//------------------------------------------------------------------
/// Disconnect the communications connection if one is currently
/// connected.
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
/// approriate error value if this method returns false. This
/// value can be NULL if the error value should be ignored.
///
/// @return
/// \b True if the disconnect succeeded, \b false otherwise. The
/// internal error object should be filled in with an
/// appropriate value based on the result of this function.
///
/// @see Error& Communication::GetError ();
//------------------------------------------------------------------
virtual lldb::ConnectionStatus
Disconnect (Error *error_ptr) = 0;
//------------------------------------------------------------------
/// Check if the connection is valid.
///
/// @return
/// \b True if this object is currently connected, \b false
/// otherwise.
//------------------------------------------------------------------
virtual bool
IsConnected () const = 0;
//------------------------------------------------------------------
/// The read function that attempts to read from the connection.
///
/// @param[in] dst
/// A destination buffer that must be at least \a dst_len bytes
/// long.
///
/// @param[in] dst_len
/// The number of bytes to attempt to read, and also the max
/// number of bytes that can be placed into \a dst.
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
/// approriate error value if this method returns zero. This
/// value can be NULL if the error value should be ignored.
///
/// @return
/// The number of bytes actually read.
///
/// @see size_t Communication::Read (void *, size_t, uint32_t);
//------------------------------------------------------------------
virtual size_t
Read (void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr) = 0;
//------------------------------------------------------------------
/// The actual write function that attempts to write to the
/// communications protocol.
///
/// Subclasses must override this function.
///
/// @param[in] src
/// A source buffer that must be at least \a src_len bytes
/// long.
///
/// @param[in] src_len
/// The number of bytes to attempt to write, and also the
/// number of bytes are currently available in \a src.
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
/// approriate error value if this method returns zero. This
/// value can be NULL if the error value should be ignored.
///
/// @return
/// The number of bytes actually Written.
//------------------------------------------------------------------
virtual size_t
Write (const void *buffer, size_t length, lldb::ConnectionStatus &status, Error *error_ptr) = 0;
private:
//------------------------------------------------------------------
// For Connection only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Connection);
};
} // namespace lldb_private
#endif // liblldb_Connection_h_

View File

@ -0,0 +1,74 @@
//===-- ConnectionFileDescriptor.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_ConnectionFileDescriptor_h_
#define liblldb_ConnectionFileDescriptor_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Connection.h"
namespace lldb_private {
class ConnectionFileDescriptor :
public Connection
{
public:
ConnectionFileDescriptor ();
ConnectionFileDescriptor (int fd, bool owns_fd);
virtual
~ConnectionFileDescriptor ();
virtual bool
IsConnected () const;
virtual lldb::ConnectionStatus
BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
virtual lldb::ConnectionStatus
Connect (const char *s, Error *error_ptr);
virtual lldb::ConnectionStatus
Disconnect (Error *error_ptr);
virtual size_t
Read (void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr);
virtual size_t
Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr);
protected:
lldb::ConnectionStatus
SocketListen (uint16_t listen_port_num, Error *error_ptr);
lldb::ConnectionStatus
SocketConnect (const char *host_and_port, Error *error_ptr);
lldb::ConnectionStatus
Close (int& fd, Error *error);
int m_fd; // Socket we use to communicate once conn established
bool m_is_socket;
bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
static int
SetSocketOption(int fd, int level, int option_name, int option_value);
private:
DISALLOW_COPY_AND_ASSIGN (ConnectionFileDescriptor);
};
} // namespace lldb_private
#endif // liblldb_ConnectionFileDescriptor_h_

View File

@ -0,0 +1,396 @@
//===-- ConstString.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_ConstString_h_
#define liblldb_ConstString_h_
#if defined(__cplusplus)
#include <assert.h>
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class ConstString ConstString.h "lldb/Core/ConstString.h"
/// @brief A uniqued constant string class.
///
/// Provides an efficient way to store strings as uniqued ref counted
/// strings. Since the strings are uniqued, finding strings that are
/// equal to one another is very fast (pointer compares). It also allows
/// for many common strings from many different sources to be shared to
/// keep the memory footprint low.
//----------------------------------------------------------------------
class ConstString
{
public:
//------------------------------------------------------------------
/// Default constructor
///
/// Initializes the string to an empty string.
//------------------------------------------------------------------
ConstString ();
//------------------------------------------------------------------
/// Copy constructor
///
/// Copies the string value in \a rhs and retains an extra reference
/// to the string value in the string pool.
///
/// @param[in] rhs
/// Another string object to copy.
//------------------------------------------------------------------
ConstString (const ConstString& rhs);
//------------------------------------------------------------------
/// Construct with C String value
///
/// Constructs this object with a C string by looking to see if the
/// C string already exists in the global string pool. If it does
/// exist, it retains an extra reference to the string in the string
/// pool. If it doesn't exist, it is added to the string pool with
/// a reference count of 1.
///
/// @param[in] cstr
/// A NULL terminated C string to add to the string pool.
//------------------------------------------------------------------
explicit ConstString (const char *cstr);
//------------------------------------------------------------------
/// Construct with C String value with max length
///
/// Constructs this object with a C string with a length. If
/// \a max_cstr_len is greater than the actual length of the string,
/// the string length will be truncated. This allows substrings to
/// be created without the need to NULL terminate the string as it
/// is passed into this function.
///
/// If the C string already exists in the global string pool, it
/// retains an extra reference to the string in the string
/// pool. If it doesn't exist, it is added to the string pool with
/// a reference count of 1.
///
/// @param[in] cstr
/// A NULL terminated C string to add to the string pool.
///
/// @param[in] max_cstr_len
/// The max length of \a cstr. If the string length of \a cstr
/// is less than \a max_cstr_len, then the string will be
/// truncated. If the string length of \a cstr is greater than
/// \a max_cstr_len, then only max_cstr_len bytes will be used
/// from \a cstr.
//------------------------------------------------------------------
explicit ConstString (const char *cstr, size_t max_cstr_len);
//------------------------------------------------------------------
/// Destructor
///
/// Decrements the reference count on the contained string, and if
/// the resulting reference count is zero, then the string is removed
/// from the global string pool. If the reference count is still
/// greater than zero, the string will remain in the string pool
/// until the last reference is released by other ConstString objects.
//------------------------------------------------------------------
~ConstString ();
//----------------------------------------------------------------------
/// C string equality function object for CStrings contains in the
/// same StringPool only. (binary predicate).
//----------------------------------------------------------------------
struct StringIsEqual
{
//--------------------------------------------------------------
/// C equality test.
///
/// Two C strings are equal when they are contained in ConstString
/// objects when their pointer values are equal to each other.
///
/// @return
/// Returns \b true if the C string in \a lhs is equal to
/// the C string value in \a rhs, \b false otherwise.
//--------------------------------------------------------------
bool operator()(const char* lhs, const char* rhs) const
{
return lhs == rhs;
}
};
//------------------------------------------------------------------
/// Convert to pointer operator.
///
/// This allows code to check a ConstString object to see if it
/// contains a valid string using code such as:
///
/// @code
/// ConstString str(...);
/// if (str)
/// { ...
/// @endcode
///
/// @return
/// A pointer to this object if the string isn't empty, NULL
/// otherwise.
//------------------------------------------------------------------
operator void*() const;
//------------------------------------------------------------------
/// Assignment operator
///
/// Assigns the string in this object with the value from \a rhs
/// and increments the reference count of that string.
///
/// The previously contained string will be get its reference count
/// decremented and removed from the string pool if its reference
/// count reaches zero.
///
/// @param[in] rhs
/// Another string object to copy into this object.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const ConstString&
operator = (const ConstString& rhs);
//------------------------------------------------------------------
/// Equal to operator
///
/// Returns true if this string is equal to the string in \a rhs.
/// This operation is very fast as it results in a pointer
/// comparison since all strings are in a uniqued and reference
/// counted string pool.
///
/// @param[in] rhs
/// Another string object to compare this object to.
///
/// @return
/// @li \b true if this object is equal to \a rhs.
/// @li \b false if this object is not equal to \a rhs.
//------------------------------------------------------------------
bool
operator == (const ConstString& rhs) const;
//------------------------------------------------------------------
/// Not equal to operator
///
/// Returns true if this string is not equal to the string in \a rhs.
/// This operation is very fast as it results in a pointer
/// comparison since all strings are in a uniqued and reference
/// counted string pool.
///
/// @param[in] rhs
/// Another string object to compare this object to.
///
/// @return
/// @li \b true if this object is not equal to \a rhs.
/// @li \b false if this object is equal to \a rhs.
//------------------------------------------------------------------
bool
operator != (const ConstString& rhs) const;
bool
operator < (const ConstString& rhs) const;
//------------------------------------------------------------------
/// Get the string value as a C string.
///
/// Get the value of the contained string as a NULL terminated C
/// string value.
///
/// If \a value_if_empty is NULL, then NULL will be returned.
///
/// @return
/// Returns \a value_if_empty if the string is empty, otherwise
/// the C string value contained in this object.
//------------------------------------------------------------------
const char *
AsCString(const char *value_if_empty = NULL) const;
const char *
GetCString () const;
size_t
GetLength () const;
//------------------------------------------------------------------
/// Clear this object's state.
///
/// Clear any contained string and reset the value to the an empty
/// string value.
///
/// The previously contained string will be get its reference count
/// decremented and removed from the string pool if its reference
/// count reaches zero.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Compare two string objects.
///
/// Compares the C string values contained in \a lhs and \a rhs and
/// returns an integer result.
///
/// @param[in] lhs
/// The Left Hand Side const ConstString object reference.
///
/// @param[in] rhs
/// The Right Hand Side const ConstString object reference.
///
/// @return
/// @li -1 if lhs < rhs
/// @li 0 if lhs == rhs
/// @li 1 if lhs > rhs
//------------------------------------------------------------------
static int
Compare (const ConstString& lhs, const ConstString& rhs);
//------------------------------------------------------------------
/// Dump the object description to a stream.
///
/// Dump the string value to the stream \a s. If the contained string
/// is empty, print \a value_if_empty to the stream instead. If
/// \a value_if_empty is NULL, then nothing will be dumped to the
/// stream.
///
/// @param[in] s
/// The stream that will be used to dump the object description.
///
/// @param[in] value_if_empty
/// The value to dump if the string is empty. If NULL, nothing
/// will be output to the stream.
//------------------------------------------------------------------
void
Dump (Stream *s, const char *value_if_empty = NULL) const;
//------------------------------------------------------------------
/// Dump the object debug description to a stream.
///
/// Dump the string value and the reference count to the stream \a
/// s.
///
/// @param[in] s
/// The stream that will be used to dump the object description.
//------------------------------------------------------------------
void
DumpDebug (Stream *s) const;
//------------------------------------------------------------------
/// Test for empty string.
///
/// @return
/// @li \b true if the contained string is empty.
/// @li \b false if the contained string is not empty.
//------------------------------------------------------------------
bool
IsEmpty () const;
//------------------------------------------------------------------
/// Set the C string value.
///
/// Set the string value in the object by uniquing the \a cstr
/// string value in our global string pool.
///
/// If the C string already exists in the global string pool, it
/// finds the current entry and retains an extra reference to the
/// string in the string pool. If it doesn't exist, it is added to
/// the string pool with a reference count of 1.
///
/// @param[in] cstr
/// A NULL terminated C string to add to the string pool.
//------------------------------------------------------------------
void
SetCString (const char *cstr);
//------------------------------------------------------------------
/// Set the C string value with length.
///
/// Set the string value in the object by uniquing \a cstr_len bytes
/// starting at the \a cstr string value in our global string pool.
/// If trim is true, then \a cstr_len indicates a maximum length of
/// the CString and if the actual length of the string is less, then
/// it will be trimmed. If trim is false, then this allows strings
/// with NULL characters to be added to the string pool.
///
/// If the C string already exists in the global string pool, it
/// retains an extra reference to the string in the string
/// pool. If it doesn't exist, it is added to the string pool with
/// a reference count of 1.
///
/// @param[in] cstr
/// A NULL terminated C string to add to the string pool.
///
/// @param[in] cstr_len
/// The absolute length of the C string if \a trim is false,
/// or the maximum length of the C string if \a trim is true.
///
/// @param[in] trim
/// If \b true, trim \a cstr to it's actual length before adding
/// it to the string pool. If \b false then cstr_len is the
/// actual length of the C string to add.
//------------------------------------------------------------------
void
SetCStringWithLength (const char *cstr, size_t cstr_len);
//------------------------------------------------------------------
/// Set the C string value with the minimum length between
/// \a fixed_cstr_len and the actual length of the C string. This
/// can be used for data structures that have a fixed length to
/// store a C string where the string might not be NULL terminated
/// if the string takes the entire buffer.
//------------------------------------------------------------------
void
SetTrimmedCStringWithLength (const char *cstr, size_t fixed_cstr_len);
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// Return the size in bytes that this object takes in memory. This
/// returns the size in bytes of this object, which does not include
/// any the shared string values it may refer to.
///
/// @return
/// The number of bytes that this object occupies in memory.
///
/// @see ConstString::StaticMemorySize ()
//------------------------------------------------------------------
size_t
MemorySize () const;
//------------------------------------------------------------------
/// Get the size in bytes of the current global string pool.
///
/// Reports the the size in bytes of all shared C string values,
/// containers and reference count values as a byte size for the
/// entire string pool.
///
/// @return
/// The number of bytes that the global string pool occupies
/// in memory.
//------------------------------------------------------------------
static size_t
StaticMemorySize ();
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
const char *m_string;
};
//------------------------------------------------------------------
/// Stream the string value \a str to the stream \a s
//------------------------------------------------------------------
Stream& operator << (Stream& s, const ConstString& str);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_ConstString_h_

View File

@ -0,0 +1,94 @@
//===-- DataBuffer.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_DataBuffer_h_
#define liblldb_DataBuffer_h_
#if defined(__cplusplus)
#include <stdint.h>
#include <string.h>
namespace lldb_private {
//----------------------------------------------------------------------
/// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h"
/// @brief A pure virtual protocol class for abstracted data buffers.
///
/// DataBuffer is an abtract class that gets packaged into a shared pointer
/// that can use to implement various ways to store data (on the heap,
/// memory mapped, cached inferior memory). It gets used by DataExtractor
/// so many DataExtractor objects can share the same data and sub-ranges
/// of that shared data, and the last object that contains a reference
/// to the shared data will free it.
///
/// Subclasses can implement as many different constructors or member
/// functions that allow data to be stored in the object's buffer prior
/// to handing the shared data to clients that use these buffers.
///
/// All subclasses must override all of the pure virtual functions as
/// they are used by clients to access the data. Having a common
/// interface allows different ways of storing data, yet using it in
/// one common way.
///
/// This class currently expects all data to be available without any
/// extra calls being made, but we can modify it to optionally get
/// data on demand with some extra function calls to load the data
/// before it gets accessed.
//----------------------------------------------------------------------
class DataBuffer
{
public:
//------------------------------------------------------------------
/// Destructor
///
/// The destructor is virtual as other classes will inherit from
/// this class and be downcast to the DataBuffer pure virtual
/// interface. The virtual destructor ensures that destructing the
/// base class will destruct the class that inherited from it
/// correctly.
//------------------------------------------------------------------
virtual
~DataBuffer()
{
}
//------------------------------------------------------------------
/// Get a pointer to the data.
///
/// @return
/// A pointer to the bytes owned by this object, or NULL if the
/// object contains no bytes.
//------------------------------------------------------------------
virtual uint8_t *
GetBytes () = 0;
//------------------------------------------------------------------
/// Get a const pointer to the data.
///
/// @return
/// A const pointer to the bytes owned by this object, or NULL
/// if the object contains no bytes.
//------------------------------------------------------------------
virtual const uint8_t *
GetBytes () const = 0;
//------------------------------------------------------------------
/// Get the number of bytes in the data buffer.
///
/// @return
/// The number of bytes this object currently contains.
//------------------------------------------------------------------
virtual size_t
GetByteSize() const = 0;
};
} // namespace lldb_private
#endif /// #if defined(__cplusplus)
#endif /// lldb_DataBuffer_h_

View File

@ -0,0 +1,136 @@
//===-- DataBufferHeap.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_DataBufferHeap_h_
#define liblldb_DataBufferHeap_h_
#if defined(__cplusplus)
#include <vector>
#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class DataBufferHeap DataBufferHeap.h "lldb/Core/DataBufferHeap.h"
/// @brief A subclass of DataBuffer that stores a data buffer on the heap.
///
/// This class keeps its data in a heap based buffer that is owned by
/// the object. This class is best used to store chunks of data that
/// are created or read from sources that can't intelligently and lazily
/// fault new data pages in. Large amounts of data that comes from files
/// should probably use the DataBufferMemoryMap class.
//----------------------------------------------------------------------
class DataBufferHeap : public DataBuffer
{
public:
//------------------------------------------------------------------
/// Default constructor
///
/// Initializes the heap based buffer with no bytes.
//------------------------------------------------------------------
DataBufferHeap ();
//------------------------------------------------------------------
/// Construct with size \a n and fill with \a ch.
///
/// Initialize this class with \a n bytes and fills the buffer with
/// \a ch.
///
/// @param[in] n
/// The number of bytes that heap based buffer should contain.
///
/// @param[in] ch
/// The character to use when filling the buffer initially.
//------------------------------------------------------------------
DataBufferHeap (size_t n, uint8_t ch);
//------------------------------------------------------------------
/// Construct by making a copy of \a src_len bytes from \a src.
///
/// @param[in] src
/// A pointer to the data to copy.
///
/// @param[in] src_len
/// The number of bytes in \a src to copy.
//------------------------------------------------------------------
DataBufferHeap (const void *src, size_t src_len);
//------------------------------------------------------------------
/// Destructor.
///
/// Virtual destructor since this class inherits from a pure virtual
/// base class #DataBuffer.
//------------------------------------------------------------------
virtual
~DataBufferHeap();
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes()
//------------------------------------------------------------------
virtual uint8_t *
GetBytes ();
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes() const
//------------------------------------------------------------------
virtual const uint8_t *
GetBytes () const;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetByteSize() const
//------------------------------------------------------------------
virtual size_t
GetByteSize () const;
//------------------------------------------------------------------
/// Set the number of bytes in the data buffer.
///
/// Sets the number of bytes that this object should be able to
/// contain. This can be used prior to copying data into the buffer.
///
/// @param[in] byte_size
/// The new size in bytes that this data buffer should attempt
/// to resize itself to.
///
/// @return
/// The size in bytes after that this heap buffer was
/// successfully resized to.
//------------------------------------------------------------------
size_t
SetByteSize (size_t byte_size);
//------------------------------------------------------------------
/// Makes a copy of the \a src_len bytes in \a src.
///
/// Copies the data in \a src into an internal buffer.
///
/// @param[in] src
/// A pointer to the data to copy.
///
/// @param[in] src_len
/// The number of bytes in \a src to copy.
//------------------------------------------------------------------
void
CopyData (const void *src, size_t src_len);
private:
//------------------------------------------------------------------
// This object uses a std::vector<uint8_t> to store its data. This
// takes care of free the data when the object is deleted.
//------------------------------------------------------------------
typedef std::vector<uint8_t> buffer_t; ///< Buffer type
buffer_t m_data; ///< The heap based buffer where data is stored
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_DataBufferHeap_h_

View File

@ -0,0 +1,156 @@
//===-- DataBufferMemoryMap.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_DataBufferMemoryMap_h_
#define liblldb_DataBufferMemoryMap_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Error.h"
#include <string>
namespace lldb_private {
//----------------------------------------------------------------------
/// @class DataBufferMemoryMap DataBufferMemoryMap.h "lldb/Core/DataBufferMemoryMap.h"
/// @brief A subclass of DataBuffer that memory maps data.
///
/// This class memory maps data and stores any needed data for the
/// memory mapping in its internal state. Memory map requests are not
/// required to have any alignment or size constraints, this class will
/// work around any host OS issues regarding such things.
///
/// This class is designed to allow pages to be faulted in as needed and
/// works well data from large files that won't be accessed all at once.
//----------------------------------------------------------------------
class DataBufferMemoryMap : public DataBuffer
{
public:
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
DataBufferMemoryMap ();
//------------------------------------------------------------------
/// Destructor.
///
/// Virtual destructor since this class inherits from a pure virtual
/// base class #DataBuffer.
//------------------------------------------------------------------
virtual
~DataBufferMemoryMap ();
//------------------------------------------------------------------
/// Reverts this object to an empty state by unmapping any memory
/// that is currently owned.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes()
//------------------------------------------------------------------
virtual uint8_t *
GetBytes ();
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes() const
//------------------------------------------------------------------
virtual const uint8_t *
GetBytes () const;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetByteSize() const
//------------------------------------------------------------------
virtual size_t
GetByteSize () const;
//------------------------------------------------------------------
/// Error get accessor.
///
/// @return
/// A const reference to Error object in case memory mapping
/// fails.
//------------------------------------------------------------------
const Error &
GetError() const;
//------------------------------------------------------------------
/// Memory map all or part of a file.
///
/// Memory map \a length bytes from \a file starting \a offset
/// bytes into the file. If \a length is set to \c SIZE_T_MAX,
/// then map as many bytes as possible.
///
/// @param[in] file
/// The file specification from which to map data.
///
/// @param[in] offset
/// The offset in bytes from the beginning of the file where
/// memory mapping should begin.
///
/// @param[in] length
/// The size in bytes that should be mapped starting \a offset
/// bytes into the file. If \a length is \c SIZE_T_MAX, map
/// as many bytes as possible.
///
/// @return
/// The number of bytes mapped starting from the \a offset.
//------------------------------------------------------------------
size_t
MemoryMapFromFileSpec (const FileSpec* file,
off_t offset = 0,
size_t length = SIZE_T_MAX);
//------------------------------------------------------------------
/// Memory map all or part of a file.
///
/// Memory map \a length bytes from an opened file descriptor \a fd
/// starting \a offset bytes into the file. If \a length is set to
/// \c SIZE_T_MAX, then map as many bytes as possible.
///
/// @param[in] fd
/// The posix file descriptor for an already opened file
/// from which to map data.
///
/// @param[in] offset
/// The offset in bytes from the beginning of the file where
/// memory mapping should begin.
///
/// @param[in] length
/// The size in bytes that should be mapped starting \a offset
/// bytes into the file. If \a length is \c SIZE_T_MAX, map
/// as many bytes as possible.
///
/// @return
/// The number of bytes mapped starting from the \a offset.
//------------------------------------------------------------------
size_t
MemoryMapFromFileDescriptor (int fd, off_t offset = 0, size_t length = SIZE_T_MAX);
protected:
//------------------------------------------------------------------
// Classes that inherit from DataBufferMemoryMap can see and modify these
//------------------------------------------------------------------
uint8_t * m_mmap_addr; ///< The actual pointer that was returned from \c mmap()
size_t m_mmap_size; ///< The actual number of bytes that were mapped when \c mmap() was called
uint8_t *m_data; ///< The data the user requested somewhere within the memory mapped data.
size_t m_size; ///< The size of the data the user got when data was requested
Error m_error; ///< An error object that describes any errors that occurred during the memory mapping process
private:
DISALLOW_COPY_AND_ASSIGN (DataBufferMemoryMap);
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_DataBufferMemoryMap_h_

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
//===-- Debugger.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_Debugger_h_
#define liblldb_Debugger_h_
#if defined(__cplusplus)
#include <stdint.h>
#include <unistd.h>
#include <stack>
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Target/TargetList.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Debugger Debugger.h "lldb/Core/Debugger.h"
/// @brief A class to manage flag bits.
///
/// Provides a global root objects for the debugger core.
//----------------------------------------------------------------------
class Debugger
{
public:
static void
Initialize ();
static void
Terminate ();
static Debugger &
GetSharedInstance ();
~Debugger ();
bool
GetAsyncExecution ();
void
SetAsyncExecution (bool async);
void
SetInputFileHandle (FILE *fh, bool tranfer_ownership);
void
SetOutputFileHandle (FILE *fh, bool tranfer_ownership);
void
SetErrorFileHandle (FILE *fh, bool tranfer_ownership);
FILE *
GetInputFileHandle ();
FILE *
GetOutputFileHandle ();
FILE *
GetErrorFileHandle ();
Stream&
GetOutputStream ()
{
return m_output_file;
}
Stream&
GetErrorStream ()
{
return m_error_file;
}
CommandInterpreter &
GetCommandInterpreter ();
Listener &
GetListener ();
SourceManager &
GetSourceManager ();
lldb::TargetSP
GetCurrentTarget ();
ExecutionContext
GetCurrentExecutionContext();
//------------------------------------------------------------------
/// Get accessor for the target list.
///
/// The target list is part of the global debugger object. This
/// the single debugger shared instance to control where targets
/// get created and to allow for tracking and searching for targets
/// based on certain criteria.
///
/// @return
/// A global shared target list.
//------------------------------------------------------------------
TargetList&
GetTargetList ();
void
DispatchInput (const char *bytes, size_t bytes_len);
void
WriteToDefaultReader (const char *bytes, size_t bytes_len);
void
PushInputReader (const lldb::InputReaderSP& reader_sp);
bool
PopInputReader (const lldb::InputReaderSP& reader_sp);
protected:
static void
DispatchInputCallback (void *baton, const void *bytes, size_t bytes_len);
void
ActivateInputReader (const lldb::InputReaderSP &reader_sp);
bool
CheckIfTopInputReaderIsDone ();
void
DisconnectInput();
bool m_async_execution;
Communication m_input_comm;
StreamFile m_input_file;
StreamFile m_output_file;
StreamFile m_error_file;
TargetList m_target_list;
Listener m_listener;
SourceManager m_source_manager;
CommandInterpreter m_command_interpreter;
std::stack<lldb::InputReaderSP> m_input_readers;
std::string m_input_reader_data;
typedef std::tr1::shared_ptr<Debugger> DebuggerSP;
static DebuggerSP &
GetDebuggerSP();
static int g_shared_debugger_refcount;
static bool g_in_terminate;
private:
Debugger (); // Access the single global instance of this class using Debugger::GetSharedInstance();
DISALLOW_COPY_AND_ASSIGN (Debugger);
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_Debugger_h_

View File

@ -0,0 +1,138 @@
//===-- Disassembler.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_Disassembler_h_
#define liblldb_Disassembler_h_
// C Includes
// C++ Includes
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/PluginInterface.h"
namespace lldb_private {
class ExecutionContext;
class Disassembler :
public PluginInterface
{
public:
class Instruction
{
public:
typedef lldb::SharedPtr<Instruction>::Type shared_ptr;
Instruction();
virtual
~Instruction();
virtual size_t
GetByteSize() const = 0;
virtual void
Dump (Stream *s, lldb::addr_t base_address, DataExtractor *bytes, uint32_t bytes_offset, const lldb_private::ExecutionContext exe_ctx, bool raw) = 0;
virtual bool
DoesBranch () const = 0;
virtual size_t
Extract (const DataExtractor& data, uint32_t data_offset) = 0;
};
class InstructionList
{
public:
InstructionList();
~InstructionList();
size_t
GetSize() const;
Instruction *
GetInstructionAtIndex (uint32_t idx);
const Instruction *
GetInstructionAtIndex (uint32_t idx) const;
void
Clear();
void
AppendInstruction (Instruction::shared_ptr &inst_sp);
private:
typedef std::vector<Instruction::shared_ptr> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
collection m_instructions;
};
static Disassembler*
FindPlugin (const ArchSpec &arch);
static bool
Disassemble (const ArchSpec &arch,
const ExecutionContext &exe_ctx,
uint32_t mixed_context_lines,
Stream &strm);
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
Disassembler(const ArchSpec &arch);
virtual ~Disassembler();
typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data);
size_t
ParseInstructions (const ExecutionContext *exe_ctx,
lldb::AddressType addr_type,
lldb::addr_t addr,
size_t byte_size,
DataExtractor& data);
virtual size_t
ParseInstructions (const DataExtractor& data,
uint32_t data_offset,
uint32_t num_instructions,
lldb::addr_t base_addr) = 0;
InstructionList &
GetInstructionList ();
const InstructionList &
GetInstructionList () const;
protected:
//------------------------------------------------------------------
// Classes that inherit from Disassembler can see and modify these
//------------------------------------------------------------------
const ArchSpec m_arch;
InstructionList m_instruction_list;
lldb::addr_t m_base_addr;
private:
//------------------------------------------------------------------
// For Disassembler only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Disassembler);
};
} // namespace lldb_private
#endif // liblldb_Disassembler_h_

View File

@ -0,0 +1,291 @@
//===-- Error.h -------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef __DCError_h__
#define __DCError_h__
#if defined(__cplusplus)
#include <mach/mach.h>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include "lldb/lldb-private.h"
namespace lldb_private {
class Log;
//----------------------------------------------------------------------
/// @class Error Error.h "lldb/Core/Error.h"
/// @brief An error handling class.
///
/// This class is designed to be able to hold any error code that can be
/// encountered on a given platform. The errors are stored as a value
/// of type Error::ValueType. This value should be large enough to hold
/// any and all errors that the class supports. Each error has an
/// associated type that is of type lldb::ErrorType. New types
/// can be added to support new error types, and architecture specific
/// types can be enabled. In the future we may wish to switch to a
/// registration mechanism where new error types can be registered at
/// runtime instead of a hard coded scheme.
///
/// All errors in this class also know how to generate a string
/// representation of themselves for printing results and error codes.
/// The string value will be fetched on demand and its string value will
/// be cached until the error is cleared of the value of the error
/// changes.
//----------------------------------------------------------------------
class Error
{
public:
//------------------------------------------------------------------
/// Every error value that this object can contain needs to be able
/// to fit into ValueType.
//------------------------------------------------------------------
typedef uint32_t ValueType;
//------------------------------------------------------------------
/// Default constructor.
///
/// Initialize the error object with a generic success value.
///
/// @param[in] err
/// An error code.
///
/// @param[in] type
/// The type for \a err.
//------------------------------------------------------------------
explicit
Error (ValueType err = 0, lldb::ErrorType type = lldb::eErrorTypeGeneric);
//------------------------------------------------------------------
/// Assignment operator.
///
/// @param[in] err
/// An error code.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const Error&
operator = (const Error& rhs);
//------------------------------------------------------------------
/// Assignment operator from a kern_return_t.
///
/// Sets the type to \c MachKernel and the error code to \a err.
///
/// @param[in] err
/// A mach error code.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const Error&
operator = (kern_return_t err);
~Error();
//------------------------------------------------------------------
/// Get the error string associated with the current error.
//
/// Gets the error value as a NULL terminated C string. The error
/// string will be fetched and cached on demand. The error string
/// will be retrieved from a callback that is appropriate for the
/// type of the error and will be cached until the error value is
/// changed or cleared.
///
/// @return
/// The error as a NULL terminated C string value if the error
/// is valid and is able to be converted to a string value,
/// NULL otherwise.
//------------------------------------------------------------------
const char *
AsCString (const char *default_error_str = "unknown error") const;
//------------------------------------------------------------------
/// Clear the object state.
///
/// Reverts the state of this object to contain a generic success
/// value and frees any cached error string value.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Test for error condition.
///
/// @return
/// \b true if this object contains an error, \b false
/// otherwise.
//------------------------------------------------------------------
bool
Fail () const;
//------------------------------------------------------------------
/// Access the error value.
///
/// @return
/// The error value.
//------------------------------------------------------------------
ValueType
GetError () const;
//------------------------------------------------------------------
/// Access the error type.
///
/// @return
/// The error type enumeration value.
//------------------------------------------------------------------
lldb::ErrorType
GetType () const;
//------------------------------------------------------------------
/// Log an error to Log().
///
/// Log the error given a formatted string \a format. If the this
/// object contains an error code, update the error string to
/// contain the prefix "error: ", followed by the formatted string,
/// followed by the error value and any string that describes the
/// error value. This allows more context to be given to an error
/// string that remains cached in this object. Logging always occurs
/// even when the error code contains a non-error value.
///
/// @param[in] format
/// A printf style format string.
///
/// @param[in] ...
/// Variable arguments that are needed for the printf style
/// format string \a format.
//------------------------------------------------------------------
void
PutToLog (Log *log, const char *format, ...);
//------------------------------------------------------------------
/// Log an error to Log() if the error value is an error.
///
/// Log the error given a formatted string \a format only if the
/// error value in this object describes an error condition. If the
/// this object contains an error, update the error string to
/// contain the prefix "error: " followed by the formatted string,
/// followed by the error value and any string that describes the
/// error value. This allows more context to be given to an error
/// string that remains cached in this object.
///
/// @param[in] format
/// A printf style format string.
///
/// @param[in] ...
/// Variable arguments that are needed for the printf style
/// format string \a format.
//------------------------------------------------------------------
void
LogIfError (Log *log, const char *format, ...);
//------------------------------------------------------------------
/// Set accessor from a kern_return_t.
///
/// Set accesssor for the error value to \a err and the error type
/// to \c MachKernel.
///
/// @param[in] err
/// A mach error code.
//------------------------------------------------------------------
void
SetError (kern_return_t err);
//------------------------------------------------------------------
/// Set accesssor with an error value and type.
///
/// Set accesssor for the error value to \a err and the error type
/// to \a type.
///
/// @param[in] err
/// A mach error code.
///
/// @param[in] type
/// The type for \a err.
//------------------------------------------------------------------
void
SetError (ValueType err, lldb::ErrorType type);
//------------------------------------------------------------------
/// Set the current error to errno.
///
/// Update the error value to be \c errno and update the type to
/// be \c Error::POSIX.
//------------------------------------------------------------------
void
SetErrorToErrno ();
//------------------------------------------------------------------
/// Set the current error to a generic error.
///
/// Update the error value to be \c LLDB_GENERIC_ERROR and update the
/// type to be \c Error::Generic.
//------------------------------------------------------------------
void
SetErrorToGenericError ();
//------------------------------------------------------------------
/// Set the current error string to \a err_str.
///
/// Set accessor for the error string value for a generic errors,
/// or to supply additional details above and beyond the standard
/// error strings that the standard type callbacks typically
/// provide. This allows custom strings to be supplied as an
/// error explanation. The error string value will remain until the
/// error value is cleared or a new error value/type is assigned.
///
/// @param err_str
/// The new custom error string to copy and cache.
//------------------------------------------------------------------
void
SetErrorString (const char *err_str);
//------------------------------------------------------------------
/// Set the current error string to a formatted error string.
///
/// @param format
/// A printf style format string
//------------------------------------------------------------------
int
SetErrorStringWithFormat (const char *format, ...);
int
SetErrorStringWithVarArg (const char *format, va_list args);
//------------------------------------------------------------------
/// Test for success condition.
///
/// Returns true if the error code in this object is considered a
/// successful return value.
///
/// @return
/// \b true if this object contains an value that describes
/// success (non-erro), \b false otherwise.
//------------------------------------------------------------------
bool
Success () const;
protected:
//------------------------------------------------------------------
/// Member variables
//------------------------------------------------------------------
ValueType m_code; ///< Error code as an integer value.
lldb::ErrorType m_type; ///< The type of the above error code.
mutable std::string m_string; ///< A string representation of the error code.
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // #ifndef __DCError_h__

View File

@ -0,0 +1,180 @@
//===-- Event.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_Event_h_
#define liblldb_Event_h_
// C Includes
// C++ Includes
#include <list>
#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Host/Predicate.h"
namespace lldb_private {
//----------------------------------------------------------------------
// lldb::EventData
//----------------------------------------------------------------------
class EventData
{
friend class Event;
public:
EventData ();
virtual
~EventData();
virtual const ConstString &
GetFlavor () const = 0;
virtual void
Dump (Stream *s) const;
private:
virtual void
DoOnRemoval (Event *event_ptr)
{
}
DISALLOW_COPY_AND_ASSIGN (EventData);
};
//----------------------------------------------------------------------
// lldb::EventDataBytes
//----------------------------------------------------------------------
class EventDataBytes : public EventData
{
public:
//------------------------------------------------------------------
// Constructors
//------------------------------------------------------------------
EventDataBytes ();
EventDataBytes (const char *cstr);
EventDataBytes (const void *src, size_t src_len);
virtual
~EventDataBytes();
//------------------------------------------------------------------
// Member functions
//------------------------------------------------------------------
virtual const ConstString &
GetFlavor () const;
virtual void
Dump (Stream *s) const;
const void *
GetBytes() const;
size_t
GetByteSize() const;
void
SetBytes (const void *src, size_t src_len);
void
SetBytesFromCString (const char *cstr);
//------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------
static const EventDataBytes *
GetEventDataFromEvent (const Event *event_ptr);
static const void *
GetBytesFromEvent (const Event *event_ptr);
static size_t
GetByteSizeFromEvent (const Event *event_ptr);
static const ConstString &
GetFlavorString ();
private:
std::string m_bytes;
DISALLOW_COPY_AND_ASSIGN (EventDataBytes);
};
//----------------------------------------------------------------------
// lldb::Event
//----------------------------------------------------------------------
class Event
{
friend class Broadcaster;
friend class Listener;
friend class EventData;
public:
Event (Broadcaster *broadcaster, uint32_t event_type, EventData *data = NULL);
Event (uint32_t event_type, EventData *data = NULL);
~Event ();
void
Dump (Stream *s) const;
EventData *
GetData ();
const EventData *
GetData () const;
uint32_t
GetType () const;
Broadcaster *
GetBroadcaster () const;
bool
BroadcasterIs (Broadcaster *broadcaster);
void
Clear();
private:
// This is only called by Listener when it pops an event off the queue for
// the listener. It calls the Event Data's DoOnRemoval() method, which is
// virtual and can be overridden by the specific data classes.
void
DoOnRemoval ();
// Called by Broadcaster::BroadcastEvent prior to letting all the listeners
// know about it update the contained broadcaster so that events can be
// popped off one queue and re-broadcast to others.
void
SetBroadcaster (Broadcaster *broadcaster);
Broadcaster * m_broadcaster; // The broadcaster that sent this event
uint32_t m_type; // The bit describing this event
std::auto_ptr<EventData> m_data_ap; // User specific data for this event
DISALLOW_COPY_AND_ASSIGN (Event);
Event(); // Disallow default constructor
};
} // namespace lldb_private
#endif // liblldb_Event_h_

View File

@ -0,0 +1,440 @@
//===-- FileSpec.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_FileSpec_h_
#define liblldb_FileSpec_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/STLUtils.h"
#include "lldb/Host/TimeValue.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class FileSpec FileSpec.h "lldb/Core/FileSpec.h"
/// @brief A file utility class.
///
/// A file specification class that divides paths up into a directory
/// and filename. These string values of the paths are put into uniqued
/// string pools for fast comparisons and efficient memory usage.
//----------------------------------------------------------------------
class FileSpec
{
public:
typedef enum FileType
{
eFileTypeInvalid = -1,
eFileTypeUknown = 0,
eFileTypeDirectory,
eFileTypePipe,
eFileTypeRegular,
eFileTypeSocket,
eFileTypeSymbolicLink,
};
FileSpec();
//------------------------------------------------------------------
/// Default constructor.
///
/// Takes an optional full path to a file. If \a path is valid,
/// this function will call FileSpec::SetFile (\a path).
///
/// @param[in] path
/// The full or partial path to a file.
///
/// @see FileSpec::SetFile ()
//------------------------------------------------------------------
explicit FileSpec (const char *path);
//------------------------------------------------------------------
/// Copy constructor
///
/// Makes a copy of the uniqued directory and filename strings from
/// \a rhs.
///
/// @param[in] rhs
/// A const FileSpec object reference to copy.
//------------------------------------------------------------------
FileSpec (const FileSpec& rhs);
//------------------------------------------------------------------
/// Copy constructor
///
/// Makes a copy of the uniqued directory and filename strings from
/// \a rhs if it is not NULL.
///
/// @param[in] rhs
/// A const FileSpec object pointer to copy if non-NULL.
//------------------------------------------------------------------
FileSpec (const FileSpec* rhs);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual in case this class is subclassed.
//------------------------------------------------------------------
virtual
~FileSpec ();
//------------------------------------------------------------------
/// Assignment operator.
///
/// Makes a copy of the uniqued directory and filename strings from
/// \a rhs.
///
/// @param[in] rhs
/// A const FileSpec object reference to assign to this object.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const FileSpec&
operator= (const FileSpec& rhs);
//------------------------------------------------------------------
/// Equal to operator
///
/// Tests if this object is equal to \a rhs.
///
/// @param[in] rhs
/// A const FileSpec object reference to compare this object
/// to.
///
/// @return
/// \b true if this object is equal to \a rhs, \b false
/// otherwise.
//------------------------------------------------------------------
bool
operator== (const FileSpec& rhs) const;
//------------------------------------------------------------------
/// Not equal to operator
///
/// Tests if this object is not equal to \a rhs.
///
/// @param[in] rhs
/// A const FileSpec object reference to compare this object
/// to.
///
/// @return
/// \b true if this object is equal to \a rhs, \b false
/// otherwise.
//------------------------------------------------------------------
bool
operator!= (const FileSpec& rhs) const;
//------------------------------------------------------------------
/// Less than to operator
///
/// Tests if this object is less than \a rhs.
///
/// @param[in] rhs
/// A const FileSpec object reference to compare this object
/// to.
///
/// @return
/// \b true if this object is less than \a rhs, \b false
/// otherwise.
//------------------------------------------------------------------
bool
operator< (const FileSpec& rhs) const;
//------------------------------------------------------------------
/// Convert to pointer operator.
///
/// This allows code to check a FileSpec object to see if it
/// contains anything valid using code such as:
///
/// @code
/// FileSpec file_spec(...);
/// if (file_spec)
/// { ...
/// @endcode
///
/// @return
/// A pointer to this object if either the directory or filename
/// is valid, NULL otherwise.
//------------------------------------------------------------------
operator
void* () const;
//------------------------------------------------------------------
/// Logical NOT operator.
///
/// This allows code to check a FileSpec object to see if it is
/// invalid using code such as:
///
/// @code
/// FileSpec file_spec(...);
/// if (!file_spec)
/// { ...
/// @endcode
///
/// @return
/// Returns \b true if the object has an empty directory and
/// filename, \b false otherwise.
//------------------------------------------------------------------
bool
operator! () const;
//------------------------------------------------------------------
/// Clears the object state.
///
/// Clear this object by releasing both the directory and filename
/// string values and reverting them to empty strings.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Compare two FileSpec objects.
///
/// If \a full is true, then both the directory and the filename
/// must match. If \a full is false, then the directory names for
/// \a lhs and \a rhs are only compared if they are both not empty.
/// This allows a FileSpec object to only contain a filename
/// and it can match FileSpec objects that have matching
/// filenames with different paths.
///
/// @param[in] lhs
/// A const reference to the Left Hand Side object to compare.
///
/// @param[in] rhs
/// A const reference to the Right Hand Side object to compare.
///
/// @param[in] full
/// If true, then both the directory and filenames will have to
/// match for a compare to return zero (equal to). If false
/// and either directory from \a lhs or \a rhs is empty, then
/// only the filename will be compared, else a full comparison
/// is done.
///
/// @return
/// @li -1 if \a lhs is less than \a rhs
/// @li 0 if \a lhs is equal to \a rhs
/// @li 1 if \a lhs is greater than \a rhs
//------------------------------------------------------------------
static int
Compare (const FileSpec& lhs, const FileSpec& rhs, bool full);
static bool
Equal (const FileSpec& a, const FileSpec& b, bool full);
//------------------------------------------------------------------
/// Dump this object to a Stream.
///
/// Dump the object to the supplied stream \a s. If the object
/// contains a valid directory name, it will be displayed followed
/// by a directory delimiter, and the filename.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// Existence test.
///
/// @return
/// \b true if the file exists on disk, \b false otherwise.
//------------------------------------------------------------------
bool
Exists () const;
uint64_t
GetByteSize() const;
//------------------------------------------------------------------
/// Directory string get accessor.
///
/// @return
/// A reference to the directory string object.
//------------------------------------------------------------------
ConstString &
GetDirectory ();
//------------------------------------------------------------------
/// Directory string const get accessor.
///
/// @return
/// A const reference to the directory string object.
//------------------------------------------------------------------
const ConstString &
GetDirectory () const;
//------------------------------------------------------------------
/// Filename string get accessor.
///
/// @return
/// A reference to the filename string object.
//------------------------------------------------------------------
ConstString &
GetFilename ();
//------------------------------------------------------------------
/// Filename string const get accessor.
///
/// @return
/// A const reference to the filename string object.
//------------------------------------------------------------------
const ConstString &
GetFilename () const;
TimeValue
GetModificationTime () const;
//------------------------------------------------------------------
/// Extract the full path to the file.
///
/// Extract the directory and path into a fixed buffer. This is
/// needed as the directory and path are stored in separate string
/// values.
///
/// @param[out] path
/// The buffer in which to place the extracted full path.
///
/// @param[in] max_path_length
/// The maximum length or \a path.
///
/// @return
/// \b true if the extracted fullpath fits into \a path, \b
/// false otherwise.
//------------------------------------------------------------------
bool
GetPath (char *path, size_t max_path_length) const;
FileType
GetFileType () const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// Return the size in bytes that this object takes in memory. This
/// returns the size in bytes of this object, not any shared string
/// values it may refer to.
///
/// @return
/// The number of bytes that this object occupies in memory.
///
/// @see ConstString::StaticMemorySize ()
//------------------------------------------------------------------
size_t
MemorySize () const;
//------------------------------------------------------------------
/// Memory map part of, or the entire contents of, a file.
///
/// Returns a shared pointer to a data buffer that contains all or
/// part of the contents of a file. The data is memory mapped and
/// will lazily page in data from the file as memory is accessed.
/// The data that is mappped will start \a offset bytes into the
/// file, and \a length bytes will be mapped. If \a length is
/// greater than the number of bytes available in the file starting
/// at \a offset, the number of bytes will be appropriately
/// truncated. The final number of bytes that get mapped can be
/// verified using the DataBuffer::GetByteSize() function on the return
/// shared data pointer object contents.
///
/// @param[in] offset
/// The offset in bytes from the beginning of the file where
/// memory mapping should begin.
///
/// @param[in] length
/// The size in bytes that should be mapped starting \a offset
/// bytes into the file. If \a length is \c SIZE_T_MAX, map
/// as many bytes as possible.
///
/// @return
/// A shared pointer to the memeory mapped data. This shared
/// pointer can contain a NULL DataBuffer pointer, so the contained
/// pointer must be checked prior to using it.
//------------------------------------------------------------------
lldb::DataBufferSP
MemoryMapFileContents (off_t offset = 0, size_t length = SIZE_T_MAX) const;
//------------------------------------------------------------------
/// Read part of, or the entire contents of, a file into a heap based data buffer.
///
/// Returns a shared pointer to a data buffer that contains all or
/// part of the contents of a file. The data copies into a heap based
/// buffer that lives in the DataBuffer shared pointer object returned.
/// The data that is cached will start \a offset bytes into the
/// file, and \a length bytes will be mapped. If \a length is
/// greater than the number of bytes available in the file starting
/// at \a offset, the number of bytes will be appropriately
/// truncated. The final number of bytes that get mapped can be
/// verified using the DataBuffer::GetByteSize() function.
///
/// @param[in] offset
/// The offset in bytes from the beginning of the file where
/// memory mapping should begin.
///
/// @param[in] length
/// The size in bytes that should be mapped starting \a offset
/// bytes into the file. If \a length is \c SIZE_T_MAX, map
/// as many bytes as possible.
///
/// @return
/// A shared pointer to the memeory mapped data. This shared
/// pointer can contain a NULL DataBuffer pointer, so the contained
/// pointer must be checked prior to using it.
//------------------------------------------------------------------
lldb::DataBufferSP
ReadFileContents (off_t offset = 0, size_t length = SIZE_T_MAX) const;
//------------------------------------------------------------------
/// Change the file specificed with a new path.
///
/// Update the contents of this object with a new path. The path will
/// be split up into a directory and filename and stored as uniqued
/// string values for quick comparison and efficient memory usage.
///
/// @param[in] path
/// A full, partial, or relative path to a file.
//------------------------------------------------------------------
void
SetFile (const char *path);
//------------------------------------------------------------------
/// Read the file into an array of strings, one per line.
///
/// Opens and reads the file in this object into an array of strings,
/// one string per line of the file. Returns a boolean indicating
/// success or failure.
///
/// @param[out] lines
/// The string array into which to read the file.
//------------------------------------------------------------------
bool
ReadFileLines (STLStringArray &lines);
static int
Resolve (const char *src_path, char *dst_path, size_t dst_len);
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
ConstString m_directory; ///< The uniqued directory path
ConstString m_filename; ///< The uniqued filename path
};
//----------------------------------------------------------------------
/// Dump a FileSpec object to a stream
//----------------------------------------------------------------------
Stream& operator << (Stream& s, const FileSpec& f);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_FileSpec_h_

View File

@ -0,0 +1,196 @@
//===-- FileSpecList.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_FileSpecList_h_
#define liblldb_FileSpecList_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "lldb/Core/FileSpec.h"
#include <vector>
namespace lldb_private {
//----------------------------------------------------------------------
/// @class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h"
/// @brief A file collection class.
///
/// A class that contains a mutable list of FileSpec objects.
//----------------------------------------------------------------------
class FileSpecList
{
public:
//------------------------------------------------------------------
/// Default constructor.
///
/// Initialize this object with an empty file list.
//------------------------------------------------------------------
FileSpecList ();
//------------------------------------------------------------------
/// Copy constructor.
///
/// Initialize this object with a copy of the file list from \a rhs.
///
/// @param[in] rhs
/// A const reference to another file list object.
//------------------------------------------------------------------
FileSpecList (const FileSpecList &rhs);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~FileSpecList ();
//------------------------------------------------------------------
/// Assignment operator.
///
/// Replace the file list in this object with the file list from
/// \a rhs.
///
/// @param[in] rhs
/// A file list object to copy.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const FileSpecList&
operator= (const FileSpecList &rhs);
//------------------------------------------------------------------
/// Append a FileSpec object to the list.
///
/// Appends \a file to the end of the file list.
///
/// @param[in] file
/// A new file to append to this file list.
//------------------------------------------------------------------
void
Append (const FileSpec &file);
//------------------------------------------------------------------
/// Append a FileSpec object if unique.
///
/// Appends \a file to the end of the file list if it doesn't
/// already exist in the file list.
///
/// @param[in] file
/// A new file to append to this file list.
///
/// @return
/// \b true if the file was appended, \b false otherwise.
//------------------------------------------------------------------
bool
AppendIfUnique (const FileSpec &file);
//------------------------------------------------------------------
/// Clears the file list.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Dumps the file list to the supplied stream pointer "s".
///
/// @param[in] s
/// The stream that will be used to dump the object description.
//------------------------------------------------------------------
void
Dump (Stream *s) const;
//------------------------------------------------------------------
/// Find a file index.
///
/// Find the index of the file in the file spec list that matches
/// \a file starting \a idx entries into the file spec list.
///
/// @param[in] idx
/// An index into the file list.
///
/// @param[in] file
/// The file specification to search for.
///
/// @return
/// The index of the file that matches \a file if it is found,
/// else UINT32_MAX is returned.
//------------------------------------------------------------------
uint32_t
FindFileIndex (uint32_t idx, const FileSpec &file) const;
//------------------------------------------------------------------
/// Get file at index.
///
/// Gets a file from the file list. If \a idx is not a valid index,
/// an empty FileSpec object will be returned. The file objects
/// that are returned can be tested using
/// FileSpec::operator void*().
///
/// @param[in] idx
/// An index into the file list.
///
/// @return
/// A copy of the FileSpec object at index \a idx. If \a idx
/// is out of range, then an empty FileSpec object will be
/// returned.
//------------------------------------------------------------------
const FileSpec &
GetFileSpecAtIndex (uint32_t idx) const;
//------------------------------------------------------------------
/// Get file specification pointer at index.
///
/// Gets a file from the file list. The file objects that are
/// returned can be tested using FileSpec::operator void*().
///
/// @param[in] idx
/// An index into the file list.
///
/// @return
/// A pointer to a contained FileSpec object at index \a idx.
/// If \a idx is out of range, then an NULL is returned.
//------------------------------------------------------------------
const FileSpec *
GetFileSpecPointerAtIndex (uint32_t idx) const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// Return the size in bytes that this object takes in memory. This
/// returns the size in bytes of this object, not any shared string
/// values it may refer to.
///
/// @return
/// The number of bytes that this object occupies in memory.
///
/// @see ConstString::StaticMemorySize ()
//------------------------------------------------------------------
size_t
MemorySize () const;
//------------------------------------------------------------------
/// Get the number of files in the file list.
///
/// @return
/// The number of files in the file spec list.
//------------------------------------------------------------------
uint32_t
GetSize () const;
static size_t GetFilesMatchingPartialPath (const char *path, bool dir_okay, FileSpecList &matches);
protected:
typedef std::vector<FileSpec> collection; ///< The collection type for the file list.
collection m_files; ///< A collection of FileSpec objects.
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_FileSpecList_h_

View File

@ -0,0 +1,153 @@
//===-- Flags.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_Flags_h_
#define liblldb_Flags_h_
#if defined(__cplusplus)
#include <stdint.h>
#include <unistd.h>
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Flags Flags.h "lldb/Core/Flags.h"
/// @brief A class to manage flag bits.
///
/// The Flags class does bits.
//----------------------------------------------------------------------
class Flags
{
public:
//----------------------------------------------------------------------
/// The value type for flag bits is a 32 bit unsigned integer type.
//----------------------------------------------------------------------
typedef uint32_t ValueType;
//----------------------------------------------------------------------
/// Construct with initial flag bit values.
///
/// Constructs this object with \a bits as the initial value for all
/// of the flag bits.
///
/// @param[in] bits
/// The initial value for all flag bits.
//----------------------------------------------------------------------
Flags (ValueType bits = 0);
//----------------------------------------------------------------------
/// Copy constructor.
///
/// Construct and copy the flag bits from \a rhs.
///
/// @param[in] rhs
/// A const Flags object reference to copy.
//----------------------------------------------------------------------
Flags (const Flags& rhs);
//----------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual in case this class is subclassed.
//----------------------------------------------------------------------
virtual
~Flags ();
//----------------------------------------------------------------------
/// Get accessor for all flag bits.
///
/// @return
/// Returns all of the flag bits as a Flags::ValueType.
//----------------------------------------------------------------------
ValueType
GetAllFlagBits () const;
size_t
GetBitSize() const;
//----------------------------------------------------------------------
/// Set accessor for all flag bits.
///
/// @param[in] bits
/// The bits with which to replace all of the current flag bits.
//----------------------------------------------------------------------
void
SetAllFlagBits (ValueType bits);
//----------------------------------------------------------------------
/// Clear one or more flag bits.
///
/// @param[in] bits
/// A bitfield containing one or more flag bits.
///
/// @return
/// The new flag bits after clearing all bits from \a bits.
//----------------------------------------------------------------------
ValueType
Clear (ValueType bits);
//----------------------------------------------------------------------
/// Set one or more flag bits.
///
/// @param[in] bits
/// A bitfield containing one or more flag bits.
///
/// @return
/// The new flag bits after setting all bits from \a bits.
//----------------------------------------------------------------------
ValueType
Set (ValueType bits);
//----------------------------------------------------------------------
/// Test one or more flag bits.
///
/// @return
/// \b true if \b any flag bits in \a bits are set, \b false
/// otherwise.
//----------------------------------------------------------------------
bool
IsSet (ValueType bits) const;
//----------------------------------------------------------------------
/// Test one or more flag bits.
///
/// @return
/// \b true if \b all flag bits in \a bits are clear, \b false
/// otherwise.
//----------------------------------------------------------------------
bool
IsClear (ValueType bits) const;
//----------------------------------------------------------------------
/// Get the number of zero bits in \a m_flags.
///
/// @return
/// The number of bits that are set to 0 in the current flags.
//----------------------------------------------------------------------
size_t
ClearCount () const;
//----------------------------------------------------------------------
/// Get the number of one bits in \a m_flags.
///
/// @return
/// The number of bits that are set to 1 in the current flags.
//----------------------------------------------------------------------
size_t
SetCount () const;
protected:
ValueType m_flags; ///< The flag bits.
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_Flags_h_

View File

@ -0,0 +1,38 @@
//===-- IOStreamMacros.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_IOStreamMacros_h_
#define liblldb_IOStreamMacros_h_
#if defined(__cplusplus)
#include <iomanip>
#define RAW_HEXBASE std::setfill('0') << std::hex << std::right
#define HEXBASE '0' << 'x' << RAW_HEXBASE
#define RAWHEX8(x) RAW_HEXBASE << std::setw(2) << ((uint32_t)(x))
#define RAWHEX16 RAW_HEXBASE << std::setw(4)
#define RAWHEX32 RAW_HEXBASE << std::setw(8)
#define RAWHEX64 RAW_HEXBASE << std::setw(16)
#define HEX8(x) HEXBASE << std::setw(2) << ((uint32_t)(x))
#define HEX16 HEXBASE << std::setw(4)
#define HEX32 HEXBASE << std::setw(8)
#define HEX64 HEXBASE << std::setw(16)
#define RAW_HEX(x) RAW_HEXBASE << std::setw(sizeof(x)*2) << (x)
#define HEX(x) HEXBASE << std::setw(sizeof(x)*2) << (x)
#define HEX_SIZE(x, sz) HEXBASE << std::setw((sz)) << (x)
#define STRING_WIDTH(w) std::setfill(' ') << std::setw(w)
#define LEFT_STRING_WIDTH(s, w) std::left << std::setfill(' ') << std::setw(w) << (s) << std::right
#define DECIMAL std::dec << std::setfill(' ')
#define DECIMAL_WIDTH(w) DECIMAL << std::setw(w)
//#define FLOAT(n, d) std::setfill(' ') << std::setw((n)+(d)+1) << std::setprecision(d) << std::showpoint << std::fixed
#define INDENT_WITH_SPACES(iword_idx) std::setfill(' ') << std::setw((iword_idx)) << ""
#define INDENT_WITH_TABS(iword_idx) std::setfill('\t') << std::setw((iword_idx)) << ""
#endif // #if defined(__cplusplus)
#endif // liblldb_IOStreamMacros_h_

View File

@ -0,0 +1,114 @@
//===-- InputReader.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_InputReader_h_
#define liblldb_InputReader_h_
#include <termios.h>
#include "lldb/lldb-include.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/Debugger.h"
namespace lldb_private {
class InputReader
{
public:
typedef size_t (*Callback) (void *baton,
InputReader *reader,
lldb::InputReaderAction notification,
const char *bytes,
size_t bytes_len);
InputReader ();
virtual
~InputReader ();
virtual Error
Initialize (Callback callback,
void *baton,
lldb::InputReaderGranularity token_size,
const char *end_token,
const char *prompt,
bool echo);
bool
IsDone () const
{
return m_done;
}
void
SetIsDone (bool b)
{
m_done = b;
}
lldb::InputReaderGranularity
GetGranularity () const
{
return m_granularity;
}
bool
GetEcho () const
{
return m_echo;
}
// Subclasses _can_ override this function to get input as it comes in
// without any granularity
virtual size_t
HandleRawBytes (const char *bytes, size_t bytes_len);
FILE *
GetInputFileHandle ();
FILE *
GetOutputFileHandle ();
bool
IsActive () const
{
return m_active;
}
const char *
GetPrompt () const;
void
RefreshPrompt();
protected:
friend class Debugger;
void
Notify (lldb::InputReaderAction notification);
Callback m_callback;
void *m_callback_baton;
std::string m_end_token;
std::string m_prompt;
lldb::InputReaderGranularity m_granularity;
bool m_done;
bool m_echo;
bool m_active;
private:
DISALLOW_COPY_AND_ASSIGN (InputReader);
};
} // namespace lldb_private
#endif // #ifndef liblldb_InputReader_h_

View File

@ -0,0 +1,149 @@
//===-- Language.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_Language_h_
#define liblldb_Language_h_
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Language Language.h "lldb/Core/Language.h"
/// @brief Encapsulates the programming language for an lldb object.
///
/// Languages are represented by an enumeration value.
///
/// The enumeration values used when describing the programming language
/// are the same values as the latest DWARF specification.
//----------------------------------------------------------------------
class Language
{
public:
//------------------------------------------------------------------
/// Programming language type.
///
/// These enumerations use the same language enumerations as the
/// DWARF specification for ease of use and consistency.
//------------------------------------------------------------------
typedef enum
{
Unknown = 0x0000, ///< Unknown or invalid language value.
C89 = 0x0001, ///< ISO C:1989.
C = 0x0002, ///< Non-standardized C, such as K&R.
Ada83 = 0x0003, ///< ISO Ada:1983.
C_plus_plus = 0x0004, ///< ISO C++:1998.
Cobol74 = 0x0005, ///< ISO Cobol:1974.
Cobol85 = 0x0006, ///< ISO Cobol:1985.
Fortran77 = 0x0007, ///< ISO Fortran 77.
Fortran90 = 0x0008, ///< ISO Fortran 90.
Pascal83 = 0x0009, ///< ISO Pascal:1983.
Modula2 = 0x000a, ///< ISO Modula-2:1996.
Java = 0x000b, ///< Java.
C99 = 0x000c, ///< ISO C:1999.
Ada95 = 0x000d, ///< ISO Ada:1995.
Fortran95 = 0x000e, ///< ISO Fortran 95.
PLI = 0x000f, ///< ANSI PL/I:1976.
ObjC = 0x0010, ///< Objective-C.
ObjC_plus_plus = 0x0011, ///< Objective-C++.
UPC = 0x0012, ///< Unified Parallel C.
D = 0x0013, ///< D.
Python = 0x0014, ///< Python.
} Type;
//------------------------------------------------------------------
/// Construct with optional language enumeration.
//------------------------------------------------------------------
Language(Language::Type language = Unknown);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual in case this class is subclassed.
//------------------------------------------------------------------
virtual
~Language();
//------------------------------------------------------------------
/// Get the language value as a NULL termianted C string.
///
/// @return
/// The C string representation of the language. The returned
/// string does not need to be freed as it comes from constant
/// strings. NULL can be returned when the language is set to
/// a value that doesn't match of of the Language::Type
/// enumerations.
//------------------------------------------------------------------
const char *
AsCString (lldb::DescriptionLevel level = lldb::eDescriptionLevelBrief) const;
void
Clear();
void
GetDescription (Stream *s, lldb::DescriptionLevel level) const;
//------------------------------------------------------------------
/// Dump the language value to the stream \a s.
///
/// @param[in] s
/// The stream to which to dump the language description.
//------------------------------------------------------------------
void
Dump(Stream *s) const;
//------------------------------------------------------------------
/// Get accessor for the language.
///
/// @return
/// The enumeration value that describes the programming
/// language that an object is associated with.
//------------------------------------------------------------------
Language::Type
GetLanguage() const;
//------------------------------------------------------------------
/// Set accessor for the language.
///
/// @param[in] language
/// The new enumeration value that describes the programming
/// language that an object is associated with.
//------------------------------------------------------------------
void
SetLanguage(Language::Type language);
//------------------------------------------------------------------
/// Set accessor for the language.
///
/// @param[in] language_cstr
/// The language name as a C string.
//------------------------------------------------------------------
bool
SetLanguageFromCString(const char *language_cstr);
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
Language::Type m_language; ///< The programming language enumeration value.
///< The enumeration values are the same as the
///< latest DWARF specification.
};
//--------------------------------------------------------------
/// Stream the language enumeration as a string object to a
/// Stream.
//--------------------------------------------------------------
Stream& operator << (Stream& s, const Language& language);
} // namespace lldb_private
#endif // liblldb_Language_h_

View File

@ -0,0 +1,173 @@
//===-- Listener.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_Select_h_
#define liblldb_Select_h_
// C Includes
// C++ Includes
#include <list>
#include <map>
#include <set>
#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Core/Event.h"
namespace lldb_private {
class Listener
{
public:
typedef bool (*HandleBroadcastCallback) (lldb::EventSP &event_sp, void *baton);
friend class Broadcaster;
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
Listener (const char *name);
~Listener ();
void
AddEvent (lldb::EventSP &event);
void
Clear ();
uint32_t
StartListeningForEvents (Broadcaster* broadcaster,
uint32_t event_mask);
uint32_t
StartListeningForEvents (Broadcaster* broadcaster,
uint32_t event_mask,
HandleBroadcastCallback callback,
void *callback_user_data);
bool
StopListeningForEvents (Broadcaster* broadcaster,
uint32_t event_mask);
// Returns true if an event was recieved, false if we timed out.
bool
WaitForEvent (const TimeValue *timeout,
lldb::EventSP &event_sp);
bool
WaitForEventForBroadcaster (const TimeValue *timeout,
Broadcaster *broadcaster,
lldb::EventSP &event_sp);
bool
WaitForEventForBroadcasterWithType (const TimeValue *timeout,
Broadcaster *broadcaster,
uint32_t event_type_mask,
lldb::EventSP &event_sp);
Event *
PeekAtNextEvent ();
Event *
PeekAtNextEventForBroadcaster (Broadcaster *broadcaster);
Event *
PeekAtNextEventForBroadcasterWithType (Broadcaster *broadcaster,
uint32_t event_type_mask);
bool
GetNextEvent (lldb::EventSP &event_sp);
bool
GetNextEventForBroadcaster (Broadcaster *broadcaster,
lldb::EventSP &event_sp);
bool
GetNextEventForBroadcasterWithType (Broadcaster *broadcaster,
uint32_t event_type_mask,
lldb::EventSP &event_sp);
size_t
HandleBroadcastEvent (lldb::EventSP &event_sp);
protected:
//------------------------------------------------------------------
// Classes that inherit from Listener can see and modify these
//------------------------------------------------------------------
struct BroadcasterInfo
{
BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = NULL, void *ud = NULL) :
event_mask (mask),
callback (cb),
callback_user_data (ud)
{
}
uint32_t event_mask;
HandleBroadcastCallback callback;
void *callback_user_data;
};
typedef std::multimap<Broadcaster*, BroadcasterInfo> broadcaster_collection;
typedef std::list<lldb::EventSP> event_collection;
bool
FindNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster
const ConstString *sources, // NULL for any event
uint32_t num_sources,
uint32_t event_type_mask,
lldb::EventSP &event_sp,
bool remove);
bool
GetNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster
const ConstString *sources, // NULL for any event
uint32_t num_sources,
uint32_t event_type_mask,
lldb::EventSP &event_sp);
bool
WaitForEventsInternal (const TimeValue *timeout,
Broadcaster *broadcaster, // NULL for any broadcaster
const ConstString *sources, // NULL for any event
uint32_t num_sources,
uint32_t event_type_mask,
lldb::EventSP &event_sp);
std::string m_name;
broadcaster_collection m_broadcasters;
Mutex m_broadcasters_mutex; // Protects m_broadcasters
event_collection m_events;
Mutex m_events_mutex; // Protects m_broadcasters and m_events
Predicate<bool> m_cond_wait;
void
BroadcasterWillDestruct (Broadcaster *);
private:
// broadcaster_collection::iterator
// FindBroadcasterWithMask (Broadcaster *broadcaster,
// uint32_t event_mask,
// bool exact);
//------------------------------------------------------------------
// For Listener only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Listener);
};
} // namespace lldb_private
#endif // liblldb_Select_h_

View File

@ -0,0 +1,243 @@
//===-- Log.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_Log_h_
#define liblldb_Log_h_
// C Includes
#include <stdbool.h>
#include <stdint.h>
#include <signal.h>
#include <stdio.h>
#include <sys/syslimits.h>
#include <unistd.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/PluginInterface.h"
//----------------------------------------------------------------------
// Logging types
//----------------------------------------------------------------------
#define LLDB_LOG_FLAG_STDOUT (1u << 0)
#define LLDB_LOG_FLAG_STDERR (1u << 1)
#define LLDB_LOG_FLAG_FATAL (1u << 2)
#define LLDB_LOG_FLAG_ERROR (1u << 3)
#define LLDB_LOG_FLAG_WARNING (1u << 4)
#define LLDB_LOG_FLAG_DEBUG (1u << 5)
#define LLDB_LOG_FLAG_VERBOSE (1u << 6)
//----------------------------------------------------------------------
// Logging Options
//----------------------------------------------------------------------
#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
#define LLDB_LOG_OPTION_DEBUG (1u << 2)
#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5)
#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
//----------------------------------------------------------------------
// Logging Functions
//----------------------------------------------------------------------
namespace lldb_private {
class Log
{
public:
//------------------------------------------------------------------
// Callback definitions for abstracted plug-in log access.
//------------------------------------------------------------------
typedef void (*DisableCallback) ();
typedef Log* (*EnableCallback) (lldb::StreamSP &log_stream_sp,
uint32_t log_options,
Args &args,
Stream *feedback_strm);
typedef void (*ListCategoriesCallback) (Stream *strm);
typedef struct Callbacks
{
DisableCallback disable;
EnableCallback enable;
ListCategoriesCallback list_categories;
};
//------------------------------------------------------------------
// Static accessors for logging channels
//------------------------------------------------------------------
static void
RegisterLogChannel (const char *channel,
const Log::Callbacks &log_callbacks);
static bool
UnregisterLogChannel (const char *channel);
static bool
GetLogChannelCallbacks (const char *channel,
Log::Callbacks &log_callbacks);
static void
EnableAllLogChannels (lldb::StreamSP &log_stream_sp,
uint32_t log_options,
Args &args,
Stream *feedback_strm);
static void
DisableAllLogChannels ();
static void
ListAllLogChannels (Stream *strm);
//------------------------------------------------------------------
// Static accessors to STDOUT logging facilities.
//------------------------------------------------------------------
static void
STDOUT (const char *format, ...);
static lldb::StreamSP
GetStreamForSTDOUT ();
static void
SetStreamForSTDOUT (lldb::StreamSP &stream_sp);
//------------------------------------------------------------------
// Static accessors to STDERR logging facilities.
//------------------------------------------------------------------
static void
STDERR (const char *format, ...);
static lldb::StreamSP
GetStreamForSTDERR ();
static void
SetStreamForSTDERR (lldb::StreamSP &stream_sp);
//------------------------------------------------------------------
// Member functions
//------------------------------------------------------------------
Log ();
Log (lldb::StreamSP &stream_sp);
~Log ();
void
PutCString (const char *cstr);
void
Printf (const char *format, ...);
void
VAPrintf (const char *format, va_list args);
void
PrintfWithFlags( uint32_t flags, const char *format, ...);
void
LogIf (uint32_t mask, const char *fmt, ...);
void
Debug (const char *fmt, ...);
void
DebugVerbose (const char *fmt, ...);
void
Error (const char *fmt, ...);
void
FatalError (int err, const char *fmt, ...);
void
Verbose (const char *fmt, ...);
void
Warning (const char *fmt, ...);
void
WarningVerbose (const char *fmt, ...);
Flags &
GetOptions();
const Flags &
GetOptions() const;
Flags &
GetMask();
const Flags &
GetMask() const;
bool
GetVerbose() const;
bool
GetDebug() const;
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
lldb::StreamSP m_stream_sp;
Flags m_options;
Flags m_mask_bits;
void
PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args);
private:
DISALLOW_COPY_AND_ASSIGN (Log);
};
class LogChannel : public PluginInterface
{
public:
LogChannel ();
virtual
~LogChannel ();
static const char *
GetPluginSuffix ();
static lldb::LogChannelSP
FindPlugin (const char *plugin_name);
virtual void
Disable () = 0;
virtual bool
Enable (lldb::StreamSP &log_stream_sp,
uint32_t log_options,
Stream *feedback_strm, // Feedback stream for argument errors etc
const Args &categories) = 0;// The categories to enable within this logging stream, if empty, enable default set
virtual void
ListCategories (Stream *strm) = 0;
protected:
lldb::LogSP m_log_sp;
private:
DISALLOW_COPY_AND_ASSIGN (LogChannel);
};
} // namespace lldb_private
#endif // liblldb_Log_H_

View File

@ -0,0 +1,485 @@
//===-- Mangled.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_Mangled_h_
#define liblldb_Mangled_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include <vector>
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Mangled Mangled.h "lldb/Core/Mangled.h"
/// @brief A class that handles mangled names.
///
/// Designed to handle mangled names. The demangled version of any names
/// will be computed when the demangled name is accessed through the
/// Demangled() acccessor. This class can also tokenize the demangled
/// version of the name for powerful searches. Functions and symbols
/// could make instances of this class for their mangled names. Uniqued
/// string pools are used for the mangled, demangled, and token string
/// values to allow for faster comparisons and for efficient memory use.
//----------------------------------------------------------------------
class Mangled
{
public:
//------------------------------------------------------------------
/// Token type enumerations.
//------------------------------------------------------------------
enum TokenType
{
eInvalid, ///< Invalid token value (unitialized value)
eNameSpace, ///< The token is a namespace name.
eMethodName, ///< The token is a global or class method name
eType, ///< The token is a language type
eTemplate, ///< The token is a template class
eTemplateBeg, ///< The token that indicates the start of a template parameters
eTemplateEnd, ///< The token that indicates the end of a template parameters
eParamsBeg, ///< The start of a method's parameters (the open parenthesis)
eParamsEnd, ///< The end of a method's parameters (the open parenthesis)
eQualifier, ///< A language qualifier
eError, ///< The token failed to parse
};
//------------------------------------------------------------------
/// Mangled::Token structure
///
/// As demangled names get tokenized, they get broken up into chunks
/// that have type enumerations (TokenType) and string values. Some of
/// the tokens are scopes (eTemplateBeg, eTemplateEnd, eParamsBeg,
/// eParamsEnd) that can indicate depth and searches can take
/// advantage of these to match using wildcards.
///
/// For example the mangled string:
///
/// "_ZNSbIhSt11char_traitsIhESaIhEE5eraseEmm"
///
/// Demangles to:
///
/// "std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::erase(unsigned long, unsigned long)"
///
/// And tokenizes to:
/// @li eNameSpace ("std")
/// @li eTemplate ("basic_string")
/// @li eTemplateBeg ()
/// @li eType ("unsigned char")
/// @li eNameSpace ("std")
/// @li eTemplate ("char_traits")
/// @li eTemplateBeg ()
/// @li eType ("unsigned char")
/// @li eTemplateEnd ()
/// @li eNameSpace ("std")
/// @li eTemplate ("allocator")
/// @li eTemplateBeg ()
/// @li eType ("unsigned char"
/// @li eTemplateEnd ()
/// @li eTemplateEnd ()
/// @li eMethodName ("erase")
/// @li eParamsBeg ()
/// @li eType ("unsigned long")
/// @li eType ("unsigned long")
/// @li eParamsEnd ()
///------------------------------------------------------------------
struct Token
{
//--------------------------------------------------------------
/// Default constructor.
///
/// Constructs this objet with an invalid token type and an
/// empty string.
//--------------------------------------------------------------
Token();
//--------------------------------------------------------------
/// Equal to operator.
///
/// Tests if this object is equal to \a rhs.
///
/// @param[in] rhs
/// A const Mangled::Token object reference to compare
/// this object to.
///
/// @return
/// \b true if this object is equal to \a rhs, \b false
/// otherwise.
//--------------------------------------------------------------
bool
operator== (const Token& rhs) const;
//--------------------------------------------------------------
/// Dump a description of this object to a Stream \a s.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//--------------------------------------------------------------
void
Dump (Stream *s) const;
//--------------------------------------------------------------
/// Test if this token is a wildcard token.
///
/// @return
/// Returns \b true if this token is a wildcard, \b false
/// otherwise.
//--------------------------------------------------------------
bool
IsWildcard() const;
//--------------------------------------------------------------
/// Members
//--------------------------------------------------------------
TokenType type; ///< The type of the token (Mangled::TokenType)
ConstString value; ///< The ConstString value associated with this token
};
//------------------------------------------------------------------
/// A collection of tokens.
///
/// This class can be instantiated with a demangled names that can
/// be used as a query using the
/// Mangled::TokenList::MatchesQuery(const TokenList&) const
/// function.
//------------------------------------------------------------------
class TokenList
{
public:
//--------------------------------------------------------------
/// Construct with a demangled name.
///
/// If demangled is valid the token list will parse up the
/// demangled string it is given, else the object will
/// initialize an empty token list.
//--------------------------------------------------------------
TokenList (const char *demangled = NULL);
//--------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------
~TokenList ();
//--------------------------------------------------------------
/// Clear the token list.
//--------------------------------------------------------------
void
Clear ();
//--------------------------------------------------------------
/// Dump a description of this object to a Stream \a s.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//--------------------------------------------------------------
void
Dump (Stream *s) const;
//--------------------------------------------------------------
/// Find a token by Mangled::TokenType.
///
/// Find the first token in the list that has \a token_type as
/// its type.
//--------------------------------------------------------------
const Token*
Find (TokenType token_type) const;
//--------------------------------------------------------------
/// Get a token by index.
///
/// @return
/// The token at index \a idx, or NULL if the index is out
/// of range.
//--------------------------------------------------------------
const Token*
GetTokenAtIndex (uint32_t idx) const;
//--------------------------------------------------------------
/// Given a token list, see if it matches this object's tokens.
/// \a token_list can contain wild card values to enable powerful
/// matching. Matching the std::string::erase(*) example that was
/// tokenized above we could use a token list such as:
///
/// token name
/// ----------- ----------------------------------------
/// eNameSpace "std"
/// eTemplate "basic_string"
/// eTemplateBeg
/// eInvalid "*"
/// eTemplateEnd
/// eMethodName "erase"
/// eParamsBeg
/// eInvalid "*"
/// eParamsEnd
///
/// @return
/// Returns \b true if it \a token_list matches this
/// object's tokens, \b false otherwise.
//--------------------------------------------------------------
bool
MatchesQuery (const TokenList& token_list) const;
//--------------------------------------------------------------
/// Parses \a demangled into tokens.
///
/// This allows complex comparisons to be done on demangled names. Comparisons can
/// include wildcards at the namespace, method name, template,
/// and template and parameter type levels.
///
/// Example queries include:
/// "std::basic_string<*>" // Find all std::basic_string variants
/// "std::basic_string<*>::erase(*)" // Find all std::basic_string::erase variants with any number of parameters
/// "*::clear()" // Find all functions with a method name of
/// // "clear" that are in any namespace that
/// // have no parameters
/// "::printf" // Find the printf function in the global namespace
/// "printf" // Ditto
/// "foo::*(int)" // Find all functions in the class or namespace "foo" that take a single integer argument
///
/// @return
/// The number of tokens that were decoded, or zero if
/// decoding fails.
//--------------------------------------------------------------
size_t
Parse (const char *demangled);
//--------------------------------------------------------------
/// Get the number of tokens in the list.
///
/// @return
/// The number of tokens in the token list.
//--------------------------------------------------------------
size_t
Size () const;
protected:
//--------------------------------------------------------------
// Member variables.
//--------------------------------------------------------------
typedef std::vector<Token> collection; ///< The collection type for a list of Token objects.
collection m_tokens; ///< The token list.
private:
DISALLOW_COPY_AND_ASSIGN (TokenList);
};
//----------------------------------------------------------------------
/// Default constructor.
///
/// Initialize with both mangled and demangled names empty.
//----------------------------------------------------------------------
Mangled ();
//----------------------------------------------------------------------
/// Construct with name.
///
/// Constructor with an optional string and a boolean indicating if it is
/// the mangled version.
///
/// @param[in] name
/// The name to copy into this object.
///
/// @param[in] is_mangled
/// If \b true then \a name is a mangled name, if \b false then
/// \a name is demangled.
//----------------------------------------------------------------------
explicit
Mangled (const char *name, bool is_mangled);
//----------------------------------------------------------------------
/// Destructor
///
/// Releases its ref counts on the mangled and demangled strings that
/// live in the global string pool.
//----------------------------------------------------------------------
~Mangled ();
//----------------------------------------------------------------------
/// Convert to pointer operator.
///
/// This allows code to check a Mangled object to see if it contains
/// a valid mangled name using code such as:
///
/// @code
/// Mangled mangled(...);
/// if (mangled)
/// { ...
/// @endcode
///
/// @return
/// A pointer to this object if either the mangled or unmangled
/// name is set, NULL otherwise.
//----------------------------------------------------------------------
operator
void*() const;
//----------------------------------------------------------------------
/// Logical NOT operator.
///
/// This allows code to check a Mangled object to see if it contains
/// an empty mangled name using code such as:
///
/// @code
/// Mangled mangled(...);
/// if (!mangled)
/// { ...
/// @endcode
///
/// @return
/// Returns \b true if the object has an empty mangled and
/// unmangled name, \b false otherwise.
//----------------------------------------------------------------------
bool
operator!() const;
//----------------------------------------------------------------------
/// Clear the mangled and demangled values.
//----------------------------------------------------------------------
void
Clear ();
//----------------------------------------------------------------------
/// Compare the mangled string values
///
/// Compares the Mangled::GetName() string in \a lhs and \a rhs.
///
/// @param[in] lhs
/// A const reference to the Left Hand Side object to compare.
///
/// @param[in] rhs
/// A const reference to the Right Hand Side object to compare.
///
/// @return
/// @li -1 if \a lhs is less than \a rhs
/// @li 0 if \a lhs is equal to \a rhs
/// @li 1 if \a lhs is greater than \a rhs
//----------------------------------------------------------------------
static int
Compare (const Mangled& lhs, const Mangled& rhs);
//----------------------------------------------------------------------
/// Dump a description of this object to a Stream \a s.
///
/// Dump a Mangled object to stream \a s. We don't force our
/// demangled name to be computed currently (we don't use the accessor).
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//----------------------------------------------------------------------
void
Dump (Stream *s) const;
//----------------------------------------------------------------------
/// Dump a debug description of this object to a Stream \a s.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//----------------------------------------------------------------------
void
DumpDebug (Stream *s) const;
//----------------------------------------------------------------------
/// Demangled name get accessor.
///
/// @return
/// A const reference to the demangled name string object.
//----------------------------------------------------------------------
const ConstString&
GetDemangledName () const;
//----------------------------------------------------------------------
/// Mangled name get accessor.
///
/// @return
/// A reference to the mangled name string object.
//----------------------------------------------------------------------
ConstString&
GetMangledName ();
//----------------------------------------------------------------------
/// Mangled name get accessor.
///
/// @return
/// A const reference to the mangled name string object.
//----------------------------------------------------------------------
const ConstString&
GetMangledName () const;
//----------------------------------------------------------------------
/// Best name get accessor.
///
/// @return
/// A const reference to the the mangled name string object if this
/// object has a valid mangled name, else a const reference to the
/// demangled name is returned.
//----------------------------------------------------------------------
const ConstString&
GetName () const;
//----------------------------------------------------------------------
/// Generate the tokens from the demangled name.
///
/// @param[out] tokens
/// A token list that will get filled in with the demangled tokens.
///
/// @return
/// The number of tokens that were parsed and stored in \a tokens.
//----------------------------------------------------------------------
size_t
GetTokens (Mangled::TokenList &tokens) const;
//----------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// Return the size in bytes that this object takes in memory. This
/// returns the size in bytes of this object, not any shared string
/// values it may refer to.
///
/// @return
/// The number of bytes that this object occupies in memory.
///
/// @see ConstString::StaticMemorySize ()
//----------------------------------------------------------------------
size_t
MemorySize () const;
//----------------------------------------------------------------------
/// Set the string value in this object.
///
/// If \a is_mangled is \b true, then the mangled named is set to \a
/// name, else the demangled name is set to \a name.
///
/// @param[in] name
/// The name to copy into this object.
///
/// @param[in] is_mangled
/// If \b true then \a name is a mangled name, if \b false then
/// \a name is demangled.
//----------------------------------------------------------------------
void
SetValue (const char *name, bool is_mangled);
private:
//----------------------------------------------------------------------
/// Mangled member variables.
//----------------------------------------------------------------------
ConstString m_mangled; ///< The mangled version of the name
mutable ConstString m_demangled; ///< Mutable so we can get it on demand with a const version of this object
};
Stream& operator << (Stream& s, const Mangled& obj);
Stream& operator << (Stream& s, const Mangled::TokenList& obj);
Stream& operator << (Stream& s, const Mangled::Token& obj);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_Mangled_h_

View File

@ -0,0 +1,597 @@
//===-- Module.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_Module_h_
#define liblldb_Module_h_
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/UUID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Symbol/TypeList.h"
//----------------------------------------------------------------------
/// @class Module Module.h "lldb/Core/Module.h"
/// @brief A class that describes an executable image and its associated
/// object and symbol files.
///
/// The module is designed to be able to select a single slice of an
/// executable image as it would appear on disk and during program
/// execution.
///
/// Modules control when and if information is parsed according to which
/// accessors are called. For example the object file (ObjectFile)
/// representation will only be parsed if the object file is requested
/// using the Module::GetObjectFile() is called. The debug symbols
/// will only be parsed if the symbol vendor (SymbolVendor) is
/// requested using the Module::GetSymbolVendor() is called.
///
/// The module will parse more detailed information as more queries are
/// made.
//----------------------------------------------------------------------
namespace lldb_private {
class Module :
public SymbolContextScope
{
public:
friend class ModuleList;
enum
{
flagsSearchedForObjParser = (1 << 0),
flagsSearchedForSymVendor = (1 << 1),
flagsParsedUUID = (1 << 2)
};
//------------------------------------------------------------------
/// Construct with file specification and architecture.
///
/// Clients that wish to share modules with other targets should
/// use ModuleList::GetSharedModule().
///
/// @param[in] file_spec
/// The file specification for the on disk repesentation of
/// this executable image.
///
/// @param[in] arch
/// The architecture to set as the current architecture in
/// this module.
///
/// @param[in] object_name
/// The name of an object in a module used to extract a module
/// within a module (.a files and modules that contain multiple
/// architectures).
///
/// @param[in] object_offset
/// The offset within an existing module used to extract a
/// module within a module (.a files and modules that contain
/// multiple architectures).
//------------------------------------------------------------------
Module (const FileSpec& file_spec,
const ArchSpec& arch,
const ConstString *object_name = NULL,
off_t object_offset = 0);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~Module ();
//------------------------------------------------------------------
/// If you have an instance of Module, get its corresponding shared
/// pointer if it has one in the shared module list.
//------------------------------------------------------------------
lldb::ModuleSP
GetSP ();
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
virtual void
CalculateSymbolContext (SymbolContext* sc);
//------------------------------------------------------------------
/// Dump a description of this object to a Stream.
///
/// Dump a description of the contents of this object to the
/// supplied stream \a s. The dumped content will be only what has
/// been loaded or parsed up to this point at which this function
/// is called, so this is a good way to see what has been parsed
/// in a module.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
//------------------------------------------------------------------
void
Dump (Stream *s);
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
virtual void
DumpSymbolContext (Stream *s);
//------------------------------------------------------------------
/// Find a symbol in the object files symbol table.
///
/// @param[in] name
/// The name of the symbol that we are looking for.
///
/// @param[in] symbol_type
/// If set to eSymbolTypeAny, find a symbol of any type that
/// has a name that matches \a name. If set to any other valid
/// SymbolType enumeration value, then search only for
/// symbols that match \a symbol_type.
///
/// @return
/// Returns a valid symbol pointer if a symbol was found,
/// NULL otherwise.
//------------------------------------------------------------------
const Symbol *
FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
size_t
FindSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, SymbolContextList &sc_list);
size_t
FindSymbolsMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list);
//------------------------------------------------------------------
/// Find functions by name.
///
/// @param[in] name
/// The name of the function we are looking for.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// @return
/// The number of matches added to \a sc_list.
//------------------------------------------------------------------
uint32_t
FindFunctions (const ConstString &name, bool append, SymbolContextList& sc_list);
//------------------------------------------------------------------
/// Find functions by name.
///
/// @param[in] regex
/// A regular expression to use when matching the name.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// @return
/// The number of matches added to \a sc_list.
//------------------------------------------------------------------
uint32_t
FindFunctions (const RegularExpression& regex, bool append, SymbolContextList& sc_list);
//------------------------------------------------------------------
/// Find global and static variables by name.
///
/// @param[in] name
/// The name of the global or static variable we are looking
/// for.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a
/// max_matches. Specify UINT_MAX to get all possible matches.
///
/// @param[in] variable_list
/// A list of variables that gets the matches appended to (if
/// \a append it \b true), or replace (if \a append is \b false).
///
/// @return
/// The number of matches added to \a variable_list.
//------------------------------------------------------------------
uint32_t
FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variable_list);
//------------------------------------------------------------------
/// Find global and static variables by regular exression.
///
/// @param[in] regex
/// A regular expression to use when matching the name.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a
/// max_matches. Specify UINT_MAX to get all possible matches.
///
/// @param[in] variable_list
/// A list of variables that gets the matches appended to (if
/// \a append it \b true), or replace (if \a append is \b false).
///
/// @return
/// The number of matches added to \a variable_list.
//------------------------------------------------------------------
uint32_t
FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variable_list);
//------------------------------------------------------------------
/// Find types by name.
///
/// @param[in] sc
/// A symbol context that scopes where to extract a type list
/// from.
///
/// @param[in] name
/// The name of the type we are looking for.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a
/// max_matches. Specify UINT_MAX to get all possible matches.
///
/// @param[in] encoding
/// Limit the search to specific types, or get all types if
/// set to Type::invalid.
///
/// @param[in] udt_name
/// If the encoding is a user defined type, specify the name
/// of the user defined type ("struct", "union", "class", etc).
///
/// @param[out] type_list
/// A type list gets populated with any matches.
///
/// @return
/// The number of matches added to \a type_list.
//------------------------------------------------------------------
// uint32_t
// FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& type_list);
//------------------------------------------------------------------
/// Find types by name.
///
/// @param[in] sc
/// A symbol context that scopes where to extract a type list
/// from.
///
/// @param[in] regex
/// A regular expression to use when matching the name.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a
/// max_matches. Specify UINT_MAX to get all possible matches.
///
/// @param[in] encoding
/// Limit the search to specific types, or get all types if
/// set to Type::invalid.
///
/// @param[in] udt_name
/// If the encoding is a user defined type, specify the name
/// of the user defined type ("struct", "union", "class", etc).
///
/// @param[out] type_list
/// A type list gets populated with any matches.
///
/// @return
/// The number of matches added to \a type_list.
//------------------------------------------------------------------
// uint32_t
// FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& type_list);
//------------------------------------------------------------------
/// Get const accessor for the module architecture.
///
/// @return
/// A const reference to the architecture object.
//------------------------------------------------------------------
const ArchSpec&
GetArchitecture () const;
//------------------------------------------------------------------
/// Get const accessor for the module file specification.
///
/// @return
/// A const reference to the file specification object.
//------------------------------------------------------------------
const FileSpec &
GetFileSpec () const;
const TimeValue &
GetModificationTime () const;
//------------------------------------------------------------------
/// Get the number of compile units for this module.
///
/// @return
/// The number of compile units that the symbol vendor plug-in
/// finds.
//------------------------------------------------------------------
uint32_t
GetNumCompileUnits();
lldb::CompUnitSP
GetCompileUnitAtIndex (uint32_t);
const ConstString &
GetObjectName() const;
off_t
GetObjectOffset() const;
//------------------------------------------------------------------
/// Get the object file representation for the current architecture.
///
/// If the object file has not been located or parsed yet, this
/// function will find the best ObjectFile plug-in that can parse
/// Module::m_file.
///
/// @return
/// If Module::m_file does not exist, or no plug-in was found
/// that can parse the file, or the object file doesn't contain
/// the current architecture in Module::m_arch, NULL will be
/// returned, else a valid object file interface will be
/// returned. The returned pointer is owned by this object and
/// remains valid as long as the object is around.
//------------------------------------------------------------------
ObjectFile *
GetObjectFile ();
//------------------------------------------------------------------
/// Get the symbol vendor interface for the current architecture.
///
/// If the symbol vendor file has not been located yet, this
/// function will find the best SymbolVendor plug-in that can
/// use the current object file.
///
/// @return
/// If this module does not have a valid object file, or no
/// plug-in can be found that can use the object file, NULL will
/// be returned, else a valid symbol vendor plug-in interface
/// will be returned. The returned pointer is owned by this
/// object and remains valid as long as the object is around.
//------------------------------------------------------------------
SymbolVendor*
GetSymbolVendor(bool can_create = true);
//------------------------------------------------------------------
/// Get accessor the type list for this module.
///
/// @return
/// A valid type list pointer, or NULL if there is no valid
/// symbol vendor for this module.
//------------------------------------------------------------------
TypeList*
GetTypeList ();
//------------------------------------------------------------------
/// Get a pointer to the UUID value contained in this object.
///
/// If the executable image file doesn't not have a UUID value built
/// into the file format, an MD5 checksum of the entire file, or
/// slice of the file for the current architecture should be used.
///
/// @return
/// A const pointer to the internal copy of the UUID value in
/// this module if this module has a valid UUID value, NULL
/// otherwise.
//------------------------------------------------------------------
const UUID &
GetUUID ();
//------------------------------------------------------------------
/// A debugging function that will cause everything in a module to
/// be parsed.
///
/// All compile units will be pasred, along with all globals and
/// static variables and all functions for those compile units.
/// All types, scopes, local variables, static variables, global
/// variables, and line tables will be parsed. This can be used
/// prior to dumping a module to see a complete list of the
/// resuling debug information that gets parsed, or as a debug
/// function to ensure that the module can consume all of the
/// debug data the symbol vendor provides.
//------------------------------------------------------------------
void
ParseAllDebugSymbols();
bool
ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr);
uint32_t
ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc);
//------------------------------------------------------------------
/// Resolve items in the symbol context for a given file and line.
///
/// Tries to resolve \a file_path and \a line to a list of matching
/// symbol contexts.
///
/// The line table entries contains addresses that can be used to
/// further resolve the values in each match: the function, block,
/// symbol. Care should be taken to minimize the amount of
/// information that is requested to only what is needed --
/// typically the module, compile unit, line table and line table
/// entry are sufficient.
///
/// @param[in] file_path
/// A path to a source file to match. If \a file_path does not
/// specify a directory, then this query will match all files
/// whose base filename matches. If \a file_path does specify
/// a directory, the fullpath to the file must match.
///
/// @param[in] line
/// The source line to match, or zero if just the compile unit
/// should be resolved.
///
/// @param[in] check_inlines
/// Check for inline file and line number matches. This option
/// should be used sparingly as it will cause all line tables
/// for every compile unit to be parsed and searched for
/// matching inline file entries.
///
/// @param[in] resolve_scope
/// The scope that should be resolved (see
/// SymbolContext::Scope).
///
/// @param[out] sc_list
/// A symbol context list that gets matching symbols contexts
/// appended to.
///
/// @return
/// The number of matches that were added to \a sc_list.
///
/// @see SymbolContext::Scope
//------------------------------------------------------------------
uint32_t
ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
//------------------------------------------------------------------
/// Resolve items in the symbol context for a given file and line.
///
/// Tries to resolve \a file_spec and \a line to a list of matching
/// symbol contexts.
///
/// The line table entries contains addresses that can be used to
/// further resolve the values in each match: the function, block,
/// symbol. Care should be taken to minimize the amount of
/// information that is requested to only what is needed --
/// typically the module, compile unit, line table and line table
/// entry are sufficient.
///
/// @param[in] file_spec
/// A file spec to a source file to match. If \a file_path does
/// not specify a directory, then this query will match all
/// files whose base filename matches. If \a file_path does
/// specify a directory, the fullpath to the file must match.
///
/// @param[in] line
/// The source line to match, or zero if just the compile unit
/// should be resolved.
///
/// @param[in] check_inlines
/// Check for inline file and line number matches. This option
/// should be used sparingly as it will cause all line tables
/// for every compile unit to be parsed and searched for
/// matching inline file entries.
///
/// @param[in] resolve_scope
/// The scope that should be resolved (see
/// SymbolContext::Scope).
///
/// @param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// @return
/// A integer that contains SymbolContext::Scope bits set for
/// each item that was successfully resolved.
///
/// @see SymbolContext::Scope
//------------------------------------------------------------------
uint32_t
ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
void
SetFileSpecAndObjectName (const FileSpec &file,
const ConstString &object_name);
protected:
//------------------------------------------------------------------
// Member Variables
//------------------------------------------------------------------
mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
TimeValue m_mod_time; ///< The modification time for this module when it was created.
const ArchSpec m_arch; ///< The architecture for this module.
UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
FileSpec m_file; ///< The file representation on disk for this module (if there is one).
Flags m_flags; ///< Flags for this module to track what has been parsed already.
ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file.
std::auto_ptr<ObjectFile> m_objfile_ap; ///< A pointer to the object file parser for this module.
std::auto_ptr<SymbolVendor> m_symfile_ap; ///< A pointer to the symbol vendor for this module.
//------------------------------------------------------------------
/// Resolve a file or load virtual address.
///
/// Tries to resolve \a vm_addr as a file address (if \a
/// vm_addr_is_file_addr is true) or as a load address if \a
/// vm_addr_is_file_addr is false) in the symbol vendor.
/// \a resolve_scope indicates what clients wish to resolve
/// and can be used to limit the scope of what is parsed.
///
/// @param[in] vm_addr
/// The load virtual address to resolve.
///
/// @param[in] vm_addr_is_file_addr
/// If \b true, \a vm_addr is a file address, else \a vm_addr
/// if a load address.
///
/// @param[in] resolve_scope
/// The scope that should be resolved (see
/// SymbolContext::Scope).
///
/// @param[out] so_addr
/// The section offset based address that got resolved if
/// any bits are returned.
///
/// @param[out] sc
// The symbol context that has objects filled in. Each bit
/// in the \a resolve_scope pertains to a member in the \a sc.
///
/// @return
/// A integer that contains SymbolContext::Scope bits set for
/// each item that was successfully resolved.
///
/// @see SymbolContext::Scope
//------------------------------------------------------------------
uint32_t
ResolveSymbolContextForAddress (lldb::addr_t vm_addr, bool vm_addr_is_file_addr, uint32_t resolve_scope, Address& so_addr, SymbolContext& sc);
void SymbolIndicesToSymbolContextList (Symtab *symtab, std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list);
private:
DISALLOW_COPY_AND_ASSIGN (Module);
};
} // namespace lldb_private
#endif // liblldb_Module_h_

View File

@ -0,0 +1,103 @@
//===-- ModuleChild.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_ModuleChild_h_
#define liblldb_ModuleChild_h_
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class ModuleChild ModuleChild.h "lldb/Core/ModuleChild.h"
/// @brief A mix in class that contains a pointer back to the module
/// that owns the object which inherits from it.
//----------------------------------------------------------------------
class ModuleChild
{
public:
//------------------------------------------------------------------
/// Construct with owning module.
///
/// @param[in] module
/// The module that owns the object that inherits from this
/// class.
//------------------------------------------------------------------
ModuleChild (Module* module);
//------------------------------------------------------------------
/// Copy constructor.
///
/// @param[in] rhs
/// A const ModuleChild class reference to copy.
//------------------------------------------------------------------
ModuleChild (const ModuleChild& rhs);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from.
//------------------------------------------------------------------
virtual
~ModuleChild();
//------------------------------------------------------------------
/// Assignment operator.
///
/// @param[in] rhs
/// A const ModuleChild class reference to copy.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const ModuleChild&
operator= (const ModuleChild& rhs);
//------------------------------------------------------------------
/// Get accessor for the module pointer.
///
/// @return
/// A pointer to the module that owns this object.
//------------------------------------------------------------------
Module *
GetModule ();
//------------------------------------------------------------------
/// Get const accessor for the module pointer.
///
/// @return
/// A const pointer to the module that owns the object that
/// inherits from this class.
//------------------------------------------------------------------
Module *
GetModule () const;
//------------------------------------------------------------------
/// Set accessor for the module pointer.
///
/// @param[in] module
/// A new module that owns the object that inherits from this
/// class.
//------------------------------------------------------------------
void
SetModule (Module *module);
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
Module *m_module; ///< The Module that owns the object that inherits
///< from this class.
};
} // namespace lldb_private
#endif // liblldb_ModuleChild_h_

View File

@ -0,0 +1,339 @@
//===-- ModuleList.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_ModuleList_h_
#define liblldb_ModuleList_h_
#include <vector>
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class ModuleList ModuleList.h "lldb/Core/ModuleList.h"
/// @brief A collection class for Module objects.
///
/// Modules in the module collection class are stored as reference
/// counted shared pointers to Module objects.
//----------------------------------------------------------------------
class ModuleList
{
public:
//------------------------------------------------------------------
/// Default constructor.
///
/// Creates an empty list of Module objects.
//------------------------------------------------------------------
ModuleList ();
//------------------------------------------------------------------
/// Copy Constructor.
///
/// Creates a new module list object with a copy of the modules from
/// \a rhs.
///
/// @param[in] rhs
/// Another module list object.
//------------------------------------------------------------------
ModuleList (const ModuleList& rhs);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~ModuleList ();
//------------------------------------------------------------------
/// Assignment operator.
///
/// Copies the module list from \a rhs into this list.
///
/// @param[in] rhs
/// Another module list object.
///
/// @return
/// A const reference to this object.
//------------------------------------------------------------------
const ModuleList&
operator= (const ModuleList& rhs);
//------------------------------------------------------------------
/// Append a module to the module list.
///
/// Appends the module to the collection.
///
/// @param[in] module_sp
/// A shared pointer to a module to add to this collection.
//------------------------------------------------------------------
void
Append (lldb::ModuleSP &module_sp);
bool
AppendInNeeded (lldb::ModuleSP &module_sp);
//------------------------------------------------------------------
/// Clear the object's state.
///
/// Clears the list of modules and releases a reference to each
/// module object and if the reference count goes to zero, the
/// module will be deleted.
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
/// Dump the description of each module contained in this list.
///
/// Dump the description of each module contained in this list to
/// the supplied stream \a s.
///
/// @param[in] s
/// The stream to which to dump the object descripton.
///
/// @see Module::Dump(Stream *) const
//------------------------------------------------------------------
void
Dump (Stream *s) const;
uint32_t
GetIndexForModule (const Module *module) const;
//------------------------------------------------------------------
/// Get the module shared pointer for the module at index \a idx.
///
/// @param[in] idx
/// An index into this module collection.
///
/// @return
/// A shared pointer to a Module which can contain NULL if
/// \a idx is out of range.
///
/// @see ModuleList::GetSize()
//------------------------------------------------------------------
lldb::ModuleSP
GetModuleAtIndex (uint32_t idx);
//------------------------------------------------------------------
/// Get the module pointer for the module at index \a idx.
///
/// @param[in] idx
/// An index into this module collection.
///
/// @return
/// A pointer to a Module which can by NULL if \a idx is out
/// of range.
///
/// @see ModuleList::GetSize()
//------------------------------------------------------------------
Module*
GetModulePointerAtIndex (uint32_t idx) const;
//------------------------------------------------------------------
/// Find functions by name.
///
/// Finds all functions that match \a name in all of the modules and
/// returns the results in \a sc_list.
///
/// @param[in] name
/// The name of the function we are looking for.
///
/// @param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
/// @return
/// The number of matches added to \a sc_list.
//------------------------------------------------------------------
size_t
FindFunctions (const ConstString &name,
SymbolContextList &sc_list);
//------------------------------------------------------------------
/// Find global and static variables by name.
///
/// @param[in] name
/// The name of the global or static variable we are looking
/// for.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a
/// max_matches. Specify UINT_MAX to get all possible matches.
///
/// @param[in] variable_list
/// A list of variables that gets the matches appended to (if
/// \a append it \b true), or replace (if \a append is \b false).
///
/// @return
/// The number of matches added to \a variable_list.
//------------------------------------------------------------------
uint32_t
FindGlobalVariables (const ConstString &name,
bool append,
uint32_t max_matches,
VariableList& variable_list);
//------------------------------------------------------------------
/// Find global and static variables by regular exression.
///
/// @param[in] regex
/// A regular expression to use when matching the name.
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
/// variable_list, else matches replace the contents of
/// \a variable_list.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a
/// max_matches. Specify UINT_MAX to get all possible matches.
///
/// @param[in] variable_list
/// A list of variables that gets the matches appended to (if
/// \a append it \b true), or replace (if \a append is \b false).
///
/// @return
/// The number of matches added to \a variable_list.
//------------------------------------------------------------------
uint32_t
FindGlobalVariables (const RegularExpression& regex,
bool append,
uint32_t max_matches,
VariableList& variable_list);
//------------------------------------------------------------------
/// Finds the first module whose file specification matches \a
/// file_spec.
///
/// @param[in] file_spec_ptr
/// A file specification object to match against the Module's
/// file specifications. If \a file_spec does not have
/// directory information, matches will occur by matching only
/// the basename of any modules in this list. If this value is
/// NULL, then file specifications won't be compared when
/// searching for matching modules.
///
/// @param[in] arch_ptr
/// The architecture to search for if non-NULL. If this value
/// is NULL no architecture matching will be performed.
///
/// @param[in] uuid_ptr
/// The uuid to search for if non-NULL. If this value is NULL
/// no uuid matching will be performed.
///
/// @param[in] object_name
/// An optional object name that must match as well. This value
/// can be NULL.
///
/// @param[out] matching_module_list
/// A module list that gets filled in with any modules that
/// match the search criteria.
///
/// @return
/// The number of matching modules found by the search.
//------------------------------------------------------------------
size_t
FindModules (const FileSpec *file_spec_ptr,
const ArchSpec *arch_ptr,
const UUID *uuid_ptr,
const ConstString *object_name,
ModuleList& matching_module_list) const;
lldb::ModuleSP
FindModule (lldb_private::Module *module_ptr);
lldb::ModuleSP
FindFirstModuleForFileSpec (const FileSpec &file_spec,
const ConstString *object_name = NULL);
size_t
FindSymbolsWithNameAndType (const ConstString &name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list);
bool
Remove (lldb::ModuleSP &module_sp);
bool
ResolveFileAddress (lldb::addr_t vm_addr,
Address& so_addr);
//------------------------------------------------------------------
/// @copydoc Module::ResolveSymbolContextForAddress (const Address &,uint32_t,SymbolContext&)
//------------------------------------------------------------------
uint32_t
ResolveSymbolContextForAddress (const Address& so_addr,
uint32_t resolve_scope,
SymbolContext& sc);
//------------------------------------------------------------------
/// @copydoc Module::ResolveSymbolContextForFilePath (const char *,uint32_t,bool,uint32_t,SymbolContextList&)
//------------------------------------------------------------------
uint32_t
ResolveSymbolContextForFilePath (const char *file_path,
uint32_t line,
bool check_inlines,
uint32_t resolve_scope,
SymbolContextList& sc_list);
//------------------------------------------------------------------
/// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec &,uint32_t,bool,uint32_t,SymbolContextList&)
//------------------------------------------------------------------
uint32_t
ResolveSymbolContextsForFileSpec (const FileSpec &file_spec,
uint32_t line,
bool check_inlines,
uint32_t resolve_scope,
SymbolContextList& sc_list);
//------------------------------------------------------------------
/// Gets the size of the module list.
///
/// @return
/// The number of modules in the module list.
//------------------------------------------------------------------
size_t
GetSize () const;
static const lldb::ModuleSP
GetModuleSP (lldb_private::Module *module_ptr);
static Error
GetSharedModule (const FileSpec& file_spec,
const ArchSpec& arch,
const UUID *uuid_ptr,
const ConstString *object_name,
off_t object_offset,
lldb::ModuleSP &module_sp,
lldb::ModuleSP *old_module_sp_ptr,
bool *did_create_ptr);
protected:
//------------------------------------------------------------------
// Class typedefs.
//------------------------------------------------------------------
typedef std::vector<lldb::ModuleSP> collection; ///< The module collection type.
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
collection m_modules; ///< The collection of modules.
mutable Mutex m_modules_mutex;
};
} // namespace lldb_private
#endif // liblldb_ModuleList_h_

View File

@ -0,0 +1,296 @@
//===-- Options.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_Options_h_
#define liblldb_Options_h_
// C Includes
#include <getopt.h>
// C++ Includes
#include <set>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Args.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Options Options.h "lldb/Core/Options.h"
/// @brief A command line option parsing protocol class.
///
/// Options is designed to be subclassed to contain all needed
/// options for a given command. The options can be parsed by calling:
/// \code
/// Error Args::ParseOptions (Options &);
/// \endcode
///
/// The options are specified using the format defined for the libc
/// options parsing function getopt_long:
/// \code
/// #include <getopt.h>
/// int getopt_long(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex);
/// \endcode
///
/// Example code:
/// \code
/// #include <getopt.h>
/// #include <string>
///
/// class CommandOptions : public Options
/// {
/// public:
/// virtual struct option *
/// GetLongOptions() {
/// return g_options;
/// }
///
/// virtual Error
/// SetOptionValue (int option_idx, int option_val, const char *option_arg)
/// {
/// Error error;
/// switch (option_val)
/// {
/// case 'g': debug = true; break;
/// case 'v': verbose = true; break;
/// case 'l': log_file = option_arg; break;
/// case 'f': log_flags = strtoull(option_arg, NULL, 0); break;
/// default:
/// error.SetErrorStringWithFormat("unrecognized short option %c", option_val);
/// break;
/// }
///
/// return error;
/// }
///
/// CommandOptions () : debug (true), verbose (false), log_file (), log_flags (0)
/// {}
///
/// bool debug;
/// bool verbose;
/// std::string log_file;
/// uint32_t log_flags;
///
/// static struct option g_options[];
///
/// };
///
/// struct option CommandOptions::g_options[] =
/// {
/// { "debug", no_argument, NULL, 'g' },
/// { "log-file", required_argument, NULL, 'l' },
/// { "log-flags", required_argument, NULL, 'f' },
/// { "verbose", no_argument, NULL, 'v' },
/// { NULL, 0, NULL, 0 }
/// };
///
/// int main (int argc, const char **argv, const char **envp)
/// {
/// CommandOptions options;
/// Args main_command;
/// main_command.SetArguments(argc, argv, false);
/// main_command.ParseOptions(options);
///
/// if (options.verbose)
/// {
/// std::cout << "verbose is on" << std::endl;
/// }
/// }
/// \endcode
//----------------------------------------------------------------------
class Options
{
public:
Options ();
virtual
~Options ();
void
BuildGetoptTable ();
void
BuildValidOptionSets ();
uint32_t
NumCommandOptions ();
//------------------------------------------------------------------
/// Get the option definitions to use when parsing Args options.
///
/// @see Args::ParseOptions (Options&)
/// @see man getopt_long
//------------------------------------------------------------------
struct option *
GetLongOptions ();
void
OptionSeen (int option_idx);
bool
VerifyOptions (CommandReturnObject &result);
// Verify that the options given are in the options table and can be used together, but there may be
// some required options that are missing (used to verify options that get folded into command aliases).
bool
VerifyPartialOptions (CommandReturnObject &result);
// void
// BuildAliasOptions (OptionArgVector *option_arg_vector, Args args);
void
OutputFormattedUsageText (Stream &strm,
const char *text,
uint32_t output_max_columns);
void
GenerateOptionUsage (Stream &strm,
CommandObject *cmd,
const char *program_name = NULL);
// The following two pure virtual functions must be defined by every class that inherits from
// this class.
virtual const lldb::OptionDefinition*
GetDefinitions () = 0;
virtual void
ResetOptionValues () = 0;
//------------------------------------------------------------------
/// Set the value of an option.
///
/// @param[in] option_idx
/// The index into the "struct option" array that was returned
/// by Options::GetLongOptions().
///
/// @param[in] option_arg
/// The argument value for the option that the user entered, or
/// NULL if there is no argument for the current option.
///
///
/// @see Args::ParseOptions (Options&)
/// @see man getopt_long
//------------------------------------------------------------------
virtual Error
SetOptionValue (int option_idx, const char *option_arg) = 0;
//------------------------------------------------------------------
/// Handles the generic bits of figuring out whether we are in an option, and if so completing
/// it.
///
/// @param[in] input
/// The command line parsed into words
///
/// @param[in] cursor_index
/// The index in \ainput of the word in which the cursor lies.
///
/// @param[in] char_pos
/// The character position of the cursor in its argument word.
///
/// @param[in] match_start_point
/// @param[in] match_return_elements
/// See CommandObject::HandleCompletions for a description of how these work.
///
/// @param[in] interpreter
/// The interpreter that's doing the completing.
///
/// @param[out] matches
/// The array of matches returned.
///
/// FIXME: This is the wrong return value, since we also need to make a distinction between
/// total number of matches, and the window the user wants returned.
///
/// @return
/// \btrue if we were in an option, \bfalse otherwise.
//------------------------------------------------------------------
bool
HandleOptionCompletion (Args &input,
OptionElementVector &option_map,
int cursor_index,
int char_pos,
int match_start_point,
int max_return_elements,
lldb_private::CommandInterpreter *interpreter,
lldb_private::StringList &matches);
//------------------------------------------------------------------
/// Handles the generic bits of figuring out whether we are in an option, and if so completing
/// it.
///
/// @param[in] input
/// The command line parsed into words
///
/// @param[in] cursor_index
/// The index in \ainput of the word in which the cursor lies.
///
/// @param[in] char_pos
/// The character position of the cursor in its argument word.
///
/// @param[in] opt_element_vector
/// The results of the options parse of \a input.
///
/// @param[in] opt_element_index
/// The position in \a opt_element_vector of the word in \a input containing the cursor.
///
/// @param[in] match_start_point
/// @param[in] match_return_elements
/// See CommandObject::HandleCompletions for a description of how these work.
///
/// @param[in] interpreter
/// The interpreter that's doing the completing.
///
/// @param[out] matches
/// The array of matches returned.
///
/// FIXME: This is the wrong return value, since we also need to make a distinction between
/// total number of matches, and the window the user wants returned.
///
/// @return
/// \btrue if we were in an option, \bfalse otherwise.
//------------------------------------------------------------------
virtual bool
HandleOptionArgumentCompletion (Args &input,
int cursor_index,
int char_pos,
OptionElementVector &opt_element_vector,
int opt_element_index,
int match_start_point,
int max_return_elements,
CommandInterpreter *interpreter,
StringList &matches);
protected:
typedef std::set<char> OptionSet;
std::vector<struct option> m_getopt_table;
OptionSet m_seen_options;
std::vector<OptionSet> m_required_options;
std::vector<OptionSet> m_optional_options;
bool
IsASubset (const OptionSet& set_a, const OptionSet& set_b);
size_t
OptionsSetDiff (const OptionSet &set_a, const OptionSet &set_b, OptionSet &diffs);
void
OptionsSetUnion (const OptionSet &set_a, const OptionSet &set_b, OptionSet &union_set);
};
} // namespace lldb_private
#endif // liblldb_Options_h_

View File

@ -0,0 +1,46 @@
//===-- PluginInterface.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_PluginInterface_h_
#define liblldb_PluginInterface_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
class PluginInterface
{
public:
virtual const char *
GetPluginName() = 0;
virtual const char *
GetShortPluginName() = 0;
virtual uint32_t
GetPluginVersion() = 0;
virtual void
GetPluginCommandHelp (const char *command, Stream *strm) = 0;
virtual Error
ExecutePluginCommand (Args &command, Stream *strm) = 0;
virtual Log *
EnablePluginLogging (Stream *strm, Args &command) = 0;
};
} // namespace lldb_private
#endif // liblldb_PluginInterface_h_

View File

@ -0,0 +1,186 @@
//===-- PluginManager.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_PluginManager_h_
#define liblldb_PluginManager_h_
#include "lldb/lldb-private.h"
namespace lldb_private {
class PluginManager
{
public:
//------------------------------------------------------------------
// ABI
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
ABICreateInstance create_callback);
static bool
UnregisterPlugin (ABICreateInstance create_callback);
static ABICreateInstance
GetABICreateCallbackAtIndex (uint32_t idx);
static ABICreateInstance
GetABICreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// Disassembler
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
DisassemblerCreateInstance create_callback);
static bool
UnregisterPlugin (DisassemblerCreateInstance create_callback);
static DisassemblerCreateInstance
GetDisassemblerCreateCallbackAtIndex (uint32_t idx);
static DisassemblerCreateInstance
GetDisassemblerCreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// DynamicLoader
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
DynamicLoaderCreateInstance create_callback);
static bool
UnregisterPlugin (DynamicLoaderCreateInstance create_callback);
static DynamicLoaderCreateInstance
GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx);
static DynamicLoaderCreateInstance
GetDynamicLoaderCreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// ObjectFile
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
ObjectFileCreateInstance create_callback);
static bool
UnregisterPlugin (ObjectFileCreateInstance create_callback);
static ObjectFileCreateInstance
GetObjectFileCreateCallbackAtIndex (uint32_t idx);
static ObjectFileCreateInstance
GetObjectFileCreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// ObjectContainer
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
ObjectContainerCreateInstance create_callback);
static bool
UnregisterPlugin (ObjectContainerCreateInstance create_callback);
static ObjectContainerCreateInstance
GetObjectContainerCreateCallbackAtIndex (uint32_t idx);
static ObjectContainerCreateInstance
GetObjectContainerCreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// LogChannel
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
LogChannelCreateInstance create_callback);
static bool
UnregisterPlugin (LogChannelCreateInstance create_callback);
static LogChannelCreateInstance
GetLogChannelCreateCallbackAtIndex (uint32_t idx);
static LogChannelCreateInstance
GetLogChannelCreateCallbackForPluginName (const char *name);
static const char *
GetLogChannelCreateNameAtIndex (uint32_t idx);
//------------------------------------------------------------------
// Process
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
ProcessCreateInstance create_callback);
static bool
UnregisterPlugin (ProcessCreateInstance create_callback);
static ProcessCreateInstance
GetProcessCreateCallbackAtIndex (uint32_t idx);
static ProcessCreateInstance
GetProcessCreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// SymbolFile
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
SymbolFileCreateInstance create_callback);
static bool
UnregisterPlugin (SymbolFileCreateInstance create_callback);
static SymbolFileCreateInstance
GetSymbolFileCreateCallbackAtIndex (uint32_t idx);
static SymbolFileCreateInstance
GetSymbolFileCreateCallbackForPluginName (const char *name);
//------------------------------------------------------------------
// SymbolVendor
//------------------------------------------------------------------
static bool
RegisterPlugin (const char *name,
const char *description,
SymbolVendorCreateInstance create_callback);
static bool
UnregisterPlugin (SymbolVendorCreateInstance create_callback);
static SymbolVendorCreateInstance
GetSymbolVendorCreateCallbackAtIndex (uint32_t idx);
static SymbolVendorCreateInstance
GetSymbolVendorCreateCallbackForPluginName (const char *name);
};
} // namespace lldb_private
#endif // liblldb_PluginManager_h_

View File

@ -0,0 +1,166 @@
//===-- RegularExpression.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_DBRegex_h_
#define liblldb_DBRegex_h_
#if defined(__cplusplus)
#include <regex.h>
#include <string>
#include <vector>
namespace lldb_private {
//----------------------------------------------------------------------
/// @class RegularExpression RegularExpression.h "lldb/Core/RegularExpression.h"
/// @brief A C++ wrapper class for regex.
///
/// This regular expression class wraps the posix regex functions
/// \c regcomp(), \c regerror(), \c regexec(), and \c regfree() from
/// the header file in \c /usr/include/regex\.h.
//----------------------------------------------------------------------
class RegularExpression
{
public:
//------------------------------------------------------------------
/// Default constructor.
///
/// The default constructor that initializes the object state such
/// that it contains no compiled regular expression.
//------------------------------------------------------------------
RegularExpression ();
//------------------------------------------------------------------
/// Constructor that takes a regulare expression with flags.
///
/// Constructor that compiles \a re using \a flags and stores the
/// resulting compiled regular expression into this object.
///
/// @param[in] re
/// A c string that represents the regular expression to
/// compile.
///
/// @param[in] flags
/// Flags that are passed the the \c regcomp() function.
//------------------------------------------------------------------
RegularExpression (const char* re, int flags = REG_EXTENDED);
//------------------------------------------------------------------
/// Destructor.
///
/// Any previosuly compiled regular expression contained in this
/// object will be freed.
//------------------------------------------------------------------
~RegularExpression ();
//------------------------------------------------------------------
/// Compile a regular expression.
///
/// Compile a regular expression using the supplied regular
/// expression text and flags. The compied regular expression lives
/// in this object so that it can be readily used for regular
/// expression matches. Execute() can be called after the regular
/// expression is compiled. Any previosuly compiled regular
/// expression contained in this object will be freed.
///
/// @param[in] re
/// A NULL terminated C string that represents the regular
/// expression to compile.
///
/// @param[in] flags
/// Flags that are passed the the \c regcomp() function.
///
/// @return
/// \b true if the regular expression compiles successfully,
/// \b false otherwise.
//------------------------------------------------------------------
bool
Compile (const char* re, int flags = REG_EXTENDED);
//------------------------------------------------------------------
/// Executes a regular expression.
///
/// Execute a regular expression match using the compiled regular
/// expression that is already in this object against the match
/// string \a s. If any parens are used for regular expression
/// matches \a match_count should indicate the number of regmatch_t
/// values that are present in \a match_ptr. The regular expression
/// will be executed using the \a execute_flags
///
/// @param[in] string
/// The string to match against the compile regular expression.
///
/// @param[in] match_count
/// The number of regmatch_t objects in \a match_ptr
///
/// @param[out] match_ptr
/// A pointer to at least \a match_count regmatch_t objects
/// if \a match_count is non-zero.
///
/// @param[in] execute_flags
/// Flags to pass to the \c regexec() function.
///
/// @return
/// \b true if \a string matches the compiled regular
/// expression, \b false otherwise.
//------------------------------------------------------------------
bool
Execute (const char* string, size_t match_count = 0, int execute_flags = 0) const;
bool
GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const;
//------------------------------------------------------------------
/// Free the compiled regular expression.
///
/// If this object contains a valid compiled regular expression,
/// this function will free any resources it was consuming.
//------------------------------------------------------------------
void
Free ();
//------------------------------------------------------------------
/// Access the regular expression text.
///
/// Returns the text that was used to compile the current regular
/// expression.
///
/// @return
/// The NULL terminated C string that was used to compile the
/// current regular expression
//------------------------------------------------------------------
const char*
GetText () const;
//------------------------------------------------------------------
/// Test if valid.
///
/// Test if this object contains a valid regular expression.
///
/// @return
/// \b true if the regular expression compiled and is ready
/// for execution, \b false otherwise.
//------------------------------------------------------------------
bool
IsValid () const;
private:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
std::string m_re; ///< A copy of the original regular expression text
int m_comp_err; ///< Error code for the regular expression compilation
regex_t m_preg; ///< The compiled regular expression
mutable std::vector<regmatch_t> m_matches; ///< Where parenthesized subexpressions results are stored
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_DBRegex_h_

View File

@ -0,0 +1,104 @@
//===-- STLUtils.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_STLUtils_h_
#define liblldb_STLUtils_h_
#if defined(__cplusplus)
#include <ext/hash_fun.h>
#include <string.h>
#include <map>
#include <ostream>
#include <vector>
//----------------------------------------------------------------------
// C string less than compare function object
//----------------------------------------------------------------------
struct CStringCompareFunctionObject
{
bool operator() (const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
//----------------------------------------------------------------------
// C string equality function object (binary predicate).
//----------------------------------------------------------------------
struct CStringEqualBinaryPredicate
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
//----------------------------------------------------------------------
// Templated type for finding an entry in a std::map<F,S> whose value
// is equal to something
//----------------------------------------------------------------------
template <class F, class S>
class ValueEquals
{
private:
S second_value;
public:
ValueEquals (const S& val) : second_value(val)
{}
// Compare the second item
bool operator() (std::pair<const F, S> elem)
{
return elem.second == second_value;
}
};
struct StdStringHash
{
size_t operator()( const std::string& x ) const
{
return __gnu_cxx::hash<const char*>()( x.c_str() );
}
};
template <class T>
inline void PrintAllCollectionElements (std::ostream &s, const T& coll, const char* header_cstr=NULL, const char* separator_cstr=" ")
{
typename T::const_iterator pos;
if (header_cstr)
s << header_cstr;
for (pos=coll.begin(); pos!=coll.end(); ++pos) {
s << *pos << separator_cstr;
}
s << std::endl;
}
// The function object below can be used to delete a STL container that
// contains C++ object pointers.
//
// Usage: std::for_each(vector.begin(), vector.end(), for_each_delete());
struct for_each_cplusplus_delete
{
template <typename T>
void operator()(T *ptr){ delete ptr;}
};
typedef std::vector<std::string> STLStringArray;
typedef std::vector<const char *> CStringArray;
#endif // #if defined(__cplusplus)
#endif // liblldb_STLUtils_h_

View File

@ -0,0 +1,302 @@
//===-- Scalar.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_Scalar_h_
#define liblldb_Scalar_h_
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
// A class designed to hold onto values and their corresponding types.
// Operators are defined and Scalar objects will correctly promote
// their types and values before performing these operations. Type
// promotion currently follows the ANSI C type promotion rules.
//----------------------------------------------------------------------
class Scalar
{
public:
enum Type
{
e_void = 0,
e_sint,
e_uint,
e_slong,
e_ulong,
e_slonglong,
e_ulonglong,
e_float,
e_double,
e_long_double
};
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
Scalar();
Scalar(int v) : m_type(e_sint), m_data() { m_data.sint = v; }
Scalar(unsigned int v) : m_type(e_uint), m_data() { m_data.uint = v; }
Scalar(long v) : m_type(e_slong), m_data() { m_data.slong = v; }
Scalar(unsigned long v) : m_type(e_ulong), m_data() { m_data.ulong = v; }
Scalar(long long v) : m_type(e_slonglong), m_data() { m_data.slonglong = v; }
Scalar(unsigned long long v): m_type(e_ulonglong), m_data() { m_data.ulonglong = v; }
Scalar(float v) : m_type(e_float), m_data() { m_data.flt = v; }
Scalar(double v) : m_type(e_double), m_data() { m_data.dbl = v; }
Scalar(long double v) : m_type(e_long_double), m_data() { m_data.ldbl = v; }
Scalar(const Scalar& rhs);
//Scalar(const RegisterValue& reg_value);
virtual ~Scalar();
size_t
GetByteSize() const;
bool
GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
bool
IsZero() const;
void
Clear() { m_type = e_void; m_data.ulonglong = 0; }
const char *
GetTypeAsCString() const;
void
GetValue (Stream *s, bool show_type) const;
bool
IsValid() const
{
return (m_type >= e_sint) && (m_type <= e_long_double);
}
bool
Promote(Scalar::Type type);
bool
Cast (Scalar::Type type);
static const char *
GetValueTypeAsCString (Scalar::Type value_type);
static Scalar::Type
GetValueTypeForSignedIntegerWithByteSize (size_t byte_size);
static Scalar::Type
GetValueTypeForUnsignedIntegerWithByteSize (size_t byte_size);
static Scalar::Type
GetValueTypeForFloatWithByteSize (size_t byte_size);
//----------------------------------------------------------------------
// All operators can benefits from the implicit conversions that will
// happen automagically by the compiler, so no temporary objects will
// need to be created. As a result, we currently don't need a variety of
// overloaded set value accessors.
//----------------------------------------------------------------------
Scalar& operator= (const int i);
Scalar& operator= (unsigned int v);
Scalar& operator= (long v);
Scalar& operator= (unsigned long v);
Scalar& operator= (long long v);
Scalar& operator= (unsigned long long v);
Scalar& operator= (float v);
Scalar& operator= (double v);
Scalar& operator= (long double v);
Scalar& operator= (const Scalar& rhs); // Assignment operator
Scalar& operator+= (const Scalar& rhs);
Scalar& operator<<= (const Scalar& rhs); // Shift left
Scalar& operator>>= (const Scalar& rhs); // Shift right (arithmetic)
Scalar& operator&= (const Scalar& rhs);
//----------------------------------------------------------------------
// Shifts the current value to the right without maintaining the current
// sign of the value (if it is signed).
//----------------------------------------------------------------------
bool
ShiftRightLogical(const Scalar& rhs); // Returns true on success
//----------------------------------------------------------------------
// Takes the absolute value of the current value if it is signed, else
// the value remains unchanged.
// Returns false if the contained value has a void type.
//----------------------------------------------------------------------
bool
AbsoluteValue(); // Returns true on success
//----------------------------------------------------------------------
// Negates the current value (even for unsigned values).
// Returns false if the contained value has a void type.
//----------------------------------------------------------------------
bool
UnaryNegate(); // Returns true on success
//----------------------------------------------------------------------
// Inverts all bits in the current value as long as it isn't void or
// a float/double/long double type.
// Returns false if the contained value has a void/float/double/long
// double type, else the value is inverted and true is returned.
//----------------------------------------------------------------------
bool
OnesComplement(); // Returns true on success
//----------------------------------------------------------------------
// Access the type of the current value.
//----------------------------------------------------------------------
Scalar::Type
GetType() const { return m_type; }
//----------------------------------------------------------------------
// Returns a casted value of the current contained data without
// modifying the current value. FAIL_VALUE will be returned if the type
// of the value is void or invalid.
//----------------------------------------------------------------------
int
SInt(int fail_value = 0) const;
// Return the raw unsigned integer without any casting or conversion
unsigned int
RawUInt () const;
// Return the raw unsigned long without any casting or conversion
unsigned long
RawULong () const;
// Return the raw unsigned long long without any casting or conversion
unsigned long long
RawULongLong () const;
unsigned int
UInt(unsigned int fail_value = 0) const;
long
SLong(long fail_value = 0) const;
unsigned long
ULong(unsigned long fail_value = 0) const;
long long
SLongLong(long long fail_value = 0) const;
unsigned long long
ULongLong(unsigned long long fail_value = 0) const;
float
Float(float fail_value = 0.0f) const;
double
Double(double fail_value = 0.0) const;
long double
LongDouble(long double fail_value = 0.0) const;
uint64_t
GetRawBits64 (uint64_t fail_value) const;
Error
SetValueFromCString (const char *s, lldb::Encoding encoding, uint32_t byte_size);
static bool
UIntValueIsValidForSize (uint64_t uval64, size_t total_byte_size)
{
if (total_byte_size > 8)
return false;
if (total_byte_size == 8)
return true;
const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
return uval64 <= max;
}
static bool
SIntValueIsValidForSize (int64_t sval64, size_t total_byte_size)
{
if (total_byte_size > 8)
return false;
if (total_byte_size == 8)
return true;
const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
const int64_t min = ~(max);
return min <= sval64 && sval64 <= max;
}
protected:
typedef union ValueData
{
int sint;
unsigned int uint;
long slong;
unsigned long ulong;
long long slonglong;
unsigned long long ulonglong;
float flt;
double dbl;
long double ldbl;
};
//------------------------------------------------------------------
// Classes that inherit from Scalar can see and modify these
//------------------------------------------------------------------
Scalar::Type m_type;
ValueData m_data;
private:
friend const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator- (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator/ (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator* (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator& (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator| (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator% (const Scalar& lhs, const Scalar& rhs);
friend const Scalar operator^ (const Scalar& lhs, const Scalar& rhs);
friend bool operator== (const Scalar& lhs, const Scalar& rhs);
friend bool operator!= (const Scalar& lhs, const Scalar& rhs);
friend bool operator< (const Scalar& lhs, const Scalar& rhs);
friend bool operator<= (const Scalar& lhs, const Scalar& rhs);
friend bool operator> (const Scalar& lhs, const Scalar& rhs);
friend bool operator>= (const Scalar& lhs, const Scalar& rhs);
};
//----------------------------------------------------------------------
// Split out the operators into a format where the compiler will be able
// to implicitly convert numbers into Scalar objects.
//
// This allows code like:
// Scalar two(2);
// Scalar four = two * 2;
// Scalar eight = 2 * four; // This would cause an error if the
// // operator* was implemented as a
// // member function.
// SEE:
// Item 19 of "Effective C++ Second Edition" by Scott Meyers
// Differentiate among members functions, non-member functions, and
// friend functions
//----------------------------------------------------------------------
const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
const Scalar operator- (const Scalar& lhs, const Scalar& rhs);
const Scalar operator/ (const Scalar& lhs, const Scalar& rhs);
const Scalar operator* (const Scalar& lhs, const Scalar& rhs);
const Scalar operator& (const Scalar& lhs, const Scalar& rhs);
const Scalar operator| (const Scalar& lhs, const Scalar& rhs);
const Scalar operator% (const Scalar& lhs, const Scalar& rhs);
const Scalar operator^ (const Scalar& lhs, const Scalar& rhs);
bool operator== (const Scalar& lhs, const Scalar& rhs);
bool operator!= (const Scalar& lhs, const Scalar& rhs);
bool operator< (const Scalar& lhs, const Scalar& rhs);
bool operator<= (const Scalar& lhs, const Scalar& rhs);
bool operator> (const Scalar& lhs, const Scalar& rhs);
bool operator>= (const Scalar& lhs, const Scalar& rhs);
} // namespace lldb_private
#endif // liblldb_Scalar_h_

View File

@ -0,0 +1,326 @@
//===-- SearchFilter.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_SearchFilter_h_
#define liblldb_SearchFilter_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/FileSpec.h"
#include "lldb/Core/Address.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Core/Module.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Searcher SearchFilter.h "lldb/Core/SearchFilter.h"
/// @brief Class that is driven by the SearchFilter to search the
/// SymbolContext space of the target program.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// Provides the callback and search depth for the SearchFilter search.
//----------------------------------------------------------------------
class Searcher
{
public:
typedef enum {
eCallbackReturnStop = 0, // Stop the iteration
eCallbackReturnContinue, // Continue the iteration
eCallbackReturnPop // Pop one level up and continue iterating
} CallbackReturn;
typedef enum {
eDepthTarget,
eDepthModule,
eDepthCompUnit,
eDepthFunction,
eDepthBlock,
eDepthAddress
} Depth;
Searcher ();
virtual ~Searcher ();
virtual CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool complete) = 0;
virtual Depth
GetDepth () = 0;
//------------------------------------------------------------------
/// Prints a canonical description for the searcher to the stream \a s.
///
/// @param[in] s
/// Stream to which the output is copied.
//------------------------------------------------------------------
virtual void
GetDescription(Stream *s);
};
//----------------------------------------------------------------------
/// @class SearchFilter SearchFilter.h "lldb/Core/SearchFilter.h"
/// @brief Class descends through the SymbolContext space of the target,
/// applying a filter at each stage till it reaches the depth specified by
/// the GetDepth method of the searcher, and calls its callback at that point.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
/// Provides the callback and search depth for the SearchFilter search.
///
/// The search is done by cooperation between the search filter and the searcher.
/// The search filter does the heavy work of recursing through the SymbolContext
/// space of the target program's symbol space. The Searcher specifies the depth
/// at which it wants its callback to be invoked. Note that since the resolution
/// of the Searcher may be greater than that of the SearchFilter, before the
/// Searcher qualifies an address it should pass it to "AddressPasses."
/// The default implementation is "Everything Passes."
//----------------------------------------------------------------------
class SearchFilter
{
public:
//------------------------------------------------------------------
/// The basic constructor takes a Target, which gives the space to search.
///
/// @param[in] target
/// The Target that provides the module list to search.
//------------------------------------------------------------------
SearchFilter (lldb::TargetSP &target_sp);
SearchFilter(const SearchFilter& rhs);
virtual
~SearchFilter ();
const SearchFilter&
operator=(const SearchFilter& rhs);
//------------------------------------------------------------------
/// Call this method with a file spec to see if that spec passes the filter.
///
/// @param[in] spec
/// The file spec to check against the filter.
/// @return
/// \b true if \a spec passes, and \b false otherwise.
//------------------------------------------------------------------
virtual bool
ModulePasses (const FileSpec &spec);
//------------------------------------------------------------------
/// Call this method with a Module to see if that module passes the filter.
///
/// @param[in] module
/// The Module to check against the filter.
///
/// @return
/// \b true if \a module passes, and \b false otherwise.
//------------------------------------------------------------------
virtual bool
ModulePasses (const lldb::ModuleSP &module_sp);
//------------------------------------------------------------------
/// Call this method with a SymbolContext and a SymbolContextScope to see if
/// that SymbolContext passes the filter up to the level in \a scope.
///
/// @param[in] context
/// The SymbolContext to check against the filter.
///
/// @param[in] scope
/// The SymbolContextItem indicating what bits of the SymbolContextScope
/// to check against the filter.
///
/// @return
/// \b true if \a SymbolContext passes, and \b false otherwise.
//------------------------------------------------------------------
virtual bool
SymbolContextPasses (const SymbolContext &context,
lldb::SymbolContextItem scope);
//------------------------------------------------------------------
/// Call this method with a Address to see if \a address passes the filter.
///
/// @param[in] addr
/// The address to check against the filter.
///
/// @return
/// \b true if \a address passes, and \b false otherwise.
//------------------------------------------------------------------
virtual bool
AddressPasses (Address &addr);
//------------------------------------------------------------------
/// Call this method with a FileSpec to see if \a file spec passes the filter
/// as the name of a compilation unit.
///
/// @param[in] fileSpec
/// The file spec to check against the filter.
///
/// @return
/// \b true if \a file spec passes, and \b false otherwise.
//------------------------------------------------------------------
virtual bool
CompUnitPasses (FileSpec &fileSpec);
//------------------------------------------------------------------
/// Call this method with a CompileUnit to see if \a comp unit passes the filter.
///
/// @param[in] compUnit
/// The CompileUnit to check against the filter.
///
/// @return
/// \b true if \a Comp Unit passes, and \b false otherwise.
//------------------------------------------------------------------
virtual bool
CompUnitPasses (CompileUnit &compUnit);
//------------------------------------------------------------------
/// Call this method to do the search using the Searcher.
///
/// @param[in] searcher
/// The searcher to drive with this search.
///
//------------------------------------------------------------------
virtual void
Search (Searcher &searcher);
//------------------------------------------------------------------
/// Call this method to do the search using the Searcher in the module list
/// \a modules.
///
/// @param[in] searcher
/// The searcher to drive with this search.
///
/// @param[in] modules
/// The module list within which to restrict the search.
///
//------------------------------------------------------------------
virtual void
SearchInModuleList (Searcher &searcher, ModuleList &modules);
//------------------------------------------------------------------
/// Prints a canonical description for the search filter to the stream \a s.
///
/// @param[in] s
/// Stream to which the output is copied.
//------------------------------------------------------------------
virtual void
GetDescription(Stream *s);
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
virtual void
Dump (Stream *s) const;
protected:
// These are utility functions to assist with the search iteration. They are used by the
// default Search method.
Searcher::CallbackReturn
DoModuleIteration (const SymbolContext &context,
Searcher &searcher);
Searcher::CallbackReturn
DoModuleIteration (const lldb::ModuleSP& module_sp,
Searcher &searcher);
Searcher::CallbackReturn
DoCUIteration (const lldb::ModuleSP& module_sp,
const SymbolContext &context,
Searcher &searcher);
Searcher::CallbackReturn
DoFunctionIteration (Function *function,
const SymbolContext &context,
Searcher &searcher);
lldb::TargetSP m_target_sp; // Every filter has to be associated with a target for
// now since you need a starting place for the search.
};
//----------------------------------------------------------------------
/// @class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h"
/// @brief This is a SearchFilter that restricts the search to a given module.
//----------------------------------------------------------------------
class SearchFilterByModule :
public SearchFilter
{
public:
//------------------------------------------------------------------
/// The basic constructor takes a Target, which gives the space to search,
/// and the module to restrict the search to.
///
/// @param[in] target
/// The Target that provides the module list to search.
///
/// @param[in] module
/// The Module that limits the search.
//------------------------------------------------------------------
SearchFilterByModule (lldb::TargetSP &targetSP,
const FileSpec &module);
SearchFilterByModule (const SearchFilterByModule& rhs);
virtual
~SearchFilterByModule ();
const SearchFilterByModule&
operator=(const SearchFilterByModule& rhs);
virtual bool
ModulePasses (const lldb::ModuleSP &module_sp);
virtual bool
ModulePasses (const FileSpec &spec);
virtual bool
SymbolContextPasses (const SymbolContext &context,
lldb::SymbolContextItem scope);
virtual bool
AddressPasses (Address &address);
virtual bool
CompUnitPasses (FileSpec &fileSpec);
virtual bool
CompUnitPasses (CompileUnit &compUnit);
virtual void
GetDescription(Stream *s);
virtual void
Dump (Stream *s) const;
virtual void
Search (Searcher &searcher);
private:
FileSpec m_module_spec;
};
} // namespace lldb_private
#endif // liblldb_SearchFilter_h_

View File

@ -0,0 +1,231 @@
//===-- Section.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_Section_h_
#define liblldb_Section_h_
#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/VMRange.h"
namespace lldb_private {
class SectionList
{
public:
typedef std::vector<lldb::SectionSP> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
SectionList();
virtual
~SectionList();
uint32_t
AddSection (lldb::SectionSP& sect_sp);
uint32_t
AddUniqueSection (lldb::SectionSP& sect_sp);
uint32_t
FindSectionIndex (const Section* sect);
bool
ContainsSection(lldb::user_id_t sect_id) const;
void
Dump (Stream *s, Process *process, bool show_header) const;
lldb::SectionSP
FindSectionByName (const ConstString &section_dstr) const;
// lldb::SectionSP
// FindSectionByNames (const char *sect, ...) const;
lldb::SectionSP
FindSectionByID (lldb::user_id_t sect_id) const;
lldb::SectionSP
GetSharedPointer (const Section *section, bool check_children) const;
lldb::SectionSP
FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT_MAX) const;
lldb::SectionSP
FindSectionContainingLinkedFileAddress (lldb::addr_t vm_addr) const;
bool
GetSectionData (const DataExtractor& module_data, DataExtractor& section_data) const;
// Get the number of sections in this list only
size_t
GetSize () const;
// Get the number of sections in this list, and any contained child sections
size_t
GetNumSections (uint32_t depth) const;
bool
ReplaceSection (lldb::user_id_t sect_id, lldb::SectionSP& sect_sp, uint32_t depth = UINT_MAX);
lldb::SectionSP
GetSectionAtIndex (uint32_t idx) const;
size_t
Slide (lldb::addr_t slide_amount, bool slide_children);
protected:
collection m_sections;
};
class Section :
public ModuleChild,
public UserID,
public Flags
{
public:
Section (
Section *parent, // NULL for top level sections, non-NULL for child sections
Module* module,
lldb::user_id_t sect_id,
const ConstString &name,
lldb::SectionType sect_type,
lldb::addr_t file_vm_addr,
lldb::addr_t vm_size,
uint64_t file_offset,
uint64_t file_size,
uint32_t flags);
~Section ();
static int
Compare (const Section& a, const Section& b);
// Get a valid shared pointer to this section object
lldb::SectionSP
GetSharedPointer() const;
bool
ContainsFileAddress (lldb::addr_t vm_addr) const;
SectionList&
GetChildren ();
const SectionList&
GetChildren () const;
void
Dump (Stream *s, Process *process) const;
void
DumpName (Stream *s) const;
lldb::addr_t
GetLoadBaseAddress (Process *process) const;
bool
ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const;
uint64_t
GetFileOffset () const;
uint64_t
GetFileSize () const;
lldb::addr_t
GetFileAddress () const;
lldb::addr_t
GetOffset () const;
lldb::addr_t
GetByteSize () const;
void
SetByteSize (lldb::addr_t byte_size);
size_t
GetSectionDataFromImage (const DataExtractor& image_data, DataExtractor& section_data) const;
bool
IsFake() const;
void
SetIsFake(bool fake);
bool
IsDescendant (const Section *section);
size_t
MemoryMapSectionDataFromObjectFile (const ObjectFile* file, DataExtractor& section_data) const;
size_t
ReadSectionDataFromObjectFile (const ObjectFile* file, DataExtractor& section_data) const;
ConstString&
GetName ();
const ConstString&
GetName () const;
bool
Slide (lldb::addr_t slide_amount, bool slide_children);
void
SetLinkedLocation (const Section *linked_section, uint64_t linked_offset);
bool
ContainsLinkedFileAddress (lldb::addr_t vm_addr) const;
const Section *
GetLinkedSection () const;
uint64_t
GetLinkedOffset () const;
lldb::addr_t
GetLinkedFileAddress () const;
lldb::SectionType
GetSectionType () const
{
return m_type;
}
protected:
Section * m_parent; // Parent section or NULL if no parent.
ConstString m_name; // Name of this section
lldb::SectionType m_type; // The type of this section
lldb::addr_t m_file_addr; // The absolute file virtual address range of this section if m_parent == NULL,
// offset from parent file virtual address if m_parent != NULL
lldb::addr_t m_byte_size; // Size in bytes that this section will occupy in memory at runtime
uint64_t m_file_offset; // Object file offset (if any)
uint64_t m_file_size; // Object file size (can be smaller than m_byte_size for zero filled sections...)
SectionList m_children; // Child sections
bool m_fake; // If true, then this section only can contain the address if one of its
// children contains an address. This allows for gaps between the children
// that are contained in the address range for this section, but do not produce
// hits unless the children contain the address.
const Section * m_linked_section;
uint64_t m_linked_offset;
private:
DISALLOW_COPY_AND_ASSIGN (Section);
};
} // namespace lldb_private
#endif // liblldb_Section_h_

View File

@ -0,0 +1,120 @@
//===-- SourceManager.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_SourceManager_h_
#define liblldb_SourceManager_h_
// C Includes
// C++ Includes
#include <map>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/FileSpec.h"
namespace lldb_private {
class SourceManager
{
public:
#ifndef SWIG
class File
{
public:
File (const FileSpec &file_spec);
~File();
size_t
DisplaySourceLines (uint32_t line,
uint32_t context_before,
uint32_t context_after,
Stream *s);
uint32_t
GetLineOffset (uint32_t line);
bool
LineIsValid (uint32_t line);
bool
FileSpecMatches (const FileSpec &file_spec);
protected:
bool
CalculateLineOffsets (uint32_t line = UINT32_MAX);
FileSpec m_file_spec;
lldb::DataBufferSP m_data_sp;
typedef std::vector<uint32_t> LineOffsets;
LineOffsets m_offsets;
};
#endif
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
SourceManager();
~SourceManager();
typedef lldb::SharedPtr<File>::Type FileSP;
FileSP
GetFile (const FileSpec &file_spec);
size_t
DisplaySourceLines (const FileSpec &file,
uint32_t line,
uint32_t context_before,
uint32_t context_after,
Stream *s);
size_t
DisplaySourceLinesWithLineNumbers (const FileSpec &file,
uint32_t line,
uint32_t context_before,
uint32_t context_after,
const char* current_line_cstr,
Stream *s);
// This variant uses the last file we visited.
size_t
DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t line,
uint32_t context_before,
uint32_t context_after,
const char* current_line_cstr,
Stream *s);
size_t
DisplayMoreWithLineNumbers (Stream *s);
protected:
//------------------------------------------------------------------
// Classes that inherit from SourceManager can see and modify these
//------------------------------------------------------------------
typedef std::map <FileSpec, FileSP> FileCache;
FileCache m_file_cache;
FileSP m_last_file_sp;
uint32_t m_last_file_line;
uint32_t m_last_file_context_before;
uint32_t m_last_file_context_after;
private:
//------------------------------------------------------------------
// For SourceManager only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (SourceManager);
};
} // namespace lldb_private
#endif // liblldb_SourceManager_h_

View File

@ -0,0 +1,43 @@
//===-- State.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_State_h_
#define liblldb_State_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
//------------------------------------------------------------------
/// Converts a StateType to a C string.
///
/// @param[in] state
/// The StateType object to convert.
///
/// @return
/// A NULL terminated C string that describes \a state. The
/// returned string comes from constant string buffers and does
/// not need to be freed.
//------------------------------------------------------------------
const char *
StateAsCString (lldb::StateType state);
bool
StateIsRunningState (lldb::StateType state);
bool
StateIsStoppedState (lldb::StateType state);
} // namespace lldb_private
#endif // liblldb_State_h_

View File

@ -0,0 +1,599 @@
//===-- Stream.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_Stream_h_
#define liblldb_Stream_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "lldb/Core/Flags.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Stream Stream.h "lldb/Core/Stream.h"
/// @brief A stream class that can stream formatted output to a file.
//----------------------------------------------------------------------
class Stream
{
public:
//------------------------------------------------------------------
/// \a m_flags bit values.
//------------------------------------------------------------------
enum
{
eVerbose = (1 << 0), ///< If set, verbose logging is enabled
eDebug = (1 << 1), ///< If set, debug logging is enabled
eAddPrefix = (1 << 2), ///< Add number prefixes for binary, octal and hex when eBinary is clear
eBinary = (1 << 3), ///< Get and put data as binary instead of as the default string mode.
};
//------------------------------------------------------------------
/// Construct with flags and address size and byte order.
///
/// Construct with dump flags \a flags and the default address
/// size. \a flags can be any of the above enumeration logical OR'ed
/// together.
//------------------------------------------------------------------
Stream (uint32_t flags,
uint32_t addr_size,
lldb::ByteOrder byte_order);
//------------------------------------------------------------------
/// Construct a default Stream, not binary, host byte order and
/// host addr size.
///
//------------------------------------------------------------------
Stream ();
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
virtual
~Stream ();
//------------------------------------------------------------------
// Subclasses must override these methods
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Flush the stream.
///
/// Subclasses should flush the stream to make any output appear
/// if the stream has any buffering.
//------------------------------------------------------------------
virtual void
Flush () = 0;
//------------------------------------------------------------------
/// Output character bytes to the stream.
///
/// Appends \a src_len characters from the buffer \a src to the
/// stream.
///
/// @param[in] src
/// A buffer containing at least \a src_len bytes of data.
///
/// @param[in] src_len
/// A number of bytes to append to the stream.
///
/// @return
/// The number of bytes that were appended to the stream.
//------------------------------------------------------------------
virtual int
Write (const void *src, size_t src_len) = 0;
//------------------------------------------------------------------
// Member functions
//------------------------------------------------------------------
int
PutChar (char ch);
//------------------------------------------------------------------
/// Set the byte_order value.
///
/// Sets the byte order of the data to extract. Extracted values
/// will be swapped if necessary when decoding.
///
/// @param[in] byte_order
/// The byte order value to use when extracting data.
///
/// @return
/// The old byte order value.
//------------------------------------------------------------------
lldb::ByteOrder
SetByteOrder (lldb::ByteOrder byte_order);
//------------------------------------------------------------------
/// Format a C string from a printf style format and variable
/// arguments and encode and append the resulting C string as hex
/// bytes.
///
/// @param[in] format
/// A printf style format string.
///
/// @param[in] ...
/// Any additional arguments needed for the printf format string.
///
/// @return
/// The number of bytes that were appended to the stream.
//------------------------------------------------------------------
int
PrintfAsRawHex8 (const char *format, ...);
//------------------------------------------------------------------
/// Format a C string from a printf style format and variable
/// arguments and encode and append the resulting C string as hex
/// bytes.
///
/// @param[in] format
/// A printf style format string.
///
/// @param[in] ...
/// Any additional arguments needed for the printf format string.
///
/// @return
/// The number of bytes that were appended to the stream.
//------------------------------------------------------------------
int
PutHex8 (uint8_t uvalue);
int
PutNHex8 (size_t n, uint8_t uvalue);
int
PutHex16 (uint16_t uvalue,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutHex32 (uint32_t uvalue,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutHex64 (uint64_t uvalue,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutMaxHex64 (uint64_t uvalue,
size_t byte_size,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutFloat (float f,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutDouble (double d,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutLongDouble (long double ld,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
int
PutPointer (void *ptr);
int
PutBytesAsRawHex8 (const void *src,
size_t src_len,
lldb::ByteOrder src_byte_order,
lldb::ByteOrder dst_byte_order);
int
PutRawBytes (const void *s, size_t src_len,
lldb::ByteOrder src_byte_order,
lldb::ByteOrder dst_byte_order);
int
PutCStringAsRawHex8 (const char *s);
//------------------------------------------------------------------
/// Output a NULL terminated C string \a cstr to the stream \a s.
///
/// @param[in] cstr
/// A NULL terminated C string.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (const char *cstr);
//------------------------------------------------------------------
/// Output a pointer value \a p to the stream \a s.
///
/// @param[in] p
/// A void pointer.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (void *p);
//------------------------------------------------------------------
/// Output a character \a ch to the stream \a s.
///
/// @param[in] ch
/// A printable character value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (char ch);
//------------------------------------------------------------------
/// Output a uint8_t \a uval to the stream \a s.
///
/// @param[in] uval
/// A uint8_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (uint8_t uval);
//------------------------------------------------------------------
/// Output a uint16_t \a uval to the stream \a s.
///
/// @param[in] uval
/// A uint16_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (uint16_t uval);
//------------------------------------------------------------------
/// Output a uint32_t \a uval to the stream \a s.
///
/// @param[in] uval
/// A uint32_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (uint32_t uval);
//------------------------------------------------------------------
/// Output a uint64_t \a uval to the stream \a s.
///
/// @param[in] uval
/// A uint64_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (uint64_t uval);
//------------------------------------------------------------------
/// Output a int8_t \a sval to the stream \a s.
///
/// @param[in] sval
/// A int8_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (int8_t sval);
//------------------------------------------------------------------
/// Output a int16_t \a sval to the stream \a s.
///
/// @param[in] sval
/// A int16_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (int16_t sval);
//------------------------------------------------------------------
/// Output a int32_t \a sval to the stream \a s.
///
/// @param[in] sval
/// A int32_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (int32_t sval);
//------------------------------------------------------------------
/// Output a int64_t \a sval to the stream \a s.
///
/// @param[in] sval
/// A int64_t value.
///
/// @return
/// A reference to this class so multiple things can be streamed
/// in one statement.
//------------------------------------------------------------------
Stream&
operator<< (int64_t sval);
//------------------------------------------------------------------
/// Output an address value to this stream.
///
/// Put an address \a addr out to the stream with optional \a prefix
/// and \a suffix strings.
///
/// @param[in] addr
/// An address value.
///
/// @param[in] addr_size
/// Size in bytes of the address, used for formatting.
///
/// @param[in] prefix
/// A prefix C string. If NULL, no prefix will be output.
///
/// @param[in] suffix
/// A suffix C string. If NULL, no suffix will be output.
//------------------------------------------------------------------
void
Address (uint64_t addr, int addr_size, const char *prefix = NULL, const char *suffix = NULL);
//------------------------------------------------------------------
/// Output an address range to this stream.
///
/// Put an address range \a lo_addr - \a hi_addr out to the stream
/// with optional \a prefix and \a suffix strings.
///
/// @param[in] lo_addr
/// The start address of the address range.
///
/// @param[in] hi_addr
/// The end address of the address range.
///
/// @param[in] addr_size
/// Size in bytes of the address, used for formatting.
///
/// @param[in] prefix
/// A prefix C string. If NULL, no prefix will be output.
///
/// @param[in] suffix
/// A suffix C string. If NULL, no suffix will be output.
//------------------------------------------------------------------
void
AddressRange(uint64_t lo_addr, uint64_t hi_addr, int addr_size, const char *prefix = NULL, const char *suffix = NULL);
//------------------------------------------------------------------
/// Output a C string to the stream with optional format.
///
/// Print a C string \a cstr to the stream using the printf format
/// in \a format.
///
/// @param[in] format
/// The printf style format to use when outputting the C string.
//------------------------------------------------------------------
int
PutCString (const char *cstr);
//------------------------------------------------------------------
/// Output and End of Line character to the stream.
//------------------------------------------------------------------
int
EOL();
//------------------------------------------------------------------
/// Get the address size in bytes.
///
/// @return
/// The size of an address in bytes that is used when outputting
/// address and pointer values to the stream.
//------------------------------------------------------------------
uint8_t
GetAddressByteSize () const;
//------------------------------------------------------------------
/// Test if debug logging is enabled.
///
/// @return
// \b true if the debug flag bit is set in this stream, \b
// false otherwise.
//------------------------------------------------------------------
bool
GetDebug() const;
//------------------------------------------------------------------
/// The flags accessor.
///
/// @return
/// A reference to the Flags member variable.
//------------------------------------------------------------------
Flags&
GetFlags();
//------------------------------------------------------------------
/// The flags const accessor.
///
/// @return
/// A const reference to the Flags member variable.
//------------------------------------------------------------------
const Flags&
GetFlags() const;
//------------------------------------------------------------------
/// Get the current indentation level.
///
/// @return
/// The current indentation level as an integer.
//------------------------------------------------------------------
int
GetIndentLevel () const;
//------------------------------------------------------------------
/// Test if verbose logging is enabled.
///
/// @return
// \b true if the verbose flag bit is set in this stream, \b
// false otherwise.
//------------------------------------------------------------------
bool
GetVerbose() const;
//------------------------------------------------------------------
/// Indent the current line in the stream.
///
/// Indent the current line using the current indentation level and
/// print an optional string following the idenatation spaces.
///
/// @param[in] s
/// A C string to print following the indentation. If NULL, just
/// output the indentation characters.
//------------------------------------------------------------------
int
Indent(const char *s = NULL);
//------------------------------------------------------------------
/// Decrement the current indentation level.
//------------------------------------------------------------------
void
IndentLess (int amount = 2);
//------------------------------------------------------------------
/// Increment the current indentation level.
//------------------------------------------------------------------
void
IndentMore (int amount = 2);
//------------------------------------------------------------------
/// Output an offset value.
///
/// Put an offset \a uval out to the stream using the printf format
/// in \a format.
///
/// @param[in] offset
/// The offset value.
///
/// @param[in] format
/// The printf style format to use when outputting the offset.
//------------------------------------------------------------------
void
Offset (uint32_t offset, const char *format = "0x%8.8x: ");
//------------------------------------------------------------------
/// Output printf formatted output to the stream.
///
/// Print some formatted output to the stream.
///
/// @param[in] format
/// A printf style format string.
///
/// @param[in] ...
/// Variable arguments that are needed for the printf style
/// format string \a format.
//------------------------------------------------------------------
int
Printf (const char *format, ...);
int
PrintfVarArg(const char *format, va_list args);
//------------------------------------------------------------------
/// Output a quoted C string value to the stream.
///
/// Print a double quoted NULL terminated C string to the stream
/// using the printf format in \a format.
///
/// @param[in] cstr
/// A NULL terminated C string value.
///
/// @param[in] format
/// The optional C string format that can be overridden.
//------------------------------------------------------------------
void
QuotedCString (const char *cstr, const char *format = "\"%s\"");
//------------------------------------------------------------------
/// Set the address size in bytes.
///
/// @param[in] addr_size
/// The new size in bytes of an address to use when outputting
/// address and pointer values.
//------------------------------------------------------------------
void
SetAddressByteSize (uint8_t addr_size);
//------------------------------------------------------------------
/// Set the current indentation level.
///
/// @param[in] level
/// The new indentation level.
//------------------------------------------------------------------
void
SetIndentLevel (int level);
//------------------------------------------------------------------
/// Output a SLEB128 number to the stream.
///
/// Put an SLEB128 \a uval out to the stream using the printf format
/// in \a format.
///
/// @param[in] uval
/// A uint64_t value that was extracted as a SLEB128 value.
///
/// @param[in] format
/// The optional printf format that can be overridden.
//------------------------------------------------------------------
int
PutSLEB128 (int64_t uval);
//------------------------------------------------------------------
/// Output a ULEB128 number to the stream.
///
/// Put an ULEB128 \a uval out to the stream using the printf format
/// in \a format.
///
/// @param[in] uval
/// A uint64_t value that was extracted as a ULEB128 value.
///
/// @param[in] format
/// The optional printf format that can be overridden.
//------------------------------------------------------------------
int
PutULEB128 (uint64_t uval);
static void
UnitTest(Stream *s);
private:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
Flags m_flags; ///< Dump flags.
uint8_t m_addr_size; ///< Size of an address in bytes.
lldb::ByteOrder m_byte_order;///< Byte order to use when encoding scalar types.
int m_indent_level; ///< Indention level.
int _PutHex8 (uint8_t uvalue, bool add_prefix);
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_Stream_h_

Some files were not shown because too many files have changed in this diff Show More