From granata.enrico at gmail.com Mon Jul 18 11:24:10 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Mon, 18 Jul 2011 16:24:10 -0000
Subject: [Lldb-commits] [lldb] r135395 - /lldb/trunk/scripts/lldb.swig
Message-ID: <20110718162410.D1CAB2A6C12E@llvm.org>
Author: enrico
Date: Mon Jul 18 11:24:10 2011
New Revision: 135395
URL: http://llvm.org/viewvc/llvm-project?rev=135395&view=rev
Log:
Runtime errors in Python scripts were not being shown; this fix makes them print out to ease correcting errors
Modified:
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135395&r1=135394&r2=135395&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 11:24:10 2011
@@ -463,22 +463,26 @@
}
else if (PyErr_Occurred ())
{
+ PyErr_Print();
PyErr_Clear();
}
Py_INCREF (session_dict);
}
else if (PyErr_Occurred())
{
+ PyErr_Print();
PyErr_Clear();
}
}
else if (PyErr_Occurred())
{
+ PyErr_Print();
PyErr_Clear();
}
}
else if (PyErr_Occurred ())
{
+ PyErr_Print();
PyErr_Clear ();
}
return retval;
From johnny.chen at apple.com Mon Jul 18 12:53:20 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 17:53:20 -0000
Subject: [Lldb-commits] [lldb] r135405 -
/lldb/trunk/scripts/Python/interface/SBTarget.i
Message-ID: <20110718175320.804BC2A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 12:53:20 2011
New Revision: 135405
URL: http://llvm.org/viewvc/llvm-project?rev=135405&view=rev
Log:
Cleaned up the interface file for SBTarget.
Modified:
lldb/trunk/scripts/Python/interface/SBTarget.i
Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=135405&r1=135404&r2=135405&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Mon Jul 18 12:53:20 2011
@@ -57,11 +57,6 @@
SBTarget (const lldb::SBTarget& rhs);
-#ifndef SWIG
- const lldb::SBTarget&
- operator = (const lldb::SBTarget& rhs);
-#endif
-
//------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------
@@ -396,53 +391,8 @@
lldb::SBBroadcaster
GetBroadcaster () const;
-#ifndef SWIG
- bool
- operator == (const lldb::SBTarget &rhs) const;
-
- bool
- operator != (const lldb::SBTarget &rhs) const;
-
-#endif
-
-#ifndef SWIG
- bool
- GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
-#endif
-
bool
GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level) const;
-
-protected:
- friend class SBAddress;
- friend class SBDebugger;
- friend class SBFunction;
- friend class SBProcess;
- friend class SBSymbol;
- friend class SBModule;
-
- //------------------------------------------------------------------
- // Constructors are private, use static Target::Create function to
- // create an instance of this class.
- //------------------------------------------------------------------
-
- SBTarget (const lldb::TargetSP& target_sp);
-
- void
- reset (const lldb::TargetSP& target_sp);
-
- lldb_private::Target *
- operator ->() const;
-
- lldb_private::Target *
- get() const;
-
-private:
- //------------------------------------------------------------------
- // For Target only
- //------------------------------------------------------------------
-
- lldb::TargetSP m_opaque_sp;
};
} // namespace lldb
From johnny.chen at apple.com Mon Jul 18 14:08:30 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 19:08:30 -0000
Subject: [Lldb-commits] [lldb] r135416 - in /lldb/trunk:
include/lldb/API/SBValue.h include/lldb/API/SBValueList.h
scripts/Python/interface/SBValue.i scripts/Python/interface/SBValueList.i
scripts/lldb.swig
Message-ID: <20110718190830.E517D2A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 14:08:30 2011
New Revision: 135416
URL: http://llvm.org/viewvc/llvm-project?rev=135416&view=rev
Log:
Add two new interface files SBValue.i and SBValueList.i, instead of directly swigging the header files.
Added:
lldb/trunk/scripts/Python/interface/SBValue.i
lldb/trunk/scripts/Python/interface/SBValueList.i
Modified:
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/API/SBValueList.h
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=135416&r1=135415&r2=135416&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Mon Jul 18 14:08:30 2011
@@ -16,56 +16,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents the value of a variable, a register, or an expression.
-
-SBValue supports iteration through its child, which in turn is represented
-as an SBValue. For example, we can get the general purpose registers of a
-frame as an SBValue, and iterate through all the registers,
-
- registerSet = frame.GetRegisters() # Returns an SBValueList.
- for regs in registerSet:
- if 'general purpose registers' in regs.getName().lower():
- GPRs = regs
- break
-
- print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren())
- for reg in GPRs:
- print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue()
-
-produces the output:
-
-General Purpose Registers (number of children = 21):
-Name: rax Value: 0x0000000100000c5c
-Name: rbx Value: 0x0000000000000000
-Name: rcx Value: 0x00007fff5fbffec0
-Name: rdx Value: 0x00007fff5fbffeb8
-Name: rdi Value: 0x0000000000000001
-Name: rsi Value: 0x00007fff5fbffea8
-Name: rbp Value: 0x00007fff5fbffe80
-Name: rsp Value: 0x00007fff5fbffe60
-Name: r8 Value: 0x0000000008668682
-Name: r9 Value: 0x0000000000000000
-Name: r10 Value: 0x0000000000001200
-Name: r11 Value: 0x0000000000000206
-Name: r12 Value: 0x0000000000000000
-Name: r13 Value: 0x0000000000000000
-Name: r14 Value: 0x0000000000000000
-Name: r15 Value: 0x0000000000000000
-Name: rip Value: 0x0000000100000dae
-Name: rflags Value: 0x0000000000000206
-Name: cs Value: 0x0000000000000027
-Name: fs Value: 0x0000000000000010
-Name: gs Value: 0x0000000000000048
-"
- ) SBValue;
-#endif
class SBValue
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBValue ();
@@ -150,9 +102,6 @@
lldb::SBValue
GetChildAtIndex (uint32_t idx);
-#ifdef SWIG
- %feature("docstring", "
-#endif
//------------------------------------------------------------------
/// Get a child value by index from a value.
///
@@ -203,9 +152,6 @@
/// @return
/// A new SBValue object that represents the child member value.
//------------------------------------------------------------------
-#ifdef SWIG
- ") GetChildAtIndex;
-#endif
lldb::SBValue
GetChildAtIndex (uint32_t idx,
lldb::DynamicValueType use_dynamic,
Modified: lldb/trunk/include/lldb/API/SBValueList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValueList.h?rev=135416&r1=135415&r2=135416&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValueList.h (original)
+++ lldb/trunk/include/lldb/API/SBValueList.h Mon Jul 18 14:08:30 2011
@@ -14,71 +14,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents a collection of SBValues. Both SBFrame's GetVariables() and
-GetRegisters() return a SBValueList.
-
-SBValueList supports SBValue iteration. For example (from test/lldbutil.py),
-
-def get_registers(frame, kind):
- '''Returns the registers given the frame and the kind of registers desired.
-
- Returns None if there's no such kind.
- '''
- registerSet = frame.GetRegisters() # Return type of SBValueList.
- for value in registerSet:
- if kind.lower() in value.GetName().lower():
- return value
-
- return None
-
-def get_GPRs(frame):
- '''Returns the general purpose registers of the frame as an SBValue.
-
- The returned SBValue object is iterable. An example:
- ...
- from lldbutil import get_GPRs
- regs = get_GPRs(frame)
- for reg in regs:
- print '%s => %s' % (reg.GetName(), reg.GetValue())
- ...
- '''
- return get_registers(frame, 'general purpose')
-
-def get_FPRs(frame):
- '''Returns the floating point registers of the frame as an SBValue.
-
- The returned SBValue object is iterable. An example:
- ...
- from lldbutil import get_FPRs
- regs = get_FPRs(frame)
- for reg in regs:
- print '%s => %s' % (reg.GetName(), reg.GetValue())
- ...
- '''
- return get_registers(frame, 'floating point')
-
-def get_ESRs(frame):
- '''Returns the exception state registers of the frame as an SBValue.
-
- The returned SBValue object is iterable. An example:
- ...
- from lldbutil import get_ESRs
- regs = get_ESRs(frame)
- for reg in regs:
- print '%s => %s' % (reg.GetName(), reg.GetValue())
- ...
- '''
- return get_registers(frame, 'exception state')
-"
- ) SBValueList;
-#endif
class SBValueList
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBValueList ();
Added: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=135416&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (added)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Mon Jul 18 14:08:30 2011
@@ -0,0 +1,265 @@
+//===-- SBValue.h -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the value of a variable, a register, or an expression.
+
+SBValue supports iteration through its child, which in turn is represented
+as an SBValue. For example, we can get the general purpose registers of a
+frame as an SBValue, and iterate through all the registers,
+
+ registerSet = frame.GetRegisters() # Returns an SBValueList.
+ for regs in registerSet:
+ if 'general purpose registers' in regs.getName().lower():
+ GPRs = regs
+ break
+
+ print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren())
+ for reg in GPRs:
+ print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue()
+
+produces the output:
+
+General Purpose Registers (number of children = 21):
+Name: rax Value: 0x0000000100000c5c
+Name: rbx Value: 0x0000000000000000
+Name: rcx Value: 0x00007fff5fbffec0
+Name: rdx Value: 0x00007fff5fbffeb8
+Name: rdi Value: 0x0000000000000001
+Name: rsi Value: 0x00007fff5fbffea8
+Name: rbp Value: 0x00007fff5fbffe80
+Name: rsp Value: 0x00007fff5fbffe60
+Name: r8 Value: 0x0000000008668682
+Name: r9 Value: 0x0000000000000000
+Name: r10 Value: 0x0000000000001200
+Name: r11 Value: 0x0000000000000206
+Name: r12 Value: 0x0000000000000000
+Name: r13 Value: 0x0000000000000000
+Name: r14 Value: 0x0000000000000000
+Name: r15 Value: 0x0000000000000000
+Name: rip Value: 0x0000000100000dae
+Name: rflags Value: 0x0000000000000206
+Name: cs Value: 0x0000000000000027
+Name: fs Value: 0x0000000000000010
+Name: gs Value: 0x0000000000000048
+"
+ ) SBValue;
+class SBValue
+{
+public:
+ SBValue ();
+
+ SBValue (const SBValue &rhs);
+
+ ~SBValue ();
+
+ bool
+ IsValid() const;
+
+ SBError
+ GetError();
+
+ lldb::user_id_t
+ GetID ();
+
+ const char *
+ GetName();
+
+ const char *
+ GetTypeName ();
+
+ size_t
+ GetByteSize ();
+
+ bool
+ IsInScope (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames.
+
+ bool
+ IsInScope ();
+
+ lldb::Format
+ GetFormat () const;
+
+ void
+ SetFormat (lldb::Format format);
+
+ const char *
+ GetValue (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames.
+
+ const char *
+ GetValue ();
+
+ ValueType
+ GetValueType ();
+
+ bool
+ GetValueDidChange (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames.
+
+ bool
+ GetValueDidChange ();
+
+ const char *
+ GetSummary (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames.
+
+ const char *
+ GetSummary ();
+
+ const char *
+ GetObjectDescription (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames.
+
+ const char *
+ GetObjectDescription ();
+
+ const char *
+ GetLocation (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames.
+
+ const char *
+ GetLocation ();
+
+ bool
+ SetValueFromCString (const lldb::SBFrame &frame, const char *value_str); // DEPRECATED - SBValues know their own frames.
+
+ bool
+ SetValueFromCString (const char *value_str);
+
+ lldb::SBValue
+ GetChildAtIndex (uint32_t idx);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Get a child value by index from a value.
+ ///
+ /// Structs, unions, classes, arrays and and pointers have child
+ /// values that can be access by index.
+ ///
+ /// Structs and unions access child members using a zero based index
+ /// for each child member. For
+ ///
+ /// Classes reserve the first indexes for base classes that have
+ /// members (empty base classes are omitted), and all members of the
+ /// current class will then follow the base classes.
+ ///
+ /// Pointers differ depending on what they point to. If the pointer
+ /// points to a simple type, the child at index zero
+ /// is the only child value available, unless \a synthetic_allowed
+ /// is \b true, in which case the pointer will be used as an array
+ /// and can create 'synthetic' child values using positive or
+ /// negative indexes. If the pointer points to an aggregate type
+ /// (an array, class, union, struct), then the pointee is
+ /// transparently skipped and any children are going to be the indexes
+ /// of the child values within the aggregate type. For example if
+ /// we have a 'Point' type and we have a SBValue that contains a
+ /// pointer to a 'Point' type, then the child at index zero will be
+ /// the 'x' member, and the child at index 1 will be the 'y' member
+ /// (the child at index zero won't be a 'Point' instance).
+ ///
+ /// Arrays have a preset number of children that can be accessed by
+ /// index and will returns invalid child values for indexes that are
+ /// out of bounds unless the \a synthetic_allowed is \b true. In this
+ /// case the array can create 'synthetic' child values for indexes
+ /// that aren't in the array bounds using positive or negative
+ /// indexes.
+ ///
+ /// @param[in] idx
+ /// The index of the child value to get
+ ///
+ /// @param[in] use_dynamic
+ /// An enumeration that specifies wether to get dynamic values,
+ /// and also if the target can be run to figure out the dynamic
+ /// type of the child value.
+ ///
+ /// @param[in] synthetic_allowed
+ /// If \b true, then allow child values to be created by index
+ /// for pointers and arrays for indexes that normally wouldn't
+ /// be allowed.
+ ///
+ /// @return
+ /// A new SBValue object that represents the child member value.
+ //------------------------------------------------------------------
+ ") GetChildAtIndex;
+ lldb::SBValue
+ GetChildAtIndex (uint32_t idx,
+ lldb::DynamicValueType use_dynamic,
+ bool can_create_synthetic);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Returns the child member index.
+ ///
+ /// Matches children of this object only and will match base classes and
+ /// member names if this is a clang typed object.
+ ///
+ /// @param[in] name
+ /// The name of the child value to get
+ ///
+ /// @return
+ /// An index to the child member value.
+ //------------------------------------------------------------------
+ ") GetIndexOfChildWithName;
+ uint32_t
+ GetIndexOfChildWithName (const char *name);
+
+ lldb::SBValue
+ GetChildMemberWithName (const char *name);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Returns the child member value.
+ ///
+ /// Matches child members of this object and child members of any base
+ /// classes.
+ ///
+ /// @param[in] name
+ /// The name of the child value to get
+ ///
+ /// @param[in] use_dynamic
+ /// An enumeration that specifies wether to get dynamic values,
+ /// and also if the target can be run to figure out the dynamic
+ /// type of the child value.
+ ///
+ /// @return
+ /// A new SBValue object that represents the child member value.
+ //------------------------------------------------------------------
+ ") GetChildMemberWithName;
+ lldb::SBValue
+ GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
+
+ %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
+ ) GetValueForExpressionPath;
+ lldb::SBValue
+ GetValueForExpressionPath(const char* expr_path);
+
+ uint32_t
+ GetNumChildren ();
+
+ void *
+ GetOpaqueType();
+
+
+ lldb::SBValue
+ Dereference ();
+
+ bool
+ TypeIsPointerType ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ GetExpressionPath (lldb::SBStream &description);
+
+ %feature("docstring", "Returns an expression path for this value."
+ ) GetValueForExpressionPath;
+ bool
+ GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBValueList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValueList.i?rev=135416&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValueList.i (added)
+++ lldb/trunk/scripts/Python/interface/SBValueList.i Mon Jul 18 14:08:30 2011
@@ -0,0 +1,99 @@
+//===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a collection of SBValues. Both SBFrame's GetVariables() and
+GetRegisters() return a SBValueList.
+
+SBValueList supports SBValue iteration. For example (from test/lldbutil.py),
+
+def get_registers(frame, kind):
+ '''Returns the registers given the frame and the kind of registers desired.
+
+ Returns None if there's no such kind.
+ '''
+ registerSet = frame.GetRegisters() # Return type of SBValueList.
+ for value in registerSet:
+ if kind.lower() in value.GetName().lower():
+ return value
+
+ return None
+
+def get_GPRs(frame):
+ '''Returns the general purpose registers of the frame as an SBValue.
+
+ The returned SBValue object is iterable. An example:
+ ...
+ from lldbutil import get_GPRs
+ regs = get_GPRs(frame)
+ for reg in regs:
+ print '%s => %s' % (reg.GetName(), reg.GetValue())
+ ...
+ '''
+ return get_registers(frame, 'general purpose')
+
+def get_FPRs(frame):
+ '''Returns the floating point registers of the frame as an SBValue.
+
+ The returned SBValue object is iterable. An example:
+ ...
+ from lldbutil import get_FPRs
+ regs = get_FPRs(frame)
+ for reg in regs:
+ print '%s => %s' % (reg.GetName(), reg.GetValue())
+ ...
+ '''
+ return get_registers(frame, 'floating point')
+
+def get_ESRs(frame):
+ '''Returns the exception state registers of the frame as an SBValue.
+
+ The returned SBValue object is iterable. An example:
+ ...
+ from lldbutil import get_ESRs
+ regs = get_ESRs(frame)
+ for reg in regs:
+ print '%s => %s' % (reg.GetName(), reg.GetValue())
+ ...
+ '''
+ return get_registers(frame, 'exception state')
+"
+ ) SBValueList;
+class SBValueList
+{
+public:
+
+ SBValueList ();
+
+ SBValueList (const lldb::SBValueList &rhs);
+
+ ~SBValueList();
+
+ bool
+ IsValid() const;
+
+ void
+ Append (const lldb::SBValue &val_obj);
+
+ void
+ Append (const lldb::SBValueList& value_list);
+
+ uint32_t
+ GetSize() const;
+
+ lldb::SBValue
+ GetValueAtIndex (uint32_t idx) const;
+
+ lldb::SBValue
+ FindValueObjectByUID (lldb::user_id_t uid);
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135416&r1=135415&r2=135416&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 14:08:30 2011
@@ -228,8 +228,8 @@
%include "./Python/interface/SBTarget.i"
%include "lldb/API/SBThread.h"
%include "lldb/API/SBType.h"
-%include "lldb/API/SBValue.h"
-%include "lldb/API/SBValueList.h"
+%include "./Python/interface/SBValue.i"
+%include "./Python/interface/SBValueList.i"
%include "./Python/python-extensions.swig"
From johnny.chen at apple.com Mon Jul 18 14:15:22 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 19:15:22 -0000
Subject: [Lldb-commits] [lldb] r135417 - in
/lldb/trunk/scripts/Python/interface: SBValue.i SBValueList.i
Message-ID: <20110718191522.664552A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 14:15:22 2011
New Revision: 135417
URL: http://llvm.org/viewvc/llvm-project?rev=135417&view=rev
Log:
Fix header documentations.
Modified:
lldb/trunk/scripts/Python/interface/SBValue.i
lldb/trunk/scripts/Python/interface/SBValueList.i
Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=135417&r1=135416&r2=135417&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Mon Jul 18 14:15:22 2011
@@ -1,4 +1,4 @@
-//===-- SBValue.h -----------------------------------------------*- C++ -*-===//
+//===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Modified: lldb/trunk/scripts/Python/interface/SBValueList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValueList.i?rev=135417&r1=135416&r2=135417&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValueList.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValueList.i Mon Jul 18 14:15:22 2011
@@ -1,4 +1,4 @@
-//===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===//
+//===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
From johnny.chen at apple.com Mon Jul 18 15:13:39 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 20:13:39 -0000
Subject: [Lldb-commits] [lldb] r135419 - in /lldb/trunk:
include/lldb/API/SBFrame.h include/lldb/API/SBProcess.h
include/lldb/API/SBThread.h scripts/Python/interface/SBFrame.i
scripts/Python/interface/SBProcess.i scripts/Python/interface/SBTarget.i
scripts/Python/interface/SBThread.i scripts/Python/interface/SBValue.i
scripts/Python/interface/SBValueList.i scripts/lldb.swig
Message-ID: <20110718201339.301AD2A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 15:13:38 2011
New Revision: 135419
URL: http://llvm.org/viewvc/llvm-project?rev=135419&view=rev
Log:
Add SWIG Python interface files for SBProcess, SBThread, and SBFrame.
Added:
lldb/trunk/scripts/Python/interface/SBFrame.i
lldb/trunk/scripts/Python/interface/SBProcess.i
lldb/trunk/scripts/Python/interface/SBThread.i
Modified:
lldb/trunk/include/lldb/API/SBFrame.h
lldb/trunk/include/lldb/API/SBProcess.h
lldb/trunk/include/lldb/API/SBThread.h
lldb/trunk/scripts/Python/interface/SBTarget.i
lldb/trunk/scripts/Python/interface/SBValue.i
lldb/trunk/scripts/Python/interface/SBValueList.i
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/include/lldb/API/SBFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFrame.h (original)
+++ lldb/trunk/include/lldb/API/SBFrame.h Mon Jul 18 15:13:38 2011
@@ -17,18 +17,8 @@
class SBValue;
-#ifdef SWIG
-%feature("docstring",
- "Represents one of the stack frames associated with a thread."
- " SBThread contains SBFrame(s)."
- ) SBFrame;
-#endif
class SBFrame
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
-
public:
SBFrame ();
@@ -77,21 +67,12 @@
lldb::SBSymbol
GetSymbol () const;
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// Gets the deepest block that contains the frame PC.
///
/// See also GetFrameBlock().
-#ifdef SWIG
- ") GetBlock;
-#endif
lldb::SBBlock
GetBlock () const;
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// Get the appropriate function name for this frame. Inlined functions in
/// LLDB are represented by Blocks that have inlined function information, so
/// just looking at the SBFunction or SBSymbol for a frame isn't enough.
@@ -105,41 +86,23 @@
/// - NULL
///
/// See also IsInlined().
-#ifdef SWIG
- ") GetFunctionName;
-#endif
const char *
GetFunctionName();
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// Return true if this frame represents an inlined function.
///
/// See also GetFunctionName().
-#ifdef SWIG
- ") IsInlined;
-#endif
bool
IsInlined();
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// The version that doesn't supply a 'use_dynamic' value will use the
/// target's default.
-#ifdef SWIG
- ") EvaluateExpression;
-#endif
lldb::SBValue
EvaluateExpression (const char *expr);
lldb::SBValue
EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// Gets the lexical block that defines the stack frame. Another way to think
/// of this is it will return the block that contains all of the variables
/// for a stack frame. Inlined functions are represented as SBBlock objects
@@ -152,9 +115,6 @@
/// in one of those inlined functions, this method will return the inlined
/// block that defines this frame. If the PC isn't currently in an inlined
/// function, the lexical block that defines the function is returned.
-#ifdef SWIG
- ") GetFrameBlock;
-#endif
lldb::SBBlock
GetFrameBlock () const;
@@ -179,14 +139,8 @@
#endif
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// The version that doesn't supply a 'use_dynamic' value will use the
/// target's default.
-#ifdef SWIG
- ") GetVariables;
-#endif
lldb::SBValueList
GetVariables (bool arguments,
bool locals,
@@ -203,31 +157,19 @@
lldb::SBValueList
GetRegisters ();
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// The version that doesn't supply a 'use_dynamic' value will use the
/// target's default.
-#ifdef SWIG
- ") FindVariable;
-#endif
lldb::SBValue
FindVariable (const char *var_name);
lldb::SBValue
FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// Find variables, register sets, registers, or persistent variables using
/// the frame as the scope.
///
/// The version that doesn't supply a 'use_dynamic' value will use the
/// target's default.
-#ifdef SWIG
- ") FindValue;
-#endif
lldb::SBValue
FindValue (const char *name, ValueType value_type);
Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Mon Jul 18 15:13:38 2011
@@ -19,37 +19,8 @@
class SBEvent;
-#ifdef SWIG
-%feature("docstring",
-"Represents the process associated with the target program.
-
-SBProcess supports thread iteration. For example (from test/lldbutil.py),
-
-# ==================================================
-# Utility functions related to Threads and Processes
-# ==================================================
-
-def get_stopped_threads(process, reason):
- '''Returns the thread(s) with the specified stop reason in a list.
-
- The list can be empty if no such thread exists.
- '''
- threads = []
- for t in process:
- if t.GetStopReason() == reason:
- threads.append(t)
- return threads
-
-...
-"
- ) SBProcess;
-#endif
class SBProcess
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
-
public:
//------------------------------------------------------------------
/// Broadcaster event bits definitions.
@@ -100,26 +71,15 @@
void
AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
-#ifdef SWIG
- %feature("docstring", "
-#endif
//------------------------------------------------------------------
/// Remote connection related functions. These will fail if the
/// process is not in eStateConnected. They are intended for use
/// when connecting to an externally managed debugserver instance.
//------------------------------------------------------------------
-#ifdef SWIG
- ") RemoteAttachToProcessWithID;
-#endif
bool
RemoteAttachToProcessWithID (lldb::pid_t pid,
lldb::SBError& error);
-#ifdef SWIG
- %feature("docstring",
- "See SBTarget.Launch for argument description and usage."
- ) RemoteLaunch;
-#endif
bool
RemoteLaunch (char const **argv,
char const **envp,
@@ -171,12 +131,6 @@
uint32_t
GetAddressByteSize() const;
-#ifdef SWIG
- %feature("docstring",
- "Kills the process and shuts down all threads that were spawned to"
- " track and monitor process."
- ) Destroy;
-#endif
lldb::SBError
Destroy ();
@@ -186,48 +140,18 @@
lldb::SBError
Stop ();
-#ifdef SWIG
- %feature("docstring", "Same as Destroy(self).") Destroy;
-#endif
lldb::SBError
Kill ();
lldb::SBError
Detach ();
-#ifdef SWIG
- %feature("docstring", "Sends the process a unix signal.") Signal;
-#endif
lldb::SBError
Signal (int signal);
-#ifdef SWIG
- %feature("autodoc",
-"Reads memory from the current process's address space and removes any
-traps that may have been inserted into the memory. It returns the byte
-buffer in a Python string. Example:
-
-# Read 4 bytes from address 'addr' and assume error.Success() is True.
-content = process.ReadMemory(addr, 4, error)
-# Use 'ascii' encoding as each byte of 'content' is within [0..255].
-new_bytes = bytearray(content, 'ascii')"
- ) ReadMemory;
-#endif
size_t
ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
-#ifdef SWIG
- %feature("autodoc",
-"Writes memory to the current process's address space and maintains any
-traps that might be present due to software breakpoints. Example:
-
-# Create a Python string from the byte array.
-new_value = str(bytes)
-result = process.WriteMemory(addr, new_value, error)
-if not error.Success() or result != len(bytes):
- print 'SBProcess.WriteMemory() failed!'"
- ) WriteMemory;
-#endif
size_t
WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Mon Jul 18 15:13:38 2011
@@ -18,38 +18,8 @@
class SBFrame;
-#ifdef SWIG
-%feature("docstring",
-"Represents a thread of execution. SBProcess contains SBThread(s).
-
-SBThread supports frame iteration. For example (from test/python_api/
-lldbutil/iter/TestLLDBIterator.py),
-
- from lldbutil import print_stacktrace
- stopped_due_to_breakpoint = False
- for thread in process:
- if self.TraceOn():
- print_stacktrace(thread)
- ID = thread.GetThreadID()
- if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
- stopped_due_to_breakpoint = True
- for frame in thread:
- self.assertTrue(frame.GetThread().GetThreadID() == ID)
- if self.TraceOn():
- print frame
-
- self.assertTrue(stopped_due_to_breakpoint)
-
-See also SBProcess and SBFrame.
-"
- ) SBThread;
-#endif
class SBThread
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
-
public:
SBThread ();
@@ -66,20 +36,11 @@
lldb::StopReason
GetStopReason();
-#ifdef SWIG
- %feature("docstring", "
-#endif
/// Get the number of words associated with the stop reason.
/// See also GetStopReasonDataAtIndex().
-#ifdef SWIG
- ") GetStopReasonDataCount;
-#endif
size_t
GetStopReasonDataCount();
-#ifdef SWIG
- %feature("docstring", "
-#endif
//--------------------------------------------------------------------------
/// Get information associated with a stop reason.
///
@@ -97,9 +58,6 @@
/// eStopReasonException N exception data
/// eStopReasonPlanComplete 0
//--------------------------------------------------------------------------
-#ifdef SWIG
- ") GetStopReasonDataAtIndex;
-#endif
uint64_t
GetStopReasonDataAtIndex(uint32_t idx);
@@ -141,9 +99,6 @@
void
RunToAddress (lldb::addr_t addr);
-#ifdef SWIG
- %feature("docstring", "
-#endif
//--------------------------------------------------------------------------
/// LLDB currently supports process centric debugging which means when any
/// thread in a process stops, all other threads are stopped. The Suspend()
@@ -165,9 +120,6 @@
/// anyone has the need for them to be reference counted, please let us
/// know.
//--------------------------------------------------------------------------
-#ifdef SWIG
- ") Suspend;
-#endif
bool
Suspend();
Added: lldb/trunk/scripts/Python/interface/SBFrame.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=135419&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFrame.i (added)
+++ lldb/trunk/scripts/Python/interface/SBFrame.i Mon Jul 18 15:13:38 2011
@@ -0,0 +1,191 @@
+//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents one of the stack frames associated with a thread.
+SBThread contains SBFrame(s)."
+) SBFrame;
+class SBFrame
+{
+public:
+ SBFrame ();
+
+ SBFrame (const lldb::SBFrame &rhs);
+
+ ~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::SBSymbol
+ GetSymbol () const;
+
+ %feature("docstring", "
+ /// Gets the deepest block that contains the frame PC.
+ ///
+ /// See also GetFrameBlock().
+ ") GetBlock;
+ lldb::SBBlock
+ GetBlock () const;
+
+ %feature("docstring", "
+ /// Get the appropriate function name for this frame. Inlined functions in
+ /// LLDB are represented by Blocks that have inlined function information, so
+ /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
+ /// This function will return the appriopriate function, symbol or inlined
+ /// function name for the frame.
+ ///
+ /// This function returns:
+ /// - the name of the inlined function (if there is one)
+ /// - the name of the concrete function (if there is one)
+ /// - the name of the symbol (if there is one)
+ /// - NULL
+ ///
+ /// See also IsInlined().
+ ") GetFunctionName;
+ const char *
+ GetFunctionName();
+
+ %feature("docstring", "
+ /// Return true if this frame represents an inlined function.
+ ///
+ /// See also GetFunctionName().
+ ") IsInlined;
+ bool
+ IsInlined();
+
+ %feature("docstring", "
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ ") EvaluateExpression;
+ lldb::SBValue
+ EvaluateExpression (const char *expr);
+
+ lldb::SBValue
+ EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
+
+ %feature("docstring", "
+ /// Gets the lexical block that defines the stack frame. Another way to think
+ /// of this is it will return the block that contains all of the variables
+ /// for a stack frame. Inlined functions are represented as SBBlock objects
+ /// that have inlined function information: the name of the inlined function,
+ /// where it was called from. The block that is returned will be the first
+ /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
+ /// the scope of the frame. When a function contains no inlined functions,
+ /// this will be the top most lexical block that defines the function.
+ /// When a function has inlined functions and the PC is currently
+ /// in one of those inlined functions, this method will return the inlined
+ /// block that defines this frame. If the PC isn't currently in an inlined
+ /// function, the lexical block that defines the function is returned.
+ ") GetFrameBlock;
+ lldb::SBBlock
+ GetFrameBlock () 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
+
+ %feature("docstring", "
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ ") GetVariables;
+ lldb::SBValueList
+ GetVariables (bool arguments,
+ bool locals,
+ bool statics,
+ bool in_scope_only);
+
+ lldb::SBValueList
+ GetVariables (bool arguments,
+ bool locals,
+ bool statics,
+ bool in_scope_only,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValueList
+ GetRegisters ();
+
+ %feature("docstring", "
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ ") FindVariable;
+ lldb::SBValue
+ FindVariable (const char *var_name);
+
+ lldb::SBValue
+ FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
+
+ %feature("docstring", "
+ /// Find variables, register sets, registers, or persistent variables using
+ /// the frame as the scope.
+ ///
+ /// The version that doesn't supply a 'use_dynamic' value will use the
+ /// target's default.
+ ") FindValue;
+ lldb::SBValue
+ FindValue (const char *name, ValueType value_type);
+
+ lldb::SBValue
+ FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBProcess.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=135419&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBProcess.i (added)
+++ lldb/trunk/scripts/Python/interface/SBProcess.i Mon Jul 18 15:13:38 2011
@@ -0,0 +1,220 @@
+//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the process associated with the target program.
+
+SBProcess supports thread iteration. For example (from test/lldbutil.py),
+
+# ==================================================
+# Utility functions related to Threads and Processes
+# ==================================================
+
+def get_stopped_threads(process, reason):
+ '''Returns the thread(s) with the specified stop reason in a list.
+
+ The list can be empty if no such thread exists.
+ '''
+ threads = []
+ for t in process:
+ if t.GetStopReason() == reason:
+ threads.append(t)
+ return threads
+
+...
+"
+) SBProcess;
+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;
+
+ lldb::ByteOrder
+ GetByteOrder() 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
+ ReportEventState (const lldb::SBEvent &event, FILE *out) const;
+
+ void
+ AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Remote connection related functions. These will fail if the
+ /// process is not in eStateConnected. They are intended for use
+ /// when connecting to an externally managed debugserver instance.
+ //------------------------------------------------------------------
+ ") RemoteAttachToProcessWithID;
+ bool
+ RemoteAttachToProcessWithID (lldb::pid_t pid,
+ lldb::SBError& error);
+
+ %feature("docstring",
+ "See SBTarget.Launch for argument description and usage."
+ ) RemoteLaunch;
+ bool
+ RemoteLaunch (char const **argv,
+ char const **envp,
+ const char *stdin_path,
+ const char *stdout_path,
+ const char *stderr_path,
+ const char *working_directory,
+ uint32_t launch_flags,
+ bool stop_at_entry,
+ lldb::SBError& error);
+
+ //------------------------------------------------------------------
+ // Thread related functions
+ //------------------------------------------------------------------
+ uint32_t
+ GetNumThreads ();
+
+ lldb::SBThread
+ GetThreadAtIndex (size_t index);
+
+ lldb::SBThread
+ GetThreadByID (lldb::tid_t sb_thread_id);
+
+ lldb::SBThread
+ GetSelectedThread () const;
+
+ bool
+ SetSelectedThread (const lldb::SBThread &thread);
+
+ bool
+ SetSelectedThreadByID (uint32_t tid);
+
+ //------------------------------------------------------------------
+ // Stepping related functions
+ //------------------------------------------------------------------
+
+ lldb::StateType
+ GetState ();
+
+ int
+ GetExitStatus ();
+
+ const char *
+ GetExitDescription ();
+
+ lldb::pid_t
+ GetProcessID ();
+
+ uint32_t
+ GetAddressByteSize() const;
+
+ %feature("docstring", "
+ Kills the process and shuts down all threads that were spawned to
+ track and monitor process.
+ ") Destroy;
+ lldb::SBError
+ Destroy ();
+
+ lldb::SBError
+ Continue ();
+
+ lldb::SBError
+ Stop ();
+
+ %feature("docstring", "Same as Destroy(self).") Destroy;
+ lldb::SBError
+ Kill ();
+
+ lldb::SBError
+ Detach ();
+
+ %feature("docstring", "Sends the process a unix signal.") Signal;
+ lldb::SBError
+ Signal (int signal);
+
+ %feature("autodoc", "
+ Reads memory from the current process's address space and removes any
+ traps that may have been inserted into the memory. It returns the byte
+ buffer in a Python string. Example:
+
+ # Read 4 bytes from address 'addr' and assume error.Success() is True.
+ content = process.ReadMemory(addr, 4, error)
+ # Use 'ascii' encoding as each byte of 'content' is within [0..255].
+ new_bytes = bytearray(content, 'ascii')
+ ") ReadMemory;
+ size_t
+ ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
+
+ %feature("autodoc", "
+ Writes memory to the current process's address space and maintains any
+ traps that might be present due to software breakpoints. Example:
+
+ # Create a Python string from the byte array.
+ new_value = str(bytes)
+ result = process.WriteMemory(addr, new_value, error)
+ if not error.Success() or result != len(bytes):
+ print 'SBProcess.WriteMemory() failed!'
+ ") WriteMemory;
+ size_t
+ WriteMemory (addr_t addr, const void *buf, size_t size, lldb::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;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ uint32_t
+ LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
+
+ lldb::SBError
+ UnloadImage (uint32_t image_token);
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Mon Jul 18 15:13:38 2011
@@ -34,9 +34,8 @@
produces:
SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
-SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
-"
- ) SBTarget;
+SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1"
+) SBTarget;
class SBTarget
{
public:
Added: lldb/trunk/scripts/Python/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=135419&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBThread.i (added)
+++ lldb/trunk/scripts/Python/interface/SBThread.i Mon Jul 18 15:13:38 2011
@@ -0,0 +1,171 @@
+//===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a thread of execution. SBProcess contains SBThread(s).
+
+SBThread supports frame iteration. For example (from test/python_api/
+lldbutil/iter/TestLLDBIterator.py),
+
+ from lldbutil import print_stacktrace
+ stopped_due_to_breakpoint = False
+ for thread in process:
+ if self.TraceOn():
+ print_stacktrace(thread)
+ ID = thread.GetThreadID()
+ if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
+ stopped_due_to_breakpoint = True
+ for frame in thread:
+ self.assertTrue(frame.GetThread().GetThreadID() == ID)
+ if self.TraceOn():
+ print frame
+
+ self.assertTrue(stopped_due_to_breakpoint)
+
+See also SBProcess and SBFrame."
+) SBThread;
+class SBThread
+{
+public:
+ SBThread ();
+
+ SBThread (const lldb::SBThread &thread);
+
+ ~SBThread();
+
+ bool
+ IsValid() const;
+
+ void
+ Clear ();
+
+ lldb::StopReason
+ GetStopReason();
+
+ %feature("docstring", "
+ /// Get the number of words associated with the stop reason.
+ /// See also GetStopReasonDataAtIndex().
+ ") GetStopReasonDataCount;
+ size_t
+ GetStopReasonDataCount();
+
+ %feature("docstring", "
+ //--------------------------------------------------------------------------
+ /// Get information associated with a stop reason.
+ ///
+ /// Breakpoint stop reasons will have data that consists of pairs of
+ /// breakpoint IDs followed by the breakpoint location IDs (they always come
+ /// in pairs).
+ ///
+ /// Stop Reason Count Data Type
+ /// ======================== ===== =========================================
+ /// eStopReasonNone 0
+ /// eStopReasonTrace 0
+ /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
+ /// eStopReasonWatchpoint N duple: {watchpoint id, location id}
+ /// eStopReasonSignal 1 unix signal number
+ /// eStopReasonException N exception data
+ /// eStopReasonPlanComplete 0
+ //--------------------------------------------------------------------------
+ ") GetStopReasonDataAtIndex;
+ uint64_t
+ GetStopReasonDataAtIndex(uint32_t idx);
+
+ 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
+ StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void
+ StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void
+ StepOut ();
+
+ void
+ StepOutOfFrame (lldb::SBFrame &frame);
+
+ void
+ StepInstruction(bool step_over);
+
+ SBError
+ StepOverUntil (lldb::SBFrame &frame,
+ lldb::SBFileSpec &file_spec,
+ uint32_t line);
+
+ void
+ RunToAddress (lldb::addr_t addr);
+
+ %feature("docstring", "
+ //--------------------------------------------------------------------------
+ /// LLDB currently supports process centric debugging which means when any
+ /// thread in a process stops, all other threads are stopped. The Suspend()
+ /// call here tells our process to suspend a thread and not let it run when
+ /// the other threads in a process are allowed to run. So when
+ /// SBProcess::Continue() is called, any threads that aren't suspended will
+ /// be allowed to run. If any of the SBThread functions for stepping are
+ /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
+ /// thread will now be allowed to run and these funtions will simply return.
+ ///
+ /// Eventually we plan to add support for thread centric debugging where
+ /// each thread is controlled individually and each thread would broadcast
+ /// its state, but we haven't implemented this yet.
+ ///
+ /// Likewise the SBThread::Resume() call will again allow the thread to run
+ /// when the process is continued.
+ ///
+ /// Suspend() and Resume() functions are not currently reference counted, if
+ /// anyone has the need for them to be reference counted, please let us
+ /// know.
+ //--------------------------------------------------------------------------
+ ") Suspend;
+ bool
+ Suspend();
+
+ bool
+ Resume ();
+
+ bool
+ IsSuspended();
+
+ uint32_t
+ GetNumFrames ();
+
+ lldb::SBFrame
+ GetFrameAtIndex (uint32_t idx);
+
+ lldb::SBFrame
+ GetSelectedFrame ();
+
+ lldb::SBFrame
+ SetSelectedFrame (uint32_t frame_idx);
+
+ lldb::SBProcess
+ GetProcess ();
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Mon Jul 18 15:13:38 2011
@@ -49,9 +49,8 @@
Name: rflags Value: 0x0000000000000206
Name: cs Value: 0x0000000000000027
Name: fs Value: 0x0000000000000010
-Name: gs Value: 0x0000000000000048
-"
- ) SBValue;
+Name: gs Value: 0x0000000000000048"
+) SBValue;
class SBValue
{
public:
Modified: lldb/trunk/scripts/Python/interface/SBValueList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValueList.i?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValueList.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValueList.i Mon Jul 18 15:13:38 2011
@@ -64,9 +64,8 @@
print '%s => %s' % (reg.GetName(), reg.GetValue())
...
'''
- return get_registers(frame, 'exception state')
-"
- ) SBValueList;
+ return get_registers(frame, 'exception state')"
+) SBValueList;
class SBValueList
{
public:
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135419&r1=135418&r2=135419&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 15:13:38 2011
@@ -209,7 +209,7 @@
%include "lldb/API/SBError.h"
%include "lldb/API/SBEvent.h"
%include "lldb/API/SBFileSpec.h"
-%include "lldb/API/SBFrame.h"
+%include "./Python/interface/SBFrame.i"
%include "lldb/API/SBFunction.h"
%include "lldb/API/SBHostOS.h"
%include "lldb/API/SBInputReader.h"
@@ -218,7 +218,7 @@
%include "lldb/API/SBLineEntry.h"
%include "lldb/API/SBListener.h"
%include "lldb/API/SBModule.h"
-%include "lldb/API/SBProcess.h"
+%include "./Python/interface/SBProcess.i"
%include "lldb/API/SBSourceManager.h"
%include "lldb/API/SBStream.h"
%include "lldb/API/SBStringList.h"
@@ -226,7 +226,7 @@
%include "lldb/API/SBSymbolContext.h"
%include "lldb/API/SBSymbolContextList.h"
%include "./Python/interface/SBTarget.i"
-%include "lldb/API/SBThread.h"
+%include "./Python/interface/SBThread.i"
%include "lldb/API/SBType.h"
%include "./Python/interface/SBValue.i"
%include "./Python/interface/SBValueList.i"
From scallanan at apple.com Mon Jul 18 16:30:18 2011
From: scallanan at apple.com (Sean Callanan)
Date: Mon, 18 Jul 2011 21:30:18 -0000
Subject: [Lldb-commits] [lldb] r135429 -
/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
Message-ID: <20110718213018.66BBF2A6C12C@llvm.org>
Author: spyffe
Date: Mon Jul 18 16:30:18 2011
New Revision: 135429
URL: http://llvm.org/viewvc/llvm-project?rev=135429&view=rev
Log:
Removed a redundant dyn_cast. Thanks to Felipe
Cabecinhas.
Modified:
lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=135429&r1=135428&r2=135429&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Mon Jul 18 16:30:18 2011
@@ -219,21 +219,19 @@
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ASTContext &Ctx(*m_ast_context);
-
- CompoundStmt *compound_stmt = dyn_cast(Body);
-
- if (!compound_stmt)
+
+ if (!Body)
return false;
- if (compound_stmt->body_empty())
+ if (Body->body_empty())
return false;
- Stmt **last_stmt_ptr = compound_stmt->body_end() - 1;
+ Stmt **last_stmt_ptr = Body->body_end() - 1;
Stmt *last_stmt = *last_stmt_ptr;
while (dyn_cast(last_stmt))
{
- if (last_stmt_ptr != compound_stmt->body_begin())
+ if (last_stmt_ptr != Body->body_begin())
{
last_stmt_ptr--;
last_stmt = *last_stmt_ptr;
From johnny.chen at apple.com Mon Jul 18 16:30:21 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 21:30:21 -0000
Subject: [Lldb-commits] [lldb] r135430 - in /lldb/trunk:
include/lldb/API/SBAddress.h include/lldb/API/SBBlock.h
include/lldb/API/SBBreakpoint.h include/lldb/API/SBBreakpointLocation.h
scripts/Python/interface/SBAddress.i scripts/Python/interface/SBBlock.i
scripts/Python/interface/SBBreakpoint.i
scripts/Python/interface/SBBreakpointLocation.i scripts/lldb.swig
Message-ID: <20110718213021.ED8882A6C12D@llvm.org>
Author: johnny
Date: Mon Jul 18 16:30:21 2011
New Revision: 135430
URL: http://llvm.org/viewvc/llvm-project?rev=135430&view=rev
Log:
Add SWIG Python interface files for SBAddress, SBBlock, SBBreakpoint, and SBBreakpointLocation.
Added:
lldb/trunk/scripts/Python/interface/SBAddress.i
lldb/trunk/scripts/Python/interface/SBBlock.i
lldb/trunk/scripts/Python/interface/SBBreakpoint.i
lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i
Modified:
lldb/trunk/include/lldb/API/SBAddress.h
lldb/trunk/include/lldb/API/SBBlock.h
lldb/trunk/include/lldb/API/SBBreakpoint.h
lldb/trunk/include/lldb/API/SBBreakpointLocation.h
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=135430&r1=135429&r2=135430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Mon Jul 18 16:30:21 2011
@@ -15,47 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"A section + offset based address class.
-
-The SBAddress 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:
- o file addresses
- o load addresses
-
-File addresses represents 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 represents 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.
-
-See docstring of SBFunction for example usage of SBAddress.
-"
- ) SBAddress;
-#endif
class SBAddress
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBAddress ();
Modified: lldb/trunk/include/lldb/API/SBBlock.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=135430&r1=135429&r2=135430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBlock.h (original)
+++ lldb/trunk/include/lldb/API/SBBlock.h Mon Jul 18 16:30:21 2011
@@ -14,16 +14,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
- "Represents a lexical block. SBFunction contains SBBlock(s)."
- ) SBBlock;
-#endif
class SBBlock
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBBlock ();
@@ -37,68 +29,30 @@
operator = (const lldb::SBBlock &rhs);
#endif
-#ifdef SWIG
- %feature("docstring",
- "Does this block represent an inlined function?"
- ) IsInlined;
-#endif
bool
IsInlined () const;
bool
IsValid () const;
-#ifdef SWIG
- %feature("autodoc",
- "Get the function name if this block represents an inlined function;\n"
- "otherwise, return None."
- ) GetInlinedName;
-#endif
const char *
GetInlinedName () const;
-#ifdef SWIG
- %feature("docstring",
- "Get the call site file if this block represents an inlined function;\n"
- "otherwise, return an invalid file spec."
- ) GetInlinedCallSiteFile;
-#endif
lldb::SBFileSpec
GetInlinedCallSiteFile () const;
-#ifdef SWIG
- %feature("docstring",
- "Get the call site line if this block represents an inlined function;\n"
- "otherwise, return 0."
- ) GetInlinedCallSiteLine;
-#endif
uint32_t
GetInlinedCallSiteLine () const;
-#ifdef SWIG
- %feature("docstring",
- "Get the call site column if this block represents an inlined function;\n"
- "otherwise, return 0."
- ) GetInlinedCallSiteColumn;
-#endif
uint32_t
GetInlinedCallSiteColumn () const;
-#ifdef SWIG
- %feature("docstring", "Get the parent block.") GetParent;
-#endif
lldb::SBBlock
GetParent ();
-#ifdef SWIG
- %feature("docstring", "Get the sibling block for this block.") GetSibling;
-#endif
lldb::SBBlock
GetSibling ();
-#ifdef SWIG
- %feature("docstring", "Get the first child block.") GetFirstChild;
-#endif
lldb::SBBlock
GetFirstChild ();
Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=135430&r1=135429&r2=135430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpoint.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpoint.h Mon Jul 18 16:30:21 2011
@@ -15,76 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents a logical breakpoint and its associated settings.
-
-For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
-TestBreakpointIgnoreCount.py),
-
- def breakpoint_ignore_count_python(self):
- '''Use Python APIs to set breakpoint ignore count.'''
- exe = os.path.join(os.getcwd(), 'a.out')
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- # Now create a breakpoint on main.c by name 'c'.
- breakpoint = target.BreakpointCreateByName('c', 'a.out')
- self.assertTrue(breakpoint and
- breakpoint.GetNumLocations() == 1,
- VALID_BREAKPOINT)
-
- # Get the breakpoint location from breakpoint after we verified that,
- # indeed, it has one location.
- location = breakpoint.GetLocationAtIndex(0)
- self.assertTrue(location and
- location.IsEnabled(),
- VALID_BREAKPOINT_LOCATION)
-
- # Set the ignore count on the breakpoint location.
- location.SetIgnoreCount(2)
- self.assertTrue(location.GetIgnoreCount() == 2,
- 'SetIgnoreCount() works correctly')
-
- # Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple(None, None, os.getcwd())
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
- # frame#2 should be on main.c:48.
- #lldbutil.print_stacktraces(process)
- from lldbutil import get_stopped_thread
- thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
- frame0 = thread.GetFrameAtIndex(0)
- frame1 = thread.GetFrameAtIndex(1)
- frame2 = thread.GetFrameAtIndex(2)
- self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
- frame1.GetLineEntry().GetLine() == self.line3 and
- frame2.GetLineEntry().GetLine() == self.line4,
- STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
-
- # The hit count for the breakpoint should be 3.
- self.assertTrue(breakpoint.GetHitCount() == 3)
-
- process.Continue()
-
-SBBreakpoint supports breakpoint location iteration. For example,
-
- for bl in breakpoint:
- print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
- print 'breakpoint location condition: %s' % hex(bl.GetCondition())
-
-"
- ) SBBreakpoint;
-#endif
class SBBreakpoint
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
typedef bool (*BreakpointHitCallback) (void *baton,
Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=135430&r1=135429&r2=135430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Jul 18 16:30:21 2011
@@ -15,24 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents one unique instance (by address) of a logical breakpoint.
-
-A breakpoint location is defined by the breakpoint that produces it,
-and the address that resulted in this particular instantiation.
-Each breakpoint location has its settable options.
-
-SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint
-for retrieval of an SBBreakpointLocation from an SBBreakpoint.
-"
- ) SBBreakpointLocation;
-#endif
class SBBreakpointLocation
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBBreakpointLocation ();
Added: lldb/trunk/scripts/Python/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=135430&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBAddress.i (added)
+++ lldb/trunk/scripts/Python/interface/SBAddress.i Mon Jul 18 16:30:21 2011
@@ -0,0 +1,80 @@
+//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"A section + offset based address class.
+
+The SBAddress 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:
+ o file addresses
+ o load addresses
+
+File addresses represents 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 represents 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.
+
+See docstring of SBFunction for example usage of SBAddress."
+) SBAddress;
+class SBAddress
+{
+public:
+
+ SBAddress ();
+
+ SBAddress (const lldb::SBAddress &rhs);
+
+ ~SBAddress ();
+
+ bool
+ IsValid () const;
+
+ void
+ Clear ();
+
+ addr_t
+ GetFileAddress () const;
+
+ addr_t
+ GetLoadAddress (const lldb::SBTarget &target) const;
+
+ bool
+ OffsetAddress (addr_t offset);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ SectionType
+ GetSectionType ();
+
+ lldb::SBModule
+ GetModule ();
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBBlock.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBlock.i?rev=135430&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBBlock.i (added)
+++ lldb/trunk/scripts/Python/interface/SBBlock.i Mon Jul 18 16:30:21 2011
@@ -0,0 +1,78 @@
+//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a lexical block. SBFunction contains SBBlock(s)."
+) SBBlock;
+class SBBlock
+{
+public:
+
+ SBBlock ();
+
+ SBBlock (const lldb::SBBlock &rhs);
+
+ ~SBBlock ();
+
+ %feature("docstring",
+ "Does this block represent an inlined function?"
+ ) IsInlined;
+ bool
+ IsInlined () const;
+
+ bool
+ IsValid () const;
+
+ %feature("docstring", "
+ Get the function name if this block represents an inlined function;
+ otherwise, return None.
+ ") GetInlinedName;
+ const char *
+ GetInlinedName () const;
+
+ %feature("docstring", "
+ Get the call site file if this block represents an inlined function;
+ otherwise, return an invalid file spec.
+ ") GetInlinedCallSiteFile;
+ lldb::SBFileSpec
+ GetInlinedCallSiteFile () const;
+
+ %feature("docstring", "
+ Get the call site line if this block represents an inlined function;
+ otherwise, return 0.
+ ") GetInlinedCallSiteLine;
+ uint32_t
+ GetInlinedCallSiteLine () const;
+
+ %feature("docstring", "
+ Get the call site column if this block represents an inlined function;
+ otherwise, return 0.
+ ") GetInlinedCallSiteColumn;
+ uint32_t
+ GetInlinedCallSiteColumn () const;
+
+ %feature("docstring", "Get the parent block.") GetParent;
+ lldb::SBBlock
+ GetParent ();
+
+ %feature("docstring", "Get the sibling block for this block.") GetSibling;
+ lldb::SBBlock
+ GetSibling ();
+
+ %feature("docstring", "Get the first child block.") GetFirstChild;
+ lldb::SBBlock
+ GetFirstChild ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBBreakpoint.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBreakpoint.i?rev=135430&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBBreakpoint.i (added)
+++ lldb/trunk/scripts/Python/interface/SBBreakpoint.i Mon Jul 18 16:30:21 2011
@@ -0,0 +1,176 @@
+//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a logical breakpoint and its associated settings.
+
+For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
+TestBreakpointIgnoreCount.py),
+
+ def breakpoint_ignore_count_python(self):
+ '''Use Python APIs to set breakpoint ignore count.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Get the breakpoint location from breakpoint after we verified that,
+ # indeed, it has one location.
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location and
+ location.IsEnabled(),
+ VALID_BREAKPOINT_LOCATION)
+
+ # Set the ignore count on the breakpoint location.
+ location.SetIgnoreCount(2)
+ self.assertTrue(location.GetIgnoreCount() == 2,
+ 'SetIgnoreCount() works correctly')
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
+ # frame#2 should be on main.c:48.
+ #lldbutil.print_stacktraces(process)
+ from lldbutil import get_stopped_thread
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
+ frame0 = thread.GetFrameAtIndex(0)
+ frame1 = thread.GetFrameAtIndex(1)
+ frame2 = thread.GetFrameAtIndex(2)
+ self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
+ frame1.GetLineEntry().GetLine() == self.line3 and
+ frame2.GetLineEntry().GetLine() == self.line4,
+ STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
+
+ # The hit count for the breakpoint should be 3.
+ self.assertTrue(breakpoint.GetHitCount() == 3)
+
+ process.Continue()
+
+SBBreakpoint supports breakpoint location iteration. For example,
+
+ for bl in breakpoint:
+ print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
+ print 'breakpoint location condition: %s' % hex(bl.GetCondition())
+") SBBreakpoint;
+class SBBreakpoint
+{
+public:
+
+ typedef bool (*BreakpointHitCallback) (void *baton,
+ SBProcess &process,
+ SBThread &thread,
+ lldb::SBBreakpointLocation &location);
+
+ SBBreakpoint ();
+
+ SBBreakpoint (const lldb::SBBreakpoint& rhs);
+
+ ~SBBreakpoint();
+
+ break_id_t
+ GetID () const;
+
+ bool
+ IsValid() const;
+
+ 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
+ SetEnabled (bool enable);
+
+ bool
+ IsEnabled ();
+
+ uint32_t
+ GetHitCount () const;
+
+ void
+ SetIgnoreCount (uint32_t count);
+
+ uint32_t
+ GetIgnoreCount () const;
+
+ void
+ SetCondition (const char *condition);
+
+ const char *
+ GetCondition ();
+
+ void
+ SetThreadID (lldb::tid_t sb_thread_id);
+
+ lldb::tid_t
+ GetThreadID ();
+
+ void
+ SetThreadIndex (uint32_t index);
+
+ uint32_t
+ GetThreadIndex() const;
+
+ void
+ SetThreadName (const char *thread_name);
+
+ const char *
+ GetThreadName () const;
+
+ void
+ SetQueueName (const char *queue_name);
+
+ const char *
+ GetQueueName () const;
+
+ void
+ SetCallback (BreakpointHitCallback callback, void *baton);
+
+ size_t
+ GetNumResolvedLocations() const;
+
+ size_t
+ GetNumLocations() const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ static lldb::BreakpointEventType
+ GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBBreakpoint
+ GetBreakpointFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBBreakpointLocation
+ GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i?rev=135430&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i (added)
+++ lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i Mon Jul 18 16:30:21 2011
@@ -0,0 +1,90 @@
+//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents one unique instance (by address) of a logical breakpoint.
+
+A breakpoint location is defined by the breakpoint that produces it,
+and the address that resulted in this particular instantiation.
+Each breakpoint location has its settable options.
+
+SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint
+for retrieval of an SBBreakpointLocation from an SBBreakpoint."
+) SBBreakpointLocation;
+class SBBreakpointLocation
+{
+public:
+
+ SBBreakpointLocation ();
+
+ SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs);
+
+ ~SBBreakpointLocation ();
+
+ bool
+ IsValid() const;
+
+ lldb::addr_t
+ GetLoadAddress ();
+
+ void
+ SetEnabled(bool enabled);
+
+ bool
+ IsEnabled ();
+
+ uint32_t
+ GetIgnoreCount ();
+
+ void
+ SetIgnoreCount (uint32_t n);
+
+ void
+ SetCondition (const char *condition);
+
+ const char *
+ GetCondition ();
+
+ void
+ SetThreadID (lldb::tid_t sb_thread_id);
+
+ lldb::tid_t
+ GetThreadID ();
+
+ void
+ SetThreadIndex (uint32_t index);
+
+ uint32_t
+ GetThreadIndex() const;
+
+ void
+ SetThreadName (const char *thread_name);
+
+ const char *
+ GetThreadName () const;
+
+ void
+ SetQueueName (const char *queue_name);
+
+ const char *
+ GetQueueName () const;
+
+ bool
+ IsResolved ();
+
+ bool
+ GetDescription (lldb::SBStream &description, DescriptionLevel level);
+
+ SBBreakpoint
+ GetBreakpoint ();
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135430&r1=135429&r2=135430&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 16:30:21 2011
@@ -196,10 +196,10 @@
%include "lldb/lldb-forward.h"
%include "lldb/lldb-forward-rtti.h"
%include "lldb/lldb-types.h"
-%include "lldb/API/SBAddress.h"
-%include "lldb/API/SBBlock.h"
-%include "lldb/API/SBBreakpoint.h"
-%include "lldb/API/SBBreakpointLocation.h"
+%include "./Python/interface/SBAddress.i"
+%include "./Python/interface/SBBlock.i"
+%include "./Python/interface/SBBreakpoint.i"
+%include "./Python/interface/SBBreakpointLocation.i"
%include "lldb/API/SBBroadcaster.h"
%include "lldb/API/SBCommandInterpreter.h"
%include "lldb/API/SBCommandReturnObject.h"
From johnny.chen at apple.com Mon Jul 18 17:11:53 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 22:11:53 -0000
Subject: [Lldb-commits] [lldb] r135432 - in /lldb/trunk:
include/lldb/API/SBCompileUnit.h include/lldb/API/SBDebugger.h
include/lldb/API/SBEvent.h scripts/Python/interface/SBCompileUnit.i
scripts/Python/interface/SBDebugger.i scripts/Python/interface/SBEvent.i
scripts/lldb.swig
Message-ID: <20110718221153.C7DD92A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 17:11:53 2011
New Revision: 135432
URL: http://llvm.org/viewvc/llvm-project?rev=135432&view=rev
Log:
Add SWIG Python interface files for SBDebugger, SBCompileUnit, and SBEvent.
Added:
lldb/trunk/scripts/Python/interface/SBCompileUnit.i
lldb/trunk/scripts/Python/interface/SBDebugger.i
lldb/trunk/scripts/Python/interface/SBEvent.i
Modified:
lldb/trunk/include/lldb/API/SBCompileUnit.h
lldb/trunk/include/lldb/API/SBDebugger.h
lldb/trunk/include/lldb/API/SBEvent.h
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=135432&r1=135431&r2=135432&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCompileUnit.h (original)
+++ lldb/trunk/include/lldb/API/SBCompileUnit.h Mon Jul 18 17:11:53 2011
@@ -15,41 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents a compilation unit, or compiled source file.
-
-SBCompileUnit supports line entry iteration. For example,
-
- for lineEntry in compileUnit:
- print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
- lineEntry.GetLine())
- print 'start addr: %s' % str(lineEntry.GetStartAddress())
- print 'end addr: %s' % str(lineEntry.GetEndAddress())
-
-produces:
-
-line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20
-start addr: a.out[0x100000d98]
-end addr: a.out[0x100000da3]
-line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21
-start addr: a.out[0x100000da3]
-end addr: a.out[0x100000da9]
-line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22
-start addr: a.out[0x100000da9]
-end addr: a.out[0x100000db6]
-line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23
-start addr: a.out[0x100000db6]
-end addr: a.out[0x100000dbc]
-...
-"
- ) SBCompileUnit;
-#endif
class SBCompileUnit
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBCompileUnit ();
Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=135432&r1=135431&r2=135432&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Jul 18 17:11:53 2011
@@ -15,111 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"SBDebugger is the primordial object that creates SBTargets and provides
-access to them. It also manages the overall debugging experiences.
-
-For example (from example/disasm.py),
-
-import lldb
-import os
-import sys
-
-def disassemble_instructions (insts):
- for i in insts:
- print i
-
-...
-
-# Create a new debugger instance
-debugger = lldb.SBDebugger.Create()
-
-# When we step or continue, don't return from the function until the process
-# stops. We do this by setting the async mode to false.
-debugger.SetAsync (False)
-
-# Create a target from a file and arch
-print 'Creating a target for \'%s\'' % exe
-
-target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
-
-if target:
- # If the target is valid set a breakpoint at main
- main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
-
- print main_bp
-
- # Launch the process. Since we specified synchronous mode, we won't return
- # from this function until we hit the breakpoint at main
- process = target.LaunchSimple (None, None, os.getcwd())
-
- # Make sure the launch went ok
- if process:
- # Print some simple process info
- state = process.GetState ()
- print process
- if state == lldb.eStateStopped:
- # Get the first thread
- thread = process.GetThreadAtIndex (0)
- if thread:
- # Print some simple thread info
- print thread
- # Get the first frame
- frame = thread.GetFrameAtIndex (0)
- if frame:
- # Print some simple frame info
- print frame
- function = frame.GetFunction()
- # See if we have debug info (a function)
- if function:
- # We do have a function, print some info for the function
- print function
- # Now get all instructions for this function and print them
- insts = function.GetInstructions(target)
- disassemble_instructions (insts)
- else:
- # See if we have a symbol in the symbol table for where we stopped
- symbol = frame.GetSymbol();
- if symbol:
- # We do have a symbol, print some info for the symbol
- print symbol
- # Now get all instructions for this symbol and print them
- insts = symbol.GetInstructions(target)
- disassemble_instructions (insts)
-
- registerList = frame.GetRegisters()
- print 'Frame registers (size of register set = %d):' % registerList.GetSize()
- for value in registerList:
- #print value
- print '%s (number of children = %d):' % (value.GetName(), value.GetNumChildren())
- for child in value:
- print 'Name: ', child.GetName(), ' Value: ', child.GetValue(frame)
-
- print 'Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program'
- next = sys.stdin.readline()
- if not next or next.rstrip('\n') == 'quit':
- print 'Terminating the inferior process...'
- process.Kill()
- else:
- # Now continue to the program exit
- process.Continue()
- # When we return from the above function we will hopefully be at the
- # program exit. Print out some process info
- print process
- elif state == lldb.eStateExited:
- print 'Didn\'t hit the breakpoint at main, program has exited...'
- else:
- print 'Unexpected process state: %s, killing process...' % debugger.StateAsCString (state)
- process.Kill()
-"
- ) SBDebugger;
-#endif
class SBDebugger
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
static void
Modified: lldb/trunk/include/lldb/API/SBEvent.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=135432&r1=135431&r2=135432&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBEvent.h (original)
+++ lldb/trunk/include/lldb/API/SBEvent.h Mon Jul 18 17:11:53 2011
@@ -20,120 +20,14 @@
class SBBroadcaster;
-#ifdef SWIG
-%feature("docstring",
-"API clients can register to receive events.
-
-For example, check out the following output:
-
-Try wait for event...
-Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running}
-Event data flavor: Process::ProcessEventData
-Process state: running
-
-Try wait for event...
-Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped}
-Event data flavor: Process::ProcessEventData
-Process state: stopped
-
-Try wait for event...
-Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited}
-Event data flavor: Process::ProcessEventData
-Process state: exited
-
-Try wait for event...
-timeout occurred waiting for event...
-
-from test/python_api/event/TestEventspy:
-
- def do_listen_for_and_print_event(self):
- '''Create a listener and use SBEvent API to print the events received.'''
- exe = os.path.join(os.getcwd(), 'a.out')
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- # Now create a breakpoint on main.c by name 'c'.
- breakpoint = target.BreakpointCreateByName('c', 'a.out')
-
- # Now launch the process, and do not stop at the entry point.
- process = target.LaunchSimple(None, None, os.getcwd())
- self.assertTrue(process.GetState() == lldb.eStateStopped,
- PROCESS_STOPPED)
-
- # Get a handle on the process's broadcaster.
- broadcaster = process.GetBroadcaster()
-
- # Create an empty event object.
- event = lldb.SBEvent()
-
- # Create a listener object and register with the broadcaster.
- listener = lldb.SBListener('my listener')
- rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged)
- self.assertTrue(rc, 'AddListener successfully retruns')
-
- traceOn = self.TraceOn()
- if traceOn:
- lldbutil.print_stacktraces(process)
-
- # Create MyListeningThread class to wait for any kind of event.
- import threading
- class MyListeningThread(threading.Thread):
- def run(self):
- count = 0
- # Let's only try at most 4 times to retrieve any kind of event.
- # After that, the thread exits.
- while not count > 3:
- if traceOn:
- print 'Try wait for event...'
- if listener.WaitForEventForBroadcasterWithType(5,
- broadcaster,
- lldb.SBProcess.eBroadcastBitStateChanged,
- event):
- if traceOn:
- desc = lldbutil.get_description(event)
- print 'Event description:', desc
- print 'Event data flavor:', event.GetDataFlavor()
- print 'Process state:', lldbutil.state_type_to_str(process.GetState())
- print
- else:
- if traceOn:
- print 'timeout occurred waiting for event...'
- count = count + 1
- return
-
- # Let's start the listening thread to retrieve the events.
- my_thread = MyListeningThread()
- my_thread.start()
-
- # Use Python API to continue the process. The listening thread should be
- # able to receive the state changed events.
- process.Continue()
-
- # Use Python API to kill the process. The listening thread should be
- # able to receive the state changed event, too.
- process.Kill()
-
- # Wait until the 'MyListeningThread' terminates.
- my_thread.join()
-"
- ) SBEvent;
-#endif
class SBEvent
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBEvent();
SBEvent (const lldb::SBEvent &rhs);
// Make an event that contains a C string.
-#ifdef SWIG
- %feature("autodoc", "__init__(self, int type, str data) -> SBEvent") SBEvent;
-#endif
SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len);
~SBEvent();
Added: lldb/trunk/scripts/Python/interface/SBCompileUnit.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCompileUnit.i?rev=135432&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCompileUnit.i (added)
+++ lldb/trunk/scripts/Python/interface/SBCompileUnit.i Mon Jul 18 17:11:53 2011
@@ -0,0 +1,70 @@
+//===-- SWIG Interface for SBCompileUnit ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a compilation unit, or compiled source file.
+
+SBCompileUnit supports line entry iteration. For example,
+
+ for lineEntry in compileUnit:
+ print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
+ lineEntry.GetLine())
+ print 'start addr: %s' % str(lineEntry.GetStartAddress())
+ print 'end addr: %s' % str(lineEntry.GetEndAddress())
+
+produces:
+
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20
+start addr: a.out[0x100000d98]
+end addr: a.out[0x100000da3]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21
+start addr: a.out[0x100000da3]
+end addr: a.out[0x100000da9]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22
+start addr: a.out[0x100000da9]
+end addr: a.out[0x100000db6]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23
+start addr: a.out[0x100000db6]
+end addr: a.out[0x100000dbc]
+...
+") SBCompileUnit;
+class SBCompileUnit
+{
+public:
+
+ SBCompileUnit ();
+
+ SBCompileUnit (const lldb::SBCompileUnit &rhs);
+
+ ~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;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBDebugger.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBDebugger.i?rev=135432&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBDebugger.i (added)
+++ lldb/trunk/scripts/Python/interface/SBDebugger.i Mon Jul 18 17:11:53 2011
@@ -0,0 +1,310 @@
+//===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"SBDebugger is the primordial object that creates SBTargets and provides
+access to them. It also manages the overall debugging experiences.
+
+For example (from example/disasm.py),
+
+import lldb
+import os
+import sys
+
+def disassemble_instructions (insts):
+ for i in insts:
+ print i
+
+...
+
+# Create a new debugger instance
+debugger = lldb.SBDebugger.Create()
+
+# When we step or continue, don't return from the function until the process
+# stops. We do this by setting the async mode to false.
+debugger.SetAsync (False)
+
+# Create a target from a file and arch
+print 'Creating a target for \'%s\'' % exe
+
+target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
+
+if target:
+ # If the target is valid set a breakpoint at main
+ main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
+
+ print main_bp
+
+ # Launch the process. Since we specified synchronous mode, we won't return
+ # from this function until we hit the breakpoint at main
+ process = target.LaunchSimple (None, None, os.getcwd())
+
+ # Make sure the launch went ok
+ if process:
+ # Print some simple process info
+ state = process.GetState ()
+ print process
+ if state == lldb.eStateStopped:
+ # Get the first thread
+ thread = process.GetThreadAtIndex (0)
+ if thread:
+ # Print some simple thread info
+ print thread
+ # Get the first frame
+ frame = thread.GetFrameAtIndex (0)
+ if frame:
+ # Print some simple frame info
+ print frame
+ function = frame.GetFunction()
+ # See if we have debug info (a function)
+ if function:
+ # We do have a function, print some info for the function
+ print function
+ # Now get all instructions for this function and print them
+ insts = function.GetInstructions(target)
+ disassemble_instructions (insts)
+ else:
+ # See if we have a symbol in the symbol table for where we stopped
+ symbol = frame.GetSymbol();
+ if symbol:
+ # We do have a symbol, print some info for the symbol
+ print symbol
+ # Now get all instructions for this symbol and print them
+ insts = symbol.GetInstructions(target)
+ disassemble_instructions (insts)
+
+ registerList = frame.GetRegisters()
+ print 'Frame registers (size of register set = %d):' % registerList.GetSize()
+ for value in registerList:
+ #print value
+ print '%s (number of children = %d):' % (value.GetName(), value.GetNumChildren())
+ for child in value:
+ print 'Name: ', child.GetName(), ' Value: ', child.GetValue(frame)
+
+ print 'Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program'
+ next = sys.stdin.readline()
+ if not next or next.rstrip('\n') == 'quit':
+ print 'Terminating the inferior process...'
+ process.Kill()
+ else:
+ # Now continue to the program exit
+ process.Continue()
+ # When we return from the above function we will hopefully be at the
+ # program exit. Print out some process info
+ print process
+ elif state == lldb.eStateExited:
+ print 'Didn\'t hit the breakpoint at main, program has exited...'
+ else:
+ print 'Unexpected process state: %s, killing process...' % debugger.StateAsCString (state)
+ process.Kill()
+") SBDebugger;
+class SBDebugger
+{
+public:
+
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb::SBDebugger
+ Create();
+
+ static void
+ Destroy (lldb::SBDebugger &debugger);
+
+ SBDebugger();
+
+ SBDebugger(const lldb::SBDebugger &rhs);
+
+ ~SBDebugger();
+
+ bool
+ IsValid() const;
+
+ void
+ Clear ();
+
+ void
+ SetAsync (bool b);
+
+ void
+ SkipLLDBInitFiles (bool b);
+
+ void
+ SetInputFileHandle (FILE *f, bool transfer_ownership);
+
+ void
+ SetOutputFileHandle (FILE *f, bool transfer_ownership);
+
+ void
+ SetErrorFileHandle (FILE *f, bool transfer_ownership);
+
+ FILE *
+ GetInputFileHandle ();
+
+ FILE *
+ GetOutputFileHandle ();
+
+ FILE *
+ GetErrorFileHandle ();
+
+ lldb::SBCommandInterpreter
+ GetCommandInterpreter ();
+
+ void
+ HandleCommand (const char *command);
+
+ lldb::SBListener
+ GetListener ();
+
+ void
+ HandleProcessEvent (const lldb::SBProcess &process,
+ const lldb::SBEvent &event,
+ FILE *out,
+ FILE *err);
+
+ lldb::SBTarget
+ CreateTargetWithFileAndTargetTriple (const char *filename,
+ const char *target_triple);
+
+ lldb::SBTarget
+ CreateTargetWithFileAndArch (const char *filename,
+ const char *archname);
+
+ lldb::SBTarget
+ CreateTarget (const char *filename);
+
+ %feature("docstring",
+ "Return true if target is deleted from the target list of the debugger."
+ ) DeleteTarget;
+ bool
+ DeleteTarget (lldb::SBTarget &target);
+
+ lldb::SBTarget
+ GetTargetAtIndex (uint32_t idx);
+
+ lldb::SBTarget
+ FindTargetWithProcessID (pid_t pid);
+
+ lldb::SBTarget
+ FindTargetWithFileAndArch (const char *filename,
+ const char *arch);
+
+ uint32_t
+ GetNumTargets ();
+
+ lldb::SBTarget
+ GetSelectedTarget ();
+
+ lldb::SBSourceManager &
+ GetSourceManager ();
+
+ // REMOVE: just for a quick fix, need to expose platforms through
+ // SBPlatform from this class.
+ lldb::SBError
+ SetCurrentPlatform (const char *platform_name);
+
+ bool
+ SetCurrentPlatformSDKRoot (const char *sysroot);
+
+ // FIXME: Once we get the set show stuff in place, the driver won't need
+ // an interface to the Set/Get UseExternalEditor.
+ bool
+ SetUseExternalEditor (bool input);
+
+ bool
+ GetUseExternalEditor ();
+
+ static bool
+ GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
+
+ static bool
+ SetDefaultArchitecture (const char *arch_name);
+
+ 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);
+
+ void
+ DispatchInput (void *baton, const void *data, size_t data_len);
+
+ void
+ DispatchInputInterrupt ();
+
+ void
+ DispatchInputEndOfFile ();
+
+ void
+ PushInputReader (lldb::SBInputReader &reader);
+
+ void
+ NotifyTopInputReader (lldb::InputReaderAction notification);
+
+ bool
+ InputReaderIsTopReader (const lldb::SBInputReader &reader);
+
+ const char *
+ GetInstanceName ();
+
+ static SBDebugger
+ FindDebuggerWithID (int id);
+
+ static lldb::SBError
+ SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
+
+ static lldb::SBStringList
+ GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ uint32_t
+ GetTerminalWidth () const;
+
+ void
+ SetTerminalWidth (uint32_t term_width);
+
+ lldb::user_id_t
+ GetID ();
+
+ const char *
+ GetPrompt() const;
+
+ void
+ SetPrompt (const char *prompt);
+
+ lldb::ScriptLanguage
+ GetScriptLanguage() const;
+
+ void
+ SetScriptLanguage (lldb::ScriptLanguage script_lang);
+
+ bool
+ GetCloseInputOnEOF () const;
+
+ void
+ SetCloseInputOnEOF (bool b);
+}; // class SBDebugger
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBEvent.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBEvent.i?rev=135432&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBEvent.i (added)
+++ lldb/trunk/scripts/Python/interface/SBEvent.i Mon Jul 18 17:11:53 2011
@@ -0,0 +1,150 @@
+//===-- SWIG Interface for SBEvent ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBBroadcaster;
+
+%feature("docstring",
+"API clients can register to receive events.
+
+For example, check out the following output:
+
+Try wait for event...
+Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running}
+Event data flavor: Process::ProcessEventData
+Process state: running
+
+Try wait for event...
+Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped}
+Event data flavor: Process::ProcessEventData
+Process state: stopped
+
+Try wait for event...
+Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited}
+Event data flavor: Process::ProcessEventData
+Process state: exited
+
+Try wait for event...
+timeout occurred waiting for event...
+
+from test/python_api/event/TestEventspy:
+
+ def do_listen_for_and_print_event(self):
+ '''Create a listener and use SBEvent API to print the events received.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ # Get a handle on the process's broadcaster.
+ broadcaster = process.GetBroadcaster()
+
+ # Create an empty event object.
+ event = lldb.SBEvent()
+
+ # Create a listener object and register with the broadcaster.
+ listener = lldb.SBListener('my listener')
+ rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged)
+ self.assertTrue(rc, 'AddListener successfully retruns')
+
+ traceOn = self.TraceOn()
+ if traceOn:
+ lldbutil.print_stacktraces(process)
+
+ # Create MyListeningThread class to wait for any kind of event.
+ import threading
+ class MyListeningThread(threading.Thread):
+ def run(self):
+ count = 0
+ # Let's only try at most 4 times to retrieve any kind of event.
+ # After that, the thread exits.
+ while not count > 3:
+ if traceOn:
+ print 'Try wait for event...'
+ if listener.WaitForEventForBroadcasterWithType(5,
+ broadcaster,
+ lldb.SBProcess.eBroadcastBitStateChanged,
+ event):
+ if traceOn:
+ desc = lldbutil.get_description(event)
+ print 'Event description:', desc
+ print 'Event data flavor:', event.GetDataFlavor()
+ print 'Process state:', lldbutil.state_type_to_str(process.GetState())
+ print
+ else:
+ if traceOn:
+ print 'timeout occurred waiting for event...'
+ count = count + 1
+ return
+
+ # Let's start the listening thread to retrieve the events.
+ my_thread = MyListeningThread()
+ my_thread.start()
+
+ # Use Python API to continue the process. The listening thread should be
+ # able to receive the state changed events.
+ process.Continue()
+
+ # Use Python API to kill the process. The listening thread should be
+ # able to receive the state changed event, too.
+ process.Kill()
+
+ # Wait until the 'MyListeningThread' terminates.
+ my_thread.join()
+") SBEvent;
+class SBEvent
+{
+public:
+ SBEvent();
+
+ SBEvent (const lldb::SBEvent &rhs);
+
+ %feature("autodoc",
+ "__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)"
+ ) SBEvent;
+ SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len);
+
+ ~SBEvent();
+
+ bool
+ IsValid() const;
+
+ const char *
+ GetDataFlavor ();
+
+ uint32_t
+ GetType () const;
+
+ lldb::SBBroadcaster
+ GetBroadcaster () const;
+
+ bool
+ BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster);
+
+ void
+ Clear();
+
+ static const char *
+ GetCStringFromEvent (const lldb::SBEvent &event);
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135432&r1=135431&r2=135432&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 17:11:53 2011
@@ -204,13 +204,13 @@
%include "lldb/API/SBCommandInterpreter.h"
%include "lldb/API/SBCommandReturnObject.h"
%include "lldb/API/SBCommunication.h"
-%include "lldb/API/SBCompileUnit.h"
-%include "lldb/API/SBDebugger.h"
+%include "./Python/interface/SBCompileUnit.i"
+%include "./Python/interface/SBDebugger.i"
%include "lldb/API/SBError.h"
-%include "lldb/API/SBEvent.h"
+%include "./Python/interface/SBEvent.i"
%include "lldb/API/SBFileSpec.h"
%include "./Python/interface/SBFrame.i"
-%include "lldb/API/SBFunction.h"
+%include "./Python/interface/SBFunction.i"
%include "lldb/API/SBHostOS.h"
%include "lldb/API/SBInputReader.h"
%include "lldb/API/SBInstruction.h"
From johnny.chen at apple.com Mon Jul 18 17:15:37 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 22:15:37 -0000
Subject: [Lldb-commits] [lldb] r135436 - in /lldb/trunk:
include/lldb/API/SBFunction.h scripts/Python/interface/SBFunction.i
Message-ID: <20110718221537.C1E252A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 17:15:37 2011
New Revision: 135436
URL: http://llvm.org/viewvc/llvm-project?rev=135436&view=rev
Log:
Missed the interface file for SBFunction in the previous checkin.
Added:
lldb/trunk/scripts/Python/interface/SBFunction.i
Modified:
lldb/trunk/include/lldb/API/SBFunction.h
Modified: lldb/trunk/include/lldb/API/SBFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=135436&r1=135435&r2=135436&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFunction.h (original)
+++ lldb/trunk/include/lldb/API/SBFunction.h Mon Jul 18 17:15:37 2011
@@ -16,49 +16,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents a generic function, which can be inlined or not.
-
-For example (from test/lldbutil.py, but slightly modified for doc purpose),
-
- ...
-
- frame = thread.GetFrameAtIndex(i)
- addr = frame.GetPCAddress()
- load_addr = addr.GetLoadAddress(target)
- function = frame.GetFunction()
- mod_name = frame.GetModule().GetFileSpec().GetFilename()
-
- if not function:
- # No debug info for 'function'.
- symbol = frame.GetSymbol()
- file_addr = addr.GetFileAddress()
- start_addr = symbol.GetStartAddress().GetFileAddress()
- symbol_name = symbol.GetName()
- symbol_offset = file_addr - start_addr
- print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
- num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset)
- else:
- # Debug info is available for 'function'.
- func_name = frame.GetFunctionName()
- file_name = frame.GetLineEntry().GetFileSpec().GetFilename()
- line_num = frame.GetLineEntry().GetLine()
- print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
- num=i, addr=load_addr, mod=mod_name,
- func='%s [inlined]' % func_name] if frame.IsInlined() else func_name,
- file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False))
-
- ...
-
-"
- ) SBFunction;
-#endif
class SBFunction
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBFunction ();
Added: lldb/trunk/scripts/Python/interface/SBFunction.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFunction.i?rev=135436&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFunction.i (added)
+++ lldb/trunk/scripts/Python/interface/SBFunction.i Mon Jul 18 17:15:37 2011
@@ -0,0 +1,81 @@
+//===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a generic function, which can be inlined or not.
+
+For example (from test/lldbutil.py, but slightly modified for doc purpose),
+
+ ...
+
+ frame = thread.GetFrameAtIndex(i)
+ addr = frame.GetPCAddress()
+ load_addr = addr.GetLoadAddress(target)
+ function = frame.GetFunction()
+ mod_name = frame.GetModule().GetFileSpec().GetFilename()
+
+ if not function:
+ # No debug info for 'function'.
+ symbol = frame.GetSymbol()
+ file_addr = addr.GetFileAddress()
+ start_addr = symbol.GetStartAddress().GetFileAddress()
+ symbol_name = symbol.GetName()
+ symbol_offset = file_addr - start_addr
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
+ num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset)
+ else:
+ # Debug info is available for 'function'.
+ func_name = frame.GetFunctionName()
+ file_name = frame.GetLineEntry().GetFileSpec().GetFilename()
+ line_num = frame.GetLineEntry().GetLine()
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
+ num=i, addr=load_addr, mod=mod_name,
+ func='%s [inlined]' % func_name] if frame.IsInlined() else func_name,
+ file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False))
+
+ ...
+") SBFunction;
+class SBFunction
+{
+public:
+
+ SBFunction ();
+
+ SBFunction (const lldb::SBFunction &rhs);
+
+ ~SBFunction ();
+
+ bool
+ IsValid () const;
+
+ const char *
+ GetName() const;
+
+ const char *
+ GetMangledName () const;
+
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBTarget target);
+
+ SBAddress
+ GetStartAddress ();
+
+ SBAddress
+ GetEndAddress ();
+
+ uint32_t
+ GetPrologueByteSize ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
From johnny.chen at apple.com Mon Jul 18 18:11:07 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 18 Jul 2011 23:11:07 -0000
Subject: [Lldb-commits] [lldb] r135441 - in /lldb/trunk:
include/lldb/API/SBLineEntry.h include/lldb/API/SBListener.h
include/lldb/API/SBModule.h scripts/Python/interface/SBBreakpoint.i
scripts/Python/interface/SBLineEntry.i
scripts/Python/interface/SBListener.i scripts/Python/interface/SBModule.i
scripts/lldb.swig
Message-ID: <20110718231107.ED4C52A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 18:11:07 2011
New Revision: 135441
URL: http://llvm.org/viewvc/llvm-project?rev=135441&view=rev
Log:
Add SWIG Python interface files for SBLineEntry, SBListener, and SBModule.
Added:
lldb/trunk/scripts/Python/interface/SBLineEntry.i
lldb/trunk/scripts/Python/interface/SBListener.i
lldb/trunk/scripts/Python/interface/SBModule.i
Modified:
lldb/trunk/include/lldb/API/SBLineEntry.h
lldb/trunk/include/lldb/API/SBListener.h
lldb/trunk/include/lldb/API/SBModule.h
lldb/trunk/scripts/Python/interface/SBBreakpoint.i
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/include/lldb/API/SBLineEntry.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=135441&r1=135440&r2=135441&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBLineEntry.h (original)
+++ lldb/trunk/include/lldb/API/SBLineEntry.h Mon Jul 18 18:11:07 2011
@@ -16,17 +16,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
- "Specifies an association with a contiguous range of instructions and"
- " a source file location. SBCompileUnit contains SBLineEntry(s)."
- ) SBLineEntry;
-#endif
class SBLineEntry
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBLineEntry ();
Modified: lldb/trunk/include/lldb/API/SBListener.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBListener.h?rev=135441&r1=135440&r2=135441&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBListener.h (original)
+++ lldb/trunk/include/lldb/API/SBListener.h Mon Jul 18 18:11:07 2011
@@ -16,9 +16,6 @@
class SBListener
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBListener ();
Modified: lldb/trunk/include/lldb/API/SBModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=135441&r1=135440&r2=135441&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBModule.h (original)
+++ lldb/trunk/include/lldb/API/SBModule.h Mon Jul 18 18:11:07 2011
@@ -16,22 +16,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
- "Represents an executable image and its associated object and symbol"
- " files.\n"
- "\n"
- "The module is designed to be able to select a single slice of an\n"
- "executable image as it would appear on disk and during program\n"
- "execution."
- ) SBModule;
-#endif
class SBModule
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
-
public:
SBModule ();
@@ -48,9 +34,6 @@
bool
IsValid () const;
-#ifdef SWIG
- %feature("docstring", "
-#endif
//------------------------------------------------------------------
/// Get const accessor for the module file specification.
///
@@ -61,15 +44,9 @@
/// @return
/// A const reference to the file specification object.
//------------------------------------------------------------------
-#ifdef SWIG
- ") GetFileSpec;
-#endif
lldb::SBFileSpec
GetFileSpec () const;
-#ifdef SWIG
- %feature("docstring", "
-#endif
//------------------------------------------------------------------
/// Get accessor for the module platform file specification.
///
@@ -85,9 +62,6 @@
/// @return
/// A const reference to the file specification object.
//------------------------------------------------------------------
-#ifdef SWIG
- ") GetPlatformFileSpec;
-#endif
lldb::SBFileSpec
GetPlatformFileSpec () const;
@@ -99,11 +73,6 @@
GetUUIDBytes () const;
#endif
-#ifdef SWIG
- %feature("docstring",
- "Returns the UUID of the module as a Python string."
- ) GetUUIDString;
-#endif
const char *
GetUUIDString () const;
@@ -133,9 +102,6 @@
lldb::SBSymbol
GetSymbolAtIndex (size_t idx);
-#ifdef SWIG
- %feature("docstring", "
-#endif
//------------------------------------------------------------------
/// Find functions by name.
///
@@ -160,18 +126,12 @@
/// @return
/// The number of matches added to \a sc_list.
//------------------------------------------------------------------
-#ifdef SWIG
- ") FindFunctions;
-#endif
uint32_t
FindFunctions (const char *name,
uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
bool append,
lldb::SBSymbolContextList& sc_list);
-#ifdef SWIG
- %feature("docstring", "
-#endif
//------------------------------------------------------------------
/// Find global and static variables by name.
///
@@ -188,9 +148,6 @@
/// @return
/// A list of matched variables in an SBValueList.
//------------------------------------------------------------------
-#ifdef SWIG
- ") FindGlobalVariables;
-#endif
lldb::SBValueList
FindGlobalVariables (lldb::SBTarget &target,
const char *name,
Modified: lldb/trunk/scripts/Python/interface/SBBreakpoint.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBreakpoint.i?rev=135441&r1=135440&r2=135441&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBBreakpoint.i (original)
+++ lldb/trunk/scripts/Python/interface/SBBreakpoint.i Mon Jul 18 18:11:07 2011
@@ -64,12 +64,19 @@
process.Continue()
-SBBreakpoint supports breakpoint location iteration. For example,
+SBBreakpoint supports breakpoint location iteration, for example,
for bl in breakpoint:
print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
print 'breakpoint location condition: %s' % hex(bl.GetCondition())
-") SBBreakpoint;
+
+and rich comparion methods which allow the API program to use,
+
+ if aBreakpoint == bBreakpoint:
+ ...
+
+to compare two breakpoints for equality."
+) SBBreakpoint;
class SBBreakpoint
{
public:
Added: lldb/trunk/scripts/Python/interface/SBLineEntry.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBLineEntry.i?rev=135441&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBLineEntry.i (added)
+++ lldb/trunk/scripts/Python/interface/SBLineEntry.i Mon Jul 18 18:11:07 2011
@@ -0,0 +1,50 @@
+//===-- SWIG Interface for SBLineEntry --------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Specifies an association with a contiguous range of instructions and
+a source file location. SBCompileUnit contains SBLineEntry(s).
+
+See also SBCompileUnit for example usage of SBLineEntry API."
+) SBLineEntry;
+class SBLineEntry
+{
+public:
+
+ SBLineEntry ();
+
+ SBLineEntry (const lldb::SBLineEntry &rhs);
+
+ ~SBLineEntry ();
+
+ lldb::SBAddress
+ GetStartAddress () const;
+
+ lldb::SBAddress
+ GetEndAddress () const;
+
+ bool
+ IsValid () const;
+
+ lldb::SBFileSpec
+ GetFileSpec () const;
+
+ uint32_t
+ GetLine () const;
+
+ uint32_t
+ GetColumn () const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBListener.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBListener.i?rev=135441&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBListener.i (added)
+++ lldb/trunk/scripts/Python/interface/SBListener.i Mon Jul 18 18:11:07 2011
@@ -0,0 +1,89 @@
+//===-- SWIG Interface for SBListener ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"API clients can register its own listener to debugger events.
+
+See aslo SBEvent for example usage of creating and adding a listener."
+) SBListener;
+class SBListener
+{
+public:
+ SBListener ();
+
+ SBListener (const char *name);
+
+ SBListener (const SBListener &rhs);
+
+ ~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);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=135441&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModule.i (added)
+++ lldb/trunk/scripts/Python/interface/SBModule.i Mon Jul 18 18:11:07 2011
@@ -0,0 +1,165 @@
+//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents 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.
+
+You can retrieve SBModule from SBSymbolContext, which in turn is available
+from SBFrame.
+
+SBModule supports symbol iteration, for example,
+
+ for symbol in module:
+ name = symbol.GetName()
+ saddr = symbol.GetStartAddress()
+ eaddr = symbol.GetEndAddress()
+
+and rich comparion methods which allow the API program to use,
+
+ if thisModule == thatModule:
+ print 'This module is the same as that module'
+
+to test module equality."
+) SBModule;
+class SBModule
+{
+public:
+
+ SBModule ();
+
+ SBModule (const SBModule &rhs);
+
+ ~SBModule ();
+
+ bool
+ IsValid () const;
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Get const accessor for the module file specification.
+ ///
+ /// This function returns the file for the module on the host system
+ /// that is running LLDB. This can differ from the path on the
+ /// platform since we might be doing remote debugging.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ ") GetFileSpec;
+ lldb::SBFileSpec
+ GetFileSpec () const;
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Get accessor for the module platform file specification.
+ ///
+ /// Platform file refers to the path of the module as it is known on
+ /// the remote system on which it is being debugged. For local
+ /// debugging this is always the same as Module::GetFileSpec(). But
+ /// remote debugging might mention a file '/usr/lib/liba.dylib'
+ /// which might be locally downloaded and cached. In this case the
+ /// platform file could be something like:
+ /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+ /// The file could also be cached in a local developer kit directory.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ ") GetPlatformFileSpec;
+ lldb::SBFileSpec
+ GetPlatformFileSpec () const;
+
+ bool
+ SetPlatformFileSpec (const lldb::SBFileSpec &platform_file);
+
+ %feature("docstring", "Returns the UUID of the module as a Python string."
+ ) GetUUIDString;
+ const char *
+ GetUUIDString () const;
+
+ bool
+ ResolveFileAddress (lldb::addr_t vm_addr,
+ lldb::SBAddress& addr);
+
+ lldb::SBSymbolContext
+ ResolveSymbolContextForAddress (const lldb::SBAddress& addr,
+ uint32_t resolve_scope);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ size_t
+ GetNumSymbols ();
+
+ lldb::SBSymbol
+ GetSymbolAtIndex (size_t idx);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// @param[in] name
+ /// The name of the function we are looking for.
+ ///
+ /// @param[in] name_type_mask
+ /// A logical OR of one or more FunctionNameType enum bits that
+ /// indicate what kind of names should be used when doing the
+ /// lookup. Bits include fully qualified names, base names,
+ /// C++ methods, or ObjC selectors.
+ /// See FunctionNameType for more details.
+ ///
+ /// @param[in] append
+ /// If true, any matches will be appended to \a sc_list, else
+ /// matches replace the contents of \a sc_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.
+ //------------------------------------------------------------------
+ ") FindFunctions;
+ uint32_t
+ FindFunctions (const char *name,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ bool append,
+ lldb::SBSymbolContextList& sc_list);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] target
+ /// A valid SBTarget instance representing the debuggee.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ ") FindGlobalVariables;
+ lldb::SBValueList
+ FindGlobalVariables (lldb::SBTarget &target,
+ const char *name,
+ uint32_t max_matches);
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135441&r1=135440&r2=135441&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 18:11:07 2011
@@ -215,9 +215,9 @@
%include "lldb/API/SBInputReader.h"
%include "lldb/API/SBInstruction.h"
%include "lldb/API/SBInstructionList.h"
-%include "lldb/API/SBLineEntry.h"
-%include "lldb/API/SBListener.h"
-%include "lldb/API/SBModule.h"
+%include "./Python/interface/SBLineEntry.i"
+%include "./Python/interface/SBListener.i"
+%include "./Python/interface/SBModule.i"
%include "./Python/interface/SBProcess.i"
%include "lldb/API/SBSourceManager.h"
%include "lldb/API/SBStream.h"
From johnso87 at crhc.illinois.edu Mon Jul 18 19:32:05 2011
From: johnso87 at crhc.illinois.edu (Matt Johnson)
Date: Mon, 18 Jul 2011 19:32:05 -0500
Subject: [Lldb-commits] [lldb] r135363 - in /lldb/trunk:
include/lldb/Core/ include/lldb/Target/ source/ source/Core/
source/Plugins/Process/MacOSX-Kernel/
source/Plugins/Process/MacOSX-User/source/
source/Plugins/Process/gdb-remote/ source/Target/
In-Reply-To: <20110717203625.CCCBF2A6C12C@llvm.org>
References: <20110717203625.CCCBF2A6C12C@llvm.org>
Message-ID: <4E24D085.80704@crhc.illinois.edu>
Hi all,
struct sockaddr and struct sockaddr_in don't have sa_len and sin_len
members, respectively in glibc/Ubuntu 11.04, breaking the build on r135363:
ConnectionFileDescriptor.cpp: In member function ?virtual size_t
lldb_private::ConnectionFileDescriptor::Read(void*, size_t, uint32_t,
lldb::ConnectionStatus&, lldb_private::Error*)?:
ConnectionFileDescriptor.cpp:289:57: error: ?struct sockaddr? has no
member named ?sa_len?
ConnectionFileDescriptor.cpp: In member function ?virtual size_t
lldb_private::ConnectionFileDescriptor::Write(const void*, size_t,
lldb::ConnectionStatus&, lldb_private::Error*)?:
ConnectionFileDescriptor.cpp:410:59: error: ?struct sockaddr? has no
member named ?sa_len?
ConnectionFileDescriptor.cpp: In member function ?lldb::ConnectionStatus
lldb_private::ConnectionFileDescriptor::ConnectUDP(const char*,
lldb_private::Error*)?:
ConnectionFileDescriptor.cpp:850:13: error: ?struct sockaddr_in? has no
member named ?sin_len?
glibc provides equivalent functionality to sa_len with a macro SA_LEN,
which looks at the sa_family member to determine the length (see
http://lists.debian.org/debian-ipv6/2001/06/msg00015.html). Fixing the
build under glibc would involve #ifdefing out the first use of sa_len
and the only use of sin_len, and replacing the second use of sa_len with
the SA_LEN() macro.
I'm not submitting a patch yet because I wanted to ask how we want to
test for sa_len and sin_len. Other projects have done it using autoconf
macros (see http://archives.seul.org/or/cvs/Jan-2009/msg00014.html
http://hackage.haskell.org/trac/ghc/ticket/2326 ), but I can't figure
out on inspection exactly how lldb's Makefile is generated. I suspect it
relies on llvm's configure script, but am not sure. If so, that would be
the appropriate place to put the member checks, but this may require
lldb to roll forward its frozen llvm version.
Thoughts?
Best,
Matt
From johnny.chen at apple.com Mon Jul 18 20:07:06 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 01:07:06 -0000
Subject: [Lldb-commits] [lldb] r135459 - in /lldb/trunk:
include/lldb/API/SBSymbol.h include/lldb/API/SBSymbolContext.h
include/lldb/API/SBSymbolContextList.h scripts/Python/interface/SBFrame.i
scripts/Python/interface/SBSymbol.i
scripts/Python/interface/SBSymbolContext.i
scripts/Python/interface/SBSymbolContextList.i scripts/lldb.swig
Message-ID: <20110719010706.B3B562A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 20:07:06 2011
New Revision: 135459
URL: http://llvm.org/viewvc/llvm-project?rev=135459&view=rev
Log:
Add SWIG interface files for SBSymbol, SBSymbolContext, and SBSymbolContextList.
Added:
lldb/trunk/scripts/Python/interface/SBSymbol.i
lldb/trunk/scripts/Python/interface/SBSymbolContext.i
lldb/trunk/scripts/Python/interface/SBSymbolContextList.i
Modified:
lldb/trunk/include/lldb/API/SBSymbol.h
lldb/trunk/include/lldb/API/SBSymbolContext.h
lldb/trunk/include/lldb/API/SBSymbolContextList.h
lldb/trunk/scripts/Python/interface/SBFrame.i
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/include/lldb/API/SBSymbol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=135459&r1=135458&r2=135459&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbol.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbol.h Mon Jul 18 20:07:06 2011
@@ -17,16 +17,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
- "Represents the symbol possibly associated with a stack frame."
- ) SBSymbol;
-#endif
class SBSymbol
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBSymbol ();
Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=135459&r1=135458&r2=135459&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbolContext.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbolContext.h Mon Jul 18 20:07:06 2011
@@ -20,50 +20,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"A context object that provides access to core debugger entities.
-
-Manay debugger functions require a context when doing lookups. This class
-provides a common structure that can be used as the result of a query that
-can contain a single result.
-
-For example,
-
- exe = os.path.join(os.getcwd(), 'a.out')
-
- # Create a target for the debugger.
- target = self.dbg.CreateTarget(exe)
-
- # Now create a breakpoint on main.c by name 'c'.
- breakpoint = target.BreakpointCreateByName('c', 'a.out')
-
- # Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple(None, None, os.getcwd())
-
- # The inferior should stop on 'c'.
- from lldbutil import get_stopped_thread
- thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- frame0 = thread.GetFrameAtIndex(0)
-
- # Now get the SBSymbolContext from this frame. We want everything. :-)
- context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
-
- # Get the module.
- module = context.GetModule()
- ...
-
- # And the compile unit associated with the frame.
- compileUnit = context.GetCompileUnit()
- ...
-"
- ) SBSymbolContext;
-#endif
class SBSymbolContext
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBSymbolContext ();
Modified: lldb/trunk/include/lldb/API/SBSymbolContextList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContextList.h?rev=135459&r1=135458&r2=135459&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbolContextList.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbolContextList.h Mon Jul 18 20:07:06 2011
@@ -15,35 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents a list of symbol context object. See also SBSymbolContext.
-
-For example (from test/python_api/target/TestTargetAPI.py),
-
- def find_functions(self, exe_name):
- '''Exercise SBTaget.FindFunctions() API.'''
- exe = os.path.join(os.getcwd(), exe_name)
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- list = lldb.SBSymbolContextList()
- num = target.FindFunctions('c', lldb.eFunctionNameTypeAuto, False, list)
- self.assertTrue(num == 1 and list.GetSize() == 1)
-
- for sc in list:
- self.assertTrue(sc.GetModule().GetFileSpec().GetFilename() == exe_name)
- self.assertTrue(sc.GetSymbol().GetName() == 'c')
-"
- ) SBSymbolContextList;
-#endif
class SBSymbolContextList
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBSymbolContextList ();
Modified: lldb/trunk/scripts/Python/interface/SBFrame.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=135459&r1=135458&r2=135459&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFrame.i (original)
+++ lldb/trunk/scripts/Python/interface/SBFrame.i Mon Jul 18 20:07:06 2011
@@ -11,7 +11,33 @@
%feature("docstring",
"Represents one of the stack frames associated with a thread.
-SBThread contains SBFrame(s)."
+SBThread contains SBFrame(s). For example (from test/lldbutil.py),
+
+def print_stacktrace(thread, string_buffer = False):
+ '''Prints a simple stack trace of this thread.'''
+
+ ...
+
+ for i in range(depth):
+ frame = thread.GetFrameAtIndex(i)
+ function = frame.GetFunction()
+
+ load_addr = addrs[i].GetLoadAddress(target)
+ if not function:
+ file_addr = addrs[i].GetFileAddress()
+ start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress()
+ symbol_offset = file_addr - start_addr
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
+ num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset)
+ else:
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
+ num=i, addr=load_addr, mod=mods[i],
+ func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i],
+ file=files[i], line=lines[i],
+ args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()')
+
+ ...
+"
) SBFrame;
class SBFrame
{
Added: lldb/trunk/scripts/Python/interface/SBSymbol.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSymbol.i?rev=135459&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSymbol.i (added)
+++ lldb/trunk/scripts/Python/interface/SBSymbol.i Mon Jul 18 20:07:06 2011
@@ -0,0 +1,57 @@
+//===-- SWIG Interface for SBSymbol -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the symbol possibly associated with a stack frame.
+SBModule contains SBSymbol(s). SBSymbol can also be retrived from SBFrame.
+
+See also SBModule and SBFrame."
+) SBSymbol;
+class SBSymbol
+{
+public:
+
+ SBSymbol ();
+
+ ~SBSymbol ();
+
+ SBSymbol (const lldb::SBSymbol &rhs);
+
+ bool
+ IsValid () const;
+
+
+ const char *
+ GetName() const;
+
+ const char *
+ GetMangledName () const;
+
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBTarget target);
+
+ SBAddress
+ GetStartAddress ();
+
+ SBAddress
+ GetEndAddress ();
+
+ uint32_t
+ GetPrologueByteSize ();
+
+ SymbolType
+ GetType ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBSymbolContext.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSymbolContext.i?rev=135459&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSymbolContext.i (added)
+++ lldb/trunk/scripts/Python/interface/SBSymbolContext.i Mon Jul 18 20:07:06 2011
@@ -0,0 +1,72 @@
+//===-- SWIG Interface for SBSymbolContext ----------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"A context object that provides access to core debugger entities.
+
+Manay debugger functions require a context when doing lookups. This class
+provides a common structure that can be used as the result of a query that
+can contain a single result.
+
+For example,
+
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target for the debugger.
+ target = self.dbg.CreateTarget(exe)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+
+ # The inferior should stop on 'c'.
+ from lldbutil import get_stopped_thread
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ frame0 = thread.GetFrameAtIndex(0)
+
+ # Now get the SBSymbolContext from this frame. We want everything. :-)
+ context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
+
+ # Get the module.
+ module = context.GetModule()
+ ...
+
+ # And the compile unit associated with the frame.
+ compileUnit = context.GetCompileUnit()
+ ...
+"
+) SBSymbolContext;
+class SBSymbolContext
+{
+public:
+ SBSymbolContext ();
+
+ SBSymbolContext (const lldb::SBSymbolContext& rhs);
+
+ ~SBSymbolContext ();
+
+ bool
+ IsValid () const;
+
+ SBModule GetModule ();
+ SBCompileUnit GetCompileUnit ();
+ SBFunction GetFunction ();
+ SBBlock GetBlock ();
+ SBLineEntry GetLineEntry ();
+ SBSymbol GetSymbol ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBSymbolContextList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSymbolContextList.i?rev=135459&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSymbolContextList.i (added)
+++ lldb/trunk/scripts/Python/interface/SBSymbolContextList.i Mon Jul 18 20:07:06 2011
@@ -0,0 +1,55 @@
+//===-- SWIG Interface for SBSymbolContextList ------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a list of symbol context object. See also SBSymbolContext.
+
+For example (from test/python_api/target/TestTargetAPI.py),
+
+ def find_functions(self, exe_name):
+ '''Exercise SBTaget.FindFunctions() API.'''
+ exe = os.path.join(os.getcwd(), exe_name)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ list = lldb.SBSymbolContextList()
+ num = target.FindFunctions('c', lldb.eFunctionNameTypeAuto, False, list)
+ self.assertTrue(num == 1 and list.GetSize() == 1)
+
+ for sc in list:
+ self.assertTrue(sc.GetModule().GetFileSpec().GetFilename() == exe_name)
+ self.assertTrue(sc.GetSymbol().GetName() == 'c')
+") SBSymbolContextList;
+class SBSymbolContextList
+{
+public:
+ SBSymbolContextList ();
+
+ SBSymbolContextList (const lldb::SBSymbolContextList& rhs);
+
+ ~SBSymbolContextList ();
+
+ bool
+ IsValid () const;
+
+ uint32_t
+ GetSize() const;
+
+ SBSymbolContext
+ GetContextAtIndex (uint32_t idx);
+
+ void
+ Clear();
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135459&r1=135458&r2=135459&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul 18 20:07:06 2011
@@ -196,6 +196,7 @@
%include "lldb/lldb-forward.h"
%include "lldb/lldb-forward-rtti.h"
%include "lldb/lldb-types.h"
+
%include "./Python/interface/SBAddress.i"
%include "./Python/interface/SBBlock.i"
%include "./Python/interface/SBBreakpoint.i"
@@ -222,9 +223,9 @@
%include "lldb/API/SBSourceManager.h"
%include "lldb/API/SBStream.h"
%include "lldb/API/SBStringList.h"
-%include "lldb/API/SBSymbol.h"
-%include "lldb/API/SBSymbolContext.h"
-%include "lldb/API/SBSymbolContextList.h"
+%include "./Python/interface/SBSymbol.i"
+%include "./Python/interface/SBSymbolContext.i"
+%include "./Python/interface/SBSymbolContextList.i"
%include "./Python/interface/SBTarget.i"
%include "./Python/interface/SBThread.i"
%include "lldb/API/SBType.h"
From johnny.chen at apple.com Mon Jul 18 20:13:00 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 01:13:00 -0000
Subject: [Lldb-commits] [lldb] r135461 -
/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
Message-ID: <20110719011300.5A6EE2A6C12C@llvm.org>
Author: johnny
Date: Mon Jul 18 20:13:00 2011
New Revision: 135461
URL: http://llvm.org/viewvc/llvm-project?rev=135461&view=rev
Log:
Initialize the all important automatic variable 'lldb::ConnectionStatus status' before
invoking the Read(...) method to read in bytes. This seems to fix the infinite looping
I was seeing on SnowLeopard while running the test suite.
Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=135461&r1=135460&r2=135461&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Mon Jul 18 20:13:00 2011
@@ -199,7 +199,7 @@
bool timed_out = false;
while (IsConnected() && !timed_out)
{
- lldb::ConnectionStatus status;
+ lldb::ConnectionStatus status = eConnectionStatusNoConnection;
size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error);
if (log)
From granata.enrico at gmail.com Mon Jul 18 21:34:22 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Tue, 19 Jul 2011 02:34:22 -0000
Subject: [Lldb-commits] [lldb] r135463 - in /lldb/trunk: include/lldb/
include/lldb/Core/ source/Commands/ source/Core/
test/functionalities/data-formatter/data-formatter-categories/
test/functionalities/data-formatter/data-formatter-globals/
test/functionalities/data-formatter/data-formatter-skip-summary/ www/
Message-ID: <20110719023422.618072A6C12C@llvm.org>
Author: enrico
Date: Mon Jul 18 21:34:21 2011
New Revision: 135463
URL: http://llvm.org/viewvc/llvm-project?rev=135463&view=rev
Log:
Fixed a bug where deleting a regex summary would not immediately reflect in the variables display
The "systemwide summaries" feature has been removed and replaced with a more general and
powerful mechanism.
Categories:
- summaries can now be grouped into buckets, called "categories" (it is expected that categories
correspond to libraries and/or runtime environments)
- to add a summary to a category, you can use the -w option to type summary add and give
a category name (e.g. type summary add -f "foo" foo_t -w foo_category)
- categories are by default disabled, which means LLDB will not look into them for summaries,
to enable a category use "type category enable". once a category is enabled, LLDB will
look into that category for summaries. the rules are quite trivial: every enabled category
is searched for an exact match. if an exact match is nowhere to be found, any match is
searched for in every enabled category (whether it involves cascading, going to base classes,
...). categories are searched into the order in which they were enabled (the most recently
enabled category first, then the second most and so on..)
- by default, most commands that deal with summaries, use a category named "default" if no
explicit -w parameter is given (the observable behavior of LLDB should not change when
categories are not explicitly used)
- the systemwide summaries are now part of a "system" category
Added:
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/main.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/
lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/main.cpp
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/include/lldb/lldb-forward-rtti.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Commands/CommandObjectType.h
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/FormatManager.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
lldb/trunk/www/varformats.html
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=135463&r1=135462&r2=135463&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon Jul 18 21:34:21 2011
@@ -474,159 +474,100 @@
public:
- class ValueFormats
+ class Formatting
{
public:
- static bool
- Get(ValueObject& vobj, ValueFormat::SharedPointer &entry);
-
- static void
- Add(const ConstString &type, const ValueFormat::SharedPointer &entry);
-
- static bool
- Delete(const ConstString &type);
-
- static void
- Clear();
-
- static void
- LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
- };
-
- class SummaryFormats
- {
- public:
-
- static bool
- Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry);
-
- static void
- Add(const ConstString &type, const SummaryFormat::SharedPointer &entry);
-
- static bool
- Delete(const ConstString &type);
-
- static void
- Clear();
-
- static void
- LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
- };
-
- class SystemSummaryFormats
- {
- public:
-
- static bool
- Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry);
-
- static void
- Add(const ConstString &type, const SummaryFormat::SharedPointer &entry);
-
- static bool
- Delete(const ConstString &type);
-
- static void
- Clear();
-
- static void
- LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
- };
-
- class RegexSummaryFormats
- {
- public:
-
- static bool
- Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry);
-
- static void
- Add(const lldb::RegularExpressionSP &type, const SummaryFormat::SharedPointer &entry);
-
- static bool
- Delete(const ConstString &type);
-
- static void
- Clear();
-
- static void
- LoopThrough(SummaryFormat::RegexSummaryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
- };
-
- class SystemRegexSummaryFormats
- {
- public:
-
- static bool
- Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry);
-
- static void
- Add(const lldb::RegularExpressionSP &type, const SummaryFormat::SharedPointer &entry);
-
- static bool
- Delete(const ConstString &type);
-
- static void
- Clear();
-
- static void
- LoopThrough(SummaryFormat::RegexSummaryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
- };
-
- class NamedSummaryFormats
- {
- public:
-
- static bool
- Get(const ConstString &type, SummaryFormat::SharedPointer &entry);
-
- static void
- Add(const ConstString &type, const SummaryFormat::SharedPointer &entry);
-
- static bool
- Delete(const ConstString &type);
-
- static void
- Clear();
-
- static void
- LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
+ class ValueFormats
+ {
+ public:
+ static bool
+ Get(ValueObject& vobj, ValueFormat::SharedPointer &entry);
+
+ static void
+ Add(const ConstString &type, const ValueFormat::SharedPointer &entry);
+
+ static bool
+ Delete(const ConstString &type);
+
+ static void
+ Clear();
+
+ static void
+ LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton);
+
+ static uint32_t
+ GetCurrentRevision();
+
+ static uint32_t
+ GetCount();
+ };
+
+ static lldb::FormatCategorySP
+ SummaryFormats(const char* category_name = NULL);
+
+ static bool
+ GetSummaryFormat(ValueObject& vobj,
+ lldb::SummaryFormatSP& entry);
+
+ class NamedSummaryFormats
+ {
+ public:
+ static bool
+ Get(const ConstString &type, SummaryFormat::SharedPointer &entry);
+
+ static void
+ Add(const ConstString &type, const SummaryFormat::SharedPointer &entry);
+
+ static bool
+ Delete(const ConstString &type);
+
+ static void
+ Clear();
+
+ static void
+ LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton);
+
+ static uint32_t
+ GetCurrentRevision();
+
+ static uint32_t
+ GetCount();
+ };
+
+ class Categories
+ {
+ public:
+
+ static bool
+ Get(const ConstString &category, lldb::FormatCategorySP &entry);
+
+ static void
+ Add(const ConstString &category);
+
+ static bool
+ Delete(const ConstString &category);
+
+ static void
+ Clear();
+
+ static void
+ Clear(ConstString &category);
+
+ static void
+ Enable(ConstString& category);
+
+ static void
+ Disable(ConstString& category);
+
+ static void
+ LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton);
+
+ static uint32_t
+ GetCurrentRevision();
+
+ static uint32_t
+ GetCount();
+ };
};
};
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135463&r1=135462&r2=135463&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Mon Jul 18 21:34:21 2011
@@ -29,6 +29,7 @@
#include
#endif
+#include
#include
- The way to obtain this effect is to bind a summary string to
- the datatype using the type summary add
+
+
There are two ways to use type summaries: the first one is to bind a
+ summary string to the datatype; the second is to bind a Python script to the
+ datatype. Both options are enabled by the type summary add
command.
In the example, the command we type was:
@@ -410,6 +412,10 @@
(lldb) type summary add -f "int = ${var.integer}, float = ${var.floating}, char = ${var.character%u}" i_am_cool
+
+ Initially, we will focus on summary strings, and then describe the Python binding
+ mechanism.
+
@@ -717,11 +723,128 @@
-
+
+
+
Most of the times, summary strings prove good enough for the job of summarizing
+ the contents of a variable. However, as soon as you need to do more than picking
+ some values and rearranging them for display, summary strings stop being an
+ effective tool. This is because summary strings lack the power to actually perform
+ some computation on the value of variables.
+
To solve this issue, you can bind some Python scripting code as a summary for
+ your datatype, and that script has the ability to both extract children variables
+ as the summary strings do and to perform active computation on the extracted
+ values. As a small example, let's say we have a Rectangle class:
+
+
+class Rectangle
+{
+private:
+ int height;
+ int width;
+public:
+ Rectangle() : height(3), width(5) {}
+ Rectangle(int H) : height(H), width(H*2-1) {}
+ Rectangle(int H, int W) : height(H), width(W) {}
+
+ int GetHeight() { return height; }
+ int GetWidth() { return width; }
+
+};
+
+
+
Summary strings are effective to reduce the screen real estate used by
+ the default viewing mode, but are not effective if we want to display the
+ area, perimeter and length of diagonal of Rectangle objects
+
+
To obtain this, we can simply attach a small Python script to the Rectangle
+ class, as shown in this example:
+
+
+
+ (lldb) type summary add -P Rectangle
+ Enter your Python command(s). Type 'DONE' to end.
+def function (valobj,dict):
+ height_val = valobj.GetChildMemberWithName('height')
+ width_val = valobj.GetChildMemberWithName('width')
+ height_str = height_val.GetValue()
+ width_str = width_val.GetValue()
+ height = int(height_str)
+ width = int(width_str)
+ area = height*width
+ perimeter = 2*height + 2*width
+ diag = sqrt(height*height+width*width)
+ return 'Area: ' + str(area) + ', Perimeter: ' + str(perimeter) + ', Diagonal: ' + str(diag)
+ DONE
+(lldb) script
+Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
+>>> from math import sqrt
+>>> quit()
+(lldb) frame variable
+(Rectangle) r1 = Area: 20, Perimeter: 18, Diagonal: 6.40312423743
+(Rectangle) r2 = Area: 72, Perimeter: 36, Diagonal: 13.416407865
+(Rectangle) r3 = Area: 16, Perimeter: 16, Diagonal: 5.65685424949
+ |
+
+
+
In this scenario, you need to enter the interactive interpreter to import the
+ function sqrt() from the math library. As the example shows, everything you enter
+ into the interactive interpreter is saved for you to use it in scripts. This way
+ you can define your own utility functions and use them in your summary scripts if
+ necessary.
+
+
In order to write effective summary scripts, you need to know the LLDB public
+ API, which is the way Python code can access the LLDB object model. For further
+ details on the API you should look at this page, or at
+ the LLDB doxygen documentation when it becomes available.
+
+
As a brief introduction, your script is encapsulated into a function that is
+ passed two parameters: valobj and dict.
+
+
dict is an internal support parameter used by LLDB and you should
+ not use it.
valobj is the object encapsulating the actual
+ variable being displayed, and its type is SBValue. The most important thing you can
+ do with an SBValue is retrieve its children objects, by calling
+ GetChildMemberWithName(), passing it the child's name as a string, or ask
+ it for its value, by calling GetValue(), which returns a Python string.
+
+
+
If you need to delve into several levels of hierarchy, as you can do with summary
+ strings, you must use the method GetValueForExpressionPath(), passing it
+ an expression path just like those you could use for summary strings. However, if you need
+ to access array slices, you cannot do that (yet) via this method call, and you must
+ use GetChildMemberWithName() querying it for the array items one by one.
+
+
Other than interactively typing a Python script there are two other ways for you
+ to input a Python script as a summary:
+
+
+ - using the -s option to
type summary add and typing the script
+ code as an option argument; as in:
+
+
+
+ (lldb) type summary add -s "height =
+ int(valobj.GetChildMemberWithName('height').GetValue());width =
+ int(valobj.GetChildMemberWithName('width').GetValue());
+ return 'Area: ' + str(height*width)" Rectangle
+ |
+
+
+ - using the -F option to
type summary add and giving the name of a
+ Python function with the correct prototype. Most probably, you will define (or have
+ already defined) the function in the interactive interpreter, or somehow
+ loaded it from a file.
+
+
+
+
+
+
+
As you noticed, in order to associate the custom
summary string to the array types, one must give the
array size as part of the typename. This can long become
@@ -845,12 +968,10 @@
There's no way to do multiple dereferencing, and you
need to be careful what the dereferencing operation is
binding to in complicated scenarios
-
There is no way to call functions inside summary
- strings, not even const ones
type format add does not support the -x
option
-
Object location cannot be printed in the summary
- string
+
Object location cannot be printed in the summary
+ string
From gclayton at apple.com Mon Jul 18 22:57:15 2011
From: gclayton at apple.com (Greg Clayton)
Date: Tue, 19 Jul 2011 03:57:15 -0000
Subject: [Lldb-commits] [lldb] r135466 - in /lldb/trunk: lldb.xcodeproj/
source/Core/ source/Host/macosx/
source/Plugins/DynamicLoader/MacOSX-Kernel/
source/Plugins/ObjectFile/Mach-O/ source/Plugins/Platform/MacOSX/
source/Plugins/Process/MacOSX-Kernel/
source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/Utility/
source/Utility/
Message-ID: <20110719035716.4C6702A6C12C@llvm.org>
Author: gclayton
Date: Mon Jul 18 22:57:15 2011
New Revision: 135466
URL: http://llvm.org/viewvc/llvm-project?rev=135466&view=rev
Log:
Modified the LocateMacOSXFilesUsingDebugSymbols(...) function to locate
an executable file if it is right next to a dSYM file that is found using
DebugSymbols. The code also looks into a bundle if the dSYM file is right
next to a bundle.
Modified the MacOSX kernel dynamic loader plug-in to correctly set the load
address for kext sections. This is a tad tricky because of how LLDB chooses
to treat mach-o segments with no name. Also modified the loader to properly
handle the older version 1 kext summary info.
Fixed a crasher in the Mach-o object file parser when it is trying to set
the section size correctly for dSYM sections.
Added packet dumpers to the CommunicationKDP class. We now also properly
detect address byte sizes based on the cpu type and subtype that is provided.
Added a read memory and read register support to CommunicationKDP. Added a
ThreadKDP class that now uses subclasses of the RegisterContextDarwin_XXX for
arm, i386 and x86_64.
Fixed some register numbering issues in the RegisterContextDarwin_arm class
and added ARM GDB numbers to the ARM_GCC_Registers.h file.
Change the RegisterContextMach_XXX classes over to subclassing their
RegisterContextDarwin_XXX counterparts so we can share the mach register
contexts between the user and kernel plug-ins.
Added:
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Host/macosx/Symbols.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h
lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp
lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h
lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp
lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h
lldb/trunk/source/Utility/ARM_GCC_Registers.h
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Jul 18 22:57:15 2011
@@ -12,18 +12,19 @@
260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260E07C7136FAB9200CF21D3 /* OptionGroupFile.cpp */; };
261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; };
2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628A4D313D4977900F5487A /* ThreadKDP.cpp */; };
262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; };
26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; };
26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; };
263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; };
2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2642FBA813D003B400ED6808 /* CommunicationKDP.cpp */; };
- 2642FBAF13D003B400ED6808 /* CommunicationKDP.h in Headers */ = {isa = PBXBuildFile; fileRef = 2642FBA913D003B400ED6808 /* CommunicationKDP.h */; };
2642FBB013D003B400ED6808 /* ProcessKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2642FBAA13D003B400ED6808 /* ProcessKDP.cpp */; };
- 2642FBB113D003B400ED6808 /* ProcessKDP.h in Headers */ = {isa = PBXBuildFile; fileRef = 2642FBAB13D003B400ED6808 /* ProcessKDP.h */; };
2642FBB213D003B400ED6808 /* ProcessKDPLog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2642FBAC13D003B400ED6808 /* ProcessKDPLog.cpp */; };
- 2642FBB313D003B400ED6808 /* ProcessKDPLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 2642FBAD13D003B400ED6808 /* ProcessKDPLog.h */; };
264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A97BD133918BC0017F0BE /* PlatformRemoteGDBServer.cpp */; };
264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */; };
+ 265205A813D3E3F700132FE2 /* RegisterContextKDP_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265205A213D3E3F700132FE2 /* RegisterContextKDP_arm.cpp */; };
+ 265205AA13D3E3F700132FE2 /* RegisterContextKDP_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265205A413D3E3F700132FE2 /* RegisterContextKDP_i386.cpp */; };
+ 265205AC13D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265205A613D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp */; };
265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; };
26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26651A17133BF9DF005B64B7 /* Opcode.cpp */; };
266603CA1345B5A8004DA8B6 /* ConnectionSharedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266603C91345B5A8004DA8B6 /* ConnectionSharedMemory.cpp */; };
@@ -73,6 +74,7 @@
2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; };
26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; };
26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; };
+ 2676045A13D49D2300AB1B6A /* ProcessControl-mig.defs in Sources */ = {isa = PBXBuildFile; fileRef = 260C89A110F57C5600BB2B04 /* ProcessControl-mig.defs */; settings = {ATTRIBUTES = (Client, Server, ); }; };
267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */; };
267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */; };
2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536B1370ACB200D186A3 /* OptionGroupBoolean.cpp */; };
@@ -342,6 +344,9 @@
268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; };
2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2690B3701381D5C300ECFBAE /* Memory.cpp */; };
2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; };
+ 26957D9813D381C900670048 /* RegisterContextDarwin_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */; };
+ 26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9413D381C900670048 /* RegisterContextDarwin_i386.cpp */; };
+ 26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9613D381C900670048 /* RegisterContextDarwin_x86_64.cpp */; };
2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; };
26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; };
26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; };
@@ -425,7 +430,6 @@
9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; };
9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */; };
9A9E1EFF1398086D005AC039 /* InputReaderStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9E1EFE1398086D005AC039 /* InputReaderStack.cpp */; };
- 9A9E1F0113980943005AC039 /* InputReaderStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9E1F0013980943005AC039 /* InputReaderStack.h */; };
9AA69DA61188F52100D753A0 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */; };
9AA69DAF118A023300D753A0 /* SBInputReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AA69DAE118A023300D753A0 /* SBInputReader.h */; settings = {ATTRIBUTES = (Public, ); }; };
9AA69DB1118A024600D753A0 /* SBInputReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */; };
@@ -639,6 +643,8 @@
26217930133BC8640083B112 /* lldb-private-types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-types.h"; path = "include/lldb/lldb-private-types.h"; sourceTree = ""; };
26217932133BCB850083B112 /* lldb-private-enumerations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-enumerations.h"; path = "include/lldb/lldb-private-enumerations.h"; sourceTree = ""; };
2623096E13D0EFFB006381D9 /* StreamBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamBuffer.h; path = include/lldb/Core/StreamBuffer.h; sourceTree = ""; };
+ 2628A4D313D4977900F5487A /* ThreadKDP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadKDP.cpp; sourceTree = ""; };
+ 2628A4D413D4977900F5487A /* ThreadKDP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadKDP.h; sourceTree = ""; };
263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
26368A3B126B697600E8659F /* darwin-debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "darwin-debug.cpp"; path = "tools/darwin-debug/darwin-debug.cpp"; sourceTree = ""; };
@@ -664,6 +670,12 @@
264AD83911095BBD00E0B039 /* CommandObjectLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectLog.h; path = source/Commands/CommandObjectLog.h; sourceTree = ""; };
264D8D4E13661BCC003A368F /* UnwindAssembly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UnwindAssembly.h; path = include/lldb/Target/UnwindAssembly.h; sourceTree = ""; };
264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindAssembly.cpp; path = source/Target/UnwindAssembly.cpp; sourceTree = ""; };
+ 265205A213D3E3F700132FE2 /* RegisterContextKDP_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextKDP_arm.cpp; sourceTree = ""; };
+ 265205A313D3E3F700132FE2 /* RegisterContextKDP_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextKDP_arm.h; sourceTree = ""; };
+ 265205A413D3E3F700132FE2 /* RegisterContextKDP_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextKDP_i386.cpp; sourceTree = ""; };
+ 265205A513D3E3F700132FE2 /* RegisterContextKDP_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextKDP_i386.h; sourceTree = ""; };
+ 265205A613D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextKDP_x86_64.cpp; sourceTree = ""; };
+ 265205A713D3E3F700132FE2 /* RegisterContextKDP_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextKDP_x86_64.h; sourceTree = ""; };
26579F68126A25920007C5CB /* darwin-debug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "darwin-debug"; sourceTree = BUILT_PRODUCTS_DIR; };
265ABF6210F42EE900531910 /* DebugSymbols.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DebugSymbols.framework; path = /System/Library/PrivateFrameworks/DebugSymbols.framework; sourceTree = ""; };
265E9BE1115C2BAA00D0DCCB /* debugserver.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = debugserver.xcodeproj; path = tools/debugserver/debugserver.xcodeproj; sourceTree = ""; };
@@ -729,6 +741,12 @@
2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; };
269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; };
269416AE119A024800FF2715 /* CommandObjectTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTarget.h; path = source/Commands/CommandObjectTarget.h; sourceTree = ""; };
+ 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextDarwin_arm.cpp; path = Utility/RegisterContextDarwin_arm.cpp; sourceTree = ""; };
+ 26957D9313D381C900670048 /* RegisterContextDarwin_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDarwin_arm.h; path = Utility/RegisterContextDarwin_arm.h; sourceTree = ""; };
+ 26957D9413D381C900670048 /* RegisterContextDarwin_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextDarwin_i386.cpp; path = Utility/RegisterContextDarwin_i386.cpp; sourceTree = ""; };
+ 26957D9513D381C900670048 /* RegisterContextDarwin_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDarwin_i386.h; path = Utility/RegisterContextDarwin_i386.h; sourceTree = ""; };
+ 26957D9613D381C900670048 /* RegisterContextDarwin_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextDarwin_x86_64.cpp; path = Utility/RegisterContextDarwin_x86_64.cpp; sourceTree = ""; };
+ 26957D9713D381C900670048 /* RegisterContextDarwin_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDarwin_x86_64.h; path = Utility/RegisterContextDarwin_x86_64.h; sourceTree = ""; };
2697A54B133A6305004E4240 /* PlatformDarwin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformDarwin.cpp; sourceTree = ""; };
2697A54C133A6305004E4240 /* PlatformDarwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformDarwin.h; sourceTree = ""; };
269FF07D12494F7D00225026 /* FuncUnwinders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FuncUnwinders.h; path = include/lldb/Symbol/FuncUnwinders.h; sourceTree = ""; };
@@ -1746,6 +1764,14 @@
2642FBAB13D003B400ED6808 /* ProcessKDP.h */,
2642FBAC13D003B400ED6808 /* ProcessKDPLog.cpp */,
2642FBAD13D003B400ED6808 /* ProcessKDPLog.h */,
+ 265205A213D3E3F700132FE2 /* RegisterContextKDP_arm.cpp */,
+ 265205A313D3E3F700132FE2 /* RegisterContextKDP_arm.h */,
+ 265205A413D3E3F700132FE2 /* RegisterContextKDP_i386.cpp */,
+ 265205A513D3E3F700132FE2 /* RegisterContextKDP_i386.h */,
+ 265205A613D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp */,
+ 265205A713D3E3F700132FE2 /* RegisterContextKDP_x86_64.h */,
+ 2628A4D313D4977900F5487A /* ThreadKDP.cpp */,
+ 2628A4D413D4977900F5487A /* ThreadKDP.h */,
);
path = "MacOSX-Kernel";
sourceTree = "";
@@ -1888,6 +1914,12 @@
B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */,
AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */,
AF68D3301255A110002FF25B /* UnwindLLDB.h */,
+ 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */,
+ 26957D9313D381C900670048 /* RegisterContextDarwin_arm.h */,
+ 26957D9413D381C900670048 /* RegisterContextDarwin_i386.cpp */,
+ 26957D9513D381C900670048 /* RegisterContextDarwin_i386.h */,
+ 26957D9613D381C900670048 /* RegisterContextDarwin_x86_64.cpp */,
+ 26957D9713D381C900670048 /* RegisterContextDarwin_x86_64.h */,
AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */,
AF68D2551255416E002FF25B /* RegisterContextLLDB.h */,
26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */,
@@ -2713,10 +2745,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- 9A9E1F0113980943005AC039 /* InputReaderStack.h in Headers */,
- 2642FBAF13D003B400ED6808 /* CommunicationKDP.h in Headers */,
- 2642FBB113D003B400ED6808 /* ProcessKDP.h in Headers */,
- 2642FBB313D003B400ED6808 /* ProcessKDPLog.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3313,6 +3341,14 @@
2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */,
2642FBB013D003B400ED6808 /* ProcessKDP.cpp in Sources */,
2642FBB213D003B400ED6808 /* ProcessKDPLog.cpp in Sources */,
+ 26957D9813D381C900670048 /* RegisterContextDarwin_arm.cpp in Sources */,
+ 26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */,
+ 26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */,
+ 265205A813D3E3F700132FE2 /* RegisterContextKDP_arm.cpp in Sources */,
+ 265205AA13D3E3F700132FE2 /* RegisterContextKDP_i386.cpp in Sources */,
+ 265205AC13D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp in Sources */,
+ 2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */,
+ 2676045A13D49D2300AB1B6A /* ProcessControl-mig.defs in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Mon Jul 18 22:57:15 2011
@@ -746,7 +746,9 @@
// Fixup the incoming path in case the path points to a valid file, yet
// the arch or UUID (if one was passed in) don't match.
- FileSpec file_spec = Symbols::LocateExecutableObjectFile (&in_file_spec, arch.IsValid() ? &arch : NULL, uuid_ptr);
+ FileSpec file_spec = Symbols::LocateExecutableObjectFile (in_file_spec ? &in_file_spec : NULL,
+ arch.IsValid() ? &arch : NULL,
+ uuid_ptr);
// Don't look for the file if it appears to be the same one we already
// checked for above...
Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Mon Jul 18 22:57:15 2011
@@ -29,6 +29,9 @@
#include "Host/macosx/cfcpp/CFCString.h"
#include "mach/machine.h"
+#include "CFCBundle.h"
+
+
using namespace lldb;
using namespace lldb_private;
using namespace llvm::MachO;
@@ -291,7 +294,7 @@
const UInt8 *module_uuid = (const UInt8 *)uuid->GetBytes();
if (module_uuid != NULL)
{
- CFCReleaser module_uuid_ref(::CFUUIDCreateWithBytes ( NULL,
+ CFCReleaser module_uuid_ref(::CFUUIDCreateWithBytes (NULL,
module_uuid[0],
module_uuid[1],
module_uuid[2],
@@ -366,6 +369,57 @@
}
}
}
+ else
+ {
+ // No dictionary, check near the dSYM bundle for an executable that matches...
+ if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
+ {
+ char *dsym_extension_pos = ::strstr (path, ".dSYM");
+ if (dsym_extension_pos)
+ {
+ *dsym_extension_pos = '\0';
+ FileSpec file_spec (path, true);
+ switch (file_spec.GetFileType())
+ {
+ case FileSpec::eFileTypeDirectory: // Bundle directory?
+ {
+ CFCBundle bundle (path);
+ CFCReleaser bundle_exe_url (bundle.CopyExecutableURL ());
+ if (bundle_exe_url.get())
+ {
+ if (::CFURLGetFileSystemRepresentation (bundle_exe_url.get(), true, (UInt8*)path, sizeof(path)-1))
+ {
+ FileSpec bundle_exe_file_spec (path, true);
+
+ if (FileAtPathContainsArchAndUUID (bundle_exe_file_spec, arch, uuid))
+ {
+ ++items_found;
+ *out_exec_fspec = bundle_exe_file_spec;
+ }
+ }
+ }
+ }
+ break;
+
+ case FileSpec::eFileTypePipe: // Forget pipes
+ case FileSpec::eFileTypeSocket: // We can't process socket files
+ case FileSpec::eFileTypeInvalid: // File doesn't exist...
+ break;
+
+ case FileSpec::eFileTypeUnknown:
+ case FileSpec::eFileTypeRegular:
+ case FileSpec::eFileTypeSymbolicLink:
+ case FileSpec::eFileTypeOther:
+ if (FileAtPathContainsArchAndUUID (file_spec, arch, uuid))
+ {
+ ++items_found;
+ *out_exec_fspec = file_spec;
+ }
+ break;
+ }
+ }
+ }
+ }
}
}
}
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp Mon Jul 18 22:57:15 2011
@@ -241,8 +241,8 @@
if (image_info_uuid_is_valid)
{
image_info.module_sp = m_process->GetTarget().GetSharedModule (FileSpec(),
- arch,
- &image_info.uuid);
+ arch,
+ &image_info.uuid);
if (did_create_ptr)
*did_create_ptr = image_info.module_sp;
}
@@ -306,26 +306,48 @@
uint32_t num_segments = info.segments.size();
for (uint32_t i=0; iFindSectionByName(info.segments[i].name));
const addr_t new_section_load_addr = info.segments[i].vmaddr;
- if (section_sp)
+ if (section_list->FindSectionByName(info.segments[i].name))
{
- const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get());
- if (old_section_load_addr == LLDB_INVALID_ADDRESS ||
- old_section_load_addr != new_section_load_addr)
+ SectionSP section_sp(section_list->FindSectionByName(info.segments[i].name));
+ if (section_sp)
{
- if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr))
- changed = true;
+ const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get());
+ if (old_section_load_addr == LLDB_INVALID_ADDRESS ||
+ old_section_load_addr != new_section_load_addr)
+ {
+ if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr))
+ changed = true;
+ }
+ }
+ else
+ {
+ fprintf (stderr,
+ "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n",
+ info.segments[i].name.AsCString(""),
+ (uint64_t)new_section_load_addr,
+ image_object_file->GetFileSpec().GetDirectory().AsCString(),
+ image_object_file->GetFileSpec().GetFilename().AsCString());
}
}
else
{
- fprintf (stderr,
- "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n",
- info.segments[i].name.AsCString(""),
- (uint64_t)new_section_load_addr,
- image_object_file->GetFileSpec().GetDirectory().AsCString(),
- image_object_file->GetFileSpec().GetFilename().AsCString());
+ // The segment name is empty which means this is a .o file.
+ // Object files in LLDB end up getting reorganized so that
+ // the segment name that is in the section is promoted into
+ // an actual segment, so we just need to go through all sections
+ // and slide them by a single amount.
+
+ uint32_t num_sections = section_list->GetSize();
+ for (uint32_t i=0; iGetSectionAtIndex (i).get();
+ if (section)
+ {
+ if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section, section->GetFileAddress() + new_section_load_addr))
+ changed = true;
+ }
+ }
}
}
}
@@ -442,10 +464,17 @@
if (bytes_read == count)
{
uint32_t offset = 0;
- m_kext_summary_header.version = data.GetU32(&offset);
- m_kext_summary_header.entry_size = data.GetU32(&offset);
- m_kext_summary_header.entry_count = data.GetU32(&offset);
- m_kext_summary_header.reserved = data.GetU32(&offset);
+ m_kext_summary_header.version = data.GetU32(&offset);
+ if (m_kext_summary_header.version >= 2)
+ {
+ m_kext_summary_header.entry_size = data.GetU32(&offset);
+ }
+ else
+ {
+ // Versions less than 2 didn't have an entry size, it was hard coded
+ m_kext_summary_header.entry_size = KERNEL_MODULE_ENTRY_SIZE_VERSION_1;
+ }
+ m_kext_summary_header.entry_count = data.GetU32(&offset);
return true;
}
}
@@ -472,14 +501,14 @@
for (uint32_t i = 0; i < count; i++)
{
- if (!kext_summaries[i].UUIDValid())
+ DataExtractor data; // Load command data
+ if (ReadMachHeader (kext_summaries[i], &data))
{
- DataExtractor data; // Load command data
- if (!ReadMachHeader (kext_summaries[i], &data))
- continue;
-
ParseLoadCommands (data, kext_summaries[i]);
}
+
+ if (log)
+ kext_summaries[i].PutToLog (log.get());
}
bool return_value = AddModulesUsingImageInfos (kext_summaries);
return return_value;
@@ -560,11 +589,14 @@
error);
if (bytes_read == count)
{
- uint32_t offset = 0;
+
DataExtractor extractor (data.GetBytes(), data.GetByteSize(), endian, addr_size);
uint32_t i=0;
- for (; i < image_infos.size() && extractor.ValidOffsetForDataOfSize(offset, m_kext_summary_header.entry_size); ++i)
+ for (uint32_t kext_summary_offset = 0;
+ i < image_infos.size() && extractor.ValidOffsetForDataOfSize(kext_summary_offset, m_kext_summary_header.entry_size);
+ ++i, kext_summary_offset += m_kext_summary_header.entry_size)
{
+ uint32_t offset = kext_summary_offset;
const void *name_data = extractor.GetData(&offset, KERNEL_MODULE_MAX_NAME);
if (name_data == NULL)
break;
@@ -577,7 +609,14 @@
image_infos[i].version = extractor.GetU64(&offset);
image_infos[i].load_tag = extractor.GetU32(&offset);
image_infos[i].flags = extractor.GetU32(&offset);
- image_infos[i].reference_list = extractor.GetU64(&offset);
+ if ((offset - kext_summary_offset) < m_kext_summary_header.entry_size)
+ {
+ image_infos[i].reference_list = extractor.GetU64(&offset);
+ }
+ else
+ {
+ image_infos[i].reference_list = 0;
+ }
}
if (i < image_infos.size())
image_infos.resize(i);
@@ -601,7 +640,7 @@
if (m_kext_summary_header.entry_count > 0 && m_kext_summary_header_addr.IsValid())
{
Address summary_addr (m_kext_summary_header_addr);
- summary_addr.Slide(16);
+ summary_addr.Slide(m_kext_summary_header.GetSize());
if (!ParseKextSummaries (summary_addr, m_kext_summary_header.entry_count))
{
m_kext_summaries.clear();
@@ -835,7 +874,7 @@
{
if (u)
{
- log->Printf("\t uuid=%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X name='%s' (UNLOADED)",
+ log->Printf("\tuuid=%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X name=\"%s\" (UNLOADED)",
u[ 0], u[ 1], u[ 2], u[ 3],
u[ 4], u[ 5], u[ 6], u[ 7],
u[ 8], u[ 9], u[10], u[11],
@@ -843,23 +882,23 @@
name);
}
else
- log->Printf("\t name='%s' (UNLOADED)", name);
+ log->Printf("\tname=\"%s\" (UNLOADED)", name);
}
else
{
if (u)
{
- log->Printf("\taddress=0x%16.16llx uuid=%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X name='%s'",
- address,
- u[ 0], u[ 1], u[ 2], u[ 3],
- u[ 4], u[ 5], u[ 6], u[ 7],
- u[ 8], u[ 9], u[10], u[11],
- u[12], u[13], u[14], u[15],
+ log->Printf("\taddr=0x%16.16llx size=0x%16.16llx version=0x%16.16llx load-tag=0x%8.8x flags=0x%8.8x ref-list=0x%16.16llx uuid=%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X name=\"%s\"",
+ address, size, version, load_tag, flags, reference_list,
+ u[ 0], u[ 1], u[ 2], u[ 3], u[ 4], u[ 5], u[ 6], u[ 7],
+ u[ 8], u[ 9], u[10], u[11], u[12], u[13], u[14], u[15],
name);
}
else
{
- log->Printf("\taddress=0x%16.16llx path='%s/%s'", address, name);
+ log->Printf("\t[0x%16.16llx - 0x%16.16llx) version=0x%16.16llx load-tag=0x%8.8x flags=0x%8.8x ref-list=0x%16.16llx name=\"%s\"",
+ address, address+size, version, load_tag, flags, reference_list,
+ name);
}
for (uint32_t i=0; iPrintf("gLoadedKextSummaries = 0x%16.16llx { version=%u, entry_size=%u, entry_count=%u, reserved=%u }",
+ log->Printf("gLoadedKextSummaries = 0x%16.16llx { version=%u, entry_size=%u, entry_count=%u }",
m_kext_summary_header_addr.GetFileAddress(),
m_kext_summary_header.version,
m_kext_summary_header.entry_size,
- m_kext_summary_header.entry_count,
- m_kext_summary_header.reserved);
+ m_kext_summary_header.entry_count);
size_t i;
const size_t count = m_kext_summaries.size();
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h Mon Jul 18 22:57:15 2011
@@ -192,7 +192,15 @@
};
- enum { KERNEL_MODULE_MAX_NAME = 64u };
+ enum
+ {
+ KERNEL_MODULE_MAX_NAME = 64u,
+ // Versions less than 2 didn't have an entry size,
+ // they had a 64 bit name, 16 byte UUID, 8 byte addr,
+ // 8 byte size, 8 byte version, 4 byte load tag, and
+ // 4 byte flags
+ KERNEL_MODULE_ENTRY_SIZE_VERSION_1 = 64u + 16u + 8u + 8u + 8u + 4u + 4u
+ };
struct OSKextLoadedKextSummary
{
@@ -327,25 +335,35 @@
uint32_t version;
uint32_t entry_size;
uint32_t entry_count;
- uint32_t reserved; /* explicit alignment for gdb */
lldb::addr_t image_infos_addr;
OSKextLoadedKextSummaryHeader() :
version (0),
entry_size (0),
entry_count (0),
- reserved (0),
image_infos_addr (LLDB_INVALID_ADDRESS)
{
}
+ uint32_t
+ GetSize()
+ {
+ switch (version)
+ {
+ case 0: return 0; // Can't know the size without a valid version
+ case 1: return 8; // Version 1 only had a version + entry_count
+ default: break;
+ }
+ // Version 2 and above has version, entry_size, entry_count, and reserved
+ return 16;
+ }
+
void
Clear()
{
version = 0;
entry_size = 0;
entry_count = 0;
- reserved = 0;
image_infos_addr = LLDB_INVALID_ADDRESS;
}
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Jul 18 22:57:15 2011
@@ -604,7 +604,7 @@
segment_name.Clear();
}
}
- if (m_header.filetype == HeaderFileTypeDSYM)
+ if (segment_sp && m_header.filetype == HeaderFileTypeDSYM)
{
if (first_segment_sectID <= sectID)
{
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Mon Jul 18 22:57:15 2011
@@ -161,14 +161,14 @@
if (!module_sp)
{
// Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule(platform_file,
- arch,
- uuid_ptr,
- object_name_ptr,
- object_offset,
- module_sp,
- old_module_sp_ptr,
- did_create_ptr);
+ error = Platform::GetSharedModule (platform_file,
+ arch,
+ uuid_ptr,
+ object_name_ptr,
+ object_offset,
+ module_sp,
+ old_module_sp_ptr,
+ did_create_ptr);
}
if (module_sp)
module_sp->SetPlatformFileSpec(platform_file);
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Mon Jul 18 22:57:15 2011
@@ -15,10 +15,13 @@
#include
// C++ Includes
+#include "llvm/Support/MachO.h"
+
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/State.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/TimeValue.h"
@@ -37,6 +40,7 @@
//----------------------------------------------------------------------
CommunicationKDP::CommunicationKDP (const char *comm_name) :
Communication(comm_name),
+ m_addr_byte_size (4),
m_byte_order (eByteOrderLittle),
m_packet_timeout (1),
m_sequence_mutex (Mutex::eMutexTypeRecursive),
@@ -129,13 +133,9 @@
LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));
if (log)
{
- PacketStreamType log_strm;
-
- DataExtractor::DumpHexBytes (&log_strm, packet_data, packet_size, UINT32_MAX, LLDB_INVALID_ADDRESS);
-
- log->Printf("send kdp-packet: %.*s",
- (uint32_t)log_strm.GetSize(),
- log_strm.GetData());
+ PacketStreamType log_strm;
+ DumpPacket (log_strm, packet_data, packet_size);
+ log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
}
ConnectionStatus status = eConnectionStatusSuccess;
@@ -298,18 +298,9 @@
if (log)
{
PacketStreamType log_strm;
- packet.Dump (&log_strm, // Stream to dump to
- 0, // Offset into "packet"
- eFormatBytes, // Dump as hex bytes
- 1, // Size of each item is 1 for single bytes
- length, // Number of bytes
- UINT32_MAX, // Num bytes per line
- LLDB_INVALID_ADDRESS, // Base address
- 0, 0); // Bitfield info set to not do anything bitfield related
+ DumpPacket (log_strm, packet);
- log->Printf("recv kdp-packet: %.*s",
- (uint32_t)log_strm.GetSize(),
- log_strm.GetData());
+ log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
}
return true;
}
@@ -336,7 +327,7 @@
uint16_t exc_port,
const char *greeting)
{
- PacketStreamType request_packet (Stream::eBinary, 4, m_byte_order);
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
if (greeting == NULL)
greeting = "";
@@ -369,7 +360,7 @@
bool
CommunicationKDP::SendRequestReattach (uint16_t reply_port)
{
- PacketStreamType request_packet (Stream::eBinary, 4, m_byte_order);
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = eCommandTypeReattach;
// Length is 8 bytes for the header plus 2 bytes for the reply UDP port
const uint32_t command_length = 8 + 2;
@@ -410,7 +401,7 @@
bool
CommunicationKDP::SendRequestVersion ()
{
- PacketStreamType request_packet (Stream::eBinary, 4, m_byte_order);
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = eCommandTypeVersion;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -454,7 +445,7 @@
bool
CommunicationKDP::SendRequestHostInfo ()
{
- PacketStreamType request_packet (Stream::eBinary, 4, m_byte_order);
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = eCommandTypeHostInfo;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -464,9 +455,17 @@
{
// Reset the sequence ID to zero for reattach
uint32_t offset = 8;
- m_kdp_hostinfo_cpu_mask = reply_packet.GetU32 (&offset);
- m_kdp_hostinfo_cpu_type = reply_packet.GetU32 (&offset);
- m_kdp_hostinfo_cpu_subtype = reply_packet.GetU32 (&offset);
+ m_kdp_hostinfo_cpu_mask = reply_packet.GetU32 (&offset);
+ m_kdp_hostinfo_cpu_type = reply_packet.GetU32 (&offset);
+ m_kdp_hostinfo_cpu_subtype = reply_packet.GetU32 (&offset);
+
+ ArchSpec kernel_arch;
+ kernel_arch.SetArchitecture (eArchTypeMachO,
+ m_kdp_hostinfo_cpu_type,
+ m_kdp_hostinfo_cpu_subtype);
+
+ m_addr_byte_size = kernel_arch.GetAddressByteSize();
+ m_byte_order = kernel_arch.GetByteOrder();
return true;
}
return false;
@@ -475,7 +474,7 @@
bool
CommunicationKDP::SendRequestDisconnect ()
{
- PacketStreamType request_packet (Stream::eBinary, 4, m_byte_order);
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = eCommandTypeDisconnect;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -489,3 +488,331 @@
return true;
}
+uint32_t
+CommunicationKDP::SendRequestReadMemory (lldb::addr_t addr,
+ void *dst,
+ uint32_t dst_len,
+ Error &error)
+{
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
+ bool use_64 = (GetVersion() >= 11);
+ uint32_t command_addr_byte_size = use_64 ? 8 : 4;
+ const CommandType command = use_64 ? eCommandTypeReadMemory64 : eCommandTypeReadMemory;
+ // Size is header + address size + uint32_t length
+ const uint32_t command_length = 8 + command_addr_byte_size + 4;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ request_packet.PutMaxHex64 (addr, command_addr_byte_size);
+ request_packet.PutHex32 (dst_len);
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ {
+ // Reset the sequence ID to zero for reattach
+ uint32_t offset = 8;
+ uint32_t kdp_error = reply_packet.GetU32 (&offset);
+ uint32_t src_len = reply_packet.GetByteSize() - 12;
+
+ if (src_len > 0)
+ {
+ const void *src = reply_packet.GetData(&offset, src_len);
+ if (src)
+ {
+ ::memcpy (dst, src, src_len);
+ error.Clear();
+ return src_len;
+ }
+ }
+ if (kdp_error)
+ error.SetErrorStringWithFormat ("kdp read memory failed (error %u)", kdp_error);
+ else
+ error.SetErrorString ("kdp read memory failed");
+ }
+ return 0;
+}
+
+const char *
+CommunicationKDP::GetCommandAsCString (uint8_t command)
+{
+ switch (command)
+ {
+ case eCommandTypeConnect: return "KDP_CONNECT";
+ case eCommandTypeDisconnect: return "KDP_DISCONNECT";
+ case eCommandTypeHostInfo: return "KDP_HOSTINFO";
+ case eCommandTypeVersion: return "KDP_VERSION";
+ case eCommandTypeMaxBytes: return "KDP_MAXBYTES";
+ case eCommandTypeReadMemory: return "KDP_READMEM";
+ case eCommandTypeWriteMemory: return "KDP_WRITEMEM";
+ case eCommandTypeReadRegisters: return "KDP_READREGS";
+ case eCommandTypeWriteRegisters: return "KDP_WRITEREGS";
+ case eCommandTypeLoad: return "KDP_LOAD";
+ case eCommandTypeImagePath: return "KDP_IMAGEPATH";
+ case eCommandTypeSuspend: return "KDP_SUSPEND";
+ case eCommandTypeResume: return "KDP_RESUMECPUS";
+ case eCommandTypeException: return "KDP_EXCEPTION";
+ case eCommandTypeTermination: return "KDP_TERMINATION";
+ case eCommandTypeBreakpointSet: return "KDP_BREAKPOINT_SET";
+ case eCommandTypeBreakpointRemove: return "KDP_BREAKPOINT_REMOVE";
+ case eCommandTypeRegions: return "KDP_REGIONS";
+ case eCommandTypeReattach: return "KDP_REATTACH";
+ case eCommandTypeHostReboot: return "KDP_HOSTREBOOT";
+ case eCommandTypeReadMemory64: return "KDP_READMEM64";
+ case eCommandTypeWriteMemory64: return "KDP_WRITEMEM64";
+ case eCommandTypeBreakpointSet64: return "KDP_BREAKPOINT64_SET";
+ case eCommandTypeBreakpointRemove64: return "KDP_BREAKPOINT64_REMOVE";
+ case eCommandTypeKernelVersion: return "KDP_KERNELVERSION";
+ }
+ return NULL;
+}
+
+void
+CommunicationKDP::DumpPacket (Stream &s, const void *data, uint32_t data_len)
+{
+ DataExtractor extractor (data, data_len, m_byte_order, m_addr_byte_size);
+ DumpPacket (s, extractor);
+}
+
+void
+CommunicationKDP::DumpPacket (Stream &s, const DataExtractor& packet)
+{
+ const char *error_desc = NULL;
+ if (packet.GetByteSize() < 8)
+ {
+ error_desc = "error: invalid packet (too short): ";
+ }
+ else
+ {
+ uint32_t offset = 0;
+ const uint8_t first_packet_byte = packet.GetU8 (&offset);
+ const uint8_t sequence_id = packet.GetU8 (&offset);
+ const uint16_t length = packet.GetU16 (&offset);
+ const uint32_t key = packet.GetU32 (&offset);
+ const CommandType command = ExtractCommand (first_packet_byte);
+ const char *command_name = GetCommandAsCString (command);
+ if (command_name)
+ {
+ const bool is_reply = ExtractIsReply(first_packet_byte);
+ s.Printf ("%s {%u:%u} <0x%4.4x> %s",
+ is_reply ? "<--" : "-->",
+ key,
+ sequence_id,
+ length,
+ command_name);
+
+ if (is_reply)
+ {
+ // Dump request reply packets
+ switch (command)
+ {
+ case eCommandTypeConnect:
+ {
+ const uint32_t error = packet.GetU32 (&offset);
+ s.Printf(" (error=0x%8.8x)", error);
+ }
+ break;
+
+ case eCommandTypeDisconnect:
+ case eCommandTypeReattach:
+ case eCommandTypeHostReboot:
+ // No return value for the reply, just the header to ack
+ break;
+
+ case eCommandTypeHostInfo:
+ {
+ const uint32_t cpu_mask = packet.GetU32 (&offset);
+ const uint32_t cpu_type = packet.GetU32 (&offset);
+ const uint32_t cpu_subtype = packet.GetU32 (&offset);
+ s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)", cpu_mask, cpu_type, cpu_subtype);
+ }
+ break;
+
+ case eCommandTypeVersion:
+ {
+ const uint32_t version = packet.GetU32 (&offset);
+ const uint32_t feature = packet.GetU32 (&offset);
+ s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
+ }
+ break;
+
+ case eCommandTypeRegions:
+ {
+ const uint32_t region_count = packet.GetU32 (&offset);
+ s.Printf(" (count = %u", region_count);
+ for (uint32_t i=0; i:\n", error, count);
+ if (count > 0)
+ DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, count), count, 32, LLDB_INVALID_ADDRESS);
+ }
+ break;
+
+ case eCommandTypeMaxBytes:
+ case eCommandTypeWriteMemory:
+ case eCommandTypeWriteRegisters:
+ case eCommandTypeLoad:
+ case eCommandTypeImagePath:
+ case eCommandTypeSuspend:
+ case eCommandTypeResume:
+ case eCommandTypeException:
+ case eCommandTypeTermination:
+ case eCommandTypeBreakpointSet:
+ case eCommandTypeBreakpointRemove:
+ case eCommandTypeWriteMemory64:
+ case eCommandTypeBreakpointSet64:
+ case eCommandTypeBreakpointRemove64:
+ case eCommandTypeKernelVersion:
+ break;
+
+ }
+ }
+ else
+ {
+ // Dump request packets
+ switch (command)
+ {
+ case eCommandTypeConnect:
+ {
+ const uint16_t reply_port = packet.GetU16 (&offset);
+ const uint16_t exc_port = packet.GetU16 (&offset);
+ s.Printf(" (reply_port=%u, exc_port=%u, greeting=\"%s\")", reply_port, exc_port, packet.GetCStr(&offset));
+ }
+ break;
+
+ case eCommandTypeDisconnect:
+ case eCommandTypeHostReboot:
+ case eCommandTypeHostInfo:
+ case eCommandTypeVersion:
+ case eCommandTypeRegions:
+ // No args, just the header in the request...
+ break;
+
+ case eCommandTypeReadMemory:
+ {
+ const uint32_t addr = packet.GetU32 (&offset);
+ const uint32_t size = packet.GetU32 (&offset);
+ s.Printf(" (addr = 0x%8.8x, size=%u)", addr, size);
+ }
+ break;
+
+ case eCommandTypeReadMemory64:
+ {
+ const uint64_t addr = packet.GetU64 (&offset);
+ const uint32_t size = packet.GetU32 (&offset);
+ s.Printf(" (addr = 0x%16.16llx, size=%u)", addr, size);
+ }
+ break;
+
+ case eCommandTypeReadRegisters:
+ {
+ const uint32_t cpu = packet.GetU32 (&offset);
+ const uint32_t flavor = packet.GetU32 (&offset);
+ s.Printf(" (cpu = %u, flavor=%u)", cpu, flavor);
+ }
+ break;
+
+ case eCommandTypeMaxBytes:
+ case eCommandTypeWriteMemory:
+ case eCommandTypeWriteRegisters:
+ case eCommandTypeLoad:
+ case eCommandTypeImagePath:
+ case eCommandTypeSuspend:
+ case eCommandTypeResume:
+ case eCommandTypeException:
+ case eCommandTypeTermination:
+ case eCommandTypeBreakpointSet:
+ case eCommandTypeBreakpointRemove:
+ break;
+
+ case eCommandTypeReattach:
+ {
+ const uint16_t reply_port = packet.GetU16 (&offset);
+ s.Printf(" (reply_port=%u)", reply_port);
+ }
+ break;
+
+ case eCommandTypeWriteMemory64:
+ case eCommandTypeBreakpointSet64:
+ case eCommandTypeBreakpointRemove64:
+ case eCommandTypeKernelVersion:
+ break;
+ }
+ }
+ }
+ else
+ {
+ error_desc = "error: invalid packet command: ";
+ }
+ }
+
+ if (error_desc)
+ {
+ s.PutCString (error_desc);
+
+ packet.Dump (&s, // Stream to dump to
+ 0, // Offset into "packet"
+ eFormatBytes, // Dump as hex bytes
+ 1, // Size of each item is 1 for single bytes
+ packet.GetByteSize(), // Number of bytes
+ UINT32_MAX, // Num bytes per line
+ LLDB_INVALID_ADDRESS, // Base address
+ 0, 0); // Bitfield info set to not do anything bitfield related
+ }
+}
+
+uint32_t
+CommunicationKDP::SendRequestReadRegisters (uint32_t cpu,
+ uint32_t flavor,
+ void *dst,
+ uint32_t dst_len,
+ Error &error)
+{
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
+ const CommandType command = eCommandTypeReadRegisters;
+ // Size is header + 4 byte cpu and 4 byte flavor
+ const uint32_t command_length = 8 + 4 + 4;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ request_packet.PutHex32 (cpu);
+ request_packet.PutHex32 (flavor);
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ {
+ // Reset the sequence ID to zero for reattach
+ uint32_t offset = 8;
+ uint32_t kdp_error = reply_packet.GetU32 (&offset);
+ uint32_t src_len = reply_packet.GetByteSize() - 12;
+
+ if (src_len > 0)
+ {
+ const uint32_t bytes_to_copy = std::min(src_len, dst_len);
+ const void *src = reply_packet.GetData(&offset, bytes_to_copy);
+ if (src)
+ {
+ ::memcpy (dst, src, bytes_to_copy);
+ error.Clear();
+ // Return the number of bytes we could have returned regardless if
+ // we copied them or not, just so we know when things don't match up
+ return src_len;
+ }
+ }
+ if (kdp_error)
+ error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u (error %u)", cpu, flavor, kdp_error);
+ else
+ error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u", cpu, flavor);
+ }
+ return 0;
+}
+
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Mon Jul 18 22:57:15 2011
@@ -140,6 +140,9 @@
lldb_private::ProcessLaunchInfo &launch_info);
+ //------------------------------------------------------------------
+ // Public Request Packets
+ //------------------------------------------------------------------
bool
SendRequestConnect (uint16_t reply_port,
uint16_t exc_port,
@@ -152,6 +155,24 @@
SendRequestDisconnect ();
uint32_t
+ SendRequestReadMemory (lldb::addr_t addr,
+ void *buf,
+ uint32_t size,
+ lldb_private::Error &error);
+
+ uint32_t
+ SendRequestReadRegisters (uint32_t cpu,
+ uint32_t flavor,
+ void *dst,
+ uint32_t dst_size,
+ lldb_private::Error &error);
+// size_t
+// SendRequestWriteMemory (lldb::addr_t addr,
+// const void *buf,
+// size_t size,
+// lldb_private::Error &error);
+
+ uint32_t
GetVersion ();
uint32_t
@@ -184,9 +205,25 @@
PacketStreamType &request_packet,
uint16_t request_length);
+ //------------------------------------------------------------------
+ // Protected Request Packets (use public accessors which will cache
+ // results.
+ //------------------------------------------------------------------
bool
SendRequestVersion ();
+ bool
+ SendRequestHostInfo ();
+
+
+ void
+ DumpPacket (lldb_private::Stream &s,
+ const void *data,
+ uint32_t data_len);
+
+ void
+ DumpPacket (lldb_private::Stream &s,
+ const lldb_private::DataExtractor& extractor);
bool
VersionIsValid() const
@@ -201,7 +238,21 @@
}
bool
- SendRequestHostInfo ();
+ ExtractIsReply (uint8_t first_packet_byte) const
+ {
+ // TODO: handle big endian...
+ return (first_packet_byte & ePacketTypeMask) != 0;
+ }
+
+ CommandType
+ ExtractCommand (uint8_t first_packet_byte) const
+ {
+ // TODO: handle big endian...
+ return (CommandType)(first_packet_byte & eCommandTypeMask);
+ }
+
+ static const char *
+ GetCommandAsCString (uint8_t command);
void
ClearKDPSettings ();
@@ -214,6 +265,7 @@
//------------------------------------------------------------------
// Classes that inherit from CommunicationKDP can see and modify these
//------------------------------------------------------------------
+ uint32_t m_addr_byte_size;
lldb::ByteOrder m_byte_order;
uint32_t m_packet_timeout;
lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Mon Jul 18 22:57:15 2011
@@ -18,11 +18,12 @@
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
// Project includes
#include "ProcessKDP.h"
#include "ProcessKDPLog.h"
-//#include "ThreadKDP.h"
+#include "ThreadKDP.h"
#include "StopInfoMachException.h"
using namespace lldb;
@@ -182,7 +183,10 @@
ArchSpec kernel_arch;
kernel_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
m_target.SetArchitecture(kernel_arch);
- // TODO: thread registers based off of architecture...
+
+ SetID (1);
+ UpdateThreadListIfNeeded ();
+ SetPrivateState (eStateStopped);
}
}
else
@@ -295,34 +299,24 @@
log->Printf ("ProcessKDP::%s (pid = %i)", __FUNCTION__, GetID());
Mutex::Locker locker (m_thread_list.GetMutex ());
- // TODO: get the thread list here!
const uint32_t stop_id = GetStopID();
- if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID())
+ if (m_thread_list.GetSize(false) == 0)
{
- // Update the thread list's stop id immediately so we don't recurse into this function.
-// ThreadList curr_thread_list (this);
-// curr_thread_list.SetStopID(stop_id);
-//
-// std::vector thread_ids;
-// bool sequence_mutex_unavailable = false;
-// const size_t num_thread_ids = m_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable);
-// if (num_thread_ids > 0)
-// {
-// for (size_t i=0; i
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "RegisterContextKDP_i386.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+
+RegisterContextKDP_i386::RegisterContextKDP_i386(Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContextDarwin_i386 (thread, concrete_frame_idx)
+{
+}
+
+RegisterContextKDP_i386::~RegisterContextKDP_i386()
+{
+}
+
+int
+RegisterContextKDP_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
+{
+ mach_msg_type_number_t count = GPRWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
+}
+
+int
+RegisterContextKDP_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
+{
+ mach_msg_type_number_t count = FPUWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
+}
+
+int
+RegisterContextKDP_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
+{
+ mach_msg_type_number_t count = EXCWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
+}
+
+int
+RegisterContextKDP_i386::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
+{
+ return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+}
+
+int
+RegisterContextKDP_i386::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
+{
+ return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+}
+
+int
+RegisterContextKDP_i386::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
+{
+ return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+}
+
+
Added: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h (added)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h Mon Jul 18 22:57:15 2011
@@ -0,0 +1,49 @@
+//===-- RegisterContextKDP_i386.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_RegisterContextKDP_i386_h_
+#define liblldb_RegisterContextKDP_i386_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "Plugins/Process/Utility/RegisterContextDarwin_i386.h"
+
+class RegisterContextKDP_i386 : public RegisterContextDarwin_i386
+{
+public:
+ RegisterContextKDP_i386 (lldb_private::Thread &thread,
+ uint32_t concrete_frame_idx);
+
+ virtual
+ ~RegisterContextKDP_i386();
+
+protected:
+
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
+};
+
+#endif // liblldb_RegisterContextKDP_i386_h_
Added: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp (added)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp Mon Jul 18 22:57:15 2011
@@ -0,0 +1,66 @@
+//===-- RegisterContextKDP_x86_64.cpp ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// C Includes
+#include
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "RegisterContextKDP_x86_64.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+
+RegisterContextKDP_x86_64::RegisterContextKDP_x86_64(Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContextDarwin_x86_64 (thread, concrete_frame_idx)
+{
+}
+
+RegisterContextKDP_x86_64::~RegisterContextKDP_x86_64()
+{
+}
+
+int
+RegisterContextKDP_x86_64::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
+{
+ return -1;
+}
+
+int
+RegisterContextKDP_x86_64::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
+{
+ return -1;
+}
+
+int
+RegisterContextKDP_x86_64::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
+{
+ return -1;
+}
+
+int
+RegisterContextKDP_x86_64::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
+{
+ return -1;
+}
+
+int
+RegisterContextKDP_x86_64::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
+{
+ return -1;
+}
+
+int
+RegisterContextKDP_x86_64::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
+{
+ return -1;
+}
Added: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h (added)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h Mon Jul 18 22:57:15 2011
@@ -0,0 +1,50 @@
+//===-- RegisterContextKDP_x86_64.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_RegisterContextKDP_x86_64_h_
+#define liblldb_RegisterContextKDP_x86_64_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "Plugins/Process/Utility/RegisterContextDarwin_x86_64.h"
+
+class RegisterContextKDP_x86_64 : public RegisterContextDarwin_x86_64
+{
+public:
+
+ RegisterContextKDP_x86_64 (lldb_private::Thread &thread,
+ uint32_t concrete_frame_idx);
+
+ virtual
+ ~RegisterContextKDP_x86_64();
+
+protected:
+
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
+};
+
+#endif // liblldb_RegisterContextKDP_x86_64_h_
Added: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp (added)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp Mon Jul 18 22:57:15 2011
@@ -0,0 +1,247 @@
+//===-- ThreadKDP.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "ThreadKDP.h"
+
+#include "llvm/Support/MachO.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/State.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Unwind.h"
+#include "lldb/Breakpoint/WatchpointLocation.h"
+
+#include "ProcessKDP.h"
+#include "ProcessKDPLog.h"
+#include "RegisterContextKDP_arm.h"
+#include "RegisterContextKDP_i386.h"
+#include "RegisterContextKDP_x86_64.h"
+#include "Plugins/Process/Utility/UnwindLLDB.h"
+
+#if defined(__APPLE__)
+#include "UnwindMacOSXFrameBackchain.h"
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// Thread Registers
+//----------------------------------------------------------------------
+
+ThreadKDP::ThreadKDP (ProcessKDP &process, lldb::tid_t tid) :
+ Thread(process, tid),
+ m_thread_name (),
+ m_dispatch_queue_name (),
+ m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS)
+{
+ ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::ThreadKDP (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+}
+
+ThreadKDP::~ThreadKDP ()
+{
+ ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::~ThreadKDP (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+ DestroyThread();
+}
+
+
+const char *
+ThreadKDP::GetInfo ()
+{
+ return NULL;
+}
+
+
+const char *
+ThreadKDP::GetName ()
+{
+ if (m_thread_name.empty())
+ return NULL;
+ return m_thread_name.c_str();
+}
+
+const char *
+ThreadKDP::GetQueueName ()
+{
+ return NULL;
+}
+
+bool
+ThreadKDP::WillResume (StateType resume_state)
+{
+ ClearStackFrames();
+ // Call the Thread::WillResume first. If we stop at a signal, the stop info
+ // class for signal will set the resume signal that we need below. The signal
+ // stuff obeys the Process::UnixSignal defaults.
+ Thread::WillResume(resume_state);
+
+ lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP));
+ if (log)
+ log->Printf ("Resuming thread: %4.4x with state: %s.", GetID(), StateAsCString(resume_state));
+
+// ProcessKDP &process = GetKDPProcess();
+// switch (resume_state)
+// {
+// case eStateSuspended:
+// case eStateStopped:
+// // Don't append anything for threads that should stay stopped.
+// break;
+//
+// case eStateRunning:
+// case eStateStepping:
+// break;
+//
+// default:
+// break;
+// }
+ return true;
+}
+
+void
+ThreadKDP::RefreshStateAfterStop()
+{
+ // Invalidate all registers in our register context. We don't set "force" to
+ // true because the stop reply packet might have had some register values
+ // that were expedited and these will already be copied into the register
+ // context by the time this function gets called. The KDPRegisterContext
+ // class has been made smart enough to detect when it needs to invalidate
+ // which registers are valid by putting hooks in the register read and
+ // register supply functions where they check the process stop ID and do
+ // the right thing.
+ const bool force = false;
+ GetRegisterContext()->InvalidateIfNeeded (force);
+}
+
+Unwind *
+ThreadKDP::GetUnwinder ()
+{
+ if (m_unwinder_ap.get() == NULL)
+ {
+ const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ());
+ const llvm::Triple::ArchType machine = target_arch.GetMachine();
+ switch (machine)
+ {
+ case llvm::Triple::x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ m_unwinder_ap.reset (new UnwindLLDB (*this));
+ break;
+
+ default:
+#if defined(__APPLE__)
+ m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this));
+#endif
+ break;
+ }
+ }
+ return m_unwinder_ap.get();
+}
+
+void
+ThreadKDP::ClearStackFrames ()
+{
+ Unwind *unwinder = GetUnwinder ();
+ if (unwinder)
+ unwinder->Clear();
+ Thread::ClearStackFrames();
+}
+
+
+bool
+ThreadKDP::ThreadIDIsValid (lldb::tid_t thread)
+{
+ return thread != 0;
+}
+
+void
+ThreadKDP::Dump(Log *log, uint32_t index)
+{
+}
+
+
+bool
+ThreadKDP::ShouldStop (bool &step_more)
+{
+ return true;
+}
+lldb::RegisterContextSP
+ThreadKDP::GetRegisterContext ()
+{
+ if (m_reg_context_sp.get() == NULL)
+ m_reg_context_sp = CreateRegisterContextForFrame (NULL);
+ return m_reg_context_sp;
+}
+
+lldb::RegisterContextSP
+ThreadKDP::CreateRegisterContextForFrame (StackFrame *frame)
+{
+ lldb::RegisterContextSP reg_ctx_sp;
+ uint32_t concrete_frame_idx = 0;
+
+ if (frame)
+ concrete_frame_idx = frame->GetConcreteFrameIndex ();
+
+ if (concrete_frame_idx == 0)
+ {
+ switch (GetKDPProcess().GetCommunication().GetCPUType())
+ {
+ case llvm::MachO::CPUTypeARM:
+ reg_ctx_sp.reset (new RegisterContextKDP_arm (*this, concrete_frame_idx));
+ break;
+ case llvm::MachO::CPUTypeI386:
+ reg_ctx_sp.reset (new RegisterContextKDP_i386 (*this, concrete_frame_idx));
+ break;
+ case llvm::MachO::CPUTypeX86_64:
+ reg_ctx_sp.reset (new RegisterContextKDP_x86_64 (*this, concrete_frame_idx));
+ break;
+ default:
+ assert (!"Add CPU type support in KDP");
+ break;
+ }
+ }
+ else if (m_unwinder_ap.get())
+ reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame);
+ return reg_ctx_sp;
+}
+
+lldb::StopInfoSP
+ThreadKDP::GetPrivateStopReason ()
+{
+ const uint32_t process_stop_id = GetProcess().GetStopID();
+ if (m_thread_stop_reason_stop_id != process_stop_id ||
+ (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ {
+ // TODO: can we query the initial state of the thread here?
+ // For now I am just going to pretend that a SIGSTOP happened.
+
+ SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP));
+
+ // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason
+ // for this thread, then m_actual_stop_info_sp will not ever contain
+ // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
+ // check will never be able to tell us if we have the correct stop info
+ // for this thread and we will continually send qThreadStopInfo packets
+ // down to the remote KDP server, so we need to keep our own notion
+ // of the stop ID that m_actual_stop_info_sp is valid for (even if it
+ // contains nothing). We use m_thread_stop_reason_stop_id for this below.
+// m_thread_stop_reason_stop_id = process_stop_id;
+// m_actual_stop_info_sp.reset();
+
+ }
+ return m_actual_stop_info_sp;
+}
+
+
Added: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h (added)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h Mon Jul 18 22:57:15 2011
@@ -0,0 +1,115 @@
+//===-- ThreadKDP.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_ThreadKDP_h_
+#define liblldb_ThreadKDP_h_
+
+#include
+
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Thread.h"
+
+class ProcessKDP;
+
+class ThreadKDP : public lldb_private::Thread
+{
+public:
+ ThreadKDP (ProcessKDP &process,
+ lldb::tid_t tid);
+
+ virtual
+ ~ThreadKDP ();
+
+ virtual bool
+ WillResume (lldb::StateType resume_state);
+
+ virtual void
+ RefreshStateAfterStop();
+
+ virtual const char *
+ GetInfo ();
+
+ virtual const char *
+ GetName ();
+
+ virtual const char *
+ GetQueueName ();
+
+ virtual lldb::RegisterContextSP
+ GetRegisterContext ();
+
+ virtual lldb::RegisterContextSP
+ CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+
+ virtual void
+ ClearStackFrames ();
+
+ ProcessKDP &
+ GetKDPProcess ()
+ {
+ return (ProcessKDP &)m_process;
+ }
+
+ void
+ Dump (lldb_private::Log *log, uint32_t index);
+
+ static bool
+ ThreadIDIsValid (lldb::tid_t thread);
+
+ bool
+ ShouldStop (bool &step_more);
+
+ const char *
+ GetBasicInfoAsString ();
+
+ void
+ SetName (const char *name)
+ {
+ if (name && name[0])
+ m_thread_name.assign (name);
+ else
+ m_thread_name.clear();
+ }
+
+ lldb::addr_t
+ GetThreadDispatchQAddr ()
+ {
+ return m_thread_dispatch_qaddr;
+ }
+
+ void
+ SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr)
+ {
+ m_thread_dispatch_qaddr = thread_dispatch_qaddr;
+ }
+
+protected:
+
+ friend class ProcessKDP;
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ std::string m_thread_name;
+ std::string m_dispatch_queue_name;
+ lldb::addr_t m_thread_dispatch_qaddr;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+
+ virtual lldb_private::Unwind *
+ GetUnwinder ();
+
+ virtual lldb::StopInfoSP
+ GetPrivateStopReason ();
+
+
+};
+
+#endif // liblldb_ThreadKDP_h_
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp Mon Jul 18 22:57:15 2011
@@ -15,1206 +15,72 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
-
// Project includes
-#include "ARM_GCC_Registers.h"
-#include "ARM_DWARF_Registers.h"
-#include "ProcessMacOSXLog.h"
+//#include "ProcessMacOSXLog.h"
using namespace lldb;
using namespace lldb_private;
-enum
-{
- gpr_r0 = 0,
- gpr_r1,
- gpr_r2,
- gpr_r3,
- gpr_r4,
- gpr_r5,
- gpr_r6,
- gpr_r7,
- gpr_r8,
- gpr_r9,
- gpr_r10,
- gpr_r11,
- gpr_r12,
- gpr_r13, gpr_sp = gpr_r13,
- gpr_r14, gpr_lr = gpr_r14,
- gpr_r15, gpr_pc = gpr_r15,
- gpr_cpsr,
-
- fpu_s0,
- fpu_s1,
- fpu_s2,
- fpu_s3,
- fpu_s4,
- fpu_s5,
- fpu_s6,
- fpu_s7,
- fpu_s8,
- fpu_s9,
- fpu_s10,
- fpu_s11,
- fpu_s12,
- fpu_s13,
- fpu_s14,
- fpu_s15,
- fpu_s16,
- fpu_s17,
- fpu_s18,
- fpu_s19,
- fpu_s20,
- fpu_s21,
- fpu_s22,
- fpu_s23,
- fpu_s24,
- fpu_s25,
- fpu_s26,
- fpu_s27,
- fpu_s28,
- fpu_s29,
- fpu_s30,
- fpu_s31,
- fpu_fpscr,
-
- exc_exception,
- exc_fsr,
- exc_far,
-
- dbg_bvr0,
- dbg_bvr1,
- dbg_bvr2,
- dbg_bvr3,
- dbg_bvr4,
- dbg_bvr5,
- dbg_bvr6,
- dbg_bvr7,
- dbg_bvr8,
- dbg_bvr9,
- dbg_bvr10,
- dbg_bvr11,
- dbg_bvr12,
- dbg_bvr13,
- dbg_bvr14,
- dbg_bvr15,
-
- dbg_bcr0,
- dbg_bcr1,
- dbg_bcr2,
- dbg_bcr3,
- dbg_bcr4,
- dbg_bcr5,
- dbg_bcr6,
- dbg_bcr7,
- dbg_bcr8,
- dbg_bcr9,
- dbg_bcr10,
- dbg_bcr11,
- dbg_bcr12,
- dbg_bcr13,
- dbg_bcr14,
- dbg_bcr15,
-
- dbg_wvr0,
- dbg_wvr1,
- dbg_wvr2,
- dbg_wvr3,
- dbg_wvr4,
- dbg_wvr5,
- dbg_wvr6,
- dbg_wvr7,
- dbg_wvr8,
- dbg_wvr9,
- dbg_wvr10,
- dbg_wvr11,
- dbg_wvr12,
- dbg_wvr13,
- dbg_wvr14,
- dbg_wvr15,
-
- dbg_wcr0,
- dbg_wcr1,
- dbg_wcr2,
- dbg_wcr3,
- dbg_wcr4,
- dbg_wcr5,
- dbg_wcr6,
- dbg_wcr7,
- dbg_wcr8,
- dbg_wcr9,
- dbg_wcr10,
- dbg_wcr11,
- dbg_wcr12,
- dbg_wcr13,
- dbg_wcr14,
- dbg_wcr15,
-
- k_num_registers
-};
-
RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext(thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
+ RegisterContextDarwin_arm (thread, concrete_frame_idx)
{
- uint32_t i;
- for (i=0; ireg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, dbg_##reg##i }
-#define REG_CONTEXT_SIZE (sizeof (RegisterContextMach_arm::GPR) + sizeof (RegisterContextMach_arm::FPU) + sizeof (RegisterContextMach_arm::EXC))
-// General purpose registers
-static RegisterInfo
-g_register_infos[] =
-{
-// NAME ALT SZ OFFSET ENCODING FORMAT COMPILER DWARF GENERIC LLDB NATIVE
-// ====== ======= == ============= ============= ============ =============== =============== ========= ==========
-{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, gpr_r0 }},
-{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, gpr_r1 }},
-{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, gpr_r2 }},
-{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, gpr_r3 }},
-{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gpr_r4 }},
-{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gpr_r5 }},
-{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gpr_r6 }},
-{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gpr_r7 }},
-{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gpr_r8 }},
-{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gpr_r9 }},
-{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gpr_r10 }},
-{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gpr_r11 }},
-{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gpr_r12 }},
-{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gpr_sp }},
-{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gpr_lr }},
-{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gpr_pc }},
-{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gpr_cpsr }},
-
-{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, fpu_s0 }},
-{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, fpu_s1 }},
-{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, fpu_s2 }},
-{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, fpu_s3 }},
-{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, fpu_s4 }},
-{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, fpu_s5 }},
-{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, fpu_s6 }},
-{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, fpu_s7 }},
-{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, fpu_s8 }},
-{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, fpu_s9 }},
-{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, fpu_s10 }},
-{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, fpu_s11 }},
-{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, fpu_s12 }},
-{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, fpu_s13 }},
-{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, fpu_s14 }},
-{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, fpu_s15 }},
-{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, fpu_s16 }},
-{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, fpu_s17 }},
-{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, fpu_s18 }},
-{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, fpu_s19 }},
-{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, fpu_s20 }},
-{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, fpu_s21 }},
-{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, fpu_s22 }},
-{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, fpu_s23 }},
-{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, fpu_s24 }},
-{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, fpu_s25 }},
-{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, fpu_s26 }},
-{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, fpu_s27 }},
-{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, fpu_s28 }},
-{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, fpu_s29 }},
-{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, fpu_s30 }},
-{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, fpu_s31 }},
-{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpscr }},
-
-{ "exception",NULL, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }},
-{ "fsr", NULL, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_fsr }},
-{ "far", NULL, 4, EXC_OFFSET(2), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }},
-
-{ DEFINE_DBG (bvr, 0) },
-{ DEFINE_DBG (bvr, 0) },
-{ DEFINE_DBG (bvr, 1) },
-{ DEFINE_DBG (bvr, 2) },
-{ DEFINE_DBG (bvr, 3) },
-{ DEFINE_DBG (bvr, 4) },
-{ DEFINE_DBG (bvr, 5) },
-{ DEFINE_DBG (bvr, 6) },
-{ DEFINE_DBG (bvr, 7) },
-{ DEFINE_DBG (bvr, 8) },
-{ DEFINE_DBG (bvr, 9) },
-{ DEFINE_DBG (bvr, 10) },
-{ DEFINE_DBG (bvr, 11) },
-{ DEFINE_DBG (bvr, 12) },
-{ DEFINE_DBG (bvr, 13) },
-{ DEFINE_DBG (bvr, 14) },
-{ DEFINE_DBG (bvr, 15) },
-
-{ DEFINE_DBG (bcr, 0) },
-{ DEFINE_DBG (bcr, 0) },
-{ DEFINE_DBG (bcr, 1) },
-{ DEFINE_DBG (bcr, 2) },
-{ DEFINE_DBG (bcr, 3) },
-{ DEFINE_DBG (bcr, 4) },
-{ DEFINE_DBG (bcr, 5) },
-{ DEFINE_DBG (bcr, 6) },
-{ DEFINE_DBG (bcr, 7) },
-{ DEFINE_DBG (bcr, 8) },
-{ DEFINE_DBG (bcr, 9) },
-{ DEFINE_DBG (bcr, 10) },
-{ DEFINE_DBG (bcr, 11) },
-{ DEFINE_DBG (bcr, 12) },
-{ DEFINE_DBG (bcr, 13) },
-{ DEFINE_DBG (bcr, 14) },
-{ DEFINE_DBG (bcr, 15) },
-
-{ DEFINE_DBG (wvr, 0) },
-{ DEFINE_DBG (wvr, 0) },
-{ DEFINE_DBG (wvr, 1) },
-{ DEFINE_DBG (wvr, 2) },
-{ DEFINE_DBG (wvr, 3) },
-{ DEFINE_DBG (wvr, 4) },
-{ DEFINE_DBG (wvr, 5) },
-{ DEFINE_DBG (wvr, 6) },
-{ DEFINE_DBG (wvr, 7) },
-{ DEFINE_DBG (wvr, 8) },
-{ DEFINE_DBG (wvr, 9) },
-{ DEFINE_DBG (wvr, 10) },
-{ DEFINE_DBG (wvr, 11) },
-{ DEFINE_DBG (wvr, 12) },
-{ DEFINE_DBG (wvr, 13) },
-{ DEFINE_DBG (wvr, 14) },
-{ DEFINE_DBG (wvr, 15) },
-
-{ DEFINE_DBG (wcr, 0) },
-{ DEFINE_DBG (wcr, 0) },
-{ DEFINE_DBG (wcr, 1) },
-{ DEFINE_DBG (wcr, 2) },
-{ DEFINE_DBG (wcr, 3) },
-{ DEFINE_DBG (wcr, 4) },
-{ DEFINE_DBG (wcr, 5) },
-{ DEFINE_DBG (wcr, 6) },
-{ DEFINE_DBG (wcr, 7) },
-{ DEFINE_DBG (wcr, 8) },
-{ DEFINE_DBG (wcr, 9) },
-{ DEFINE_DBG (wcr, 10) },
-{ DEFINE_DBG (wcr, 11) },
-{ DEFINE_DBG (wcr, 12) },
-{ DEFINE_DBG (wcr, 13) },
-{ DEFINE_DBG (wcr, 14) },
-{ DEFINE_DBG (wcr, 15) }
-};
-
-// General purpose registers
-static uint32_t
-g_gpr_regnums[] =
-{
- gpr_r0,
- gpr_r1,
- gpr_r2,
- gpr_r3,
- gpr_r4,
- gpr_r5,
- gpr_r6,
- gpr_r7,
- gpr_r8,
- gpr_r9,
- gpr_r10,
- gpr_r11,
- gpr_r12,
- gpr_sp,
- gpr_lr,
- gpr_pc,
- gpr_cpsr
-};
-
-// Floating point registers
-static uint32_t
-g_fpu_regnums[] =
-{
- fpu_s0,
- fpu_s1,
- fpu_s2,
- fpu_s3,
- fpu_s4,
- fpu_s5,
- fpu_s6,
- fpu_s7,
- fpu_s8,
- fpu_s9,
- fpu_s10,
- fpu_s11,
- fpu_s12,
- fpu_s13,
- fpu_s14,
- fpu_s15,
- fpu_s16,
- fpu_s17,
- fpu_s18,
- fpu_s19,
- fpu_s20,
- fpu_s21,
- fpu_s22,
- fpu_s23,
- fpu_s24,
- fpu_s25,
- fpu_s26,
- fpu_s27,
- fpu_s28,
- fpu_s29,
- fpu_s30,
- fpu_s31,
- fpu_fpscr,
-};
-
-// Exception registers
-
-static uint32_t
-g_exc_regnums[] =
-{
- exc_exception,
- exc_fsr,
- exc_far,
-};
-
-static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo));
-
-void
-RegisterContextMach_arm::InvalidateAllRegisters ()
-{
- InvalidateAllRegisterStates();
-}
-
-
-size_t
-RegisterContextMach_arm::GetRegisterCount ()
-{
- assert(k_num_register_infos == k_num_registers);
- return k_num_registers;
-}
-
-const RegisterInfo *
-RegisterContextMach_arm::GetRegisterInfoAtIndex (uint32_t reg)
-{
- assert(k_num_register_infos == k_num_registers);
- if (reg < k_num_registers)
- return &g_register_infos[reg];
- return NULL;
-}
-
-size_t
-RegisterContextMach_arm::GetRegisterInfosCount ()
-{
- return k_num_register_infos;
-}
-
-const RegisterInfo *
-RegisterContextMach_arm::GetRegisterInfos ()
-{
- return g_register_infos;
-}
-
-
-// Number of registers in each register set
-const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) / sizeof(uint32_t);
-const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) / sizeof(uint32_t);
-const size_t k_num_exc_registers = sizeof(g_exc_regnums) / sizeof(uint32_t);
-
-//----------------------------------------------------------------------
-// Register set definitions. The first definitions at register set index
-// of zero is for all registers, followed by other registers sets. The
-// register information for the all register set need not be filled in.
-//----------------------------------------------------------------------
-static const RegisterSet g_reg_sets[] =
-{
- { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums, },
- { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums },
- { "Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums }
-};
-
-const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
-
-
-size_t
-RegisterContextMach_arm::GetRegisterSetCount ()
-{
- return k_num_regsets;
-}
-
-const RegisterSet *
-RegisterContextMach_arm::GetRegisterSet (uint32_t reg_set)
-{
- if (reg_set < k_num_regsets)
- return &g_reg_sets[reg_set];
- return NULL;
-}
-
-
-//----------------------------------------------------------------------
-// Register information defintions for 32 bit i386.
-//----------------------------------------------------------------------
-int
-RegisterContextMach_arm::GetSetForNativeRegNum (int reg)
-{
- if (reg < fpu_s0)
- return GPRRegSet;
- else if (reg < exc_exception)
- return FPURegSet;
- else if (reg < k_num_registers)
- return EXCRegSet;
- return -1;
-}
-
int
-RegisterContextMach_arm::ReadGPR (bool force)
+RegisterContextMach_arm::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
- int set = GPRRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = GPRWordCount;
- SetError(GPRRegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&gpr, &count));
- }
- return GetError(GPRRegSet, Read);
+ mach_msg_type_number_t count = GPRWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
}
int
-RegisterContextMach_arm::ReadFPU (bool force)
+RegisterContextMach_arm::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
- int set = FPURegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = FPUWordCount;
- SetError(FPURegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&fpu, &count));
- }
- return GetError(FPURegSet, Read);
+ mach_msg_type_number_t count = FPUWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
}
int
-RegisterContextMach_arm::ReadEXC (bool force)
+RegisterContextMach_arm::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
- int set = EXCRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = EXCWordCount;
- SetError(EXCRegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&exc, &count));
- }
- return GetError(EXCRegSet, Read);
+ mach_msg_type_number_t count = EXCWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
}
int
-RegisterContextMach_arm::ReadDBG (bool force)
+RegisterContextMach_arm::DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
{
- int set = DBGRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = DBGWordCount;
- SetError(DBGRegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&dbg, &count));
- }
- return GetError(DBGRegSet, Read);
+ mach_msg_type_number_t count = DBGWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&dbg, &count);
}
int
-RegisterContextMach_arm::WriteGPR ()
+RegisterContextMach_arm::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
{
- int set = GPRRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError(GPRRegSet, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&gpr, GPRWordCount));
- return GetError(GPRRegSet, Write);
+ return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
}
int
-RegisterContextMach_arm::WriteFPU ()
+RegisterContextMach_arm::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
{
- int set = FPURegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError(FPURegSet, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&fpu, FPUWordCount));
- return GetError(FPURegSet, Write);
+ return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
}
int
-RegisterContextMach_arm::WriteEXC ()
+RegisterContextMach_arm::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
{
- int set = EXCRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError(EXCRegSet, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&exc, EXCWordCount));
- return GetError(EXCRegSet, Write);
+ return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
}
int
-RegisterContextMach_arm::WriteDBG ()
-{
- int set = DBGRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError(DBGRegSet, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&dbg, DBGWordCount));
- return GetError(DBGRegSet, Write);
-}
-
-
-int
-RegisterContextMach_arm::ReadRegisterSet (uint32_t set, bool force)
-{
- switch (set)
- {
- case GPRRegSet: return ReadGPR(force);
- case FPURegSet: return ReadFPU(force);
- case EXCRegSet: return ReadEXC(force);
- case DBGRegSet: return ReadDBG(force);
- default: break;
- }
- return KERN_INVALID_ARGUMENT;
-}
-
-int
-RegisterContextMach_arm::WriteRegisterSet (uint32_t set)
-{
- // Make sure we have a valid context to set.
- if (RegisterSetIsCached(set))
- {
- switch (set)
- {
- case GPRRegSet: return WriteGPR();
- case FPURegSet: return WriteFPU();
- case EXCRegSet: return WriteEXC();
- case DBGRegSet: return WriteDBG();
- default: break;
- }
- }
- return KERN_INVALID_ARGUMENT;
-}
-
-void
-RegisterContextMach_arm::LogDBGRegisters (Log *log, const DBG& dbg)
-{
- if (log)
- {
- for (uint32_t i=0; i<16; i++)
- log->Printf("BVR%-2u/BCR%-2u = { 0x%8.8x, 0x%8.8x } WVR%-2u/WCR%-2u = { 0x%8.8x, 0x%8.8x }",
- i, i, dbg.bvr[i], dbg.bcr[i],
- i, i, dbg.wvr[i], dbg.wcr[i]);
- }
-}
-
-
-bool
-RegisterContextMach_arm::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value)
-{
- const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- int set = RegisterContextMach_arm::GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- switch (reg)
- {
- case gpr_r0:
- case gpr_r1:
- case gpr_r2:
- case gpr_r3:
- case gpr_r4:
- case gpr_r5:
- case gpr_r6:
- case gpr_r7:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_sp:
- case gpr_lr:
- case gpr_pc:
- case gpr_cpsr:
- value.SetUInt32 (gpr.r[reg - gpr_r0]);
- break;
-
- case fpu_s0:
- case fpu_s1:
- case fpu_s2:
- case fpu_s3:
- case fpu_s4:
- case fpu_s5:
- case fpu_s6:
- case fpu_s7:
- case fpu_s8:
- case fpu_s9:
- case fpu_s10:
- case fpu_s11:
- case fpu_s12:
- case fpu_s13:
- case fpu_s14:
- case fpu_s15:
- case fpu_s16:
- case fpu_s17:
- case fpu_s18:
- case fpu_s19:
- case fpu_s20:
- case fpu_s21:
- case fpu_s22:
- case fpu_s23:
- case fpu_s24:
- case fpu_s25:
- case fpu_s26:
- case fpu_s27:
- case fpu_s28:
- case fpu_s29:
- case fpu_s30:
- case fpu_s31:
- value.SetUInt32 (fpu.floats.s[reg], RegisterValue::eTypeFloat);
- break;
-
- case fpu_fpscr:
- value.SetUInt32 (fpu.fpscr);
- break;
-
- case exc_exception:
- value.SetUInt32 (exc.exception);
- break;
- case exc_fsr:
- value.SetUInt32 (exc.fsr);
- break;
- case exc_far:
- value.SetUInt32 (exc.far);
- break;
-
- default:
- value.SetValueToInvalid();
- return false;
-
- }
- return true;
-}
-
-
-bool
-RegisterContextMach_arm::WriteRegister (const RegisterInfo *reg_info,
- const RegisterValue &value)
-{
- const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- int set = GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- switch (reg)
- {
- case gpr_r0:
- case gpr_r1:
- case gpr_r2:
- case gpr_r3:
- case gpr_r4:
- case gpr_r5:
- case gpr_r6:
- case gpr_r7:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_sp:
- case gpr_lr:
- case gpr_pc:
- case gpr_cpsr:
- gpr.r[reg - gpr_r0] = value.GetAsUInt32();
- break;
-
- case fpu_s0:
- case fpu_s1:
- case fpu_s2:
- case fpu_s3:
- case fpu_s4:
- case fpu_s5:
- case fpu_s6:
- case fpu_s7:
- case fpu_s8:
- case fpu_s9:
- case fpu_s10:
- case fpu_s11:
- case fpu_s12:
- case fpu_s13:
- case fpu_s14:
- case fpu_s15:
- case fpu_s16:
- case fpu_s17:
- case fpu_s18:
- case fpu_s19:
- case fpu_s20:
- case fpu_s21:
- case fpu_s22:
- case fpu_s23:
- case fpu_s24:
- case fpu_s25:
- case fpu_s26:
- case fpu_s27:
- case fpu_s28:
- case fpu_s29:
- case fpu_s30:
- case fpu_s31:
- fpu.floats.s[reg] = value.GetAsUInt32();
- break;
-
- case fpu_fpscr:
- fpu.fpscr = value.GetAsUInt32();
- break;
-
- case exc_exception:
- exc.exception = value.GetAsUInt32();
- break;
- case exc_fsr:
- exc.fsr = value.GetAsUInt32();
- break;
- case exc_far:
- exc.far = value.GetAsUInt32();
- break;
-
- default:
- return false;
-
- }
- return WriteRegisterSet(set) == KERN_SUCCESS;
-}
-
-bool
-RegisterContextMach_arm::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
-{
- data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
- if (data_sp &&
- ReadGPR (false) == KERN_SUCCESS &&
- ReadFPU (false) == KERN_SUCCESS &&
- ReadEXC (false) == KERN_SUCCESS)
- {
- uint8_t *dst = data_sp->GetBytes();
- ::memcpy (dst, &gpr, sizeof(gpr));
- dst += sizeof(gpr);
-
- ::memcpy (dst, &fpu, sizeof(fpu));
- dst += sizeof(gpr);
-
- ::memcpy (dst, &exc, sizeof(exc));
- return true;
- }
- return false;
-}
-
-bool
-RegisterContextMach_arm::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
-{
- if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
- {
- const uint8_t *src = data_sp->GetBytes();
- ::memcpy (&gpr, src, sizeof(gpr));
- src += sizeof(gpr);
-
- ::memcpy (&fpu, src, sizeof(fpu));
- src += sizeof(gpr);
-
- ::memcpy (&exc, src, sizeof(exc));
- uint32_t success_count = 0;
- if (WriteGPR() == KERN_SUCCESS)
- ++success_count;
- if (WriteFPU() == KERN_SUCCESS)
- ++success_count;
- if (WriteEXC() == KERN_SUCCESS)
- ++success_count;
- return success_count == 3;
- }
- return false;
-}
-
-uint32_t
-RegisterContextMach_arm::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t reg)
-{
- if (kind == eRegisterKindGeneric)
- {
- switch (reg)
- {
- case LLDB_REGNUM_GENERIC_PC: return gpr_pc;
- case LLDB_REGNUM_GENERIC_SP: return gpr_sp;
- case LLDB_REGNUM_GENERIC_FP: return gpr_r7;
- case LLDB_REGNUM_GENERIC_RA: return gpr_lr;
- case LLDB_REGNUM_GENERIC_FLAGS: return gpr_cpsr;
- default:
- break;
- }
- }
- else if (kind == eRegisterKindDWARF)
- {
- switch (reg)
- {
- case dwarf_r0: return gpr_r0;
- case dwarf_r1: return gpr_r1;
- case dwarf_r2: return gpr_r2;
- case dwarf_r3: return gpr_r3;
- case dwarf_r4: return gpr_r4;
- case dwarf_r5: return gpr_r5;
- case dwarf_r6: return gpr_r6;
- case dwarf_r7: return gpr_r7;
- case dwarf_r8: return gpr_r8;
- case dwarf_r9: return gpr_r9;
- case dwarf_r10: return gpr_r10;
- case dwarf_r11: return gpr_r11;
- case dwarf_r12: return gpr_r12;
- case dwarf_sp: return gpr_sp;
- case dwarf_lr: return gpr_lr;
- case dwarf_pc: return gpr_pc;
- case dwarf_spsr: return gpr_cpsr;
-
- case dwarf_s0: return fpu_s0;
- case dwarf_s1: return fpu_s1;
- case dwarf_s2: return fpu_s2;
- case dwarf_s3: return fpu_s3;
- case dwarf_s4: return fpu_s4;
- case dwarf_s5: return fpu_s5;
- case dwarf_s6: return fpu_s6;
- case dwarf_s7: return fpu_s7;
- case dwarf_s8: return fpu_s8;
- case dwarf_s9: return fpu_s9;
- case dwarf_s10: return fpu_s10;
- case dwarf_s11: return fpu_s11;
- case dwarf_s12: return fpu_s12;
- case dwarf_s13: return fpu_s13;
- case dwarf_s14: return fpu_s14;
- case dwarf_s15: return fpu_s15;
- case dwarf_s16: return fpu_s16;
- case dwarf_s17: return fpu_s17;
- case dwarf_s18: return fpu_s18;
- case dwarf_s19: return fpu_s19;
- case dwarf_s20: return fpu_s20;
- case dwarf_s21: return fpu_s21;
- case dwarf_s22: return fpu_s22;
- case dwarf_s23: return fpu_s23;
- case dwarf_s24: return fpu_s24;
- case dwarf_s25: return fpu_s25;
- case dwarf_s26: return fpu_s26;
- case dwarf_s27: return fpu_s27;
- case dwarf_s28: return fpu_s28;
- case dwarf_s29: return fpu_s29;
- case dwarf_s30: return fpu_s30;
- case dwarf_s31: return fpu_s31;
-
- default:
- break;
- }
- }
- else if (kind == eRegisterKindGCC)
- {
- switch (reg)
- {
- case gcc_r0: return gpr_r0;
- case gcc_r1: return gpr_r1;
- case gcc_r2: return gpr_r2;
- case gcc_r3: return gpr_r3;
- case gcc_r4: return gpr_r4;
- case gcc_r5: return gpr_r5;
- case gcc_r6: return gpr_r6;
- case gcc_r7: return gpr_r7;
- case gcc_r8: return gpr_r8;
- case gcc_r9: return gpr_r9;
- case gcc_r10: return gpr_r10;
- case gcc_r11: return gpr_r11;
- case gcc_r12: return gpr_r12;
- case gcc_sp: return gpr_sp;
- case gcc_lr: return gpr_lr;
- case gcc_pc: return gpr_pc;
- case gcc_cpsr: return gpr_cpsr;
- }
- }
- else if (kind == eRegisterKindLLDB)
- {
- return reg;
- }
- return LLDB_INVALID_REGNUM;
-}
-
-
-uint32_t
-RegisterContextMach_arm::NumSupportedHardwareBreakpoints ()
-{
-#if defined (__arm__)
- // Set the init value to something that will let us know that we need to
- // autodetect how many breakpoints are supported dynamically...
- static uint32_t g_num_supported_hw_breakpoints = UINT32_MAX;
- if (g_num_supported_hw_breakpoints == UINT32_MAX)
- {
- // Set this to zero in case we can't tell if there are any HW breakpoints
- g_num_supported_hw_breakpoints = 0;
-
- uint32_t register_DBGDIDR;
-
- asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
- g_num_supported_hw_breakpoints = bits(register_DBGDIDR, 27, 24);
- // Zero is reserved for the BRP count, so don't increment it if it is zero
- if (g_num_supported_hw_breakpoints > 0)
- g_num_supported_hw_breakpoints++;
- ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_breakpoints);
-
- }
- return g_num_supported_hw_breakpoints;
-#else
- // TODO: figure out remote case here!
- return 6;
-#endif
-}
-
-uint32_t
-RegisterContextMach_arm::SetHardwareBreakpoint (lldb::addr_t addr, size_t size)
+RegisterContextMach_arm::DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg)
{
- // Make sure our address isn't bogus
- if (addr & 1)
- return LLDB_INVALID_INDEX32;
-
- int kret = ReadDBG (false);
-
- if (kret == KERN_SUCCESS)
- {
- const uint32_t num_hw_breakpoints = NumSupportedHardwareBreakpoints();
- uint32_t i;
- for (i=0; i 0x%8.8x.", kret);
-
- if (kret == KERN_SUCCESS)
- return i;
- }
- else
- {
- ProcessMacOSXLog::LogIf(PD_LOG_BREAKPOINTS, "RegisterContextMach_arm::EnableHardwareBreakpoint(addr = %8.8p, size = %u) => all hardware breakpoint resources are being used.", addr, size);
- }
- }
-
- return LLDB_INVALID_INDEX32;
-}
-
-bool
-RegisterContextMach_arm::ClearHardwareBreakpoint (uint32_t hw_index)
-{
- int kret = ReadDBG (false);
-
- const uint32_t num_hw_points = NumSupportedHardwareBreakpoints();
- if (kret == KERN_SUCCESS)
- {
- if (hw_index < num_hw_points)
- {
- dbg.bcr[hw_index] = 0;
- ProcessMacOSXLog::LogIf(PD_LOG_BREAKPOINTS, "RegisterContextMach_arm::SetHardwareBreakpoint( %u ) - BVR%u = 0x%8.8x BCR%u = 0x%8.8x",
- hw_index,
- hw_index,
- dbg.bvr[hw_index],
- hw_index,
- dbg.bcr[hw_index]);
-
- kret = WriteDBG();
-
- if (kret == KERN_SUCCESS)
- return true;
- }
- }
- return false;
-}
-
-uint32_t
-RegisterContextMach_arm::NumSupportedHardwareWatchpoints ()
-{
-#if defined (__arm__)
- // Set the init value to something that will let us know that we need to
- // autodetect how many watchpoints are supported dynamically...
- static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX;
- if (g_num_supported_hw_watchpoints == UINT32_MAX)
- {
- // Set this to zero in case we can't tell if there are any HW breakpoints
- g_num_supported_hw_watchpoints = 0;
-
- uint32_t register_DBGDIDR;
- asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
- g_num_supported_hw_watchpoints = bits(register_DBGDIDR, 31, 28) + 1;
- ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_watchpoints);
- }
- return g_num_supported_hw_watchpoints;
-#else
- // TODO: figure out remote case here!
- return 2;
-#endif
-}
-
-
-uint32_t
-RegisterContextMach_arm::SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write)
-{
- ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextMach_arm::EnableHardwareWatchpoint(addr = %8.8p, size = %u, read = %u, write = %u)", addr, size, read, write);
-
- const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
-
- // Can't watch zero bytes
- if (size == 0)
- return LLDB_INVALID_INDEX32;
-
- // We must watch for either read or write
- if (read == false && write == false)
- return LLDB_INVALID_INDEX32;
-
- // Can't watch more than 4 bytes per WVR/WCR pair
- if (size > 4)
- return LLDB_INVALID_INDEX32;
-
- // We can only watch up to four bytes that follow a 4 byte aligned address
- // per watchpoint register pair. Since we have at most so we can only watch
- // until the next 4 byte boundary and we need to make sure we can properly
- // encode this.
- uint32_t addr_word_offset = addr % 4;
- ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextMach_arm::EnableHardwareWatchpoint() - addr_word_offset = 0x%8.8x", addr_word_offset);
-
- uint32_t byte_mask = ((1u << size) - 1u) << addr_word_offset;
- ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextMach_arm::EnableHardwareWatchpoint() - byte_mask = 0x%8.8x", byte_mask);
- if (byte_mask > 0xfu)
- return LLDB_INVALID_INDEX32;
-
- // Read the debug state
- int kret = ReadDBG (false);
-
- if (kret == KERN_SUCCESS)
- {
- // Check to make sure we have the needed hardware support
- uint32_t i = 0;
-
- for (i=0; i 0x%8.8x.", kret);
-
- if (kret == KERN_SUCCESS)
- return i;
- }
- else
- {
- ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextMach_arm::EnableHardwareWatchpoint(): All hardware resources (%u) are in use.", num_hw_watchpoints);
- }
- }
- return LLDB_INVALID_INDEX32;
-}
-
-bool
-RegisterContextMach_arm::ClearHardwareWatchpoint (uint32_t hw_index)
-{
- int kret = ReadDBG (false);
-
- const uint32_t num_hw_points = NumSupportedHardwareWatchpoints();
- if (kret == KERN_SUCCESS)
- {
- if (hw_index < num_hw_points)
- {
- dbg.wcr[hw_index] = 0;
- ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextMach_arm::ClearHardwareWatchpoint( %u ) - WVR%u = 0x%8.8x WCR%u = 0x%8.8x",
- hw_index,
- hw_index,
- dbg.wvr[hw_index],
- hw_index,
- dbg.wcr[hw_index]);
-
- kret = WriteDBG();
-
- if (kret == KERN_SUCCESS)
- return true;
- }
- }
- return false;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&dbg, DBGWordCount);
}
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h Mon Jul 18 22:57:15 2011
@@ -11,46 +11,13 @@
#define liblldb_RegisterContextMach_arm_h_
// C Includes
-#include
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Target/RegisterContext.h"
+#include "Plugins/Process/Utility/RegisterContextDarwin_arm.h"
-// BCR address match type
-#define BCR_M_IMVA_MATCH ((uint32_t)(0u << 21))
-#define BCR_M_CONTEXT_ID_MATCH ((uint32_t)(1u << 21))
-#define BCR_M_IMVA_MISMATCH ((uint32_t)(2u << 21))
-#define BCR_M_RESERVED ((uint32_t)(3u << 21))
-
-// Link a BVR/BCR or WVR/WCR pair to another
-#define E_ENABLE_LINKING ((uint32_t)(1u << 20))
-
-// Byte Address Select
-#define BAS_IMVA_PLUS_0 ((uint32_t)(1u << 5))
-#define BAS_IMVA_PLUS_1 ((uint32_t)(1u << 6))
-#define BAS_IMVA_PLUS_2 ((uint32_t)(1u << 7))
-#define BAS_IMVA_PLUS_3 ((uint32_t)(1u << 8))
-#define BAS_IMVA_0_1 ((uint32_t)(3u << 5))
-#define BAS_IMVA_2_3 ((uint32_t)(3u << 7))
-#define BAS_IMVA_ALL ((uint32_t)(0xfu << 5))
-
-// Break only in privileged or user mode
-#define S_RSVD ((uint32_t)(0u << 1))
-#define S_PRIV ((uint32_t)(1u << 1))
-#define S_USER ((uint32_t)(2u << 1))
-#define S_PRIV_USER ((S_PRIV) | (S_USER))
-
-#define BCR_ENABLE ((uint32_t)(1u))
-#define WCR_ENABLE ((uint32_t)(1u))
-
-// Watchpoint load/store
-#define WCR_LOAD ((uint32_t)(1u << 3))
-#define WCR_STORE ((uint32_t)(1u << 4))
-
-class RegisterContextMach_arm : public lldb_private::RegisterContext
+class RegisterContextMach_arm : public RegisterContextDarwin_arm
{
public:
@@ -59,242 +26,31 @@
virtual
~RegisterContextMach_arm();
- virtual void
- InvalidateAllRegisters ();
-
- virtual size_t
- GetRegisterCount ();
-
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (uint32_t reg);
-
- virtual size_t
- GetRegisterSetCount ();
-
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (uint32_t set);
-
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue ®_value);
-
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue ®_value);
-
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
-
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
-
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
-
- virtual uint32_t
- NumSupportedHardwareBreakpoints ();
-
- virtual uint32_t
- SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
-
- virtual bool
- ClearHardwareBreakpoint (uint32_t hw_idx);
-
- virtual uint32_t
- NumSupportedHardwareWatchpoints ();
-
- virtual uint32_t
- SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
-
- virtual bool
- ClearHardwareWatchpoint (uint32_t hw_index);
-
- struct GPR
- {
- uint32_t r[16]; // R0-R15
- uint32_t cpsr; // CPSR
- };
-
-
- struct FPU
- {
- union {
- uint32_t s[32];
- uint64_t d[16];
- } floats;
- uint32_t fpscr;
- };
-
-// struct NeonReg
-// {
-// uint8_t bytes[16];
-// };
-//
-// struct VFPv3
-// {
-// union {
-// uint32_t s[32];
-// uint64_t d[32];
-// NeonReg q[16];
-// } v3;
-// uint32_t fpscr;
-// };
-
- struct EXC
- {
- uint32_t exception;
- uint32_t fsr; /* Fault status */
- uint32_t far; /* Virtual Fault Address */
- };
-
- struct DBG
- {
- uint32_t bvr[16];
- uint32_t bcr[16];
- uint32_t wvr[16];
- uint32_t wcr[16];
- };
-
- static void
- LogDBGRegisters (lldb_private::Log *log, const DBG& dbg);
-
protected:
- enum
- {
- GPRRegSet = 1,
- FPURegSet = 2,
- EXCRegSet = 3,
- DBGRegSet = 4,
- };
-
- enum
- {
- GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
- FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
- EXCWordCount = sizeof(EXC)/sizeof(uint32_t),
- DBGWordCount = sizeof(DBG)/sizeof(uint32_t)
- };
-
- enum
- {
- Read = 0,
- Write = 1,
- kNumErrors = 2
- };
-
- GPR gpr;
- FPU fpu;
- EXC exc;
- DBG dbg;
- int gpr_errs[2]; // Read/Write errors
- int fpu_errs[2]; // Read/Write errors
- int exc_errs[2]; // Read/Write errors
- int dbg_errs[2]; // Read/Write errors
-
- void
- InvalidateAllRegisterStates()
- {
- SetError (GPRRegSet, Read, -1);
- SetError (FPURegSet, Read, -1);
- SetError (EXCRegSet, Read, -1);
- }
-
- int
- GetError (int flavor, uint32_t err_idx) const
- {
- if (err_idx < kNumErrors)
- {
- switch (flavor)
- {
- // When getting all errors, just OR all values together to see if
- // we got any kind of error.
- case GPRRegSet: return gpr_errs[err_idx];
- case FPURegSet: return fpu_errs[err_idx];
- case EXCRegSet: return exc_errs[err_idx];
- case DBGRegSet: return dbg_errs[err_idx];
- default: break;
- }
- }
- return -1;
- }
-
- bool
- SetError (int flavor, uint32_t err_idx, int err)
- {
- if (err_idx < kNumErrors)
- {
- switch (flavor)
- {
- case GPRRegSet:
- gpr_errs[err_idx] = err;
- return true;
-
- case FPURegSet:
- fpu_errs[err_idx] = err;
- return true;
-
- case EXCRegSet:
- exc_errs[err_idx] = err;
- return true;
-
- case DBGRegSet:
- exc_errs[err_idx] = err;
- return true;
-
- default: break;
- }
- }
- return false;
- }
-
- bool
- RegisterSetIsCached (int set) const
- {
- return GetError(set, Read) == 0;
- }
-
- int
- ReadGPR (bool force);
-
- int
- ReadFPU (bool force);
-
- int
- ReadEXC (bool force);
-
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
+
int
- ReadDBG (bool force);
-
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
+
int
- WriteGPR ();
-
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
+
int
- WriteFPU ();
-
+ DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg);
+
int
- WriteEXC ();
-
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
+
int
- WriteDBG ();
-
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
+
int
- ReadRegisterSet (uint32_t set, bool force);
-
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
+
int
- WriteRegisterSet (uint32_t set);
-
- static uint32_t
- GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
-
- static int
- GetSetForNativeRegNum (int reg_num);
-
- static size_t
- GetRegisterInfosCount ();
-
- static const lldb_private::RegisterInfo *
- GetRegisterInfos ();
+ DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg);
};
#endif // liblldb_RegisterContextMach_arm_h_
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp Mon Jul 18 22:57:15 2011
@@ -13,965 +13,59 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
-
// Project includes
#include "RegisterContextMach_i386.h"
-#include "ProcessMacOSXLog.h"
using namespace lldb;
using namespace lldb_private;
-enum
-{
- gpr_eax = 0,
- gpr_ebx,
- gpr_ecx,
- gpr_edx,
- gpr_edi,
- gpr_esi,
- gpr_ebp,
- gpr_esp,
- gpr_ss,
- gpr_eflags,
- gpr_eip,
- gpr_cs,
- gpr_ds,
- gpr_es,
- gpr_fs,
- gpr_gs,
-
- fpu_fcw,
- fpu_fsw,
- fpu_ftw,
- fpu_fop,
- fpu_ip,
- fpu_cs,
- fpu_dp,
- fpu_ds,
- fpu_mxcsr,
- fpu_mxcsrmask,
- fpu_stmm0,
- fpu_stmm1,
- fpu_stmm2,
- fpu_stmm3,
- fpu_stmm4,
- fpu_stmm5,
- fpu_stmm6,
- fpu_stmm7,
- fpu_xmm0,
- fpu_xmm1,
- fpu_xmm2,
- fpu_xmm3,
- fpu_xmm4,
- fpu_xmm5,
- fpu_xmm6,
- fpu_xmm7,
-
- exc_trapno,
- exc_err,
- exc_faultvaddr,
-
- k_num_registers,
-
- // Aliases
- fpu_fctrl = fpu_fcw,
- fpu_fstat = fpu_fsw,
- fpu_ftag = fpu_ftw,
- fpu_fiseg = fpu_cs,
- fpu_fioff = fpu_ip,
- fpu_foseg = fpu_ds,
- fpu_fooff = fpu_dp
-};
-
-enum
-{
- gcc_eax = 0,
- gcc_ecx,
- gcc_edx,
- gcc_ebx,
- gcc_ebp,
- gcc_esp,
- gcc_esi,
- gcc_edi,
- gcc_eip,
- gcc_eflags
-};
-enum
-{
- dwarf_eax = 0,
- dwarf_ecx,
- dwarf_edx,
- dwarf_ebx,
- dwarf_esp,
- dwarf_ebp,
- dwarf_esi,
- dwarf_edi,
- dwarf_eip,
- dwarf_eflags,
- dwarf_stmm0 = 11,
- dwarf_stmm1,
- dwarf_stmm2,
- dwarf_stmm3,
- dwarf_stmm4,
- dwarf_stmm5,
- dwarf_stmm6,
- dwarf_stmm7,
- dwarf_xmm0 = 21,
- dwarf_xmm1,
- dwarf_xmm2,
- dwarf_xmm3,
- dwarf_xmm4,
- dwarf_xmm5,
- dwarf_xmm6,
- dwarf_xmm7
-};
-
-enum
-{
- gdb_eax = 0,
- gdb_ecx = 1,
- gdb_edx = 2,
- gdb_ebx = 3,
- gdb_esp = 4,
- gdb_ebp = 5,
- gdb_esi = 6,
- gdb_edi = 7,
- gdb_eip = 8,
- gdb_eflags = 9,
- gdb_cs = 10,
- gdb_ss = 11,
- gdb_ds = 12,
- gdb_es = 13,
- gdb_fs = 14,
- gdb_gs = 15,
- gdb_stmm0 = 16,
- gdb_stmm1 = 17,
- gdb_stmm2 = 18,
- gdb_stmm3 = 19,
- gdb_stmm4 = 20,
- gdb_stmm5 = 21,
- gdb_stmm6 = 22,
- gdb_stmm7 = 23,
- gdb_fctrl = 24, gdb_fcw = gdb_fctrl,
- gdb_fstat = 25, gdb_fsw = gdb_fstat,
- gdb_ftag = 26, gdb_ftw = gdb_ftag,
- gdb_fiseg = 27, gdb_fpu_cs = gdb_fiseg,
- gdb_fioff = 28, gdb_ip = gdb_fioff,
- gdb_foseg = 29, gdb_fpu_ds = gdb_foseg,
- gdb_fooff = 30, gdb_dp = gdb_fooff,
- gdb_fop = 31,
- gdb_xmm0 = 32,
- gdb_xmm1 = 33,
- gdb_xmm2 = 34,
- gdb_xmm3 = 35,
- gdb_xmm4 = 36,
- gdb_xmm5 = 37,
- gdb_xmm6 = 38,
- gdb_xmm7 = 39,
- gdb_mxcsr = 40,
- gdb_mm0 = 41,
- gdb_mm1 = 42,
- gdb_mm2 = 43,
- gdb_mm3 = 44,
- gdb_mm4 = 45,
- gdb_mm5 = 46,
- gdb_mm6 = 47,
- gdb_mm7 = 48
-};
-
-RegisterContextMach_i386::RegisterContextMach_i386 (Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext(thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
+RegisterContextMach_i386::RegisterContextMach_i386(Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContextDarwin_i386 (thread, concrete_frame_idx)
{
- uint32_t i;
- for (i=0; ireg), GPR_OFFSET(reg), eEncodingUint, eFormatHex
-#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextMach_i386::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex
-#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextMach_i386::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_##reg##i, LLDB_INVALID_REGNUM, gdb_##reg##i, fpu_##reg##i }
-
-#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextMach_i386::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex
-#define REG_CONTEXT_SIZE (sizeof (RegisterContextMach_i386::GPR) + sizeof (RegisterContextMach_i386::FPU) + sizeof (RegisterContextMach_i386::EXC))
-
-static RegisterInfo g_register_infos[] =
-{
-// Macro auto defines most stuff GCC REG KIND NUM DWARF REG KIND NUM GENERIC REG KIND NUM GDB REG KIND NUM LLDB REG KIND NUM
-// =============================== ======================= =================== ========================== ========================== =================
- { DEFINE_GPR(eax , NULL) , { gcc_eax , dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax , gpr_eax }},
- { DEFINE_GPR(ebx , NULL) , { gcc_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx , gpr_ebx }},
- { DEFINE_GPR(ecx , NULL) , { gcc_ecx , dwarf_ecx , LLDB_INVALID_REGNUM , gdb_ecx , gpr_ecx }},
- { DEFINE_GPR(edx , NULL) , { gcc_edx , dwarf_edx , LLDB_INVALID_REGNUM , gdb_edx , gpr_edx }},
- { DEFINE_GPR(edi , NULL) , { gcc_edi , dwarf_edi , LLDB_INVALID_REGNUM , gdb_edi , gpr_edi }},
- { DEFINE_GPR(esi , NULL) , { gcc_esi , dwarf_esi , LLDB_INVALID_REGNUM , gdb_esi , gpr_esi }},
- { DEFINE_GPR(ebp , "fp") , { gcc_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp , gpr_ebp }},
- { DEFINE_GPR(esp , "sp") , { gcc_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp , gpr_esp }},
- { DEFINE_GPR(ss , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ss , gpr_ss }},
- { DEFINE_GPR(eflags , "flags") , { gcc_eflags , dwarf_eflags , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags , gpr_eflags }},
- { DEFINE_GPR(eip , "pc") , { gcc_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip , gpr_eip }},
- { DEFINE_GPR(cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , gpr_cs }},
- { DEFINE_GPR(ds , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , gpr_ds }},
- { DEFINE_GPR(es , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_es , gpr_es }},
- { DEFINE_GPR(fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fs , gpr_fs }},
- { DEFINE_GPR(gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gs , gpr_gs }},
-
- { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fcw , fpu_fcw }},
- { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fsw , fpu_fsw }},
- { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ftw , fpu_ftw }},
- { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fop , fpu_fop }},
- { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ip , fpu_ip }},
- { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , fpu_cs }},
- { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_dp , fpu_dp }},
- { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , fpu_ds }},
- { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_mxcsr , fpu_mxcsr }},
- { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , fpu_mxcsrmask }},
- { DEFINE_FPU_VECT(stmm,0) },
- { DEFINE_FPU_VECT(stmm,1) },
- { DEFINE_FPU_VECT(stmm,2) },
- { DEFINE_FPU_VECT(stmm,3) },
- { DEFINE_FPU_VECT(stmm,4) },
- { DEFINE_FPU_VECT(stmm,5) },
- { DEFINE_FPU_VECT(stmm,6) },
- { DEFINE_FPU_VECT(stmm,7) },
- { DEFINE_FPU_VECT(xmm,0) },
- { DEFINE_FPU_VECT(xmm,1) },
- { DEFINE_FPU_VECT(xmm,2) },
- { DEFINE_FPU_VECT(xmm,3) },
- { DEFINE_FPU_VECT(xmm,4) },
- { DEFINE_FPU_VECT(xmm,5) },
- { DEFINE_FPU_VECT(xmm,6) },
- { DEFINE_FPU_VECT(xmm,7) },
-
- { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_trapno }},
- { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_err }},
- { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_faultvaddr }}
-};
-
-static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo));
-
-void
-RegisterContextMach_i386::InvalidateAllRegisters ()
-{
- InvalidateAllRegisterStates();
-}
-
-
-size_t
-RegisterContextMach_i386::GetRegisterCount ()
-{
- assert(k_num_register_infos == k_num_registers);
- return k_num_registers;
-}
-
-const RegisterInfo *
-RegisterContextMach_i386::GetRegisterInfoAtIndex (uint32_t reg)
-{
- assert(k_num_register_infos == k_num_registers);
- if (reg < k_num_registers)
- return &g_register_infos[reg];
- return NULL;
-}
-
-size_t
-RegisterContextMach_i386::GetRegisterInfosCount ()
-{
- return k_num_register_infos;
-}
-
-const RegisterInfo *
-RegisterContextMach_i386::GetRegisterInfos ()
-{
- return g_register_infos;
-}
-
-
-// General purpose registers
-static uint32_t
-g_gpr_regnums[] =
-{
- gpr_eax,
- gpr_ebx,
- gpr_ecx,
- gpr_edx,
- gpr_edi,
- gpr_esi,
- gpr_ebp,
- gpr_esp,
- gpr_ss,
- gpr_eflags,
- gpr_eip,
- gpr_cs,
- gpr_ds,
- gpr_es,
- gpr_fs,
- gpr_gs
-};
-
-// Floating point registers
-static uint32_t
-g_fpu_regnums[] =
-{
- fpu_fcw,
- fpu_fsw,
- fpu_ftw,
- fpu_fop,
- fpu_ip,
- fpu_cs,
- fpu_dp,
- fpu_ds,
- fpu_mxcsr,
- fpu_mxcsrmask,
- fpu_stmm0,
- fpu_stmm1,
- fpu_stmm2,
- fpu_stmm3,
- fpu_stmm4,
- fpu_stmm5,
- fpu_stmm6,
- fpu_stmm7,
- fpu_xmm0,
- fpu_xmm1,
- fpu_xmm2,
- fpu_xmm3,
- fpu_xmm4,
- fpu_xmm5,
- fpu_xmm6,
- fpu_xmm7
-};
-
-// Exception registers
-
-static uint32_t
-g_exc_regnums[] =
-{
- exc_trapno,
- exc_err,
- exc_faultvaddr
-};
-
-// Number of registers in each register set
-const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) / sizeof(uint32_t);
-const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) / sizeof(uint32_t);
-const size_t k_num_exc_registers = sizeof(g_exc_regnums) / sizeof(uint32_t);
-
-//----------------------------------------------------------------------
-// Register set definitions. The first definitions at register set index
-// of zero is for all registers, followed by other registers sets. The
-// register information for the all register set need not be filled in.
-//----------------------------------------------------------------------
-static const RegisterSet g_reg_sets[] =
-{
- { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums, },
- { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums },
- { "Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums }
-};
-
-const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
-
-
-size_t
-RegisterContextMach_i386::GetRegisterSetCount ()
-{
- return k_num_regsets;
-}
-
-const RegisterSet *
-RegisterContextMach_i386::GetRegisterSet (uint32_t reg_set)
-{
- if (reg_set < k_num_regsets)
- return &g_reg_sets[reg_set];
- return NULL;
-}
-
-
-//----------------------------------------------------------------------
-// Register information definitions for 32 bit i386.
-//----------------------------------------------------------------------
int
-RegisterContextMach_i386::GetSetForNativeRegNum (int reg_num)
+RegisterContextMach_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
- if (reg_num < fpu_fcw)
- return GPRRegSet;
- else if (reg_num < exc_trapno)
- return FPURegSet;
- else if (reg_num < k_num_registers)
- return EXCRegSet;
- return -1;
+ mach_msg_type_number_t count = GPRWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
}
-
-void
-RegisterContextMach_i386::LogGPR(Log *log, const char *title)
-{
- if (log)
- {
- if (title)
- log->Printf ("%s", title);
- for (uint32_t i=0; iPrintf("%12s = 0x%8.8x", g_register_infos[reg].name, (&gpr.eax)[reg]);
- }
- }
-}
-
-
-
-kern_return_t
-RegisterContextMach_i386::ReadGPR (bool force)
-{
- int set = GPRRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = GPRWordCount;
- SetError(set, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&gpr, &count));
- LogGPR (ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_THREAD).get(), "RegisterContextMach_i386::ReadGPR()");
- }
- return GetError(set, Read);
-}
-
-kern_return_t
-RegisterContextMach_i386::ReadFPU (bool force)
-{
- int set = FPURegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = FPUWordCount;
- SetError(set, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&fpu, &count));
- }
- return GetError(set, Read);
-}
-
-kern_return_t
-RegisterContextMach_i386::ReadEXC (bool force)
-{
- int set = EXCRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = EXCWordCount;
- SetError(set, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&exc, &count));
- }
- return GetError(set, Read);
-}
-
-kern_return_t
-RegisterContextMach_i386::WriteGPR ()
-{
- int set = GPRRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&gpr, GPRWordCount));
- SetError (set, Read, -1);
- return GetError(set, Write);
-}
-
-kern_return_t
-RegisterContextMach_i386::WriteFPU ()
-{
- int set = FPURegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&fpu, FPUWordCount));
- SetError (set, Read, -1);
- return GetError(set, Write);
-}
-
-kern_return_t
-RegisterContextMach_i386::WriteEXC ()
-{
- int set = EXCRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&exc, EXCWordCount));
- SetError (set, Read, -1);
- return GetError(set, Write);
-}
-
-kern_return_t
-RegisterContextMach_i386::ReadRegisterSet (uint32_t set, bool force)
-{
- switch (set)
- {
- case GPRRegSet: return ReadGPR(force);
- case FPURegSet: return ReadFPU(force);
- case EXCRegSet: return ReadEXC(force);
- default: break;
- }
- return KERN_INVALID_ARGUMENT;
-}
-
-kern_return_t
-RegisterContextMach_i386::WriteRegisterSet (uint32_t set)
-{
- // Make sure we have a valid context to set.
- if (RegisterSetIsCached(set))
- {
- switch (set)
- {
- case GPRRegSet: return WriteGPR();
- case FPURegSet: return WriteFPU();
- case EXCRegSet: return WriteEXC();
- default: break;
- }
- }
- return KERN_INVALID_ARGUMENT;
-}
-
-bool
-RegisterContextMach_i386::ReadRegister (const RegisterInfo *reg_info,
- RegisterValue &value)
-{
- const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- int set = RegisterContextMach_i386::GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- switch (reg)
- {
- case gpr_eax:
- case gpr_ebx:
- case gpr_ecx:
- case gpr_edx:
- case gpr_edi:
- case gpr_esi:
- case gpr_ebp:
- case gpr_esp:
- case gpr_ss:
- case gpr_eflags:
- case gpr_eip:
- case gpr_cs:
- case gpr_ds:
- case gpr_es:
- case gpr_fs:
- case gpr_gs:
- value = (&gpr.eax)[reg - gpr_eax];
- break;
-
- case fpu_fcw:
- value = fpu.fcw;
- break;
-
- case fpu_fsw:
- value = fpu.fsw;
- break;
-
- case fpu_ftw:
- value = fpu.ftw;
- break;
-
- case fpu_fop:
- value = fpu.fop;
- break;
-
- case fpu_ip:
- value = fpu.ip;
- break;
-
- case fpu_cs:
- value = fpu.cs;
- break;
-
- case fpu_dp:
- value = fpu.dp;
- break;
-
- case fpu_ds:
- value = fpu.ds;
- break;
-
- case fpu_mxcsr:
- value = fpu.mxcsr;
- break;
-
- case fpu_mxcsrmask:
- value = fpu.mxcsrmask;
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- // These values don't fit into scalar types,
- // RegisterContext::ReadRegisterBytes() must be used for these
- // registers
- //::memcpy (reg_value.value.vector.uint8, fpu.stmm[reg - fpu_stmm0].bytes, 10);
- return false;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- //::memcpy (reg_value.value.vector.uint8, fpu.xmm[reg - fpu_xmm0].bytes, 16);
- return false;
-
- case exc_trapno:
- value = exc.trapno;
- break;
-
- case exc_err:
- value = exc.err;
- break;
-
- case exc_faultvaddr:
- value = exc.faultvaddr;
- break;
-
- default:
- return false;
- }
- return true;
-}
-
-
-bool
-RegisterContextMach_i386::WriteRegister (const RegisterInfo *reg_info,
- const RegisterValue &value)
+int
+RegisterContextMach_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
- const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- int set = GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- switch (reg)
- {
- case gpr_eax:
- case gpr_ebx:
- case gpr_ecx:
- case gpr_edx:
- case gpr_edi:
- case gpr_esi:
- case gpr_ebp:
- case gpr_esp:
- case gpr_ss:
- case gpr_eflags:
- case gpr_eip:
- case gpr_cs:
- case gpr_ds:
- case gpr_es:
- case gpr_fs:
- case gpr_gs:
- (&gpr.eax)[reg - gpr_eax] = value.GetAsUInt32();
- break;
-
- case fpu_fcw:
- fpu.fcw = value.GetAsUInt16();
- break;
-
- case fpu_fsw:
- fpu.fsw = value.GetAsUInt16();
- break;
-
- case fpu_ftw:
- fpu.ftw = value.GetAsUInt8();
- break;
-
- case fpu_fop:
- fpu.fop = value.GetAsUInt16();
- break;
-
- case fpu_ip:
- fpu.ip = value.GetAsUInt32();
- break;
-
- case fpu_cs:
- fpu.cs = value.GetAsUInt16();
- break;
-
- case fpu_dp:
- fpu.dp = value.GetAsUInt32();
- break;
-
- case fpu_ds:
- fpu.ds = value.GetAsUInt16();
- break;
-
- case fpu_mxcsr:
- fpu.mxcsr = value.GetAsUInt32();
- break;
-
- case fpu_mxcsrmask:
- fpu.mxcsrmask = value.GetAsUInt32();
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize());
- return false;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize());
- return false;
-
- case exc_trapno:
- exc.trapno = value.GetAsUInt32();
- break;
-
- case exc_err:
- exc.err = value.GetAsUInt32();
- break;
-
- case exc_faultvaddr:
- exc.faultvaddr = value.GetAsUInt32();
- break;
-
- default:
- return false;
- }
- return WriteRegisterSet(set) == KERN_SUCCESS;
+ mach_msg_type_number_t count = FPUWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
}
-bool
-RegisterContextMach_i386::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+int
+RegisterContextMach_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
- data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
- if (data_sp &&
- ReadGPR (false) == KERN_SUCCESS &&
- ReadFPU (false) == KERN_SUCCESS &&
- ReadEXC (false) == KERN_SUCCESS)
- {
- uint8_t *dst = data_sp->GetBytes();
- ::memcpy (dst, &gpr, sizeof(gpr));
- dst += sizeof(gpr);
-
- ::memcpy (dst, &fpu, sizeof(fpu));
- dst += sizeof(gpr);
-
- ::memcpy (dst, &exc, sizeof(exc));
- return true;
- }
- return false;
+ mach_msg_type_number_t count = EXCWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
}
-bool
-RegisterContextMach_i386::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
+int
+RegisterContextMach_i386::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
{
- if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
- {
- const uint8_t *src = data_sp->GetBytes();
- ::memcpy (&gpr, src, sizeof(gpr));
- src += sizeof(gpr);
-
- ::memcpy (&fpu, src, sizeof(fpu));
- src += sizeof(gpr);
-
- ::memcpy (&exc, src, sizeof(exc));
- uint32_t success_count = 0;
- if (WriteGPR() == KERN_SUCCESS)
- ++success_count;
- if (WriteFPU() == KERN_SUCCESS)
- ++success_count;
- if (WriteEXC() == KERN_SUCCESS)
- ++success_count;
- return success_count == 3;
- }
- return false;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
}
-
-uint32_t
-RegisterContextMach_i386::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t reg)
+int
+RegisterContextMach_i386::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
{
- if (kind == eRegisterKindGeneric)
- {
- switch (reg)
- {
- case LLDB_REGNUM_GENERIC_PC: return gpr_eip;
- case LLDB_REGNUM_GENERIC_SP: return gpr_esp;
- case LLDB_REGNUM_GENERIC_FP: return gpr_ebp;
- case LLDB_REGNUM_GENERIC_FLAGS: return gpr_eflags;
- case LLDB_REGNUM_GENERIC_RA:
- default:
- break;
- }
- }
- else if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF)
- {
- switch (reg)
- {
- case dwarf_eax: return gpr_eax;
- case dwarf_ecx: return gpr_ecx;
- case dwarf_edx: return gpr_edx;
- case dwarf_ebx: return gpr_ebx;
- case dwarf_esp: return gpr_esp;
- case dwarf_ebp: return gpr_ebp;
- case dwarf_esi: return gpr_esi;
- case dwarf_edi: return gpr_edi;
- case dwarf_eip: return gpr_eip;
- case dwarf_eflags: return gpr_eflags;
- case dwarf_stmm0: return fpu_stmm0;
- case dwarf_stmm1: return fpu_stmm1;
- case dwarf_stmm2: return fpu_stmm2;
- case dwarf_stmm3: return fpu_stmm3;
- case dwarf_stmm4: return fpu_stmm4;
- case dwarf_stmm5: return fpu_stmm5;
- case dwarf_stmm6: return fpu_stmm6;
- case dwarf_stmm7: return fpu_stmm7;
- case dwarf_xmm0: return fpu_xmm0;
- case dwarf_xmm1: return fpu_xmm1;
- case dwarf_xmm2: return fpu_xmm2;
- case dwarf_xmm3: return fpu_xmm3;
- case dwarf_xmm4: return fpu_xmm4;
- case dwarf_xmm5: return fpu_xmm5;
- case dwarf_xmm6: return fpu_xmm6;
- case dwarf_xmm7: return fpu_xmm7;
- default:
- break;
- }
- }
- else if (kind == eRegisterKindGDB)
- {
- switch (reg)
- {
- case gdb_eax : return gpr_eax;
- case gdb_ebx : return gpr_ebx;
- case gdb_ecx : return gpr_ecx;
- case gdb_edx : return gpr_edx;
- case gdb_esi : return gpr_esi;
- case gdb_edi : return gpr_edi;
- case gdb_ebp : return gpr_ebp;
- case gdb_esp : return gpr_esp;
- case gdb_eip : return gpr_eip;
- case gdb_eflags : return gpr_eflags;
- case gdb_cs : return gpr_cs;
- case gdb_ss : return gpr_ss;
- case gdb_ds : return gpr_ds;
- case gdb_es : return gpr_es;
- case gdb_fs : return gpr_fs;
- case gdb_gs : return gpr_gs;
- case gdb_stmm0 : return fpu_stmm0;
- case gdb_stmm1 : return fpu_stmm1;
- case gdb_stmm2 : return fpu_stmm2;
- case gdb_stmm3 : return fpu_stmm3;
- case gdb_stmm4 : return fpu_stmm4;
- case gdb_stmm5 : return fpu_stmm5;
- case gdb_stmm6 : return fpu_stmm6;
- case gdb_stmm7 : return fpu_stmm7;
- case gdb_fctrl : return fpu_fctrl;
- case gdb_fstat : return fpu_fstat;
- case gdb_ftag : return fpu_ftag;
- case gdb_fiseg : return fpu_fiseg;
- case gdb_fioff : return fpu_fioff;
- case gdb_foseg : return fpu_foseg;
- case gdb_fooff : return fpu_fooff;
- case gdb_fop : return fpu_fop;
- case gdb_xmm0 : return fpu_xmm0;
- case gdb_xmm1 : return fpu_xmm1;
- case gdb_xmm2 : return fpu_xmm2;
- case gdb_xmm3 : return fpu_xmm3;
- case gdb_xmm4 : return fpu_xmm4;
- case gdb_xmm5 : return fpu_xmm5;
- case gdb_xmm6 : return fpu_xmm6;
- case gdb_xmm7 : return fpu_xmm7;
- case gdb_mxcsr : return fpu_mxcsr;
- default:
- break;
- }
- }
- else if (kind == eRegisterKindLLDB)
- {
- return reg;
- }
- return LLDB_INVALID_REGNUM;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
}
-
-bool
-RegisterContextMach_i386::HardwareSingleStep (bool enable)
+int
+RegisterContextMach_i386::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
{
- if (ReadGPR(false) != KERN_SUCCESS)
- return false;
-
- const uint32_t trace_bit = 0x100u;
- if (enable)
- {
- // If the trace bit is already set, there is nothing to do
- if (gpr.eflags & trace_bit)
- return true;
- else
- gpr.eflags |= trace_bit;
- }
- else
- {
- // If the trace bit is already cleared, there is nothing to do
- if (gpr.eflags & trace_bit)
- gpr.eflags &= ~trace_bit;
- else
- return true;
- }
-
- return WriteGPR() == KERN_SUCCESS;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
}
-
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h Mon Jul 18 22:57:15 2011
@@ -14,237 +14,36 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Target/RegisterContext.h"
+#include "Plugins/Process/Utility/RegisterContextDarwin_i386.h"
-class RegisterContextMach_i386 : public lldb_private::RegisterContext
+class RegisterContextMach_i386 : public RegisterContextDarwin_i386
{
public:
-
- RegisterContextMach_i386(lldb_private::Thread &thread,
- uint32_t concrete_frame_idx);
-
+
+ RegisterContextMach_i386(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
+
virtual
~RegisterContextMach_i386();
-
- virtual void
- InvalidateAllRegisters ();
-
- virtual size_t
- GetRegisterCount ();
-
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (uint32_t reg);
-
- virtual size_t
- GetRegisterSetCount ();
-
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (uint32_t set);
-
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
-
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
-
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
-
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
-
- virtual bool
- HardwareSingleStep (bool enable);
-
- struct GPR
- {
- uint32_t eax;
- uint32_t ebx;
- uint32_t ecx;
- uint32_t edx;
- uint32_t edi;
- uint32_t esi;
- uint32_t ebp;
- uint32_t esp;
- uint32_t ss;
- uint32_t eflags;
- uint32_t eip;
- uint32_t cs;
- uint32_t ds;
- uint32_t es;
- uint32_t fs;
- uint32_t gs;
- };
-
- struct MMSReg
- {
- uint8_t bytes[10];
- uint8_t pad[6];
- };
-
- struct XMMReg
- {
- uint8_t bytes[16];
- };
-
- struct FPU
- {
- uint32_t pad[2];
- uint16_t fcw;
- uint16_t fsw;
- uint8_t ftw;
- uint8_t pad1;
- uint16_t fop;
- uint32_t ip;
- uint16_t cs;
- uint16_t pad2;
- uint32_t dp;
- uint16_t ds;
- uint16_t pad3;
- uint32_t mxcsr;
- uint32_t mxcsrmask;
- MMSReg stmm[8];
- XMMReg xmm[8];
- uint8_t pad4[14*16];
- int pad5;
- };
-
- struct EXC
- {
- uint32_t trapno;
- uint32_t err;
- uint32_t faultvaddr;
- };
-
protected:
-
- enum
- {
- GPRRegSet = 1,
- FPURegSet = 2,
- EXCRegSet = 3
- };
-
- enum
- {
- GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
- FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
- EXCWordCount = sizeof(EXC)/sizeof(uint32_t)
- };
-
- enum
- {
- Read = 0,
- Write = 1,
- kNumErrors = 2
- };
-
- GPR gpr;
- FPU fpu;
- EXC exc;
- kern_return_t gpr_errs[2]; // Read/Write errors
- kern_return_t fpu_errs[2]; // Read/Write errors
- kern_return_t exc_errs[2]; // Read/Write errors
-
- void
- InvalidateAllRegisterStates()
- {
- SetError (GPRRegSet, Read, -1);
- SetError (FPURegSet, Read, -1);
- SetError (EXCRegSet, Read, -1);
- }
-
- kern_return_t
- GetError (int flavor, uint32_t err_idx) const
- {
- if (err_idx < kNumErrors)
- {
- switch (flavor)
- {
- // When getting all errors, just OR all values together to see if
- // we got any kind of error.
- case GPRRegSet: return gpr_errs[err_idx];
- case FPURegSet: return fpu_errs[err_idx];
- case EXCRegSet: return exc_errs[err_idx];
- default: break;
- }
- }
- return -1;
- }
-
- bool
- SetError (int flavor, uint32_t err_idx, kern_return_t err)
- {
- if (err_idx < kNumErrors)
- {
- switch (flavor)
- {
- case GPRRegSet:
- gpr_errs[err_idx] = err;
- return true;
-
- case FPURegSet:
- fpu_errs[err_idx] = err;
- return true;
-
- case EXCRegSet:
- exc_errs[err_idx] = err;
- return true;
-
- default: break;
- }
- }
- return false;
- }
-
- bool
- RegisterSetIsCached (int set) const
- {
- return GetError(set, Read) == KERN_SUCCESS;
- }
-
- void
- LogGPR (lldb_private::Log *log, const char *title);
-
- kern_return_t
- ReadGPR (bool force);
-
- kern_return_t
- ReadFPU (bool force);
-
- kern_return_t
- ReadEXC (bool force);
-
- kern_return_t
- WriteGPR ();
-
- kern_return_t
- WriteFPU ();
-
- kern_return_t
- WriteEXC ();
-
- kern_return_t
- ReadRegisterSet (uint32_t set, bool force);
-
- kern_return_t
- WriteRegisterSet (uint32_t set);
-
- static uint32_t
- GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
-
- static int
- GetSetForNativeRegNum (int reg_num);
-
- static size_t
- GetRegisterInfosCount ();
-
- static const lldb_private::RegisterInfo *
- GetRegisterInfos ();
+
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
};
#endif // liblldb_RegisterContextMach_i386_h_
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp Mon Jul 18 22:57:15 2011
@@ -13,1055 +13,58 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
-
// Project includes
#include "RegisterContextMach_x86_64.h"
-#include "ProcessMacOSXLog.h"
using namespace lldb;
using namespace lldb_private;
-enum
-{
- gpr_rax = 0,
- gpr_rbx,
- gpr_rcx,
- gpr_rdx,
- gpr_rdi,
- gpr_rsi,
- gpr_rbp,
- gpr_rsp,
- gpr_r8,
- gpr_r9,
- gpr_r10,
- gpr_r11,
- gpr_r12,
- gpr_r13,
- gpr_r14,
- gpr_r15,
- gpr_rip,
- gpr_rflags,
- gpr_cs,
- gpr_fs,
- gpr_gs,
-
- fpu_fcw,
- fpu_fsw,
- fpu_ftw,
- fpu_fop,
- fpu_ip,
- fpu_cs,
- fpu_dp,
- fpu_ds,
- fpu_mxcsr,
- fpu_mxcsrmask,
- fpu_stmm0,
- fpu_stmm1,
- fpu_stmm2,
- fpu_stmm3,
- fpu_stmm4,
- fpu_stmm5,
- fpu_stmm6,
- fpu_stmm7,
- fpu_xmm0,
- fpu_xmm1,
- fpu_xmm2,
- fpu_xmm3,
- fpu_xmm4,
- fpu_xmm5,
- fpu_xmm6,
- fpu_xmm7,
- fpu_xmm8,
- fpu_xmm9,
- fpu_xmm10,
- fpu_xmm11,
- fpu_xmm12,
- fpu_xmm13,
- fpu_xmm14,
- fpu_xmm15,
-
- exc_trapno,
- exc_err,
- exc_faultvaddr,
-
- k_num_registers,
-
- // Aliases
- fpu_fctrl = fpu_fcw,
- fpu_fstat = fpu_fsw,
- fpu_ftag = fpu_ftw,
- fpu_fiseg = fpu_cs,
- fpu_fioff = fpu_ip,
- fpu_foseg = fpu_ds,
- fpu_fooff = fpu_dp,
-};
-
-enum gcc_dwarf_regnums
-{
- gcc_dwarf_gpr_rax = 0,
- gcc_dwarf_gpr_rdx,
- gcc_dwarf_gpr_rcx,
- gcc_dwarf_gpr_rbx,
- gcc_dwarf_gpr_rsi,
- gcc_dwarf_gpr_rdi,
- gcc_dwarf_gpr_rbp,
- gcc_dwarf_gpr_rsp,
- gcc_dwarf_gpr_r8,
- gcc_dwarf_gpr_r9,
- gcc_dwarf_gpr_r10,
- gcc_dwarf_gpr_r11,
- gcc_dwarf_gpr_r12,
- gcc_dwarf_gpr_r13,
- gcc_dwarf_gpr_r14,
- gcc_dwarf_gpr_r15,
- gcc_dwarf_gpr_rip,
- gcc_dwarf_fpu_xmm0,
- gcc_dwarf_fpu_xmm1,
- gcc_dwarf_fpu_xmm2,
- gcc_dwarf_fpu_xmm3,
- gcc_dwarf_fpu_xmm4,
- gcc_dwarf_fpu_xmm5,
- gcc_dwarf_fpu_xmm6,
- gcc_dwarf_fpu_xmm7,
- gcc_dwarf_fpu_xmm8,
- gcc_dwarf_fpu_xmm9,
- gcc_dwarf_fpu_xmm10,
- gcc_dwarf_fpu_xmm11,
- gcc_dwarf_fpu_xmm12,
- gcc_dwarf_fpu_xmm13,
- gcc_dwarf_fpu_xmm14,
- gcc_dwarf_fpu_xmm15,
- gcc_dwarf_fpu_stmm0,
- gcc_dwarf_fpu_stmm1,
- gcc_dwarf_fpu_stmm2,
- gcc_dwarf_fpu_stmm3,
- gcc_dwarf_fpu_stmm4,
- gcc_dwarf_fpu_stmm5,
- gcc_dwarf_fpu_stmm6,
- gcc_dwarf_fpu_stmm7,
-
-};
-enum gdb_regnums
+RegisterContextMach_x86_64::RegisterContextMach_x86_64(Thread &thread, uint32_t concrete_frame_idx) :
+RegisterContextDarwin_x86_64 (thread, concrete_frame_idx)
{
- gdb_gpr_rax = 0,
- gdb_gpr_rbx = 1,
- gdb_gpr_rcx = 2,
- gdb_gpr_rdx = 3,
- gdb_gpr_rsi = 4,
- gdb_gpr_rdi = 5,
- gdb_gpr_rbp = 6,
- gdb_gpr_rsp = 7,
- gdb_gpr_r8 = 8,
- gdb_gpr_r9 = 9,
- gdb_gpr_r10 = 10,
- gdb_gpr_r11 = 11,
- gdb_gpr_r12 = 12,
- gdb_gpr_r13 = 13,
- gdb_gpr_r14 = 14,
- gdb_gpr_r15 = 15,
- gdb_gpr_rip = 16,
- gdb_gpr_rflags = 17,
- gdb_gpr_cs = 18,
- gdb_gpr_ss = 19,
- gdb_gpr_ds = 20,
- gdb_gpr_es = 21,
- gdb_gpr_fs = 22,
- gdb_gpr_gs = 23,
- gdb_fpu_stmm0 = 24,
- gdb_fpu_stmm1 = 25,
- gdb_fpu_stmm2 = 26,
- gdb_fpu_stmm3 = 27,
- gdb_fpu_stmm4 = 28,
- gdb_fpu_stmm5 = 29,
- gdb_fpu_stmm6 = 30,
- gdb_fpu_stmm7 = 31,
- gdb_fpu_fctrl = 32, gdb_fpu_fcw = gdb_fpu_fctrl,
- gdb_fpu_fstat = 33, gdb_fpu_fsw = gdb_fpu_fstat,
- gdb_fpu_ftag = 34, gdb_fpu_ftw = gdb_fpu_ftag,
- gdb_fpu_fiseg = 35, gdb_fpu_cs = gdb_fpu_fiseg,
- gdb_fpu_fioff = 36, gdb_fpu_ip = gdb_fpu_fioff,
- gdb_fpu_foseg = 37, gdb_fpu_ds = gdb_fpu_foseg,
- gdb_fpu_fooff = 38, gdb_fpu_dp = gdb_fpu_fooff,
- gdb_fpu_fop = 39,
- gdb_fpu_xmm0 = 40,
- gdb_fpu_xmm1 = 41,
- gdb_fpu_xmm2 = 42,
- gdb_fpu_xmm3 = 43,
- gdb_fpu_xmm4 = 44,
- gdb_fpu_xmm5 = 45,
- gdb_fpu_xmm6 = 46,
- gdb_fpu_xmm7 = 47,
- gdb_fpu_xmm8 = 48,
- gdb_fpu_xmm9 = 49,
- gdb_fpu_xmm10 = 50,
- gdb_fpu_xmm11 = 51,
- gdb_fpu_xmm12 = 52,
- gdb_fpu_xmm13 = 53,
- gdb_fpu_xmm14 = 54,
- gdb_fpu_xmm15 = 55,
- gdb_fpu_mxcsr = 56,
-};
-
-RegisterContextMach_x86_64::RegisterContextMach_x86_64 (Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext (thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
-{
- uint32_t i;
- for (i=0; ireg), GPR_OFFSET(reg), eEncodingUint, eFormatHex
-#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextMach_x86_64::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex
-#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextMach_x86_64::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i }
-#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextMach_x86_64::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex
-
-#define REG_CONTEXT_SIZE (sizeof (RegisterContextMach_x86_64::GPR) + sizeof (RegisterContextMach_x86_64::FPU) + sizeof (RegisterContextMach_x86_64::EXC))
-
-// General purpose registers for 64 bit
-static RegisterInfo g_register_infos[] =
-{
-// Macro auto defines most stuff GCC REG KIND NUM DWARF REG KIND NUM GENERIC REG KIND NUM GDB REG KIND NUM LLDB REG KIND NUM
-// =============================== ======================= =================== ========================== ========================== =====================
- { DEFINE_GPR (rax , NULL) , { gcc_dwarf_gpr_rax , gcc_dwarf_gpr_rax , LLDB_INVALID_REGNUM , gdb_gpr_rax , gpr_rax }},
- { DEFINE_GPR (rbx , NULL) , { gcc_dwarf_gpr_rbx , gcc_dwarf_gpr_rbx , LLDB_INVALID_REGNUM , gdb_gpr_rbx , gpr_rbx }},
- { DEFINE_GPR (rcx , NULL) , { gcc_dwarf_gpr_rcx , gcc_dwarf_gpr_rcx , LLDB_INVALID_REGNUM , gdb_gpr_rcx , gpr_rcx }},
- { DEFINE_GPR (rdx , NULL) , { gcc_dwarf_gpr_rdx , gcc_dwarf_gpr_rdx , LLDB_INVALID_REGNUM , gdb_gpr_rdx , gpr_rdx }},
- { DEFINE_GPR (rdi , NULL) , { gcc_dwarf_gpr_rdi , gcc_dwarf_gpr_rdi , LLDB_INVALID_REGNUM , gdb_gpr_rdi , gpr_rdi }},
- { DEFINE_GPR (rsi , NULL) , { gcc_dwarf_gpr_rsi , gcc_dwarf_gpr_rsi , LLDB_INVALID_REGNUM , gdb_gpr_rsi , gpr_rsi }},
- { DEFINE_GPR (rbp , "fp") , { gcc_dwarf_gpr_rbp , gcc_dwarf_gpr_rbp , LLDB_REGNUM_GENERIC_FP , gdb_gpr_rbp , gpr_rbp }},
- { DEFINE_GPR (rsp , "sp") , { gcc_dwarf_gpr_rsp , gcc_dwarf_gpr_rsp , LLDB_REGNUM_GENERIC_SP , gdb_gpr_rsp , gpr_rsp }},
- { DEFINE_GPR (r8 , NULL) , { gcc_dwarf_gpr_r8 , gcc_dwarf_gpr_r8 , LLDB_INVALID_REGNUM , gdb_gpr_r8 , gpr_r8 }},
- { DEFINE_GPR (r9 , NULL) , { gcc_dwarf_gpr_r9 , gcc_dwarf_gpr_r9 , LLDB_INVALID_REGNUM , gdb_gpr_r9 , gpr_r9 }},
- { DEFINE_GPR (r10 , NULL) , { gcc_dwarf_gpr_r10 , gcc_dwarf_gpr_r10 , LLDB_INVALID_REGNUM , gdb_gpr_r10 , gpr_r10 }},
- { DEFINE_GPR (r11 , NULL) , { gcc_dwarf_gpr_r11 , gcc_dwarf_gpr_r11 , LLDB_INVALID_REGNUM , gdb_gpr_r11 , gpr_r11 }},
- { DEFINE_GPR (r12 , NULL) , { gcc_dwarf_gpr_r12 , gcc_dwarf_gpr_r12 , LLDB_INVALID_REGNUM , gdb_gpr_r12 , gpr_r12 }},
- { DEFINE_GPR (r13 , NULL) , { gcc_dwarf_gpr_r13 , gcc_dwarf_gpr_r13 , LLDB_INVALID_REGNUM , gdb_gpr_r13 , gpr_r13 }},
- { DEFINE_GPR (r14 , NULL) , { gcc_dwarf_gpr_r14 , gcc_dwarf_gpr_r14 , LLDB_INVALID_REGNUM , gdb_gpr_r14 , gpr_r14 }},
- { DEFINE_GPR (r15 , NULL) , { gcc_dwarf_gpr_r15 , gcc_dwarf_gpr_r15 , LLDB_INVALID_REGNUM , gdb_gpr_r15 , gpr_r15 }},
- { DEFINE_GPR (rip , "pc") , { gcc_dwarf_gpr_rip , gcc_dwarf_gpr_rip , LLDB_REGNUM_GENERIC_PC , gdb_gpr_rip , gpr_rip }},
- { DEFINE_GPR (rflags, "flags") , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , gdb_gpr_rflags , gpr_rflags }},
- { DEFINE_GPR (cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_cs , gpr_cs }},
- { DEFINE_GPR (fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_fs , gpr_fs }},
- { DEFINE_GPR (gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_gs , gpr_gs }},
-
- { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fcw , fpu_fcw }},
- { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fsw , fpu_fsw }},
- { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ftw , fpu_ftw }},
- { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fop , fpu_fop }},
- { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ip , fpu_ip }},
- { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_cs , fpu_cs }},
- { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_dp , fpu_dp }},
- { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ds , fpu_ds }},
- { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_mxcsr , fpu_mxcsr }},
- { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , fpu_mxcsrmask }},
- { DEFINE_FPU_VECT(stmm,0) },
- { DEFINE_FPU_VECT(stmm,1) },
- { DEFINE_FPU_VECT(stmm,2) },
- { DEFINE_FPU_VECT(stmm,3) },
- { DEFINE_FPU_VECT(stmm,4) },
- { DEFINE_FPU_VECT(stmm,5) },
- { DEFINE_FPU_VECT(stmm,6) },
- { DEFINE_FPU_VECT(stmm,7) },
- { DEFINE_FPU_VECT(xmm,0) },
- { DEFINE_FPU_VECT(xmm,1) },
- { DEFINE_FPU_VECT(xmm,2) },
- { DEFINE_FPU_VECT(xmm,3) },
- { DEFINE_FPU_VECT(xmm,4) },
- { DEFINE_FPU_VECT(xmm,5) },
- { DEFINE_FPU_VECT(xmm,6) },
- { DEFINE_FPU_VECT(xmm,7) },
- { DEFINE_FPU_VECT(xmm,8) },
- { DEFINE_FPU_VECT(xmm,9) },
- { DEFINE_FPU_VECT(xmm,10) },
- { DEFINE_FPU_VECT(xmm,11) },
- { DEFINE_FPU_VECT(xmm,12) },
- { DEFINE_FPU_VECT(xmm,13) },
- { DEFINE_FPU_VECT(xmm,14) },
- { DEFINE_FPU_VECT(xmm,15) },
-
- { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_trapno }},
- { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_err }},
- { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_faultvaddr }}
-};
-
-static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo));
-
-
-void
-RegisterContextMach_x86_64::InvalidateAllRegisters ()
-{
- InvalidateAllRegisterStates();
-}
-
-
-size_t
-RegisterContextMach_x86_64::GetRegisterCount ()
-{
- assert(k_num_register_infos == k_num_registers);
- return k_num_registers;
-}
-
-
-const RegisterInfo *
-RegisterContextMach_x86_64::GetRegisterInfoAtIndex (uint32_t reg)
-{
- assert(k_num_register_infos == k_num_registers);
- if (reg < k_num_registers)
- return &g_register_infos[reg];
- return NULL;
-}
-
-
-size_t
-RegisterContextMach_x86_64::GetRegisterInfosCount ()
-{
- return k_num_register_infos;
-}
-
-const lldb_private::RegisterInfo *
-RegisterContextMach_x86_64::GetRegisterInfos ()
-{
- return g_register_infos;
-}
-
-
-
-static uint32_t g_gpr_regnums[] =
-{
- gpr_rax,
- gpr_rbx,
- gpr_rcx,
- gpr_rdx,
- gpr_rdi,
- gpr_rsi,
- gpr_rbp,
- gpr_rsp,
- gpr_r8,
- gpr_r9,
- gpr_r10,
- gpr_r11,
- gpr_r12,
- gpr_r13,
- gpr_r14,
- gpr_r15,
- gpr_rip,
- gpr_rflags,
- gpr_cs,
- gpr_fs,
- gpr_gs
-};
-
-static uint32_t g_fpu_regnums[] =
-{
- fpu_fcw,
- fpu_fsw,
- fpu_ftw,
- fpu_fop,
- fpu_ip,
- fpu_cs,
- fpu_dp,
- fpu_ds,
- fpu_mxcsr,
- fpu_mxcsrmask,
- fpu_stmm0,
- fpu_stmm1,
- fpu_stmm2,
- fpu_stmm3,
- fpu_stmm4,
- fpu_stmm5,
- fpu_stmm6,
- fpu_stmm7,
- fpu_xmm0,
- fpu_xmm1,
- fpu_xmm2,
- fpu_xmm3,
- fpu_xmm4,
- fpu_xmm5,
- fpu_xmm6,
- fpu_xmm7,
- fpu_xmm8,
- fpu_xmm9,
- fpu_xmm10,
- fpu_xmm11,
- fpu_xmm12,
- fpu_xmm13,
- fpu_xmm14,
- fpu_xmm15
-};
-
-static uint32_t
-g_exc_regnums[] =
-{
- exc_trapno,
- exc_err,
- exc_faultvaddr
-};
-
-// Number of registers in each register set
-const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) / sizeof(uint32_t);
-const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) / sizeof(uint32_t);
-const size_t k_num_exc_registers = sizeof(g_exc_regnums) / sizeof(uint32_t);
-
-//----------------------------------------------------------------------
-// Register set definitions. The first definitions at register set index
-// of zero is for all registers, followed by other registers sets. The
-// register information for the all register set need not be filled in.
-//----------------------------------------------------------------------
-static const RegisterSet g_reg_sets[] =
-{
- { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums, },
- { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums },
- { "Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums }
-};
-
-const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
-
-
-size_t
-RegisterContextMach_x86_64::GetRegisterSetCount ()
-{
- return k_num_regsets;
-}
-
-const RegisterSet *
-RegisterContextMach_x86_64::GetRegisterSet (uint32_t reg_set)
-{
- if (reg_set < k_num_regsets)
- return &g_reg_sets[reg_set];
- return NULL;
-}
-
int
-RegisterContextMach_x86_64::GetSetForNativeRegNum (int reg_num)
+RegisterContextMach_x86_64::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
- if (reg_num < fpu_fcw)
- return GPRRegSet;
- else if (reg_num < exc_trapno)
- return FPURegSet;
- else if (reg_num < k_num_registers)
- return EXCRegSet;
- return -1;
+ mach_msg_type_number_t count = GPRWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
}
-void
-RegisterContextMach_x86_64::LogGPR(Log *log, const char *format, ...)
-{
- if (log)
- {
- if (format)
- {
- va_list args;
- va_start (args, format);
- log->VAPrintf (format, args);
- va_end (args);
- }
- for (uint32_t i=0; iPrintf("%12s = 0x%16.16llx", g_register_infos[reg].name, (&gpr.rax)[reg]);
- }
- }
-}
-
-kern_return_t
-RegisterContextMach_x86_64::ReadGPR (bool force)
-{
- int set = GPRRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = GPRWordCount;
- SetError(GPRRegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&gpr, &count));
- LogSP log (ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_THREAD));
- if (log)
- LogGPR (log.get(), "RegisterContextMach_x86_64::ReadGPR(thread = 0x%4.4x)", GetThreadID());
- }
- return GetError(GPRRegSet, Read);
-}
-
-kern_return_t
-RegisterContextMach_x86_64::ReadFPU (bool force)
-{
- int set = FPURegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = FPUWordCount;
- SetError(FPURegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&fpu, &count));
- }
- return GetError(FPURegSet, Read);
-}
-
-kern_return_t
-RegisterContextMach_x86_64::ReadEXC (bool force)
-{
- int set = EXCRegSet;
- if (force || !RegisterSetIsCached(set))
- {
- mach_msg_type_number_t count = EXCWordCount;
- SetError(EXCRegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&exc, &count));
- }
- return GetError(EXCRegSet, Read);
-}
-
-kern_return_t
-RegisterContextMach_x86_64::WriteGPR ()
-{
- int set = GPRRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- LogSP log (ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_THREAD));
- if (log)
- LogGPR (log.get(), "RegisterContextMach_x86_64::WriteGPR (thread = 0x%4.4x)", GetThreadID());
- SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&gpr, GPRWordCount));
- SetError (set, Read, -1);
- return GetError (set, Write);
-}
-
-kern_return_t
-RegisterContextMach_x86_64::WriteFPU ()
-{
- int set = FPURegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&fpu, FPUWordCount));
- SetError (set, Read, -1);
- return GetError (set, Write);
-}
-
-kern_return_t
-RegisterContextMach_x86_64::WriteEXC ()
-{
- int set = EXCRegSet;
- if (!RegisterSetIsCached(set))
- {
- SetError (set, Write, -1);
- return KERN_INVALID_ARGUMENT;
- }
- SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&exc, EXCWordCount));
- SetError (set, Read, -1);
- return GetError (set, Write);
-}
-
-kern_return_t
-RegisterContextMach_x86_64::ReadRegisterSet(uint32_t set, bool force)
-{
- switch (set)
- {
- case GPRRegSet: return ReadGPR (force);
- case FPURegSet: return ReadFPU (force);
- case EXCRegSet: return ReadEXC (force);
- default: break;
- }
- return KERN_INVALID_ARGUMENT;
-}
-
-kern_return_t
-RegisterContextMach_x86_64::WriteRegisterSet(uint32_t set)
-{
- // Make sure we have a valid context to set.
- switch (set)
- {
- case GPRRegSet: return WriteGPR ();
- case FPURegSet: return WriteFPU ();
- case EXCRegSet: return WriteEXC ();
- default: break;
- }
- return KERN_INVALID_ARGUMENT;
-}
-
-
-bool
-RegisterContextMach_x86_64::ReadRegister (const RegisterInfo *reg_info,
- RegisterValue &value)
-{
- const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg);
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- switch (reg)
- {
- case gpr_rax:
- case gpr_rbx:
- case gpr_rcx:
- case gpr_rdx:
- case gpr_rdi:
- case gpr_rsi:
- case gpr_rbp:
- case gpr_rsp:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_r13:
- case gpr_r14:
- case gpr_r15:
- case gpr_rip:
- case gpr_rflags:
- case gpr_cs:
- case gpr_fs:
- case gpr_gs:
- value = (&gpr.rax)[reg - gpr_rax];
- break;
-
- case fpu_fcw:
- value = fpu.fcw;
- break;
-
- case fpu_fsw:
- value = fpu.fsw;
- break;
-
- case fpu_ftw:
- value = fpu.ftw;
- break;
-
- case fpu_fop:
- value = fpu.fop;
- break;
-
- case fpu_ip:
- value = fpu.ip;
- break;
-
- case fpu_cs:
- value = fpu.cs;
- break;
-
- case fpu_dp:
- value = fpu.dp;
- break;
-
- case fpu_ds:
- value = fpu.ds;
- break;
-
- case fpu_mxcsr:
- value = fpu.mxcsr;
- break;
-
- case fpu_mxcsrmask:
- value = fpu.mxcsrmask;
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- value.SetBytes(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- value.SetBytes(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_trapno:
- value = exc.trapno;
- break;
-
- case exc_err:
- value = exc.err;
- break;
-
- case exc_faultvaddr:
- value = exc.faultvaddr;
- break;
-
- default:
- return false;
- }
- return true;
-}
-
-
-bool
-RegisterContextMach_x86_64::WriteRegister (const RegisterInfo *reg_info,
- const RegisterValue &value)
+int
+RegisterContextMach_x86_64::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
- const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- switch (reg)
- {
- case gpr_rax:
- case gpr_rbx:
- case gpr_rcx:
- case gpr_rdx:
- case gpr_rdi:
- case gpr_rsi:
- case gpr_rbp:
- case gpr_rsp:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_r13:
- case gpr_r14:
- case gpr_r15:
- case gpr_rip:
- case gpr_rflags:
- case gpr_cs:
- case gpr_fs:
- case gpr_gs:
- (&gpr.rax)[reg - gpr_rax] = value.GetAsUInt64();
- break;
-
- case fpu_fcw:
- fpu.fcw = value.GetAsUInt16();
- break;
-
- case fpu_fsw:
- fpu.fsw = value.GetAsUInt16();
- break;
-
- case fpu_ftw:
- fpu.ftw = value.GetAsUInt8();
- break;
-
- case fpu_fop:
- fpu.fop = value.GetAsUInt16();
- break;
-
- case fpu_ip:
- fpu.ip = value.GetAsUInt32();
- break;
-
- case fpu_cs:
- fpu.cs = value.GetAsUInt16();
- break;
-
- case fpu_dp:
- fpu.dp = value.GetAsUInt32();
- break;
-
- case fpu_ds:
- fpu.ds = value.GetAsUInt16();
- break;
-
- case fpu_mxcsr:
- fpu.mxcsr = value.GetAsUInt32();
- break;
-
- case fpu_mxcsrmask:
- fpu.mxcsrmask = value.GetAsUInt32();
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize());
- break;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize());
- return false;
-
- case exc_trapno:
- exc.trapno = value.GetAsUInt32();
- break;
-
- case exc_err:
- exc.err = value.GetAsUInt32();
- break;
-
- case exc_faultvaddr:
- exc.faultvaddr = value.GetAsUInt64();
- break;
-
- default:
- return false;
- }
- return WriteRegisterSet(set) == KERN_SUCCESS;
+ mach_msg_type_number_t count = FPUWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
}
-bool
-RegisterContextMach_x86_64::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+int
+RegisterContextMach_x86_64::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
- data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
- if (data_sp &&
- ReadGPR (false) == KERN_SUCCESS &&
- ReadFPU (false) == KERN_SUCCESS &&
- ReadEXC (false) == KERN_SUCCESS)
- {
- uint8_t *dst = data_sp->GetBytes();
- ::memcpy (dst, &gpr, sizeof(gpr));
- dst += sizeof(gpr);
-
- ::memcpy (dst, &fpu, sizeof(fpu));
- dst += sizeof(gpr);
-
- ::memcpy (dst, &exc, sizeof(exc));
- return true;
- }
- return false;
+ mach_msg_type_number_t count = EXCWordCount;
+ return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
}
-bool
-RegisterContextMach_x86_64::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
+int
+RegisterContextMach_x86_64::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
{
- if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
- {
- const uint8_t *src = data_sp->GetBytes();
- ::memcpy (&gpr, src, sizeof(gpr));
- src += sizeof(gpr);
-
- ::memcpy (&fpu, src, sizeof(fpu));
- src += sizeof(gpr);
-
- ::memcpy (&exc, src, sizeof(exc));
- uint32_t success_count = 0;
- if (WriteGPR() == KERN_SUCCESS)
- ++success_count;
- if (WriteFPU() == KERN_SUCCESS)
- ++success_count;
- if (WriteEXC() == KERN_SUCCESS)
- ++success_count;
- return success_count == 3;
- }
- return false;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
}
-
-uint32_t
-RegisterContextMach_x86_64::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t reg)
+int
+RegisterContextMach_x86_64::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
{
- if (kind == eRegisterKindGeneric)
- {
- switch (reg)
- {
- case LLDB_REGNUM_GENERIC_PC: return gpr_rip;
- case LLDB_REGNUM_GENERIC_SP: return gpr_rsp;
- case LLDB_REGNUM_GENERIC_FP: return gpr_rbp;
- case LLDB_REGNUM_GENERIC_FLAGS: return gpr_rflags;
- case LLDB_REGNUM_GENERIC_RA:
- default:
- break;
- }
- }
- else if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF)
- {
- switch (reg)
- {
- case gcc_dwarf_gpr_rax: return gpr_rax;
- case gcc_dwarf_gpr_rdx: return gpr_rdx;
- case gcc_dwarf_gpr_rcx: return gpr_rcx;
- case gcc_dwarf_gpr_rbx: return gpr_rbx;
- case gcc_dwarf_gpr_rsi: return gpr_rsi;
- case gcc_dwarf_gpr_rdi: return gpr_rdi;
- case gcc_dwarf_gpr_rbp: return gpr_rbp;
- case gcc_dwarf_gpr_rsp: return gpr_rsp;
- case gcc_dwarf_gpr_r8: return gpr_r8;
- case gcc_dwarf_gpr_r9: return gpr_r9;
- case gcc_dwarf_gpr_r10: return gpr_r10;
- case gcc_dwarf_gpr_r11: return gpr_r11;
- case gcc_dwarf_gpr_r12: return gpr_r12;
- case gcc_dwarf_gpr_r13: return gpr_r13;
- case gcc_dwarf_gpr_r14: return gpr_r14;
- case gcc_dwarf_gpr_r15: return gpr_r15;
- case gcc_dwarf_gpr_rip: return gpr_rip;
- case gcc_dwarf_fpu_xmm0: return fpu_xmm0;
- case gcc_dwarf_fpu_xmm1: return fpu_xmm1;
- case gcc_dwarf_fpu_xmm2: return fpu_xmm2;
- case gcc_dwarf_fpu_xmm3: return fpu_xmm3;
- case gcc_dwarf_fpu_xmm4: return fpu_xmm4;
- case gcc_dwarf_fpu_xmm5: return fpu_xmm5;
- case gcc_dwarf_fpu_xmm6: return fpu_xmm6;
- case gcc_dwarf_fpu_xmm7: return fpu_xmm7;
- case gcc_dwarf_fpu_xmm8: return fpu_xmm8;
- case gcc_dwarf_fpu_xmm9: return fpu_xmm9;
- case gcc_dwarf_fpu_xmm10: return fpu_xmm10;
- case gcc_dwarf_fpu_xmm11: return fpu_xmm11;
- case gcc_dwarf_fpu_xmm12: return fpu_xmm12;
- case gcc_dwarf_fpu_xmm13: return fpu_xmm13;
- case gcc_dwarf_fpu_xmm14: return fpu_xmm14;
- case gcc_dwarf_fpu_xmm15: return fpu_xmm15;
- case gcc_dwarf_fpu_stmm0: return fpu_stmm0;
- case gcc_dwarf_fpu_stmm1: return fpu_stmm1;
- case gcc_dwarf_fpu_stmm2: return fpu_stmm2;
- case gcc_dwarf_fpu_stmm3: return fpu_stmm3;
- case gcc_dwarf_fpu_stmm4: return fpu_stmm4;
- case gcc_dwarf_fpu_stmm5: return fpu_stmm5;
- case gcc_dwarf_fpu_stmm6: return fpu_stmm6;
- case gcc_dwarf_fpu_stmm7: return fpu_stmm7;
- default:
- break;
- }
- }
- else if (kind == eRegisterKindGDB)
- {
- switch (reg)
- {
- case gdb_gpr_rax : return gpr_rax;
- case gdb_gpr_rbx : return gpr_rbx;
- case gdb_gpr_rcx : return gpr_rcx;
- case gdb_gpr_rdx : return gpr_rdx;
- case gdb_gpr_rsi : return gpr_rsi;
- case gdb_gpr_rdi : return gpr_rdi;
- case gdb_gpr_rbp : return gpr_rbp;
- case gdb_gpr_rsp : return gpr_rsp;
- case gdb_gpr_r8 : return gpr_r8;
- case gdb_gpr_r9 : return gpr_r9;
- case gdb_gpr_r10 : return gpr_r10;
- case gdb_gpr_r11 : return gpr_r11;
- case gdb_gpr_r12 : return gpr_r12;
- case gdb_gpr_r13 : return gpr_r13;
- case gdb_gpr_r14 : return gpr_r14;
- case gdb_gpr_r15 : return gpr_r15;
- case gdb_gpr_rip : return gpr_rip;
- case gdb_gpr_rflags : return gpr_rflags;
- case gdb_gpr_cs : return gpr_cs;
- case gdb_gpr_ss : return gpr_gs; // HACK: For now for "ss", just copy what is in "gs"
- case gdb_gpr_ds : return gpr_gs; // HACK: For now for "ds", just copy what is in "gs"
- case gdb_gpr_es : return gpr_gs; // HACK: For now for "es", just copy what is in "gs"
- case gdb_gpr_fs : return gpr_fs;
- case gdb_gpr_gs : return gpr_gs;
- case gdb_fpu_stmm0 : return fpu_stmm0;
- case gdb_fpu_stmm1 : return fpu_stmm1;
- case gdb_fpu_stmm2 : return fpu_stmm2;
- case gdb_fpu_stmm3 : return fpu_stmm3;
- case gdb_fpu_stmm4 : return fpu_stmm4;
- case gdb_fpu_stmm5 : return fpu_stmm5;
- case gdb_fpu_stmm6 : return fpu_stmm6;
- case gdb_fpu_stmm7 : return fpu_stmm7;
- case gdb_fpu_fctrl : return fpu_fctrl;
- case gdb_fpu_fstat : return fpu_fstat;
- case gdb_fpu_ftag : return fpu_ftag;
- case gdb_fpu_fiseg : return fpu_fiseg;
- case gdb_fpu_fioff : return fpu_fioff;
- case gdb_fpu_foseg : return fpu_foseg;
- case gdb_fpu_fooff : return fpu_fooff;
- case gdb_fpu_fop : return fpu_fop;
- case gdb_fpu_xmm0 : return fpu_xmm0;
- case gdb_fpu_xmm1 : return fpu_xmm1;
- case gdb_fpu_xmm2 : return fpu_xmm2;
- case gdb_fpu_xmm3 : return fpu_xmm3;
- case gdb_fpu_xmm4 : return fpu_xmm4;
- case gdb_fpu_xmm5 : return fpu_xmm5;
- case gdb_fpu_xmm6 : return fpu_xmm6;
- case gdb_fpu_xmm7 : return fpu_xmm7;
- case gdb_fpu_xmm8 : return fpu_xmm8;
- case gdb_fpu_xmm9 : return fpu_xmm9;
- case gdb_fpu_xmm10 : return fpu_xmm10;
- case gdb_fpu_xmm11 : return fpu_xmm11;
- case gdb_fpu_xmm12 : return fpu_xmm12;
- case gdb_fpu_xmm13 : return fpu_xmm13;
- case gdb_fpu_xmm14 : return fpu_xmm14;
- case gdb_fpu_xmm15 : return fpu_xmm15;
- case gdb_fpu_mxcsr : return fpu_mxcsr;
- default:
- break;
- }
- }
- else if (kind == eRegisterKindLLDB)
- {
- return reg;
- }
- return LLDB_INVALID_REGNUM;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
}
-bool
-RegisterContextMach_x86_64::HardwareSingleStep (bool enable)
+int
+RegisterContextMach_x86_64::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
{
- if (ReadGPR(true) != KERN_SUCCESS)
- return false;
-
- const uint64_t trace_bit = 0x100ull;
- if (enable)
- {
-
- if (gpr.rflags & trace_bit)
- return true; // trace bit is already set, there is nothing to do
- else
- gpr.rflags |= trace_bit;
- }
- else
- {
- if (gpr.rflags & trace_bit)
- gpr.rflags &= ~trace_bit;
- else
- return true; // trace bit is clear, there is nothing to do
- }
-
- return WriteGPR() == KERN_SUCCESS;
+ return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
}
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h Mon Jul 18 22:57:15 2011
@@ -1,4 +1,4 @@
-//===-- RegisterContextMach_x86_64.h ----------------------------*- C++ -*-===//
+//===-- RegisterContextMach_x86_64.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,242 +14,36 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Target/RegisterContext.h"
+#include "Plugins/Process/Utility/RegisterContextDarwin_x86_64.h"
-class RegisterContextMach_x86_64 : public lldb_private::RegisterContext
+class RegisterContextMach_x86_64 : public RegisterContextDarwin_x86_64
{
public:
- RegisterContextMach_x86_64 (lldb_private::Thread &thread,
- uint32_t concrete_frame_idx);
-
+
+ RegisterContextMach_x86_64(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
+
virtual
~RegisterContextMach_x86_64();
-
- virtual void
- InvalidateAllRegisters ();
-
- virtual size_t
- GetRegisterCount ();
-
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (uint32_t reg);
-
- virtual size_t
- GetRegisterSetCount ();
-
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (uint32_t set);
-
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
-
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
-
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
-
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
-
- virtual bool
- HardwareSingleStep (bool enable);
-
- struct GPR
- {
- uint64_t rax;
- uint64_t rbx;
- uint64_t rcx;
- uint64_t rdx;
- uint64_t rdi;
- uint64_t rsi;
- uint64_t rbp;
- uint64_t rsp;
- uint64_t r8;
- uint64_t r9;
- uint64_t r10;
- uint64_t r11;
- uint64_t r12;
- uint64_t r13;
- uint64_t r14;
- uint64_t r15;
- uint64_t rip;
- uint64_t rflags;
- uint64_t cs;
- uint64_t fs;
- uint64_t gs;
- };
-
- struct MMSReg
- {
- uint8_t bytes[10];
- uint8_t pad[6];
- };
-
- struct XMMReg
- {
- uint8_t bytes[16];
- };
-
- struct FPU
- {
- uint32_t pad[2];
- uint16_t fcw; // "fctrl"
- uint16_t fsw; // "fstat"
- uint8_t ftw; // "ftag"
- uint8_t pad1;
- uint16_t fop; // "fop"
- uint32_t ip; // "fioff"
- uint16_t cs; // "fiseg"
- uint16_t pad2;
- uint32_t dp; // "fooff"
- uint16_t ds; // "foseg"
- uint16_t pad3;
- uint32_t mxcsr;
- uint32_t mxcsrmask;
- MMSReg stmm[8];
- XMMReg xmm[16];
- uint8_t pad4[6*16];
- int pad5;
- };
-
- struct EXC
- {
- uint32_t trapno;
- uint32_t err;
- uint64_t faultvaddr;
- };
-
protected:
-
- enum
- {
- GPRRegSet = 4,
- FPURegSet = 5,
- EXCRegSet = 6
- };
-
- enum
- {
- GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
- FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
- EXCWordCount = sizeof(EXC)/sizeof(uint32_t)
- };
-
- enum
- {
- Read = 0,
- Write = 1,
- kNumErrors = 2
- };
-
- GPR gpr;
- FPU fpu;
- EXC exc;
- kern_return_t gpr_errs[2]; // Read/Write errors
- kern_return_t fpu_errs[2]; // Read/Write errors
- kern_return_t exc_errs[2]; // Read/Write errors
-
- void
- InvalidateAllRegisterStates()
- {
- SetError (GPRRegSet, Read, -1);
- SetError (FPURegSet, Read, -1);
- SetError (EXCRegSet, Read, -1);
- }
-
- kern_return_t
- GetError (int flavor, uint32_t err_idx) const
- {
- if (err_idx < kNumErrors)
- {
- switch (flavor)
- {
- // When getting all errors, just OR all values together to see if
- // we got any kind of error.
- case GPRRegSet: return gpr_errs[err_idx];
- case FPURegSet: return fpu_errs[err_idx];
- case EXCRegSet: return exc_errs[err_idx];
- default: break;
- }
- }
- return -1;
- }
-
- bool
- SetError (int flavor, uint32_t err_idx, kern_return_t err)
- {
- if (err_idx < kNumErrors)
- {
- switch (flavor)
- {
- case GPRRegSet:
- gpr_errs[err_idx] = err;
- return true;
-
- case FPURegSet:
- fpu_errs[err_idx] = err;
- return true;
-
- case EXCRegSet:
- exc_errs[err_idx] = err;
- return true;
-
- default: break;
- }
- }
- return false;
- }
-
- bool
- RegisterSetIsCached (int set) const
- {
- return GetError(set, Read) == KERN_SUCCESS;
- }
-
- void
- LogGPR (lldb_private::Log *log, const char *format, ...);
-
- kern_return_t
- ReadGPR (bool force);
-
- kern_return_t
- ReadFPU (bool force);
-
- kern_return_t
- ReadEXC (bool force);
-
- kern_return_t
- WriteGPR ();
-
- kern_return_t
- WriteFPU ();
-
- kern_return_t
- WriteEXC ();
-
- kern_return_t
- ReadRegisterSet (uint32_t set, bool force);
-
- kern_return_t
- WriteRegisterSet (uint32_t set);
-
- static uint32_t
- GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
-
- static int
- GetSetForNativeRegNum (int reg_num);
-
- static size_t
- GetRegisterInfosCount ();
-
- static const lldb_private::RegisterInfo *
- GetRegisterInfos ();
-
+
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
};
#endif // liblldb_RegisterContextMach_x86_64_h_
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp Mon Jul 18 22:57:15 2011
@@ -0,0 +1,1216 @@
+//===-- RegisterContextDarwin_arm.cpp ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "RegisterContextDarwin_arm.h"
+
+// C Includes
+#include
+#include
+
+// C++ Includes
+// Other libraries and framework includes
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Host/Endian.h"
+
+// Project includes
+#include "ARM_GCC_Registers.h"
+#include "ARM_DWARF_Registers.h"
+#include "ProcessMacOSXLog.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+enum
+{
+ gpr_r0 = 0,
+ gpr_r1,
+ gpr_r2,
+ gpr_r3,
+ gpr_r4,
+ gpr_r5,
+ gpr_r6,
+ gpr_r7,
+ gpr_r8,
+ gpr_r9,
+ gpr_r10,
+ gpr_r11,
+ gpr_r12,
+ gpr_r13, gpr_sp = gpr_r13,
+ gpr_r14, gpr_lr = gpr_r14,
+ gpr_r15, gpr_pc = gpr_r15,
+ gpr_cpsr,
+
+ fpu_s0,
+ fpu_s1,
+ fpu_s2,
+ fpu_s3,
+ fpu_s4,
+ fpu_s5,
+ fpu_s6,
+ fpu_s7,
+ fpu_s8,
+ fpu_s9,
+ fpu_s10,
+ fpu_s11,
+ fpu_s12,
+ fpu_s13,
+ fpu_s14,
+ fpu_s15,
+ fpu_s16,
+ fpu_s17,
+ fpu_s18,
+ fpu_s19,
+ fpu_s20,
+ fpu_s21,
+ fpu_s22,
+ fpu_s23,
+ fpu_s24,
+ fpu_s25,
+ fpu_s26,
+ fpu_s27,
+ fpu_s28,
+ fpu_s29,
+ fpu_s30,
+ fpu_s31,
+ fpu_fpscr,
+
+ exc_exception,
+ exc_fsr,
+ exc_far,
+
+ dbg_bvr0,
+ dbg_bvr1,
+ dbg_bvr2,
+ dbg_bvr3,
+ dbg_bvr4,
+ dbg_bvr5,
+ dbg_bvr6,
+ dbg_bvr7,
+ dbg_bvr8,
+ dbg_bvr9,
+ dbg_bvr10,
+ dbg_bvr11,
+ dbg_bvr12,
+ dbg_bvr13,
+ dbg_bvr14,
+ dbg_bvr15,
+
+ dbg_bcr0,
+ dbg_bcr1,
+ dbg_bcr2,
+ dbg_bcr3,
+ dbg_bcr4,
+ dbg_bcr5,
+ dbg_bcr6,
+ dbg_bcr7,
+ dbg_bcr8,
+ dbg_bcr9,
+ dbg_bcr10,
+ dbg_bcr11,
+ dbg_bcr12,
+ dbg_bcr13,
+ dbg_bcr14,
+ dbg_bcr15,
+
+ dbg_wvr0,
+ dbg_wvr1,
+ dbg_wvr2,
+ dbg_wvr3,
+ dbg_wvr4,
+ dbg_wvr5,
+ dbg_wvr6,
+ dbg_wvr7,
+ dbg_wvr8,
+ dbg_wvr9,
+ dbg_wvr10,
+ dbg_wvr11,
+ dbg_wvr12,
+ dbg_wvr13,
+ dbg_wvr14,
+ dbg_wvr15,
+
+ dbg_wcr0,
+ dbg_wcr1,
+ dbg_wcr2,
+ dbg_wcr3,
+ dbg_wcr4,
+ dbg_wcr5,
+ dbg_wcr6,
+ dbg_wcr7,
+ dbg_wcr8,
+ dbg_wcr9,
+ dbg_wcr10,
+ dbg_wcr11,
+ dbg_wcr12,
+ dbg_wcr13,
+ dbg_wcr14,
+ dbg_wcr15,
+
+ k_num_registers
+};
+
+
+RegisterContextDarwin_arm::RegisterContextDarwin_arm(Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext(thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; ireg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, dbg_##reg##i }
+#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU) + sizeof (RegisterContextDarwin_arm::EXC))
+
+static RegisterInfo g_register_infos[] = {
+// General purpose registers
+// NAME ALT SZ OFFSET ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE
+// ====== ======= == ============= ============= ============ =============== =============== ========================= ===================== =============
+{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, gdb_arm_r0, gpr_r0 }},
+{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, gdb_arm_r1, gpr_r1 }},
+{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, gdb_arm_r2, gpr_r2 }},
+{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, gdb_arm_r3, gpr_r3 }},
+{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gdb_arm_r4, gpr_r4 }},
+{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gdb_arm_r5, gpr_r5 }},
+{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gdb_arm_r6, gpr_r6 }},
+{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gdb_arm_r7, gpr_r7 }},
+{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gdb_arm_r8, gpr_r8 }},
+{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gdb_arm_r9, gpr_r9 }},
+{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gdb_arm_r10, gpr_r10 }},
+{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gdb_arm_r11, gpr_r11 }},
+{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gdb_arm_r12, gpr_r12 }},
+{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gdb_arm_sp, gpr_sp }},
+{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_arm_lr, gpr_lr }},
+{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_arm_pc, gpr_pc }},
+{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gdb_arm_cpsr, gpr_cpsr }},
+
+{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, gdb_arm_s0, fpu_s0 }},
+{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, gdb_arm_s1, fpu_s1 }},
+{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, gdb_arm_s2, fpu_s2 }},
+{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, gdb_arm_s3, fpu_s3 }},
+{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, gdb_arm_s4, fpu_s4 }},
+{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, gdb_arm_s5, fpu_s5 }},
+{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, gdb_arm_s6, fpu_s6 }},
+{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, gdb_arm_s7, fpu_s7 }},
+{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, gdb_arm_s8, fpu_s8 }},
+{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, gdb_arm_s9, fpu_s9 }},
+{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, gdb_arm_s10, fpu_s10 }},
+{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, gdb_arm_s11, fpu_s11 }},
+{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, gdb_arm_s12, fpu_s12 }},
+{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, gdb_arm_s13, fpu_s13 }},
+{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, gdb_arm_s14, fpu_s14 }},
+{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, gdb_arm_s15, fpu_s15 }},
+{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, gdb_arm_s16, fpu_s16 }},
+{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, gdb_arm_s17, fpu_s17 }},
+{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, gdb_arm_s18, fpu_s18 }},
+{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, gdb_arm_s19, fpu_s19 }},
+{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, gdb_arm_s20, fpu_s20 }},
+{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, gdb_arm_s21, fpu_s21 }},
+{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, gdb_arm_s22, fpu_s22 }},
+{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, gdb_arm_s23, fpu_s23 }},
+{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, gdb_arm_s24, fpu_s24 }},
+{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, gdb_arm_s25, fpu_s25 }},
+{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, gdb_arm_s26, fpu_s26 }},
+{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, gdb_arm_s27, fpu_s27 }},
+{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, gdb_arm_s28, fpu_s28 }},
+{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, gdb_arm_s29, fpu_s29 }},
+{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, gdb_arm_s30, fpu_s30 }},
+{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, gdb_arm_s31, fpu_s31 }},
+{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, gdb_arm_fpscr, fpu_fpscr }},
+
+{ "exception",NULL, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }},
+{ "fsr", NULL, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_fsr }},
+{ "far", NULL, 4, EXC_OFFSET(2), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }},
+
+{ DEFINE_DBG (bvr, 0) },
+{ DEFINE_DBG (bvr, 1) },
+{ DEFINE_DBG (bvr, 2) },
+{ DEFINE_DBG (bvr, 3) },
+{ DEFINE_DBG (bvr, 4) },
+{ DEFINE_DBG (bvr, 5) },
+{ DEFINE_DBG (bvr, 6) },
+{ DEFINE_DBG (bvr, 7) },
+{ DEFINE_DBG (bvr, 8) },
+{ DEFINE_DBG (bvr, 9) },
+{ DEFINE_DBG (bvr, 10) },
+{ DEFINE_DBG (bvr, 11) },
+{ DEFINE_DBG (bvr, 12) },
+{ DEFINE_DBG (bvr, 13) },
+{ DEFINE_DBG (bvr, 14) },
+{ DEFINE_DBG (bvr, 15) },
+
+{ DEFINE_DBG (bcr, 0) },
+{ DEFINE_DBG (bcr, 1) },
+{ DEFINE_DBG (bcr, 2) },
+{ DEFINE_DBG (bcr, 3) },
+{ DEFINE_DBG (bcr, 4) },
+{ DEFINE_DBG (bcr, 5) },
+{ DEFINE_DBG (bcr, 6) },
+{ DEFINE_DBG (bcr, 7) },
+{ DEFINE_DBG (bcr, 8) },
+{ DEFINE_DBG (bcr, 9) },
+{ DEFINE_DBG (bcr, 10) },
+{ DEFINE_DBG (bcr, 11) },
+{ DEFINE_DBG (bcr, 12) },
+{ DEFINE_DBG (bcr, 13) },
+{ DEFINE_DBG (bcr, 14) },
+{ DEFINE_DBG (bcr, 15) },
+
+{ DEFINE_DBG (wvr, 0) },
+{ DEFINE_DBG (wvr, 1) },
+{ DEFINE_DBG (wvr, 2) },
+{ DEFINE_DBG (wvr, 3) },
+{ DEFINE_DBG (wvr, 4) },
+{ DEFINE_DBG (wvr, 5) },
+{ DEFINE_DBG (wvr, 6) },
+{ DEFINE_DBG (wvr, 7) },
+{ DEFINE_DBG (wvr, 8) },
+{ DEFINE_DBG (wvr, 9) },
+{ DEFINE_DBG (wvr, 10) },
+{ DEFINE_DBG (wvr, 11) },
+{ DEFINE_DBG (wvr, 12) },
+{ DEFINE_DBG (wvr, 13) },
+{ DEFINE_DBG (wvr, 14) },
+{ DEFINE_DBG (wvr, 15) },
+
+{ DEFINE_DBG (wcr, 0) },
+{ DEFINE_DBG (wcr, 1) },
+{ DEFINE_DBG (wcr, 2) },
+{ DEFINE_DBG (wcr, 3) },
+{ DEFINE_DBG (wcr, 4) },
+{ DEFINE_DBG (wcr, 5) },
+{ DEFINE_DBG (wcr, 6) },
+{ DEFINE_DBG (wcr, 7) },
+{ DEFINE_DBG (wcr, 8) },
+{ DEFINE_DBG (wcr, 9) },
+{ DEFINE_DBG (wcr, 10) },
+{ DEFINE_DBG (wcr, 11) },
+{ DEFINE_DBG (wcr, 12) },
+{ DEFINE_DBG (wcr, 13) },
+{ DEFINE_DBG (wcr, 14) },
+{ DEFINE_DBG (wcr, 15) }
+};
+
+// General purpose registers
+static uint32_t
+g_gpr_regnums[] =
+{
+ gpr_r0,
+ gpr_r1,
+ gpr_r2,
+ gpr_r3,
+ gpr_r4,
+ gpr_r5,
+ gpr_r6,
+ gpr_r7,
+ gpr_r8,
+ gpr_r9,
+ gpr_r10,
+ gpr_r11,
+ gpr_r12,
+ gpr_sp,
+ gpr_lr,
+ gpr_pc,
+ gpr_cpsr
+};
+
+// Floating point registers
+static uint32_t
+g_fpu_regnums[] =
+{
+ fpu_s0,
+ fpu_s1,
+ fpu_s2,
+ fpu_s3,
+ fpu_s4,
+ fpu_s5,
+ fpu_s6,
+ fpu_s7,
+ fpu_s8,
+ fpu_s9,
+ fpu_s10,
+ fpu_s11,
+ fpu_s12,
+ fpu_s13,
+ fpu_s14,
+ fpu_s15,
+ fpu_s16,
+ fpu_s17,
+ fpu_s18,
+ fpu_s19,
+ fpu_s20,
+ fpu_s21,
+ fpu_s22,
+ fpu_s23,
+ fpu_s24,
+ fpu_s25,
+ fpu_s26,
+ fpu_s27,
+ fpu_s28,
+ fpu_s29,
+ fpu_s30,
+ fpu_s31,
+ fpu_fpscr,
+};
+
+// Exception registers
+
+static uint32_t
+g_exc_regnums[] =
+{
+ exc_exception,
+ exc_fsr,
+ exc_far,
+};
+
+static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo));
+
+void
+RegisterContextDarwin_arm::InvalidateAllRegisters ()
+{
+ InvalidateAllRegisterStates();
+}
+
+
+size_t
+RegisterContextDarwin_arm::GetRegisterCount ()
+{
+ assert(k_num_register_infos == k_num_registers);
+ return k_num_registers;
+}
+
+const RegisterInfo *
+RegisterContextDarwin_arm::GetRegisterInfoAtIndex (uint32_t reg)
+{
+ assert(k_num_register_infos == k_num_registers);
+ if (reg < k_num_registers)
+ return &g_register_infos[reg];
+ return NULL;
+}
+
+size_t
+RegisterContextDarwin_arm::GetRegisterInfosCount ()
+{
+ return k_num_register_infos;
+}
+
+const RegisterInfo *
+RegisterContextDarwin_arm::GetRegisterInfos ()
+{
+ return g_register_infos;
+}
+
+
+// Number of registers in each register set
+const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) / sizeof(uint32_t);
+const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) / sizeof(uint32_t);
+const size_t k_num_exc_registers = sizeof(g_exc_regnums) / sizeof(uint32_t);
+
+//----------------------------------------------------------------------
+// Register set definitions. The first definitions at register set index
+// of zero is for all registers, followed by other registers sets. The
+// register information for the all register set need not be filled in.
+//----------------------------------------------------------------------
+static const RegisterSet g_reg_sets[] =
+{
+ { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums, },
+ { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums },
+ { "Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums }
+};
+
+const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
+
+
+size_t
+RegisterContextDarwin_arm::GetRegisterSetCount ()
+{
+ return k_num_regsets;
+}
+
+const RegisterSet *
+RegisterContextDarwin_arm::GetRegisterSet (uint32_t reg_set)
+{
+ if (reg_set < k_num_regsets)
+ return &g_reg_sets[reg_set];
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------
+// Register information defintions for 32 bit i386.
+//----------------------------------------------------------------------
+int
+RegisterContextDarwin_arm::GetSetForNativeRegNum (int reg)
+{
+ if (reg < fpu_s0)
+ return GPRRegSet;
+ else if (reg < exc_exception)
+ return FPURegSet;
+ else if (reg < k_num_registers)
+ return EXCRegSet;
+ return -1;
+}
+
+int
+RegisterContextDarwin_arm::ReadGPR (bool force)
+{
+ int set = GPRRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadGPR(GetThreadID(), set, gpr));
+ }
+ return GetError(GPRRegSet, Read);
+}
+
+int
+RegisterContextDarwin_arm::ReadFPU (bool force)
+{
+ int set = FPURegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadFPU(GetThreadID(), set, fpu));
+ }
+ return GetError(FPURegSet, Read);
+}
+
+int
+RegisterContextDarwin_arm::ReadEXC (bool force)
+{
+ int set = EXCRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadEXC(GetThreadID(), set, exc));
+ }
+ return GetError(EXCRegSet, Read);
+}
+
+int
+RegisterContextDarwin_arm::ReadDBG (bool force)
+{
+ int set = DBGRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadDBG(GetThreadID(), set, dbg));
+ }
+ return GetError(DBGRegSet, Read);
+}
+
+int
+RegisterContextDarwin_arm::WriteGPR ()
+{
+ int set = GPRRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return KERN_INVALID_ARGUMENT;
+ }
+ SetError (set, Write, DoWriteGPR(GetThreadID(), set, gpr));
+ SetError (set, Read, -1);
+ return GetError(GPRRegSet, Write);
+}
+
+int
+RegisterContextDarwin_arm::WriteFPU ()
+{
+ int set = FPURegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return KERN_INVALID_ARGUMENT;
+ }
+ SetError (set, Write, DoWriteFPU(GetThreadID(), set, fpu));
+ SetError (set, Read, -1);
+ return GetError(FPURegSet, Write);
+}
+
+int
+RegisterContextDarwin_arm::WriteEXC ()
+{
+ int set = EXCRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return KERN_INVALID_ARGUMENT;
+ }
+ SetError (set, Write, DoWriteEXC(GetThreadID(), set, exc));
+ SetError (set, Read, -1);
+ return GetError(EXCRegSet, Write);
+}
+
+int
+RegisterContextDarwin_arm::WriteDBG ()
+{
+ int set = DBGRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return KERN_INVALID_ARGUMENT;
+ }
+ SetError (set, Write, DoWriteDBG(GetThreadID(), set, dbg));
+ SetError (set, Read, -1);
+ return GetError(DBGRegSet, Write);
+}
+
+
+int
+RegisterContextDarwin_arm::ReadRegisterSet (uint32_t set, bool force)
+{
+ switch (set)
+ {
+ case GPRRegSet: return ReadGPR(force);
+ case FPURegSet: return ReadFPU(force);
+ case EXCRegSet: return ReadEXC(force);
+ case DBGRegSet: return ReadDBG(force);
+ default: break;
+ }
+ return KERN_INVALID_ARGUMENT;
+}
+
+int
+RegisterContextDarwin_arm::WriteRegisterSet (uint32_t set)
+{
+ // Make sure we have a valid context to set.
+ if (RegisterSetIsCached(set))
+ {
+ switch (set)
+ {
+ case GPRRegSet: return WriteGPR();
+ case FPURegSet: return WriteFPU();
+ case EXCRegSet: return WriteEXC();
+ case DBGRegSet: return WriteDBG();
+ default: break;
+ }
+ }
+ return KERN_INVALID_ARGUMENT;
+}
+
+void
+RegisterContextDarwin_arm::LogDBGRegisters (Log *log, const DBG& dbg)
+{
+ if (log)
+ {
+ for (uint32_t i=0; i<16; i++)
+ log->Printf("BVR%-2u/BCR%-2u = { 0x%8.8x, 0x%8.8x } WVR%-2u/WCR%-2u = { 0x%8.8x, 0x%8.8x }",
+ i, i, dbg.bvr[i], dbg.bcr[i],
+ i, i, dbg.wvr[i], dbg.wcr[i]);
+ }
+}
+
+
+bool
+RegisterContextDarwin_arm::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value)
+{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ int set = RegisterContextDarwin_arm::GetSetForNativeRegNum (reg);
+
+ if (set == -1)
+ return false;
+
+ if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+ return false;
+
+ switch (reg)
+ {
+ case gpr_r0:
+ case gpr_r1:
+ case gpr_r2:
+ case gpr_r3:
+ case gpr_r4:
+ case gpr_r5:
+ case gpr_r6:
+ case gpr_r7:
+ case gpr_r8:
+ case gpr_r9:
+ case gpr_r10:
+ case gpr_r11:
+ case gpr_r12:
+ case gpr_sp:
+ case gpr_lr:
+ case gpr_pc:
+ case gpr_cpsr:
+ value.SetUInt32 (gpr.r[reg - gpr_r0]);
+ break;
+
+ case fpu_s0:
+ case fpu_s1:
+ case fpu_s2:
+ case fpu_s3:
+ case fpu_s4:
+ case fpu_s5:
+ case fpu_s6:
+ case fpu_s7:
+ case fpu_s8:
+ case fpu_s9:
+ case fpu_s10:
+ case fpu_s11:
+ case fpu_s12:
+ case fpu_s13:
+ case fpu_s14:
+ case fpu_s15:
+ case fpu_s16:
+ case fpu_s17:
+ case fpu_s18:
+ case fpu_s19:
+ case fpu_s20:
+ case fpu_s21:
+ case fpu_s22:
+ case fpu_s23:
+ case fpu_s24:
+ case fpu_s25:
+ case fpu_s26:
+ case fpu_s27:
+ case fpu_s28:
+ case fpu_s29:
+ case fpu_s30:
+ case fpu_s31:
+ value.SetUInt32 (fpu.floats.s[reg], RegisterValue::eTypeFloat);
+ break;
+
+ case fpu_fpscr:
+ value.SetUInt32 (fpu.fpscr);
+ break;
+
+ case exc_exception:
+ value.SetUInt32 (exc.exception);
+ break;
+ case exc_fsr:
+ value.SetUInt32 (exc.fsr);
+ break;
+ case exc_far:
+ value.SetUInt32 (exc.far);
+ break;
+
+ default:
+ value.SetValueToInvalid();
+ return false;
+
+ }
+ return true;
+}
+
+
+bool
+RegisterContextDarwin_arm::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
+{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ int set = GetSetForNativeRegNum (reg);
+
+ if (set == -1)
+ return false;
+
+ if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+ return false;
+
+ switch (reg)
+ {
+ case gpr_r0:
+ case gpr_r1:
+ case gpr_r2:
+ case gpr_r3:
+ case gpr_r4:
+ case gpr_r5:
+ case gpr_r6:
+ case gpr_r7:
+ case gpr_r8:
+ case gpr_r9:
+ case gpr_r10:
+ case gpr_r11:
+ case gpr_r12:
+ case gpr_sp:
+ case gpr_lr:
+ case gpr_pc:
+ case gpr_cpsr:
+ gpr.r[reg - gpr_r0] = value.GetAsUInt32();
+ break;
+
+ case fpu_s0:
+ case fpu_s1:
+ case fpu_s2:
+ case fpu_s3:
+ case fpu_s4:
+ case fpu_s5:
+ case fpu_s6:
+ case fpu_s7:
+ case fpu_s8:
+ case fpu_s9:
+ case fpu_s10:
+ case fpu_s11:
+ case fpu_s12:
+ case fpu_s13:
+ case fpu_s14:
+ case fpu_s15:
+ case fpu_s16:
+ case fpu_s17:
+ case fpu_s18:
+ case fpu_s19:
+ case fpu_s20:
+ case fpu_s21:
+ case fpu_s22:
+ case fpu_s23:
+ case fpu_s24:
+ case fpu_s25:
+ case fpu_s26:
+ case fpu_s27:
+ case fpu_s28:
+ case fpu_s29:
+ case fpu_s30:
+ case fpu_s31:
+ fpu.floats.s[reg] = value.GetAsUInt32();
+ break;
+
+ case fpu_fpscr:
+ fpu.fpscr = value.GetAsUInt32();
+ break;
+
+ case exc_exception:
+ exc.exception = value.GetAsUInt32();
+ break;
+ case exc_fsr:
+ exc.fsr = value.GetAsUInt32();
+ break;
+ case exc_far:
+ exc.far = value.GetAsUInt32();
+ break;
+
+ default:
+ return false;
+
+ }
+ return WriteRegisterSet(set) == KERN_SUCCESS;
+}
+
+bool
+RegisterContextDarwin_arm::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+{
+ data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
+ if (data_sp &&
+ ReadGPR (false) == KERN_SUCCESS &&
+ ReadFPU (false) == KERN_SUCCESS &&
+ ReadEXC (false) == KERN_SUCCESS)
+ {
+ uint8_t *dst = data_sp->GetBytes();
+ ::memcpy (dst, &gpr, sizeof(gpr));
+ dst += sizeof(gpr);
+
+ ::memcpy (dst, &fpu, sizeof(fpu));
+ dst += sizeof(gpr);
+
+ ::memcpy (dst, &exc, sizeof(exc));
+ return true;
+ }
+ return false;
+}
+
+bool
+RegisterContextDarwin_arm::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
+{
+ if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
+ {
+ const uint8_t *src = data_sp->GetBytes();
+ ::memcpy (&gpr, src, sizeof(gpr));
+ src += sizeof(gpr);
+
+ ::memcpy (&fpu, src, sizeof(fpu));
+ src += sizeof(gpr);
+
+ ::memcpy (&exc, src, sizeof(exc));
+ uint32_t success_count = 0;
+ if (WriteGPR() == KERN_SUCCESS)
+ ++success_count;
+ if (WriteFPU() == KERN_SUCCESS)
+ ++success_count;
+ if (WriteEXC() == KERN_SUCCESS)
+ ++success_count;
+ return success_count == 3;
+ }
+ return false;
+}
+
+uint32_t
+RegisterContextDarwin_arm::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t reg)
+{
+ if (kind == eRegisterKindGeneric)
+ {
+ switch (reg)
+ {
+ case LLDB_REGNUM_GENERIC_PC: return gpr_pc;
+ case LLDB_REGNUM_GENERIC_SP: return gpr_sp;
+ case LLDB_REGNUM_GENERIC_FP: return gpr_r7;
+ case LLDB_REGNUM_GENERIC_RA: return gpr_lr;
+ case LLDB_REGNUM_GENERIC_FLAGS: return gpr_cpsr;
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindDWARF)
+ {
+ switch (reg)
+ {
+ case dwarf_r0: return gpr_r0;
+ case dwarf_r1: return gpr_r1;
+ case dwarf_r2: return gpr_r2;
+ case dwarf_r3: return gpr_r3;
+ case dwarf_r4: return gpr_r4;
+ case dwarf_r5: return gpr_r5;
+ case dwarf_r6: return gpr_r6;
+ case dwarf_r7: return gpr_r7;
+ case dwarf_r8: return gpr_r8;
+ case dwarf_r9: return gpr_r9;
+ case dwarf_r10: return gpr_r10;
+ case dwarf_r11: return gpr_r11;
+ case dwarf_r12: return gpr_r12;
+ case dwarf_sp: return gpr_sp;
+ case dwarf_lr: return gpr_lr;
+ case dwarf_pc: return gpr_pc;
+ case dwarf_spsr: return gpr_cpsr;
+
+ case dwarf_s0: return fpu_s0;
+ case dwarf_s1: return fpu_s1;
+ case dwarf_s2: return fpu_s2;
+ case dwarf_s3: return fpu_s3;
+ case dwarf_s4: return fpu_s4;
+ case dwarf_s5: return fpu_s5;
+ case dwarf_s6: return fpu_s6;
+ case dwarf_s7: return fpu_s7;
+ case dwarf_s8: return fpu_s8;
+ case dwarf_s9: return fpu_s9;
+ case dwarf_s10: return fpu_s10;
+ case dwarf_s11: return fpu_s11;
+ case dwarf_s12: return fpu_s12;
+ case dwarf_s13: return fpu_s13;
+ case dwarf_s14: return fpu_s14;
+ case dwarf_s15: return fpu_s15;
+ case dwarf_s16: return fpu_s16;
+ case dwarf_s17: return fpu_s17;
+ case dwarf_s18: return fpu_s18;
+ case dwarf_s19: return fpu_s19;
+ case dwarf_s20: return fpu_s20;
+ case dwarf_s21: return fpu_s21;
+ case dwarf_s22: return fpu_s22;
+ case dwarf_s23: return fpu_s23;
+ case dwarf_s24: return fpu_s24;
+ case dwarf_s25: return fpu_s25;
+ case dwarf_s26: return fpu_s26;
+ case dwarf_s27: return fpu_s27;
+ case dwarf_s28: return fpu_s28;
+ case dwarf_s29: return fpu_s29;
+ case dwarf_s30: return fpu_s30;
+ case dwarf_s31: return fpu_s31;
+
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindGCC)
+ {
+ switch (reg)
+ {
+ case gcc_r0: return gpr_r0;
+ case gcc_r1: return gpr_r1;
+ case gcc_r2: return gpr_r2;
+ case gcc_r3: return gpr_r3;
+ case gcc_r4: return gpr_r4;
+ case gcc_r5: return gpr_r5;
+ case gcc_r6: return gpr_r6;
+ case gcc_r7: return gpr_r7;
+ case gcc_r8: return gpr_r8;
+ case gcc_r9: return gpr_r9;
+ case gcc_r10: return gpr_r10;
+ case gcc_r11: return gpr_r11;
+ case gcc_r12: return gpr_r12;
+ case gcc_sp: return gpr_sp;
+ case gcc_lr: return gpr_lr;
+ case gcc_pc: return gpr_pc;
+ case gcc_cpsr: return gpr_cpsr;
+ }
+ }
+ else if (kind == eRegisterKindLLDB)
+ {
+ return reg;
+ }
+ return LLDB_INVALID_REGNUM;
+}
+
+
+uint32_t
+RegisterContextDarwin_arm::NumSupportedHardwareBreakpoints ()
+{
+#if defined (__arm__)
+ // Set the init value to something that will let us know that we need to
+ // autodetect how many breakpoints are supported dynamically...
+ static uint32_t g_num_supported_hw_breakpoints = UINT32_MAX;
+ if (g_num_supported_hw_breakpoints == UINT32_MAX)
+ {
+ // Set this to zero in case we can't tell if there are any HW breakpoints
+ g_num_supported_hw_breakpoints = 0;
+
+ uint32_t register_DBGDIDR;
+
+ asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
+ g_num_supported_hw_breakpoints = bits(register_DBGDIDR, 27, 24);
+ // Zero is reserved for the BRP count, so don't increment it if it is zero
+ if (g_num_supported_hw_breakpoints > 0)
+ g_num_supported_hw_breakpoints++;
+ ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_breakpoints);
+
+ }
+ return g_num_supported_hw_breakpoints;
+#else
+ // TODO: figure out remote case here!
+ return 6;
+#endif
+}
+
+uint32_t
+RegisterContextDarwin_arm::SetHardwareBreakpoint (lldb::addr_t addr, size_t size)
+{
+ // Make sure our address isn't bogus
+ if (addr & 1)
+ return LLDB_INVALID_INDEX32;
+
+ int kret = ReadDBG (false);
+
+ if (kret == KERN_SUCCESS)
+ {
+ const uint32_t num_hw_breakpoints = NumSupportedHardwareBreakpoints();
+ uint32_t i;
+ for (i=0; i 0x%8.8x.", kret);
+
+ if (kret == KERN_SUCCESS)
+ return i;
+ }
+ else
+ {
+ ProcessMacOSXLog::LogIf(PD_LOG_BREAKPOINTS, "RegisterContextDarwin_arm::EnableHardwareBreakpoint(addr = %8.8p, size = %u) => all hardware breakpoint resources are being used.", addr, size);
+ }
+ }
+
+ return LLDB_INVALID_INDEX32;
+}
+
+bool
+RegisterContextDarwin_arm::ClearHardwareBreakpoint (uint32_t hw_index)
+{
+ int kret = ReadDBG (false);
+
+ const uint32_t num_hw_points = NumSupportedHardwareBreakpoints();
+ if (kret == KERN_SUCCESS)
+ {
+ if (hw_index < num_hw_points)
+ {
+ dbg.bcr[hw_index] = 0;
+ ProcessMacOSXLog::LogIf(PD_LOG_BREAKPOINTS, "RegisterContextDarwin_arm::SetHardwareBreakpoint( %u ) - BVR%u = 0x%8.8x BCR%u = 0x%8.8x",
+ hw_index,
+ hw_index,
+ dbg.bvr[hw_index],
+ hw_index,
+ dbg.bcr[hw_index]);
+
+ kret = WriteDBG();
+
+ if (kret == KERN_SUCCESS)
+ return true;
+ }
+ }
+ return false;
+}
+
+uint32_t
+RegisterContextDarwin_arm::NumSupportedHardwareWatchpoints ()
+{
+#if defined (__arm__)
+ // Set the init value to something that will let us know that we need to
+ // autodetect how many watchpoints are supported dynamically...
+ static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX;
+ if (g_num_supported_hw_watchpoints == UINT32_MAX)
+ {
+ // Set this to zero in case we can't tell if there are any HW breakpoints
+ g_num_supported_hw_watchpoints = 0;
+
+ uint32_t register_DBGDIDR;
+ asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
+ g_num_supported_hw_watchpoints = bits(register_DBGDIDR, 31, 28) + 1;
+ ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_watchpoints);
+ }
+ return g_num_supported_hw_watchpoints;
+#else
+ // TODO: figure out remote case here!
+ return 2;
+#endif
+}
+
+
+uint32_t
+RegisterContextDarwin_arm::SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write)
+{
+ ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextDarwin_arm::EnableHardwareWatchpoint(addr = %8.8p, size = %u, read = %u, write = %u)", addr, size, read, write);
+
+ const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
+
+ // Can't watch zero bytes
+ if (size == 0)
+ return LLDB_INVALID_INDEX32;
+
+ // We must watch for either read or write
+ if (read == false && write == false)
+ return LLDB_INVALID_INDEX32;
+
+ // Can't watch more than 4 bytes per WVR/WCR pair
+ if (size > 4)
+ return LLDB_INVALID_INDEX32;
+
+ // We can only watch up to four bytes that follow a 4 byte aligned address
+ // per watchpoint register pair. Since we have at most so we can only watch
+ // until the next 4 byte boundary and we need to make sure we can properly
+ // encode this.
+ uint32_t addr_word_offset = addr % 4;
+ ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextDarwin_arm::EnableHardwareWatchpoint() - addr_word_offset = 0x%8.8x", addr_word_offset);
+
+ uint32_t byte_mask = ((1u << size) - 1u) << addr_word_offset;
+ ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextDarwin_arm::EnableHardwareWatchpoint() - byte_mask = 0x%8.8x", byte_mask);
+ if (byte_mask > 0xfu)
+ return LLDB_INVALID_INDEX32;
+
+ // Read the debug state
+ int kret = ReadDBG (false);
+
+ if (kret == KERN_SUCCESS)
+ {
+ // Check to make sure we have the needed hardware support
+ uint32_t i = 0;
+
+ for (i=0; i 0x%8.8x.", kret);
+
+ if (kret == KERN_SUCCESS)
+ return i;
+ }
+ else
+ {
+ ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextDarwin_arm::EnableHardwareWatchpoint(): All hardware resources (%u) are in use.", num_hw_watchpoints);
+ }
+ }
+ return LLDB_INVALID_INDEX32;
+}
+
+bool
+RegisterContextDarwin_arm::ClearHardwareWatchpoint (uint32_t hw_index)
+{
+ int kret = ReadDBG (false);
+
+ const uint32_t num_hw_points = NumSupportedHardwareWatchpoints();
+ if (kret == KERN_SUCCESS)
+ {
+ if (hw_index < num_hw_points)
+ {
+ dbg.wcr[hw_index] = 0;
+ ProcessMacOSXLog::LogIf(PD_LOG_WATCHPOINTS, "RegisterContextDarwin_arm::ClearHardwareWatchpoint( %u ) - WVR%u = 0x%8.8x WCR%u = 0x%8.8x",
+ hw_index,
+ hw_index,
+ dbg.wvr[hw_index],
+ hw_index,
+ dbg.wcr[hw_index]);
+
+ kret = WriteDBG();
+
+ if (kret == KERN_SUCCESS)
+ return true;
+ }
+ }
+ return false;
+}
+
+
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h Mon Jul 18 22:57:15 2011
@@ -0,0 +1,348 @@
+//===-- RegisterContextDarwin_arm.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_RegisterContextDarwin_arm_h_
+#define liblldb_RegisterContextDarwin_arm_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/RegisterContext.h"
+
+// BCR address match type
+#define BCR_M_IMVA_MATCH ((uint32_t)(0u << 21))
+#define BCR_M_CONTEXT_ID_MATCH ((uint32_t)(1u << 21))
+#define BCR_M_IMVA_MISMATCH ((uint32_t)(2u << 21))
+#define BCR_M_RESERVED ((uint32_t)(3u << 21))
+
+// Link a BVR/BCR or WVR/WCR pair to another
+#define E_ENABLE_LINKING ((uint32_t)(1u << 20))
+
+// Byte Address Select
+#define BAS_IMVA_PLUS_0 ((uint32_t)(1u << 5))
+#define BAS_IMVA_PLUS_1 ((uint32_t)(1u << 6))
+#define BAS_IMVA_PLUS_2 ((uint32_t)(1u << 7))
+#define BAS_IMVA_PLUS_3 ((uint32_t)(1u << 8))
+#define BAS_IMVA_0_1 ((uint32_t)(3u << 5))
+#define BAS_IMVA_2_3 ((uint32_t)(3u << 7))
+#define BAS_IMVA_ALL ((uint32_t)(0xfu << 5))
+
+// Break only in privileged or user mode
+#define S_RSVD ((uint32_t)(0u << 1))
+#define S_PRIV ((uint32_t)(1u << 1))
+#define S_USER ((uint32_t)(2u << 1))
+#define S_PRIV_USER ((S_PRIV) | (S_USER))
+
+#define BCR_ENABLE ((uint32_t)(1u))
+#define WCR_ENABLE ((uint32_t)(1u))
+
+// Watchpoint load/store
+#define WCR_LOAD ((uint32_t)(1u << 3))
+#define WCR_STORE ((uint32_t)(1u << 4))
+
+class RegisterContextDarwin_arm : public lldb_private::RegisterContext
+{
+public:
+
+ RegisterContextDarwin_arm(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
+
+ virtual
+ ~RegisterContextDarwin_arm();
+
+ virtual void
+ InvalidateAllRegisters ();
+
+ virtual size_t
+ GetRegisterCount ();
+
+ virtual const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex (uint32_t reg);
+
+ virtual size_t
+ GetRegisterSetCount ();
+
+ virtual const lldb_private::RegisterSet *
+ GetRegisterSet (uint32_t set);
+
+ virtual bool
+ ReadRegister (const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue ®_value);
+
+ virtual bool
+ WriteRegister (const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue ®_value);
+
+ virtual bool
+ ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+
+ virtual bool
+ WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+
+ virtual uint32_t
+ ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
+
+ virtual uint32_t
+ NumSupportedHardwareBreakpoints ();
+
+ virtual uint32_t
+ SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
+
+ virtual bool
+ ClearHardwareBreakpoint (uint32_t hw_idx);
+
+ virtual uint32_t
+ NumSupportedHardwareWatchpoints ();
+
+ virtual uint32_t
+ SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
+
+ virtual bool
+ ClearHardwareWatchpoint (uint32_t hw_index);
+
+ struct GPR
+ {
+ uint32_t r[16]; // R0-R15
+ uint32_t cpsr; // CPSR
+ };
+
+
+ struct FPU
+ {
+ union {
+ uint32_t s[32];
+ uint64_t d[16];
+ } floats;
+ uint32_t fpscr;
+ };
+
+// struct NeonReg
+// {
+// uint8_t bytes[16];
+// };
+//
+// struct VFPv3
+// {
+// union {
+// uint32_t s[32];
+// uint64_t d[32];
+// NeonReg q[16];
+// } v3;
+// uint32_t fpscr;
+// };
+
+ struct EXC
+ {
+ uint32_t exception;
+ uint32_t fsr; /* Fault status */
+ uint32_t far; /* Virtual Fault Address */
+ };
+
+ struct DBG
+ {
+ uint32_t bvr[16];
+ uint32_t bcr[16];
+ uint32_t wvr[16];
+ uint32_t wcr[16];
+ };
+
+ static void
+ LogDBGRegisters (lldb_private::Log *log, const DBG& dbg);
+
+protected:
+
+ enum
+ {
+ GPRRegSet = 1,
+ FPURegSet = 2,
+ EXCRegSet = 3,
+ DBGRegSet = 4,
+ };
+
+ enum
+ {
+ GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
+ FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
+ EXCWordCount = sizeof(EXC)/sizeof(uint32_t),
+ DBGWordCount = sizeof(DBG)/sizeof(uint32_t)
+ };
+
+ enum
+ {
+ Read = 0,
+ Write = 1,
+ kNumErrors = 2
+ };
+
+ GPR gpr;
+ FPU fpu;
+ EXC exc;
+ DBG dbg;
+ int gpr_errs[2]; // Read/Write errors
+ int fpu_errs[2]; // Read/Write errors
+ int exc_errs[2]; // Read/Write errors
+ int dbg_errs[2]; // Read/Write errors
+
+ void
+ InvalidateAllRegisterStates()
+ {
+ SetError (GPRRegSet, Read, -1);
+ SetError (FPURegSet, Read, -1);
+ SetError (EXCRegSet, Read, -1);
+ }
+
+ int
+ GetError (int flavor, uint32_t err_idx) const
+ {
+ if (err_idx < kNumErrors)
+ {
+ switch (flavor)
+ {
+ // When getting all errors, just OR all values together to see if
+ // we got any kind of error.
+ case GPRRegSet: return gpr_errs[err_idx];
+ case FPURegSet: return fpu_errs[err_idx];
+ case EXCRegSet: return exc_errs[err_idx];
+ case DBGRegSet: return dbg_errs[err_idx];
+ default: break;
+ }
+ }
+ return -1;
+ }
+
+ bool
+ SetError (int flavor, uint32_t err_idx, int err)
+ {
+ if (err_idx < kNumErrors)
+ {
+ switch (flavor)
+ {
+ case GPRRegSet:
+ gpr_errs[err_idx] = err;
+ return true;
+
+ case FPURegSet:
+ fpu_errs[err_idx] = err;
+ return true;
+
+ case EXCRegSet:
+ exc_errs[err_idx] = err;
+ return true;
+
+ case DBGRegSet:
+ exc_errs[err_idx] = err;
+ return true;
+
+ default: break;
+ }
+ }
+ return false;
+ }
+
+ bool
+ RegisterSetIsCached (int set) const
+ {
+ return GetError(set, Read) == 0;
+ }
+
+ int
+ ReadGPR (bool force);
+
+ int
+ ReadFPU (bool force);
+
+ int
+ ReadEXC (bool force);
+
+ int
+ ReadDBG (bool force);
+
+ int
+ WriteGPR ();
+
+ int
+ WriteFPU ();
+
+ int
+ WriteEXC ();
+
+ int
+ WriteDBG ();
+
+
+ // Subclasses override these to do the actual reading.
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
+ {
+ return -1;
+ }
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
+ {
+ return -1;
+ }
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
+ {
+ return -1;
+ }
+
+ int
+ DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg)
+ {
+ return -1;
+ }
+
+ int
+ ReadRegisterSet (uint32_t set, bool force);
+
+ int
+ WriteRegisterSet (uint32_t set);
+
+ static uint32_t
+ GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
+
+ static int
+ GetSetForNativeRegNum (int reg_num);
+
+ static size_t
+ GetRegisterInfosCount ();
+
+ static const lldb_private::RegisterInfo *
+ GetRegisterInfos ();
+};
+
+#endif // liblldb_RegisterContextDarwin_arm_h_
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp Mon Jul 18 22:57:15 2011
@@ -0,0 +1,971 @@
+//===-- RegisterContextDarwin_i386.cpp --------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Host/Endian.h"
+
+// Project includes
+#include "RegisterContextDarwin_i386.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+enum
+{
+ gpr_eax = 0,
+ gpr_ebx,
+ gpr_ecx,
+ gpr_edx,
+ gpr_edi,
+ gpr_esi,
+ gpr_ebp,
+ gpr_esp,
+ gpr_ss,
+ gpr_eflags,
+ gpr_eip,
+ gpr_cs,
+ gpr_ds,
+ gpr_es,
+ gpr_fs,
+ gpr_gs,
+
+ fpu_fcw,
+ fpu_fsw,
+ fpu_ftw,
+ fpu_fop,
+ fpu_ip,
+ fpu_cs,
+ fpu_dp,
+ fpu_ds,
+ fpu_mxcsr,
+ fpu_mxcsrmask,
+ fpu_stmm0,
+ fpu_stmm1,
+ fpu_stmm2,
+ fpu_stmm3,
+ fpu_stmm4,
+ fpu_stmm5,
+ fpu_stmm6,
+ fpu_stmm7,
+ fpu_xmm0,
+ fpu_xmm1,
+ fpu_xmm2,
+ fpu_xmm3,
+ fpu_xmm4,
+ fpu_xmm5,
+ fpu_xmm6,
+ fpu_xmm7,
+
+ exc_trapno,
+ exc_err,
+ exc_faultvaddr,
+
+ k_num_registers,
+
+ // Aliases
+ fpu_fctrl = fpu_fcw,
+ fpu_fstat = fpu_fsw,
+ fpu_ftag = fpu_ftw,
+ fpu_fiseg = fpu_cs,
+ fpu_fioff = fpu_ip,
+ fpu_foseg = fpu_ds,
+ fpu_fooff = fpu_dp
+};
+
+enum
+{
+ gcc_eax = 0,
+ gcc_ecx,
+ gcc_edx,
+ gcc_ebx,
+ gcc_ebp,
+ gcc_esp,
+ gcc_esi,
+ gcc_edi,
+ gcc_eip,
+ gcc_eflags
+};
+
+enum
+{
+ dwarf_eax = 0,
+ dwarf_ecx,
+ dwarf_edx,
+ dwarf_ebx,
+ dwarf_esp,
+ dwarf_ebp,
+ dwarf_esi,
+ dwarf_edi,
+ dwarf_eip,
+ dwarf_eflags,
+ dwarf_stmm0 = 11,
+ dwarf_stmm1,
+ dwarf_stmm2,
+ dwarf_stmm3,
+ dwarf_stmm4,
+ dwarf_stmm5,
+ dwarf_stmm6,
+ dwarf_stmm7,
+ dwarf_xmm0 = 21,
+ dwarf_xmm1,
+ dwarf_xmm2,
+ dwarf_xmm3,
+ dwarf_xmm4,
+ dwarf_xmm5,
+ dwarf_xmm6,
+ dwarf_xmm7
+};
+
+enum
+{
+ gdb_eax = 0,
+ gdb_ecx = 1,
+ gdb_edx = 2,
+ gdb_ebx = 3,
+ gdb_esp = 4,
+ gdb_ebp = 5,
+ gdb_esi = 6,
+ gdb_edi = 7,
+ gdb_eip = 8,
+ gdb_eflags = 9,
+ gdb_cs = 10,
+ gdb_ss = 11,
+ gdb_ds = 12,
+ gdb_es = 13,
+ gdb_fs = 14,
+ gdb_gs = 15,
+ gdb_stmm0 = 16,
+ gdb_stmm1 = 17,
+ gdb_stmm2 = 18,
+ gdb_stmm3 = 19,
+ gdb_stmm4 = 20,
+ gdb_stmm5 = 21,
+ gdb_stmm6 = 22,
+ gdb_stmm7 = 23,
+ gdb_fctrl = 24, gdb_fcw = gdb_fctrl,
+ gdb_fstat = 25, gdb_fsw = gdb_fstat,
+ gdb_ftag = 26, gdb_ftw = gdb_ftag,
+ gdb_fiseg = 27, gdb_fpu_cs = gdb_fiseg,
+ gdb_fioff = 28, gdb_ip = gdb_fioff,
+ gdb_foseg = 29, gdb_fpu_ds = gdb_foseg,
+ gdb_fooff = 30, gdb_dp = gdb_fooff,
+ gdb_fop = 31,
+ gdb_xmm0 = 32,
+ gdb_xmm1 = 33,
+ gdb_xmm2 = 34,
+ gdb_xmm3 = 35,
+ gdb_xmm4 = 36,
+ gdb_xmm5 = 37,
+ gdb_xmm6 = 38,
+ gdb_xmm7 = 39,
+ gdb_mxcsr = 40,
+ gdb_mm0 = 41,
+ gdb_mm1 = 42,
+ gdb_mm2 = 43,
+ gdb_mm3 = 44,
+ gdb_mm4 = 45,
+ gdb_mm5 = 46,
+ gdb_mm6 = 47,
+ gdb_mm7 = 48
+};
+
+RegisterContextDarwin_i386::RegisterContextDarwin_i386 (Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext(thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; ireg), GPR_OFFSET(reg), eEncodingUint, eFormatHex
+#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextDarwin_i386::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex
+#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextDarwin_i386::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_##reg##i, LLDB_INVALID_REGNUM, gdb_##reg##i, fpu_##reg##i }
+
+#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextDarwin_i386::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex
+#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_i386::GPR) + sizeof (RegisterContextDarwin_i386::FPU) + sizeof (RegisterContextDarwin_i386::EXC))
+
+static RegisterInfo g_register_infos[] =
+{
+// Macro auto defines most stuff GCC DWARF GENERIC GDB LLDB
+// =============================== ======================= =================== ========================= ================== =================
+ { DEFINE_GPR(eax , NULL) , { gcc_eax , dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax , gpr_eax }},
+ { DEFINE_GPR(ebx , NULL) , { gcc_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx , gpr_ebx }},
+ { DEFINE_GPR(ecx , NULL) , { gcc_ecx , dwarf_ecx , LLDB_INVALID_REGNUM , gdb_ecx , gpr_ecx }},
+ { DEFINE_GPR(edx , NULL) , { gcc_edx , dwarf_edx , LLDB_INVALID_REGNUM , gdb_edx , gpr_edx }},
+ { DEFINE_GPR(edi , NULL) , { gcc_edi , dwarf_edi , LLDB_INVALID_REGNUM , gdb_edi , gpr_edi }},
+ { DEFINE_GPR(esi , NULL) , { gcc_esi , dwarf_esi , LLDB_INVALID_REGNUM , gdb_esi , gpr_esi }},
+ { DEFINE_GPR(ebp , "fp") , { gcc_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp , gpr_ebp }},
+ { DEFINE_GPR(esp , "sp") , { gcc_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp , gpr_esp }},
+ { DEFINE_GPR(ss , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ss , gpr_ss }},
+ { DEFINE_GPR(eflags , "flags") , { gcc_eflags , dwarf_eflags , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags , gpr_eflags }},
+ { DEFINE_GPR(eip , "pc") , { gcc_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip , gpr_eip }},
+ { DEFINE_GPR(cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_cs , gpr_cs }},
+ { DEFINE_GPR(ds , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ds , gpr_ds }},
+ { DEFINE_GPR(es , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_es , gpr_es }},
+ { DEFINE_GPR(fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fs , gpr_fs }},
+ { DEFINE_GPR(gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gs , gpr_gs }},
+
+ { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fcw , fpu_fcw }},
+ { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fsw , fpu_fsw }},
+ { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ftw , fpu_ftw }},
+ { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fop , fpu_fop }},
+ { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ip , fpu_ip }},
+ { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_cs , fpu_cs }},
+ { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_dp , fpu_dp }},
+ { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ds , fpu_ds }},
+ { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_mxcsr , fpu_mxcsr }},
+ { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsrmask}},
+ { DEFINE_FPU_VECT(stmm,0) },
+ { DEFINE_FPU_VECT(stmm,1) },
+ { DEFINE_FPU_VECT(stmm,2) },
+ { DEFINE_FPU_VECT(stmm,3) },
+ { DEFINE_FPU_VECT(stmm,4) },
+ { DEFINE_FPU_VECT(stmm,5) },
+ { DEFINE_FPU_VECT(stmm,6) },
+ { DEFINE_FPU_VECT(stmm,7) },
+ { DEFINE_FPU_VECT(xmm,0) },
+ { DEFINE_FPU_VECT(xmm,1) },
+ { DEFINE_FPU_VECT(xmm,2) },
+ { DEFINE_FPU_VECT(xmm,3) },
+ { DEFINE_FPU_VECT(xmm,4) },
+ { DEFINE_FPU_VECT(xmm,5) },
+ { DEFINE_FPU_VECT(xmm,6) },
+ { DEFINE_FPU_VECT(xmm,7) },
+
+ { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_trapno }},
+ { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_err }},
+ { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_faultvaddr }}
+};
+
+static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo));
+
+void
+RegisterContextDarwin_i386::InvalidateAllRegisters ()
+{
+ InvalidateAllRegisterStates();
+}
+
+
+size_t
+RegisterContextDarwin_i386::GetRegisterCount ()
+{
+ assert(k_num_register_infos == k_num_registers);
+ return k_num_registers;
+}
+
+const RegisterInfo *
+RegisterContextDarwin_i386::GetRegisterInfoAtIndex (uint32_t reg)
+{
+ assert(k_num_register_infos == k_num_registers);
+ if (reg < k_num_registers)
+ return &g_register_infos[reg];
+ return NULL;
+}
+
+size_t
+RegisterContextDarwin_i386::GetRegisterInfosCount ()
+{
+ return k_num_register_infos;
+}
+
+const RegisterInfo *
+RegisterContextDarwin_i386::GetRegisterInfos ()
+{
+ return g_register_infos;
+}
+
+
+// General purpose registers
+static uint32_t
+g_gpr_regnums[] =
+{
+ gpr_eax,
+ gpr_ebx,
+ gpr_ecx,
+ gpr_edx,
+ gpr_edi,
+ gpr_esi,
+ gpr_ebp,
+ gpr_esp,
+ gpr_ss,
+ gpr_eflags,
+ gpr_eip,
+ gpr_cs,
+ gpr_ds,
+ gpr_es,
+ gpr_fs,
+ gpr_gs
+};
+
+// Floating point registers
+static uint32_t
+g_fpu_regnums[] =
+{
+ fpu_fcw,
+ fpu_fsw,
+ fpu_ftw,
+ fpu_fop,
+ fpu_ip,
+ fpu_cs,
+ fpu_dp,
+ fpu_ds,
+ fpu_mxcsr,
+ fpu_mxcsrmask,
+ fpu_stmm0,
+ fpu_stmm1,
+ fpu_stmm2,
+ fpu_stmm3,
+ fpu_stmm4,
+ fpu_stmm5,
+ fpu_stmm6,
+ fpu_stmm7,
+ fpu_xmm0,
+ fpu_xmm1,
+ fpu_xmm2,
+ fpu_xmm3,
+ fpu_xmm4,
+ fpu_xmm5,
+ fpu_xmm6,
+ fpu_xmm7
+};
+
+// Exception registers
+
+static uint32_t
+g_exc_regnums[] =
+{
+ exc_trapno,
+ exc_err,
+ exc_faultvaddr
+};
+
+// Number of registers in each register set
+const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) / sizeof(uint32_t);
+const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) / sizeof(uint32_t);
+const size_t k_num_exc_registers = sizeof(g_exc_regnums) / sizeof(uint32_t);
+
+//----------------------------------------------------------------------
+// Register set definitions. The first definitions at register set index
+// of zero is for all registers, followed by other registers sets. The
+// register information for the all register set need not be filled in.
+//----------------------------------------------------------------------
+static const RegisterSet g_reg_sets[] =
+{
+ { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums, },
+ { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums },
+ { "Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums }
+};
+
+const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
+
+
+size_t
+RegisterContextDarwin_i386::GetRegisterSetCount ()
+{
+ return k_num_regsets;
+}
+
+const RegisterSet *
+RegisterContextDarwin_i386::GetRegisterSet (uint32_t reg_set)
+{
+ if (reg_set < k_num_regsets)
+ return &g_reg_sets[reg_set];
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------
+// Register information definitions for 32 bit i386.
+//----------------------------------------------------------------------
+int
+RegisterContextDarwin_i386::GetSetForNativeRegNum (int reg_num)
+{
+ if (reg_num < fpu_fcw)
+ return GPRRegSet;
+ else if (reg_num < exc_trapno)
+ return FPURegSet;
+ else if (reg_num < k_num_registers)
+ return EXCRegSet;
+ return -1;
+}
+
+
+void
+RegisterContextDarwin_i386::LogGPR(Log *log, const char *title)
+{
+ if (log)
+ {
+ if (title)
+ log->Printf ("%s", title);
+ for (uint32_t i=0; iPrintf("%12s = 0x%8.8x", g_register_infos[reg].name, (&gpr.eax)[reg]);
+ }
+ }
+}
+
+
+
+int
+RegisterContextDarwin_i386::ReadGPR (bool force)
+{
+ int set = GPRRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadGPR(GetThreadID(), set, gpr));
+ }
+ return GetError(set, Read);
+}
+
+int
+RegisterContextDarwin_i386::ReadFPU (bool force)
+{
+ int set = FPURegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadFPU(GetThreadID(), set, fpu));
+ }
+ return GetError(set, Read);
+}
+
+int
+RegisterContextDarwin_i386::ReadEXC (bool force)
+{
+ int set = EXCRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadEXC(GetThreadID(), set, exc));
+ }
+ return GetError(set, Read);
+}
+
+int
+RegisterContextDarwin_i386::WriteGPR ()
+{
+ int set = GPRRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return -1;
+ }
+ SetError (set, Write, DoWriteGPR(GetThreadID(), set, gpr));
+ SetError (set, Read, -1);
+ return GetError(set, Write);
+}
+
+int
+RegisterContextDarwin_i386::WriteFPU ()
+{
+ int set = FPURegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return -1;
+ }
+ SetError (set, Write, DoWriteFPU(GetThreadID(), set, fpu));
+ SetError (set, Read, -1);
+ return GetError(set, Write);
+}
+
+int
+RegisterContextDarwin_i386::WriteEXC ()
+{
+ int set = EXCRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return -1;
+ }
+ SetError (set, Write, DoWriteEXC(GetThreadID(), set, exc));
+ SetError (set, Read, -1);
+ return GetError(set, Write);
+}
+
+int
+RegisterContextDarwin_i386::ReadRegisterSet (uint32_t set, bool force)
+{
+ switch (set)
+ {
+ case GPRRegSet: return ReadGPR(force);
+ case FPURegSet: return ReadFPU(force);
+ case EXCRegSet: return ReadEXC(force);
+ default: break;
+ }
+ return -1;
+}
+
+int
+RegisterContextDarwin_i386::WriteRegisterSet (uint32_t set)
+{
+ // Make sure we have a valid context to set.
+ if (RegisterSetIsCached(set))
+ {
+ switch (set)
+ {
+ case GPRRegSet: return WriteGPR();
+ case FPURegSet: return WriteFPU();
+ case EXCRegSet: return WriteEXC();
+ default: break;
+ }
+ }
+ return -1;
+}
+
+bool
+RegisterContextDarwin_i386::ReadRegister (const RegisterInfo *reg_info,
+ RegisterValue &value)
+{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ int set = RegisterContextDarwin_i386::GetSetForNativeRegNum (reg);
+
+ if (set == -1)
+ return false;
+
+ if (ReadRegisterSet(set, false) != 0)
+ return false;
+
+ switch (reg)
+ {
+ case gpr_eax:
+ case gpr_ebx:
+ case gpr_ecx:
+ case gpr_edx:
+ case gpr_edi:
+ case gpr_esi:
+ case gpr_ebp:
+ case gpr_esp:
+ case gpr_ss:
+ case gpr_eflags:
+ case gpr_eip:
+ case gpr_cs:
+ case gpr_ds:
+ case gpr_es:
+ case gpr_fs:
+ case gpr_gs:
+ value = (&gpr.eax)[reg - gpr_eax];
+ break;
+
+ case fpu_fcw:
+ value = fpu.fcw;
+ break;
+
+ case fpu_fsw:
+ value = fpu.fsw;
+ break;
+
+ case fpu_ftw:
+ value = fpu.ftw;
+ break;
+
+ case fpu_fop:
+ value = fpu.fop;
+ break;
+
+ case fpu_ip:
+ value = fpu.ip;
+ break;
+
+ case fpu_cs:
+ value = fpu.cs;
+ break;
+
+ case fpu_dp:
+ value = fpu.dp;
+ break;
+
+ case fpu_ds:
+ value = fpu.ds;
+ break;
+
+ case fpu_mxcsr:
+ value = fpu.mxcsr;
+ break;
+
+ case fpu_mxcsrmask:
+ value = fpu.mxcsrmask;
+ break;
+
+ case fpu_stmm0:
+ case fpu_stmm1:
+ case fpu_stmm2:
+ case fpu_stmm3:
+ case fpu_stmm4:
+ case fpu_stmm5:
+ case fpu_stmm6:
+ case fpu_stmm7:
+ // These values don't fit into scalar types,
+ // RegisterContext::ReadRegisterBytes() must be used for these
+ // registers
+ //::memcpy (reg_value.value.vector.uint8, fpu.stmm[reg - fpu_stmm0].bytes, 10);
+ return false;
+
+ case fpu_xmm0:
+ case fpu_xmm1:
+ case fpu_xmm2:
+ case fpu_xmm3:
+ case fpu_xmm4:
+ case fpu_xmm5:
+ case fpu_xmm6:
+ case fpu_xmm7:
+ // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
+ // must be used for these registers
+ //::memcpy (reg_value.value.vector.uint8, fpu.xmm[reg - fpu_xmm0].bytes, 16);
+ return false;
+
+ case exc_trapno:
+ value = exc.trapno;
+ break;
+
+ case exc_err:
+ value = exc.err;
+ break;
+
+ case exc_faultvaddr:
+ value = exc.faultvaddr;
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+}
+
+
+bool
+RegisterContextDarwin_i386::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
+{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ int set = GetSetForNativeRegNum (reg);
+
+ if (set == -1)
+ return false;
+
+ if (ReadRegisterSet(set, false) != 0)
+ return false;
+
+ switch (reg)
+ {
+ case gpr_eax:
+ case gpr_ebx:
+ case gpr_ecx:
+ case gpr_edx:
+ case gpr_edi:
+ case gpr_esi:
+ case gpr_ebp:
+ case gpr_esp:
+ case gpr_ss:
+ case gpr_eflags:
+ case gpr_eip:
+ case gpr_cs:
+ case gpr_ds:
+ case gpr_es:
+ case gpr_fs:
+ case gpr_gs:
+ (&gpr.eax)[reg - gpr_eax] = value.GetAsUInt32();
+ break;
+
+ case fpu_fcw:
+ fpu.fcw = value.GetAsUInt16();
+ break;
+
+ case fpu_fsw:
+ fpu.fsw = value.GetAsUInt16();
+ break;
+
+ case fpu_ftw:
+ fpu.ftw = value.GetAsUInt8();
+ break;
+
+ case fpu_fop:
+ fpu.fop = value.GetAsUInt16();
+ break;
+
+ case fpu_ip:
+ fpu.ip = value.GetAsUInt32();
+ break;
+
+ case fpu_cs:
+ fpu.cs = value.GetAsUInt16();
+ break;
+
+ case fpu_dp:
+ fpu.dp = value.GetAsUInt32();
+ break;
+
+ case fpu_ds:
+ fpu.ds = value.GetAsUInt16();
+ break;
+
+ case fpu_mxcsr:
+ fpu.mxcsr = value.GetAsUInt32();
+ break;
+
+ case fpu_mxcsrmask:
+ fpu.mxcsrmask = value.GetAsUInt32();
+ break;
+
+ case fpu_stmm0:
+ case fpu_stmm1:
+ case fpu_stmm2:
+ case fpu_stmm3:
+ case fpu_stmm4:
+ case fpu_stmm5:
+ case fpu_stmm6:
+ case fpu_stmm7:
+ // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
+ // must be used for these registers
+ ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize());
+ return false;
+
+ case fpu_xmm0:
+ case fpu_xmm1:
+ case fpu_xmm2:
+ case fpu_xmm3:
+ case fpu_xmm4:
+ case fpu_xmm5:
+ case fpu_xmm6:
+ case fpu_xmm7:
+ // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
+ // must be used for these registers
+ ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize());
+ return false;
+
+ case exc_trapno:
+ exc.trapno = value.GetAsUInt32();
+ break;
+
+ case exc_err:
+ exc.err = value.GetAsUInt32();
+ break;
+
+ case exc_faultvaddr:
+ exc.faultvaddr = value.GetAsUInt32();
+ break;
+
+ default:
+ return false;
+ }
+ return WriteRegisterSet(set) == 0;
+}
+
+bool
+RegisterContextDarwin_i386::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+{
+ data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
+ if (data_sp &&
+ ReadGPR (false) == 0 &&
+ ReadFPU (false) == 0 &&
+ ReadEXC (false) == 0)
+ {
+ uint8_t *dst = data_sp->GetBytes();
+ ::memcpy (dst, &gpr, sizeof(gpr));
+ dst += sizeof(gpr);
+
+ ::memcpy (dst, &fpu, sizeof(fpu));
+ dst += sizeof(gpr);
+
+ ::memcpy (dst, &exc, sizeof(exc));
+ return true;
+ }
+ return false;
+}
+
+bool
+RegisterContextDarwin_i386::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
+{
+ if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
+ {
+ const uint8_t *src = data_sp->GetBytes();
+ ::memcpy (&gpr, src, sizeof(gpr));
+ src += sizeof(gpr);
+
+ ::memcpy (&fpu, src, sizeof(fpu));
+ src += sizeof(gpr);
+
+ ::memcpy (&exc, src, sizeof(exc));
+ uint32_t success_count = 0;
+ if (WriteGPR() == 0)
+ ++success_count;
+ if (WriteFPU() == 0)
+ ++success_count;
+ if (WriteEXC() == 0)
+ ++success_count;
+ return success_count == 3;
+ }
+ return false;
+}
+
+
+uint32_t
+RegisterContextDarwin_i386::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t reg)
+{
+ if (kind == eRegisterKindGeneric)
+ {
+ switch (reg)
+ {
+ case LLDB_REGNUM_GENERIC_PC: return gpr_eip;
+ case LLDB_REGNUM_GENERIC_SP: return gpr_esp;
+ case LLDB_REGNUM_GENERIC_FP: return gpr_ebp;
+ case LLDB_REGNUM_GENERIC_FLAGS: return gpr_eflags;
+ case LLDB_REGNUM_GENERIC_RA:
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF)
+ {
+ switch (reg)
+ {
+ case dwarf_eax: return gpr_eax;
+ case dwarf_ecx: return gpr_ecx;
+ case dwarf_edx: return gpr_edx;
+ case dwarf_ebx: return gpr_ebx;
+ case dwarf_esp: return gpr_esp;
+ case dwarf_ebp: return gpr_ebp;
+ case dwarf_esi: return gpr_esi;
+ case dwarf_edi: return gpr_edi;
+ case dwarf_eip: return gpr_eip;
+ case dwarf_eflags: return gpr_eflags;
+ case dwarf_stmm0: return fpu_stmm0;
+ case dwarf_stmm1: return fpu_stmm1;
+ case dwarf_stmm2: return fpu_stmm2;
+ case dwarf_stmm3: return fpu_stmm3;
+ case dwarf_stmm4: return fpu_stmm4;
+ case dwarf_stmm5: return fpu_stmm5;
+ case dwarf_stmm6: return fpu_stmm6;
+ case dwarf_stmm7: return fpu_stmm7;
+ case dwarf_xmm0: return fpu_xmm0;
+ case dwarf_xmm1: return fpu_xmm1;
+ case dwarf_xmm2: return fpu_xmm2;
+ case dwarf_xmm3: return fpu_xmm3;
+ case dwarf_xmm4: return fpu_xmm4;
+ case dwarf_xmm5: return fpu_xmm5;
+ case dwarf_xmm6: return fpu_xmm6;
+ case dwarf_xmm7: return fpu_xmm7;
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindGDB)
+ {
+ switch (reg)
+ {
+ case gdb_eax : return gpr_eax;
+ case gdb_ebx : return gpr_ebx;
+ case gdb_ecx : return gpr_ecx;
+ case gdb_edx : return gpr_edx;
+ case gdb_esi : return gpr_esi;
+ case gdb_edi : return gpr_edi;
+ case gdb_ebp : return gpr_ebp;
+ case gdb_esp : return gpr_esp;
+ case gdb_eip : return gpr_eip;
+ case gdb_eflags : return gpr_eflags;
+ case gdb_cs : return gpr_cs;
+ case gdb_ss : return gpr_ss;
+ case gdb_ds : return gpr_ds;
+ case gdb_es : return gpr_es;
+ case gdb_fs : return gpr_fs;
+ case gdb_gs : return gpr_gs;
+ case gdb_stmm0 : return fpu_stmm0;
+ case gdb_stmm1 : return fpu_stmm1;
+ case gdb_stmm2 : return fpu_stmm2;
+ case gdb_stmm3 : return fpu_stmm3;
+ case gdb_stmm4 : return fpu_stmm4;
+ case gdb_stmm5 : return fpu_stmm5;
+ case gdb_stmm6 : return fpu_stmm6;
+ case gdb_stmm7 : return fpu_stmm7;
+ case gdb_fctrl : return fpu_fctrl;
+ case gdb_fstat : return fpu_fstat;
+ case gdb_ftag : return fpu_ftag;
+ case gdb_fiseg : return fpu_fiseg;
+ case gdb_fioff : return fpu_fioff;
+ case gdb_foseg : return fpu_foseg;
+ case gdb_fooff : return fpu_fooff;
+ case gdb_fop : return fpu_fop;
+ case gdb_xmm0 : return fpu_xmm0;
+ case gdb_xmm1 : return fpu_xmm1;
+ case gdb_xmm2 : return fpu_xmm2;
+ case gdb_xmm3 : return fpu_xmm3;
+ case gdb_xmm4 : return fpu_xmm4;
+ case gdb_xmm5 : return fpu_xmm5;
+ case gdb_xmm6 : return fpu_xmm6;
+ case gdb_xmm7 : return fpu_xmm7;
+ case gdb_mxcsr : return fpu_mxcsr;
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindLLDB)
+ {
+ return reg;
+ }
+ return LLDB_INVALID_REGNUM;
+}
+
+
+bool
+RegisterContextDarwin_i386::HardwareSingleStep (bool enable)
+{
+ if (ReadGPR(false) != 0)
+ return false;
+
+ const uint32_t trace_bit = 0x100u;
+ if (enable)
+ {
+ // If the trace bit is already set, there is nothing to do
+ if (gpr.eflags & trace_bit)
+ return true;
+ else
+ gpr.eflags |= trace_bit;
+ }
+ else
+ {
+ // If the trace bit is already cleared, there is nothing to do
+ if (gpr.eflags & trace_bit)
+ gpr.eflags &= ~trace_bit;
+ else
+ return true;
+ }
+
+ return WriteGPR() == 0;
+}
+
+
+
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h Mon Jul 18 22:57:15 2011
@@ -0,0 +1,287 @@
+//===-- RegisterContextDarwin_i386.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_RegisterContextDarwin_i386_h_
+#define liblldb_RegisterContextDarwin_i386_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/RegisterContext.h"
+
+class RegisterContextDarwin_i386 : public lldb_private::RegisterContext
+{
+public:
+
+ RegisterContextDarwin_i386(lldb_private::Thread &thread,
+ uint32_t concrete_frame_idx);
+
+ virtual
+ ~RegisterContextDarwin_i386();
+
+ virtual void
+ InvalidateAllRegisters ();
+
+ virtual size_t
+ GetRegisterCount ();
+
+ virtual const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex (uint32_t reg);
+
+ virtual size_t
+ GetRegisterSetCount ();
+
+ virtual const lldb_private::RegisterSet *
+ GetRegisterSet (uint32_t set);
+
+ virtual bool
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+
+ virtual bool
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
+ virtual bool
+ ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+
+ virtual bool
+ WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+
+ virtual uint32_t
+ ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
+
+ virtual bool
+ HardwareSingleStep (bool enable);
+
+ struct GPR
+ {
+ uint32_t eax;
+ uint32_t ebx;
+ uint32_t ecx;
+ uint32_t edx;
+ uint32_t edi;
+ uint32_t esi;
+ uint32_t ebp;
+ uint32_t esp;
+ uint32_t ss;
+ uint32_t eflags;
+ uint32_t eip;
+ uint32_t cs;
+ uint32_t ds;
+ uint32_t es;
+ uint32_t fs;
+ uint32_t gs;
+ };
+
+ struct MMSReg
+ {
+ uint8_t bytes[10];
+ uint8_t pad[6];
+ };
+
+ struct XMMReg
+ {
+ uint8_t bytes[16];
+ };
+
+ struct FPU
+ {
+ uint32_t pad[2];
+ uint16_t fcw;
+ uint16_t fsw;
+ uint8_t ftw;
+ uint8_t pad1;
+ uint16_t fop;
+ uint32_t ip;
+ uint16_t cs;
+ uint16_t pad2;
+ uint32_t dp;
+ uint16_t ds;
+ uint16_t pad3;
+ uint32_t mxcsr;
+ uint32_t mxcsrmask;
+ MMSReg stmm[8];
+ XMMReg xmm[8];
+ uint8_t pad4[14*16];
+ int pad5;
+ };
+
+ struct EXC
+ {
+ uint32_t trapno;
+ uint32_t err;
+ uint32_t faultvaddr;
+ };
+
+protected:
+
+ enum
+ {
+ GPRRegSet = 1,
+ FPURegSet = 2,
+ EXCRegSet = 3
+ };
+
+ enum
+ {
+ GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
+ FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
+ EXCWordCount = sizeof(EXC)/sizeof(uint32_t)
+ };
+
+ enum
+ {
+ Read = 0,
+ Write = 1,
+ kNumErrors = 2
+ };
+
+ GPR gpr;
+ FPU fpu;
+ EXC exc;
+ int gpr_errs[2]; // Read/Write errors
+ int fpu_errs[2]; // Read/Write errors
+ int exc_errs[2]; // Read/Write errors
+
+ void
+ InvalidateAllRegisterStates()
+ {
+ SetError (GPRRegSet, Read, -1);
+ SetError (FPURegSet, Read, -1);
+ SetError (EXCRegSet, Read, -1);
+ }
+
+ int
+ GetError (int flavor, uint32_t err_idx) const
+ {
+ if (err_idx < kNumErrors)
+ {
+ switch (flavor)
+ {
+ // When getting all errors, just OR all values together to see if
+ // we got any kind of error.
+ case GPRRegSet: return gpr_errs[err_idx];
+ case FPURegSet: return fpu_errs[err_idx];
+ case EXCRegSet: return exc_errs[err_idx];
+ default: break;
+ }
+ }
+ return -1;
+ }
+
+ bool
+ SetError (int flavor, uint32_t err_idx, int err)
+ {
+ if (err_idx < kNumErrors)
+ {
+ switch (flavor)
+ {
+ case GPRRegSet:
+ gpr_errs[err_idx] = err;
+ return true;
+
+ case FPURegSet:
+ fpu_errs[err_idx] = err;
+ return true;
+
+ case EXCRegSet:
+ exc_errs[err_idx] = err;
+ return true;
+
+ default: break;
+ }
+ }
+ return false;
+ }
+
+ bool
+ RegisterSetIsCached (int set) const
+ {
+ return GetError(set, Read) == 0;
+ }
+
+ void
+ LogGPR (lldb_private::Log *log, const char *title);
+
+ int
+ ReadGPR (bool force);
+
+ int
+ ReadFPU (bool force);
+
+ int
+ ReadEXC (bool force);
+
+ int
+ WriteGPR ();
+
+ int
+ WriteFPU ();
+
+ int
+ WriteEXC ();
+
+ // Subclasses override these to do the actual reading.
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
+ {
+ return -1;
+ }
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
+ {
+ return -1;
+ }
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
+ {
+ return -1;
+ }
+
+ int
+ ReadRegisterSet (uint32_t set, bool force);
+
+ int
+ WriteRegisterSet (uint32_t set);
+
+ static uint32_t
+ GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
+
+ static int
+ GetSetForNativeRegNum (int reg_num);
+
+ static size_t
+ GetRegisterInfosCount ();
+
+ static const lldb_private::RegisterInfo *
+ GetRegisterInfos ();
+};
+
+#endif // liblldb_RegisterContextDarwin_i386_h_
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp Mon Jul 18 22:57:15 2011
@@ -0,0 +1,1056 @@
+//===-- RegisterContextDarwin_x86_64.cpp ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Host/Endian.h"
+
+// Project includes
+#include "RegisterContextDarwin_x86_64.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+enum
+{
+ gpr_rax = 0,
+ gpr_rbx,
+ gpr_rcx,
+ gpr_rdx,
+ gpr_rdi,
+ gpr_rsi,
+ gpr_rbp,
+ gpr_rsp,
+ gpr_r8,
+ gpr_r9,
+ gpr_r10,
+ gpr_r11,
+ gpr_r12,
+ gpr_r13,
+ gpr_r14,
+ gpr_r15,
+ gpr_rip,
+ gpr_rflags,
+ gpr_cs,
+ gpr_fs,
+ gpr_gs,
+
+ fpu_fcw,
+ fpu_fsw,
+ fpu_ftw,
+ fpu_fop,
+ fpu_ip,
+ fpu_cs,
+ fpu_dp,
+ fpu_ds,
+ fpu_mxcsr,
+ fpu_mxcsrmask,
+ fpu_stmm0,
+ fpu_stmm1,
+ fpu_stmm2,
+ fpu_stmm3,
+ fpu_stmm4,
+ fpu_stmm5,
+ fpu_stmm6,
+ fpu_stmm7,
+ fpu_xmm0,
+ fpu_xmm1,
+ fpu_xmm2,
+ fpu_xmm3,
+ fpu_xmm4,
+ fpu_xmm5,
+ fpu_xmm6,
+ fpu_xmm7,
+ fpu_xmm8,
+ fpu_xmm9,
+ fpu_xmm10,
+ fpu_xmm11,
+ fpu_xmm12,
+ fpu_xmm13,
+ fpu_xmm14,
+ fpu_xmm15,
+
+ exc_trapno,
+ exc_err,
+ exc_faultvaddr,
+
+ k_num_registers,
+
+ // Aliases
+ fpu_fctrl = fpu_fcw,
+ fpu_fstat = fpu_fsw,
+ fpu_ftag = fpu_ftw,
+ fpu_fiseg = fpu_cs,
+ fpu_fioff = fpu_ip,
+ fpu_foseg = fpu_ds,
+ fpu_fooff = fpu_dp,
+};
+
+enum gcc_dwarf_regnums
+{
+ gcc_dwarf_gpr_rax = 0,
+ gcc_dwarf_gpr_rdx,
+ gcc_dwarf_gpr_rcx,
+ gcc_dwarf_gpr_rbx,
+ gcc_dwarf_gpr_rsi,
+ gcc_dwarf_gpr_rdi,
+ gcc_dwarf_gpr_rbp,
+ gcc_dwarf_gpr_rsp,
+ gcc_dwarf_gpr_r8,
+ gcc_dwarf_gpr_r9,
+ gcc_dwarf_gpr_r10,
+ gcc_dwarf_gpr_r11,
+ gcc_dwarf_gpr_r12,
+ gcc_dwarf_gpr_r13,
+ gcc_dwarf_gpr_r14,
+ gcc_dwarf_gpr_r15,
+ gcc_dwarf_gpr_rip,
+ gcc_dwarf_fpu_xmm0,
+ gcc_dwarf_fpu_xmm1,
+ gcc_dwarf_fpu_xmm2,
+ gcc_dwarf_fpu_xmm3,
+ gcc_dwarf_fpu_xmm4,
+ gcc_dwarf_fpu_xmm5,
+ gcc_dwarf_fpu_xmm6,
+ gcc_dwarf_fpu_xmm7,
+ gcc_dwarf_fpu_xmm8,
+ gcc_dwarf_fpu_xmm9,
+ gcc_dwarf_fpu_xmm10,
+ gcc_dwarf_fpu_xmm11,
+ gcc_dwarf_fpu_xmm12,
+ gcc_dwarf_fpu_xmm13,
+ gcc_dwarf_fpu_xmm14,
+ gcc_dwarf_fpu_xmm15,
+ gcc_dwarf_fpu_stmm0,
+ gcc_dwarf_fpu_stmm1,
+ gcc_dwarf_fpu_stmm2,
+ gcc_dwarf_fpu_stmm3,
+ gcc_dwarf_fpu_stmm4,
+ gcc_dwarf_fpu_stmm5,
+ gcc_dwarf_fpu_stmm6,
+ gcc_dwarf_fpu_stmm7,
+
+};
+
+enum gdb_regnums
+{
+ gdb_gpr_rax = 0,
+ gdb_gpr_rbx = 1,
+ gdb_gpr_rcx = 2,
+ gdb_gpr_rdx = 3,
+ gdb_gpr_rsi = 4,
+ gdb_gpr_rdi = 5,
+ gdb_gpr_rbp = 6,
+ gdb_gpr_rsp = 7,
+ gdb_gpr_r8 = 8,
+ gdb_gpr_r9 = 9,
+ gdb_gpr_r10 = 10,
+ gdb_gpr_r11 = 11,
+ gdb_gpr_r12 = 12,
+ gdb_gpr_r13 = 13,
+ gdb_gpr_r14 = 14,
+ gdb_gpr_r15 = 15,
+ gdb_gpr_rip = 16,
+ gdb_gpr_rflags = 17,
+ gdb_gpr_cs = 18,
+ gdb_gpr_ss = 19,
+ gdb_gpr_ds = 20,
+ gdb_gpr_es = 21,
+ gdb_gpr_fs = 22,
+ gdb_gpr_gs = 23,
+ gdb_fpu_stmm0 = 24,
+ gdb_fpu_stmm1 = 25,
+ gdb_fpu_stmm2 = 26,
+ gdb_fpu_stmm3 = 27,
+ gdb_fpu_stmm4 = 28,
+ gdb_fpu_stmm5 = 29,
+ gdb_fpu_stmm6 = 30,
+ gdb_fpu_stmm7 = 31,
+ gdb_fpu_fctrl = 32, gdb_fpu_fcw = gdb_fpu_fctrl,
+ gdb_fpu_fstat = 33, gdb_fpu_fsw = gdb_fpu_fstat,
+ gdb_fpu_ftag = 34, gdb_fpu_ftw = gdb_fpu_ftag,
+ gdb_fpu_fiseg = 35, gdb_fpu_cs = gdb_fpu_fiseg,
+ gdb_fpu_fioff = 36, gdb_fpu_ip = gdb_fpu_fioff,
+ gdb_fpu_foseg = 37, gdb_fpu_ds = gdb_fpu_foseg,
+ gdb_fpu_fooff = 38, gdb_fpu_dp = gdb_fpu_fooff,
+ gdb_fpu_fop = 39,
+ gdb_fpu_xmm0 = 40,
+ gdb_fpu_xmm1 = 41,
+ gdb_fpu_xmm2 = 42,
+ gdb_fpu_xmm3 = 43,
+ gdb_fpu_xmm4 = 44,
+ gdb_fpu_xmm5 = 45,
+ gdb_fpu_xmm6 = 46,
+ gdb_fpu_xmm7 = 47,
+ gdb_fpu_xmm8 = 48,
+ gdb_fpu_xmm9 = 49,
+ gdb_fpu_xmm10 = 50,
+ gdb_fpu_xmm11 = 51,
+ gdb_fpu_xmm12 = 52,
+ gdb_fpu_xmm13 = 53,
+ gdb_fpu_xmm14 = 54,
+ gdb_fpu_xmm15 = 55,
+ gdb_fpu_mxcsr = 56,
+};
+
+RegisterContextDarwin_x86_64::RegisterContextDarwin_x86_64 (Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext (thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; ireg), GPR_OFFSET(reg), eEncodingUint, eFormatHex
+#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextDarwin_x86_64::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex
+#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextDarwin_x86_64::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i }
+#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextDarwin_x86_64::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex
+
+#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_x86_64::GPR) + sizeof (RegisterContextDarwin_x86_64::FPU) + sizeof (RegisterContextDarwin_x86_64::EXC))
+
+// General purpose registers for 64 bit
+static RegisterInfo g_register_infos[] =
+{
+// Macro auto defines most stuff GCC DWARF GENERIC GDB LLDB
+// =============================== ====================== =================== ========================== ==================== =====================
+ { DEFINE_GPR (rax , NULL) , { gcc_dwarf_gpr_rax , gcc_dwarf_gpr_rax , LLDB_INVALID_REGNUM , gdb_gpr_rax , gpr_rax }},
+ { DEFINE_GPR (rbx , NULL) , { gcc_dwarf_gpr_rbx , gcc_dwarf_gpr_rbx , LLDB_INVALID_REGNUM , gdb_gpr_rbx , gpr_rbx }},
+ { DEFINE_GPR (rcx , NULL) , { gcc_dwarf_gpr_rcx , gcc_dwarf_gpr_rcx , LLDB_INVALID_REGNUM , gdb_gpr_rcx , gpr_rcx }},
+ { DEFINE_GPR (rdx , NULL) , { gcc_dwarf_gpr_rdx , gcc_dwarf_gpr_rdx , LLDB_INVALID_REGNUM , gdb_gpr_rdx , gpr_rdx }},
+ { DEFINE_GPR (rdi , NULL) , { gcc_dwarf_gpr_rdi , gcc_dwarf_gpr_rdi , LLDB_INVALID_REGNUM , gdb_gpr_rdi , gpr_rdi }},
+ { DEFINE_GPR (rsi , NULL) , { gcc_dwarf_gpr_rsi , gcc_dwarf_gpr_rsi , LLDB_INVALID_REGNUM , gdb_gpr_rsi , gpr_rsi }},
+ { DEFINE_GPR (rbp , "fp") , { gcc_dwarf_gpr_rbp , gcc_dwarf_gpr_rbp , LLDB_REGNUM_GENERIC_FP , gdb_gpr_rbp , gpr_rbp }},
+ { DEFINE_GPR (rsp , "sp") , { gcc_dwarf_gpr_rsp , gcc_dwarf_gpr_rsp , LLDB_REGNUM_GENERIC_SP , gdb_gpr_rsp , gpr_rsp }},
+ { DEFINE_GPR (r8 , NULL) , { gcc_dwarf_gpr_r8 , gcc_dwarf_gpr_r8 , LLDB_INVALID_REGNUM , gdb_gpr_r8 , gpr_r8 }},
+ { DEFINE_GPR (r9 , NULL) , { gcc_dwarf_gpr_r9 , gcc_dwarf_gpr_r9 , LLDB_INVALID_REGNUM , gdb_gpr_r9 , gpr_r9 }},
+ { DEFINE_GPR (r10 , NULL) , { gcc_dwarf_gpr_r10 , gcc_dwarf_gpr_r10 , LLDB_INVALID_REGNUM , gdb_gpr_r10 , gpr_r10 }},
+ { DEFINE_GPR (r11 , NULL) , { gcc_dwarf_gpr_r11 , gcc_dwarf_gpr_r11 , LLDB_INVALID_REGNUM , gdb_gpr_r11 , gpr_r11 }},
+ { DEFINE_GPR (r12 , NULL) , { gcc_dwarf_gpr_r12 , gcc_dwarf_gpr_r12 , LLDB_INVALID_REGNUM , gdb_gpr_r12 , gpr_r12 }},
+ { DEFINE_GPR (r13 , NULL) , { gcc_dwarf_gpr_r13 , gcc_dwarf_gpr_r13 , LLDB_INVALID_REGNUM , gdb_gpr_r13 , gpr_r13 }},
+ { DEFINE_GPR (r14 , NULL) , { gcc_dwarf_gpr_r14 , gcc_dwarf_gpr_r14 , LLDB_INVALID_REGNUM , gdb_gpr_r14 , gpr_r14 }},
+ { DEFINE_GPR (r15 , NULL) , { gcc_dwarf_gpr_r15 , gcc_dwarf_gpr_r15 , LLDB_INVALID_REGNUM , gdb_gpr_r15 , gpr_r15 }},
+ { DEFINE_GPR (rip , "pc") , { gcc_dwarf_gpr_rip , gcc_dwarf_gpr_rip , LLDB_REGNUM_GENERIC_PC , gdb_gpr_rip , gpr_rip }},
+ { DEFINE_GPR (rflags, "flags") , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, gdb_gpr_rflags , gpr_rflags }},
+ { DEFINE_GPR (cs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gpr_cs , gpr_cs }},
+ { DEFINE_GPR (fs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gpr_fs , gpr_fs }},
+ { DEFINE_GPR (gs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gpr_gs , gpr_gs }},
+
+ { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_fcw , fpu_fcw }},
+ { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_fsw , fpu_fsw }},
+ { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_ftw , fpu_ftw }},
+ { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_fop , fpu_fop }},
+ { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_ip , fpu_ip }},
+ { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_cs , fpu_cs }},
+ { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_dp , fpu_dp }},
+ { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_ds , fpu_ds }},
+ { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_mxcsr , fpu_mxcsr }},
+ { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsrmask }},
+ { DEFINE_FPU_VECT(stmm,0) },
+ { DEFINE_FPU_VECT(stmm,1) },
+ { DEFINE_FPU_VECT(stmm,2) },
+ { DEFINE_FPU_VECT(stmm,3) },
+ { DEFINE_FPU_VECT(stmm,4) },
+ { DEFINE_FPU_VECT(stmm,5) },
+ { DEFINE_FPU_VECT(stmm,6) },
+ { DEFINE_FPU_VECT(stmm,7) },
+ { DEFINE_FPU_VECT(xmm,0) },
+ { DEFINE_FPU_VECT(xmm,1) },
+ { DEFINE_FPU_VECT(xmm,2) },
+ { DEFINE_FPU_VECT(xmm,3) },
+ { DEFINE_FPU_VECT(xmm,4) },
+ { DEFINE_FPU_VECT(xmm,5) },
+ { DEFINE_FPU_VECT(xmm,6) },
+ { DEFINE_FPU_VECT(xmm,7) },
+ { DEFINE_FPU_VECT(xmm,8) },
+ { DEFINE_FPU_VECT(xmm,9) },
+ { DEFINE_FPU_VECT(xmm,10) },
+ { DEFINE_FPU_VECT(xmm,11) },
+ { DEFINE_FPU_VECT(xmm,12) },
+ { DEFINE_FPU_VECT(xmm,13) },
+ { DEFINE_FPU_VECT(xmm,14) },
+ { DEFINE_FPU_VECT(xmm,15) },
+
+ { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_trapno }},
+ { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_err }},
+ { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_faultvaddr }}
+};
+
+static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo));
+
+
+void
+RegisterContextDarwin_x86_64::InvalidateAllRegisters ()
+{
+ InvalidateAllRegisterStates();
+}
+
+
+size_t
+RegisterContextDarwin_x86_64::GetRegisterCount ()
+{
+ assert(k_num_register_infos == k_num_registers);
+ return k_num_registers;
+}
+
+
+const RegisterInfo *
+RegisterContextDarwin_x86_64::GetRegisterInfoAtIndex (uint32_t reg)
+{
+ assert(k_num_register_infos == k_num_registers);
+ if (reg < k_num_registers)
+ return &g_register_infos[reg];
+ return NULL;
+}
+
+
+size_t
+RegisterContextDarwin_x86_64::GetRegisterInfosCount ()
+{
+ return k_num_register_infos;
+}
+
+const lldb_private::RegisterInfo *
+RegisterContextDarwin_x86_64::GetRegisterInfos ()
+{
+ return g_register_infos;
+}
+
+
+
+static uint32_t g_gpr_regnums[] =
+{
+ gpr_rax,
+ gpr_rbx,
+ gpr_rcx,
+ gpr_rdx,
+ gpr_rdi,
+ gpr_rsi,
+ gpr_rbp,
+ gpr_rsp,
+ gpr_r8,
+ gpr_r9,
+ gpr_r10,
+ gpr_r11,
+ gpr_r12,
+ gpr_r13,
+ gpr_r14,
+ gpr_r15,
+ gpr_rip,
+ gpr_rflags,
+ gpr_cs,
+ gpr_fs,
+ gpr_gs
+};
+
+static uint32_t g_fpu_regnums[] =
+{
+ fpu_fcw,
+ fpu_fsw,
+ fpu_ftw,
+ fpu_fop,
+ fpu_ip,
+ fpu_cs,
+ fpu_dp,
+ fpu_ds,
+ fpu_mxcsr,
+ fpu_mxcsrmask,
+ fpu_stmm0,
+ fpu_stmm1,
+ fpu_stmm2,
+ fpu_stmm3,
+ fpu_stmm4,
+ fpu_stmm5,
+ fpu_stmm6,
+ fpu_stmm7,
+ fpu_xmm0,
+ fpu_xmm1,
+ fpu_xmm2,
+ fpu_xmm3,
+ fpu_xmm4,
+ fpu_xmm5,
+ fpu_xmm6,
+ fpu_xmm7,
+ fpu_xmm8,
+ fpu_xmm9,
+ fpu_xmm10,
+ fpu_xmm11,
+ fpu_xmm12,
+ fpu_xmm13,
+ fpu_xmm14,
+ fpu_xmm15
+};
+
+static uint32_t
+g_exc_regnums[] =
+{
+ exc_trapno,
+ exc_err,
+ exc_faultvaddr
+};
+
+// Number of registers in each register set
+const size_t k_num_gpr_registers = sizeof(g_gpr_regnums) / sizeof(uint32_t);
+const size_t k_num_fpu_registers = sizeof(g_fpu_regnums) / sizeof(uint32_t);
+const size_t k_num_exc_registers = sizeof(g_exc_regnums) / sizeof(uint32_t);
+
+//----------------------------------------------------------------------
+// Register set definitions. The first definitions at register set index
+// of zero is for all registers, followed by other registers sets. The
+// register information for the all register set need not be filled in.
+//----------------------------------------------------------------------
+static const RegisterSet g_reg_sets[] =
+{
+ { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums, },
+ { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums },
+ { "Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums }
+};
+
+const size_t k_num_regsets = sizeof(g_reg_sets) / sizeof(RegisterSet);
+
+
+size_t
+RegisterContextDarwin_x86_64::GetRegisterSetCount ()
+{
+ return k_num_regsets;
+}
+
+const RegisterSet *
+RegisterContextDarwin_x86_64::GetRegisterSet (uint32_t reg_set)
+{
+ if (reg_set < k_num_regsets)
+ return &g_reg_sets[reg_set];
+ return NULL;
+}
+
+int
+RegisterContextDarwin_x86_64::GetSetForNativeRegNum (int reg_num)
+{
+ if (reg_num < fpu_fcw)
+ return GPRRegSet;
+ else if (reg_num < exc_trapno)
+ return FPURegSet;
+ else if (reg_num < k_num_registers)
+ return EXCRegSet;
+ return -1;
+}
+
+void
+RegisterContextDarwin_x86_64::LogGPR(Log *log, const char *format, ...)
+{
+ if (log)
+ {
+ if (format)
+ {
+ va_list args;
+ va_start (args, format);
+ log->VAPrintf (format, args);
+ va_end (args);
+ }
+ for (uint32_t i=0; iPrintf("%12s = 0x%16.16llx", g_register_infos[reg].name, (&gpr.rax)[reg]);
+ }
+ }
+}
+
+int
+RegisterContextDarwin_x86_64::ReadGPR (bool force)
+{
+ int set = GPRRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadGPR(GetThreadID(), set, gpr));
+ }
+ return GetError(GPRRegSet, Read);
+}
+
+int
+RegisterContextDarwin_x86_64::ReadFPU (bool force)
+{
+ int set = FPURegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadFPU(GetThreadID(), set, fpu));
+ }
+ return GetError(FPURegSet, Read);
+}
+
+int
+RegisterContextDarwin_x86_64::ReadEXC (bool force)
+{
+ int set = EXCRegSet;
+ if (force || !RegisterSetIsCached(set))
+ {
+ SetError(set, Read, DoReadEXC(GetThreadID(), set, exc));
+ }
+ return GetError(EXCRegSet, Read);
+}
+
+int
+RegisterContextDarwin_x86_64::WriteGPR ()
+{
+ int set = GPRRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return -1;
+ }
+ SetError (set, Write, DoWriteGPR(GetThreadID(), set, gpr));
+ SetError (set, Read, -1);
+ return GetError (set, Write);
+}
+
+int
+RegisterContextDarwin_x86_64::WriteFPU ()
+{
+ int set = FPURegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return -1;
+ }
+ SetError (set, Write, DoWriteFPU(GetThreadID(), set, fpu));
+ SetError (set, Read, -1);
+ return GetError (set, Write);
+}
+
+int
+RegisterContextDarwin_x86_64::WriteEXC ()
+{
+ int set = EXCRegSet;
+ if (!RegisterSetIsCached(set))
+ {
+ SetError (set, Write, -1);
+ return -1;
+ }
+ SetError (set, Write, DoWriteEXC(GetThreadID(), set, exc));
+ SetError (set, Read, -1);
+ return GetError (set, Write);
+}
+
+int
+RegisterContextDarwin_x86_64::ReadRegisterSet(uint32_t set, bool force)
+{
+ switch (set)
+ {
+ case GPRRegSet: return ReadGPR (force);
+ case FPURegSet: return ReadFPU (force);
+ case EXCRegSet: return ReadEXC (force);
+ default: break;
+ }
+ return -1;
+}
+
+int
+RegisterContextDarwin_x86_64::WriteRegisterSet(uint32_t set)
+{
+ // Make sure we have a valid context to set.
+ switch (set)
+ {
+ case GPRRegSet: return WriteGPR ();
+ case FPURegSet: return WriteFPU ();
+ case EXCRegSet: return WriteEXC ();
+ default: break;
+ }
+ return -1;
+}
+
+
+bool
+RegisterContextDarwin_x86_64::ReadRegister (const RegisterInfo *reg_info,
+ RegisterValue &value)
+{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ int set = RegisterContextDarwin_x86_64::GetSetForNativeRegNum (reg);
+ if (set == -1)
+ return false;
+
+ if (ReadRegisterSet(set, false) != 0)
+ return false;
+
+ switch (reg)
+ {
+ case gpr_rax:
+ case gpr_rbx:
+ case gpr_rcx:
+ case gpr_rdx:
+ case gpr_rdi:
+ case gpr_rsi:
+ case gpr_rbp:
+ case gpr_rsp:
+ case gpr_r8:
+ case gpr_r9:
+ case gpr_r10:
+ case gpr_r11:
+ case gpr_r12:
+ case gpr_r13:
+ case gpr_r14:
+ case gpr_r15:
+ case gpr_rip:
+ case gpr_rflags:
+ case gpr_cs:
+ case gpr_fs:
+ case gpr_gs:
+ value = (&gpr.rax)[reg - gpr_rax];
+ break;
+
+ case fpu_fcw:
+ value = fpu.fcw;
+ break;
+
+ case fpu_fsw:
+ value = fpu.fsw;
+ break;
+
+ case fpu_ftw:
+ value = fpu.ftw;
+ break;
+
+ case fpu_fop:
+ value = fpu.fop;
+ break;
+
+ case fpu_ip:
+ value = fpu.ip;
+ break;
+
+ case fpu_cs:
+ value = fpu.cs;
+ break;
+
+ case fpu_dp:
+ value = fpu.dp;
+ break;
+
+ case fpu_ds:
+ value = fpu.ds;
+ break;
+
+ case fpu_mxcsr:
+ value = fpu.mxcsr;
+ break;
+
+ case fpu_mxcsrmask:
+ value = fpu.mxcsrmask;
+ break;
+
+ case fpu_stmm0:
+ case fpu_stmm1:
+ case fpu_stmm2:
+ case fpu_stmm3:
+ case fpu_stmm4:
+ case fpu_stmm5:
+ case fpu_stmm6:
+ case fpu_stmm7:
+ value.SetBytes(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ break;
+
+ case fpu_xmm0:
+ case fpu_xmm1:
+ case fpu_xmm2:
+ case fpu_xmm3:
+ case fpu_xmm4:
+ case fpu_xmm5:
+ case fpu_xmm6:
+ case fpu_xmm7:
+ case fpu_xmm8:
+ case fpu_xmm9:
+ case fpu_xmm10:
+ case fpu_xmm11:
+ case fpu_xmm12:
+ case fpu_xmm13:
+ case fpu_xmm14:
+ case fpu_xmm15:
+ value.SetBytes(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ break;
+
+ case exc_trapno:
+ value = exc.trapno;
+ break;
+
+ case exc_err:
+ value = exc.err;
+ break;
+
+ case exc_faultvaddr:
+ value = exc.faultvaddr;
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+}
+
+
+bool
+RegisterContextDarwin_x86_64::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
+{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ int set = RegisterContextDarwin_x86_64::GetSetForNativeRegNum (reg);
+
+ if (set == -1)
+ return false;
+
+ if (ReadRegisterSet(set, false) != 0)
+ return false;
+
+ switch (reg)
+ {
+ case gpr_rax:
+ case gpr_rbx:
+ case gpr_rcx:
+ case gpr_rdx:
+ case gpr_rdi:
+ case gpr_rsi:
+ case gpr_rbp:
+ case gpr_rsp:
+ case gpr_r8:
+ case gpr_r9:
+ case gpr_r10:
+ case gpr_r11:
+ case gpr_r12:
+ case gpr_r13:
+ case gpr_r14:
+ case gpr_r15:
+ case gpr_rip:
+ case gpr_rflags:
+ case gpr_cs:
+ case gpr_fs:
+ case gpr_gs:
+ (&gpr.rax)[reg - gpr_rax] = value.GetAsUInt64();
+ break;
+
+ case fpu_fcw:
+ fpu.fcw = value.GetAsUInt16();
+ break;
+
+ case fpu_fsw:
+ fpu.fsw = value.GetAsUInt16();
+ break;
+
+ case fpu_ftw:
+ fpu.ftw = value.GetAsUInt8();
+ break;
+
+ case fpu_fop:
+ fpu.fop = value.GetAsUInt16();
+ break;
+
+ case fpu_ip:
+ fpu.ip = value.GetAsUInt32();
+ break;
+
+ case fpu_cs:
+ fpu.cs = value.GetAsUInt16();
+ break;
+
+ case fpu_dp:
+ fpu.dp = value.GetAsUInt32();
+ break;
+
+ case fpu_ds:
+ fpu.ds = value.GetAsUInt16();
+ break;
+
+ case fpu_mxcsr:
+ fpu.mxcsr = value.GetAsUInt32();
+ break;
+
+ case fpu_mxcsrmask:
+ fpu.mxcsrmask = value.GetAsUInt32();
+ break;
+
+ case fpu_stmm0:
+ case fpu_stmm1:
+ case fpu_stmm2:
+ case fpu_stmm3:
+ case fpu_stmm4:
+ case fpu_stmm5:
+ case fpu_stmm6:
+ case fpu_stmm7:
+ ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize());
+ break;
+
+ case fpu_xmm0:
+ case fpu_xmm1:
+ case fpu_xmm2:
+ case fpu_xmm3:
+ case fpu_xmm4:
+ case fpu_xmm5:
+ case fpu_xmm6:
+ case fpu_xmm7:
+ case fpu_xmm8:
+ case fpu_xmm9:
+ case fpu_xmm10:
+ case fpu_xmm11:
+ case fpu_xmm12:
+ case fpu_xmm13:
+ case fpu_xmm14:
+ case fpu_xmm15:
+ ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize());
+ return false;
+
+ case exc_trapno:
+ exc.trapno = value.GetAsUInt32();
+ break;
+
+ case exc_err:
+ exc.err = value.GetAsUInt32();
+ break;
+
+ case exc_faultvaddr:
+ exc.faultvaddr = value.GetAsUInt64();
+ break;
+
+ default:
+ return false;
+ }
+ return WriteRegisterSet(set) == 0;
+}
+
+bool
+RegisterContextDarwin_x86_64::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+{
+ data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
+ if (data_sp &&
+ ReadGPR (false) == 0 &&
+ ReadFPU (false) == 0 &&
+ ReadEXC (false) == 0)
+ {
+ uint8_t *dst = data_sp->GetBytes();
+ ::memcpy (dst, &gpr, sizeof(gpr));
+ dst += sizeof(gpr);
+
+ ::memcpy (dst, &fpu, sizeof(fpu));
+ dst += sizeof(gpr);
+
+ ::memcpy (dst, &exc, sizeof(exc));
+ return true;
+ }
+ return false;
+}
+
+bool
+RegisterContextDarwin_x86_64::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
+{
+ if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
+ {
+ const uint8_t *src = data_sp->GetBytes();
+ ::memcpy (&gpr, src, sizeof(gpr));
+ src += sizeof(gpr);
+
+ ::memcpy (&fpu, src, sizeof(fpu));
+ src += sizeof(gpr);
+
+ ::memcpy (&exc, src, sizeof(exc));
+ uint32_t success_count = 0;
+ if (WriteGPR() == 0)
+ ++success_count;
+ if (WriteFPU() == 0)
+ ++success_count;
+ if (WriteEXC() == 0)
+ ++success_count;
+ return success_count == 3;
+ }
+ return false;
+}
+
+
+uint32_t
+RegisterContextDarwin_x86_64::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t reg)
+{
+ if (kind == eRegisterKindGeneric)
+ {
+ switch (reg)
+ {
+ case LLDB_REGNUM_GENERIC_PC: return gpr_rip;
+ case LLDB_REGNUM_GENERIC_SP: return gpr_rsp;
+ case LLDB_REGNUM_GENERIC_FP: return gpr_rbp;
+ case LLDB_REGNUM_GENERIC_FLAGS: return gpr_rflags;
+ case LLDB_REGNUM_GENERIC_RA:
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF)
+ {
+ switch (reg)
+ {
+ case gcc_dwarf_gpr_rax: return gpr_rax;
+ case gcc_dwarf_gpr_rdx: return gpr_rdx;
+ case gcc_dwarf_gpr_rcx: return gpr_rcx;
+ case gcc_dwarf_gpr_rbx: return gpr_rbx;
+ case gcc_dwarf_gpr_rsi: return gpr_rsi;
+ case gcc_dwarf_gpr_rdi: return gpr_rdi;
+ case gcc_dwarf_gpr_rbp: return gpr_rbp;
+ case gcc_dwarf_gpr_rsp: return gpr_rsp;
+ case gcc_dwarf_gpr_r8: return gpr_r8;
+ case gcc_dwarf_gpr_r9: return gpr_r9;
+ case gcc_dwarf_gpr_r10: return gpr_r10;
+ case gcc_dwarf_gpr_r11: return gpr_r11;
+ case gcc_dwarf_gpr_r12: return gpr_r12;
+ case gcc_dwarf_gpr_r13: return gpr_r13;
+ case gcc_dwarf_gpr_r14: return gpr_r14;
+ case gcc_dwarf_gpr_r15: return gpr_r15;
+ case gcc_dwarf_gpr_rip: return gpr_rip;
+ case gcc_dwarf_fpu_xmm0: return fpu_xmm0;
+ case gcc_dwarf_fpu_xmm1: return fpu_xmm1;
+ case gcc_dwarf_fpu_xmm2: return fpu_xmm2;
+ case gcc_dwarf_fpu_xmm3: return fpu_xmm3;
+ case gcc_dwarf_fpu_xmm4: return fpu_xmm4;
+ case gcc_dwarf_fpu_xmm5: return fpu_xmm5;
+ case gcc_dwarf_fpu_xmm6: return fpu_xmm6;
+ case gcc_dwarf_fpu_xmm7: return fpu_xmm7;
+ case gcc_dwarf_fpu_xmm8: return fpu_xmm8;
+ case gcc_dwarf_fpu_xmm9: return fpu_xmm9;
+ case gcc_dwarf_fpu_xmm10: return fpu_xmm10;
+ case gcc_dwarf_fpu_xmm11: return fpu_xmm11;
+ case gcc_dwarf_fpu_xmm12: return fpu_xmm12;
+ case gcc_dwarf_fpu_xmm13: return fpu_xmm13;
+ case gcc_dwarf_fpu_xmm14: return fpu_xmm14;
+ case gcc_dwarf_fpu_xmm15: return fpu_xmm15;
+ case gcc_dwarf_fpu_stmm0: return fpu_stmm0;
+ case gcc_dwarf_fpu_stmm1: return fpu_stmm1;
+ case gcc_dwarf_fpu_stmm2: return fpu_stmm2;
+ case gcc_dwarf_fpu_stmm3: return fpu_stmm3;
+ case gcc_dwarf_fpu_stmm4: return fpu_stmm4;
+ case gcc_dwarf_fpu_stmm5: return fpu_stmm5;
+ case gcc_dwarf_fpu_stmm6: return fpu_stmm6;
+ case gcc_dwarf_fpu_stmm7: return fpu_stmm7;
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindGDB)
+ {
+ switch (reg)
+ {
+ case gdb_gpr_rax : return gpr_rax;
+ case gdb_gpr_rbx : return gpr_rbx;
+ case gdb_gpr_rcx : return gpr_rcx;
+ case gdb_gpr_rdx : return gpr_rdx;
+ case gdb_gpr_rsi : return gpr_rsi;
+ case gdb_gpr_rdi : return gpr_rdi;
+ case gdb_gpr_rbp : return gpr_rbp;
+ case gdb_gpr_rsp : return gpr_rsp;
+ case gdb_gpr_r8 : return gpr_r8;
+ case gdb_gpr_r9 : return gpr_r9;
+ case gdb_gpr_r10 : return gpr_r10;
+ case gdb_gpr_r11 : return gpr_r11;
+ case gdb_gpr_r12 : return gpr_r12;
+ case gdb_gpr_r13 : return gpr_r13;
+ case gdb_gpr_r14 : return gpr_r14;
+ case gdb_gpr_r15 : return gpr_r15;
+ case gdb_gpr_rip : return gpr_rip;
+ case gdb_gpr_rflags : return gpr_rflags;
+ case gdb_gpr_cs : return gpr_cs;
+ case gdb_gpr_ss : return gpr_gs; // HACK: For now for "ss", just copy what is in "gs"
+ case gdb_gpr_ds : return gpr_gs; // HACK: For now for "ds", just copy what is in "gs"
+ case gdb_gpr_es : return gpr_gs; // HACK: For now for "es", just copy what is in "gs"
+ case gdb_gpr_fs : return gpr_fs;
+ case gdb_gpr_gs : return gpr_gs;
+ case gdb_fpu_stmm0 : return fpu_stmm0;
+ case gdb_fpu_stmm1 : return fpu_stmm1;
+ case gdb_fpu_stmm2 : return fpu_stmm2;
+ case gdb_fpu_stmm3 : return fpu_stmm3;
+ case gdb_fpu_stmm4 : return fpu_stmm4;
+ case gdb_fpu_stmm5 : return fpu_stmm5;
+ case gdb_fpu_stmm6 : return fpu_stmm6;
+ case gdb_fpu_stmm7 : return fpu_stmm7;
+ case gdb_fpu_fctrl : return fpu_fctrl;
+ case gdb_fpu_fstat : return fpu_fstat;
+ case gdb_fpu_ftag : return fpu_ftag;
+ case gdb_fpu_fiseg : return fpu_fiseg;
+ case gdb_fpu_fioff : return fpu_fioff;
+ case gdb_fpu_foseg : return fpu_foseg;
+ case gdb_fpu_fooff : return fpu_fooff;
+ case gdb_fpu_fop : return fpu_fop;
+ case gdb_fpu_xmm0 : return fpu_xmm0;
+ case gdb_fpu_xmm1 : return fpu_xmm1;
+ case gdb_fpu_xmm2 : return fpu_xmm2;
+ case gdb_fpu_xmm3 : return fpu_xmm3;
+ case gdb_fpu_xmm4 : return fpu_xmm4;
+ case gdb_fpu_xmm5 : return fpu_xmm5;
+ case gdb_fpu_xmm6 : return fpu_xmm6;
+ case gdb_fpu_xmm7 : return fpu_xmm7;
+ case gdb_fpu_xmm8 : return fpu_xmm8;
+ case gdb_fpu_xmm9 : return fpu_xmm9;
+ case gdb_fpu_xmm10 : return fpu_xmm10;
+ case gdb_fpu_xmm11 : return fpu_xmm11;
+ case gdb_fpu_xmm12 : return fpu_xmm12;
+ case gdb_fpu_xmm13 : return fpu_xmm13;
+ case gdb_fpu_xmm14 : return fpu_xmm14;
+ case gdb_fpu_xmm15 : return fpu_xmm15;
+ case gdb_fpu_mxcsr : return fpu_mxcsr;
+ default:
+ break;
+ }
+ }
+ else if (kind == eRegisterKindLLDB)
+ {
+ return reg;
+ }
+ return LLDB_INVALID_REGNUM;
+}
+
+bool
+RegisterContextDarwin_x86_64::HardwareSingleStep (bool enable)
+{
+ if (ReadGPR(true) != 0)
+ return false;
+
+ const uint64_t trace_bit = 0x100ull;
+ if (enable)
+ {
+
+ if (gpr.rflags & trace_bit)
+ return true; // trace bit is already set, there is nothing to do
+ else
+ gpr.rflags |= trace_bit;
+ }
+ else
+ {
+ if (gpr.rflags & trace_bit)
+ gpr.rflags &= ~trace_bit;
+ else
+ return true; // trace bit is clear, there is nothing to do
+ }
+
+ return WriteGPR() == 0;
+}
+
Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h?rev=135466&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h Mon Jul 18 22:57:15 2011
@@ -0,0 +1,293 @@
+//===-- RegisterContextDarwin_x86_64.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_RegisterContextDarwin_x86_64_h_
+#define liblldb_RegisterContextDarwin_x86_64_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/RegisterContext.h"
+
+class RegisterContextDarwin_x86_64 : public lldb_private::RegisterContext
+{
+public:
+ RegisterContextDarwin_x86_64 (lldb_private::Thread &thread,
+ uint32_t concrete_frame_idx);
+
+ virtual
+ ~RegisterContextDarwin_x86_64();
+
+ virtual void
+ InvalidateAllRegisters ();
+
+ virtual size_t
+ GetRegisterCount ();
+
+ virtual const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex (uint32_t reg);
+
+ virtual size_t
+ GetRegisterSetCount ();
+
+ virtual const lldb_private::RegisterSet *
+ GetRegisterSet (uint32_t set);
+
+ virtual bool
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+
+ virtual bool
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
+ virtual bool
+ ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+
+ virtual bool
+ WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+
+ virtual uint32_t
+ ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
+
+ virtual bool
+ HardwareSingleStep (bool enable);
+
+ struct GPR
+ {
+ uint64_t rax;
+ uint64_t rbx;
+ uint64_t rcx;
+ uint64_t rdx;
+ uint64_t rdi;
+ uint64_t rsi;
+ uint64_t rbp;
+ uint64_t rsp;
+ uint64_t r8;
+ uint64_t r9;
+ uint64_t r10;
+ uint64_t r11;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ uint64_t rip;
+ uint64_t rflags;
+ uint64_t cs;
+ uint64_t fs;
+ uint64_t gs;
+ };
+
+ struct MMSReg
+ {
+ uint8_t bytes[10];
+ uint8_t pad[6];
+ };
+
+ struct XMMReg
+ {
+ uint8_t bytes[16];
+ };
+
+ struct FPU
+ {
+ uint32_t pad[2];
+ uint16_t fcw; // "fctrl"
+ uint16_t fsw; // "fstat"
+ uint8_t ftw; // "ftag"
+ uint8_t pad1;
+ uint16_t fop; // "fop"
+ uint32_t ip; // "fioff"
+ uint16_t cs; // "fiseg"
+ uint16_t pad2;
+ uint32_t dp; // "fooff"
+ uint16_t ds; // "foseg"
+ uint16_t pad3;
+ uint32_t mxcsr;
+ uint32_t mxcsrmask;
+ MMSReg stmm[8];
+ XMMReg xmm[16];
+ uint8_t pad4[6*16];
+ int pad5;
+ };
+
+ struct EXC
+ {
+ uint32_t trapno;
+ uint32_t err;
+ uint64_t faultvaddr;
+ };
+
+protected:
+
+ enum
+ {
+ GPRRegSet = 4,
+ FPURegSet = 5,
+ EXCRegSet = 6
+ };
+
+ enum
+ {
+ GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
+ FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
+ EXCWordCount = sizeof(EXC)/sizeof(uint32_t)
+ };
+
+ enum
+ {
+ Read = 0,
+ Write = 1,
+ kNumErrors = 2
+ };
+
+ GPR gpr;
+ FPU fpu;
+ EXC exc;
+ int gpr_errs[2]; // Read/Write errors
+ int fpu_errs[2]; // Read/Write errors
+ int exc_errs[2]; // Read/Write errors
+
+ void
+ InvalidateAllRegisterStates()
+ {
+ SetError (GPRRegSet, Read, -1);
+ SetError (FPURegSet, Read, -1);
+ SetError (EXCRegSet, Read, -1);
+ }
+
+ int
+ GetError (int flavor, uint32_t err_idx) const
+ {
+ if (err_idx < kNumErrors)
+ {
+ switch (flavor)
+ {
+ // When getting all errors, just OR all values together to see if
+ // we got any kind of error.
+ case GPRRegSet: return gpr_errs[err_idx];
+ case FPURegSet: return fpu_errs[err_idx];
+ case EXCRegSet: return exc_errs[err_idx];
+ default: break;
+ }
+ }
+ return -1;
+ }
+
+ bool
+ SetError (int flavor, uint32_t err_idx, int err)
+ {
+ if (err_idx < kNumErrors)
+ {
+ switch (flavor)
+ {
+ case GPRRegSet:
+ gpr_errs[err_idx] = err;
+ return true;
+
+ case FPURegSet:
+ fpu_errs[err_idx] = err;
+ return true;
+
+ case EXCRegSet:
+ exc_errs[err_idx] = err;
+ return true;
+
+ default: break;
+ }
+ }
+ return false;
+ }
+
+ bool
+ RegisterSetIsCached (int set) const
+ {
+ return GetError(set, Read) == 0;
+ }
+
+ void
+ LogGPR (lldb_private::Log *log, const char *format, ...);
+
+ int
+ ReadGPR (bool force);
+
+ int
+ ReadFPU (bool force);
+
+ int
+ ReadEXC (bool force);
+
+ int
+ WriteGPR ();
+
+ int
+ WriteFPU ();
+
+ int
+ WriteEXC ();
+
+ // Subclasses override these to do the actual reading.
+ virtual int
+ DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
+ {
+ return -1;
+ }
+
+ int
+ DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
+ {
+ return -1;
+ }
+
+ int
+ DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
+ {
+ return -1;
+ }
+
+ int
+ DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
+ {
+ return -1;
+ }
+
+
+ int
+ ReadRegisterSet (uint32_t set, bool force);
+
+ int
+ WriteRegisterSet (uint32_t set);
+
+ static uint32_t
+ GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
+
+ static int
+ GetSetForNativeRegNum (int reg_num);
+
+ static size_t
+ GetRegisterInfosCount ();
+
+ static const lldb_private::RegisterInfo *
+ GetRegisterInfos ();
+
+};
+
+#endif // liblldb_RegisterContextDarwin_x86_64_h_
Modified: lldb/trunk/source/Utility/ARM_GCC_Registers.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_GCC_Registers.h?rev=135466&r1=135465&r2=135466&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ARM_GCC_Registers.h (original)
+++ lldb/trunk/source/Utility/ARM_GCC_Registers.h Mon Jul 18 22:57:15 2011
@@ -31,5 +31,116 @@
gcc_cpsr
};
+enum
+{
+// Name Nr Rel Offset Size Type Raw value
+ gdb_arm_r0 = 0, // 0 0 4 int32_t
+ gdb_arm_r1 = 1, // 1 4 4 int32_t
+ gdb_arm_r2 = 2, // 2 8 4 int32_t
+ gdb_arm_r3 = 3, // 3 12 4 int32_t
+ gdb_arm_r4 = 4, // 4 16 4 int32_t
+ gdb_arm_r5 = 5, // 5 20 4 int32_t
+ gdb_arm_r6 = 6, // 6 24 4 int32_t
+ gdb_arm_r7 = 7, // 7 28 4 int32_t
+ gdb_arm_r8 = 8, // 8 32 4 int32_t
+ gdb_arm_r9 = 9, // 9 36 4 int32_t
+ gdb_arm_r10 = 10, // 10 40 4 int32_t
+ gdb_arm_r11 = 11, // 11 44 4 int32_t
+ gdb_arm_r12 = 12, // 12 48 4 int32_t
+ gdb_arm_sp = 13, // 13 52 4 int32_t
+ gdb_arm_lr = 14, // 14 56 4 int32_t
+ gdb_arm_pc = 15, // 15 60 4 int32_t
+ gdb_arm_f0 = 16, // 16 64 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f1 = 17, // 17 76 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f2 = 18, // 18 88 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f3 = 19, // 19 100 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f4 = 20, // 20 112 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f5 = 21, // 21 124 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f6 = 22, // 22 136 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f7 = 23, // 23 148 12 _arm_ext_littlebyte_bigword
+ gdb_arm_f8 = 24, // 24 160 12 _arm_ext_littlebyte_bigword
+ gdb_arm_cpsr = 25, // 25 172 4 int32_t
+ gdb_arm_s0 = 26, // 26 176 4 _ieee_single_little
+ gdb_arm_s1 = 27, // 27 180 4 _ieee_single_little
+ gdb_arm_s2 = 28, // 28 184 4 _ieee_single_little
+ gdb_arm_s3 = 29, // 29 188 4 _ieee_single_little
+ gdb_arm_s4 = 30, // 30 192 4 _ieee_single_little
+ gdb_arm_s5 = 31, // 31 196 4 _ieee_single_little
+ gdb_arm_s6 = 32, // 32 200 4 _ieee_single_little
+ gdb_arm_s7 = 33, // 33 204 4 _ieee_single_little
+ gdb_arm_s8 = 34, // 34 208 4 _ieee_single_little
+ gdb_arm_s9 = 35, // 35 212 4 _ieee_single_little
+ gdb_arm_s10 = 36, // 36 216 4 _ieee_single_little
+ gdb_arm_s11 = 37, // 37 220 4 _ieee_single_little
+ gdb_arm_s12 = 38, // 38 224 4 _ieee_single_little
+ gdb_arm_s13 = 39, // 39 228 4 _ieee_single_little
+ gdb_arm_s14 = 40, // 40 232 4 _ieee_single_little
+ gdb_arm_s15 = 41, // 41 236 4 _ieee_single_little
+ gdb_arm_s16 = 42, // 42 240 4 _ieee_single_little
+ gdb_arm_s17 = 43, // 43 244 4 _ieee_single_little
+ gdb_arm_s18 = 44, // 44 248 4 _ieee_single_little
+ gdb_arm_s19 = 45, // 45 252 4 _ieee_single_little
+ gdb_arm_s20 = 46, // 46 256 4 _ieee_single_little
+ gdb_arm_s21 = 47, // 47 260 4 _ieee_single_little
+ gdb_arm_s22 = 48, // 48 264 4 _ieee_single_little
+ gdb_arm_s23 = 49, // 49 268 4 _ieee_single_little
+ gdb_arm_s24 = 50, // 50 272 4 _ieee_single_little
+ gdb_arm_s25 = 51, // 51 276 4 _ieee_single_little
+ gdb_arm_s26 = 52, // 52 280 4 _ieee_single_little
+ gdb_arm_s27 = 53, // 53 284 4 _ieee_single_little
+ gdb_arm_s28 = 54, // 54 288 4 _ieee_single_little
+ gdb_arm_s29 = 55, // 55 292 4 _ieee_single_little
+ gdb_arm_s30 = 56, // 56 296 4 _ieee_single_little
+ gdb_arm_s31 = 57, // 57 300 4 _ieee_single_little
+ gdb_arm_fpscr = 58, // 58 304 4 int32_t
+ gdb_arm_d16 = 59, // 59 308 8 _ieee_double_little
+ gdb_arm_d17 = 60, // 60 316 8 _ieee_double_little
+ gdb_arm_d18 = 61, // 61 324 8 _ieee_double_little
+ gdb_arm_d19 = 62, // 62 332 8 _ieee_double_little
+ gdb_arm_d20 = 63, // 63 340 8 _ieee_double_little
+ gdb_arm_d21 = 64, // 64 348 8 _ieee_double_little
+ gdb_arm_d22 = 65, // 65 356 8 _ieee_double_little
+ gdb_arm_d23 = 66, // 66 364 8 _ieee_double_little
+ gdb_arm_d24 = 67, // 67 372 8 _ieee_double_little
+ gdb_arm_d25 = 68, // 68 380 8 _ieee_double_little
+ gdb_arm_d26 = 69, // 69 388 8 _ieee_double_little
+ gdb_arm_d27 = 70, // 70 396 8 _ieee_double_little
+ gdb_arm_d28 = 71, // 71 404 8 _ieee_double_little
+ gdb_arm_d29 = 72, // 72 412 8 _ieee_double_little
+ gdb_arm_d30 = 73, // 73 420 8 _ieee_double_little
+ gdb_arm_d31 = 74, // 74 428 8 _ieee_double_little
+ gdb_arm_d0 = 75, // 0 436 8 _ieee_double_little
+ gdb_arm_d1 = 76, // 1 444 8 _ieee_double_little
+ gdb_arm_d2 = 77, // 2 452 8 _ieee_double_little
+ gdb_arm_d3 = 78, // 3 460 8 _ieee_double_little
+ gdb_arm_d4 = 79, // 4 468 8 _ieee_double_little
+ gdb_arm_d5 = 80, // 5 476 8 _ieee_double_little
+ gdb_arm_d6 = 81, // 6 484 8 _ieee_double_little
+ gdb_arm_d7 = 82, // 7 492 8 _ieee_double_little
+ gdb_arm_d8 = 83, // 8 500 8 _ieee_double_little
+ gdb_arm_d9 = 84, // 9 508 8 _ieee_double_little
+ gdb_arm_d10 = 85, // 10 516 8 _ieee_double_little
+ gdb_arm_d11 = 86, // 11 524 8 _ieee_double_little
+ gdb_arm_d12 = 87, // 12 532 8 _ieee_double_little
+ gdb_arm_d13 = 88, // 13 540 8 _ieee_double_little
+ gdb_arm_d14 = 89, // 14 548 8 _ieee_double_little
+ gdb_arm_d15 = 90, // 15 556 8 _ieee_double_little
+ gdb_arm_q0 = 91, // 16 564 16 _vec128
+ gdb_arm_q1 = 92, // 17 580 16 _vec128
+ gdb_arm_q2 = 93, // 18 596 16 _vec128
+ gdb_arm_q3 = 94, // 19 612 16 _vec128
+ gdb_arm_q4 = 95, // 20 628 16 _vec128
+ gdb_arm_q5 = 96, // 21 644 16 _vec128
+ gdb_arm_q6 = 97, // 22 660 16 _vec128
+ gdb_arm_q7 = 98, // 23 676 16 _vec128
+ gdb_arm_q8 = 99, // 24 692 16 _vec128
+ gdb_arm_q9 = 100, // 25 708 16 _vec128
+ gdb_arm_q10 = 101, // 26 724 16 _vec128
+ gdb_arm_q11 = 102, // 27 740 16 _vec128
+ gdb_arm_q12 = 103, // 28 756 16 _vec128
+ gdb_arm_q13 = 104, // 29 772 16 _vec128
+ gdb_arm_q14 = 105, // 30 788 16 _vec128
+ gdb_arm_q15 = 106 // 31 804 16 _vec128
+};
#endif // utility_ARM_GCC_Registers_h_
From gclayton at apple.com Tue Jul 19 11:44:54 2011
From: gclayton at apple.com (Greg Clayton)
Date: Tue, 19 Jul 2011 16:44:54 -0000
Subject: [Lldb-commits] [lldb] r135488 - in /lldb/trunk:
include/lldb/Core/ConnectionFileDescriptor.h
include/lldb/Host/SocketAddress.h lldb.xcodeproj/project.pbxproj
source/Core/ConnectionFileDescriptor.cpp
source/Host/common/SocketAddress.cpp
Message-ID: <20110719164454.943162A6C12D@llvm.org>
Author: gclayton
Date: Tue Jul 19 11:44:54 2011
New Revision: 135488
URL: http://llvm.org/viewvc/llvm-project?rev=135488&view=rev
Log:
Abstract "struct sockaddr", "struct sockaddr_in", "struct sockaddr_in6" and
"struct sockaddr_storage" into a new host class called SocketAddress. This
will allow us to control the host specific implementations (such as how to
get the length) into a single Host specific class.
Added:
lldb/trunk/include/lldb/Host/SocketAddress.h
lldb/trunk/source/Host/common/SocketAddress.cpp
Modified:
lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=135488&r1=135487&r2=135488&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Tue Jul 19 11:44:54 2011
@@ -19,6 +19,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Connection.h"
+#include "lldb/Host/SocketAddress.h"
namespace lldb_private {
@@ -96,20 +97,11 @@
eFDTypeSocketUDP // Unconnected UDP socket requiring sendto/recvfrom
} FDType;
- typedef union sockaddr_tag
- {
- struct sockaddr sa;
- struct sockaddr_in sa_ipv4;
- struct sockaddr_in6 sa_ipv6;
- struct sockaddr_storage sa_storage;
- } sockaddr_t;
-
-
int m_fd_send;
int m_fd_recv;
FDType m_fd_send_type;
FDType m_fd_recv_type;
- sockaddr_t m_udp_send_sockaddr;
+ SocketAddress m_udp_send_sockaddr;
bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
uint32_t m_socket_timeout_usec;
Added: lldb/trunk/include/lldb/Host/SocketAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/SocketAddress.h?rev=135488&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/SocketAddress.h (added)
+++ lldb/trunk/include/lldb/Host/SocketAddress.h Tue Jul 19 11:44:54 2011
@@ -0,0 +1,180 @@
+//===-- SocketAddress.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_SocketAddress_h_
+#define liblldb_SocketAddress_h_
+
+// C Includes
+#include
+#include
+#include
+#include
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+
+namespace lldb_private {
+
+class SocketAddress
+{
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SocketAddress();
+ SocketAddress(const SocketAddress& rhs);
+ ~SocketAddress();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const SocketAddress&
+ operator=(const SocketAddress& rhs);
+
+ const SocketAddress&
+ operator=(const struct addrinfo *addr_info);
+
+ void
+ Clear ();
+
+ socklen_t
+ GetLength () const;
+
+ static socklen_t
+ GetMaxLength ();
+
+ void
+ SetLength (socklen_t len);
+
+ sa_family_t
+ GetFamily () const;
+
+ void
+ SetFamily (sa_family_t family);
+
+ in_port_t
+ GetPort () const;
+
+ bool
+ IsValid () const;
+
+ struct sockaddr &
+ sockaddr ()
+ {
+ return m_socket_addr.sa;
+ }
+
+ const struct sockaddr &
+ sockaddr () const
+ {
+ return m_socket_addr.sa;
+ }
+
+ struct sockaddr_in &
+ sockaddr_in ()
+ {
+ return m_socket_addr.sa_ipv4;
+ }
+
+ const struct sockaddr_in &
+ sockaddr_in () const
+ {
+ return m_socket_addr.sa_ipv4;
+ }
+
+ struct sockaddr_in6 &
+ sockaddr_in6 ()
+ {
+ return m_socket_addr.sa_ipv6;
+ }
+
+ const struct sockaddr_in6 &
+ sockaddr_in6 () const
+ {
+ return m_socket_addr.sa_ipv6;
+ }
+
+ struct sockaddr_storage &
+ sockaddr_storage ()
+ {
+ return m_socket_addr.sa_storage;
+ }
+
+
+ const struct sockaddr_storage &
+ sockaddr_storage () const
+ {
+ return m_socket_addr.sa_storage;
+ }
+ //------------------------------------------------------------------
+ // Conversion operators to allow getting the contents of this class
+ // as a subclass
+ //------------------------------------------------------------------
+
+ operator struct sockaddr * ()
+ {
+ return &m_socket_addr.sa;
+ }
+
+ operator const struct sockaddr * () const
+ {
+ return &m_socket_addr.sa;
+ }
+
+ operator struct sockaddr_in * ()
+ {
+ return &m_socket_addr.sa_ipv4;
+ }
+
+ operator const struct sockaddr_in * () const
+ {
+ return &m_socket_addr.sa_ipv4;
+ }
+
+ operator struct sockaddr_in6 * ()
+ {
+ return &m_socket_addr.sa_ipv6;
+ }
+
+ operator const struct sockaddr_in6 * () const
+ {
+ return &m_socket_addr.sa_ipv6;
+ }
+
+ operator const struct sockaddr_storage * () const
+ {
+ return &m_socket_addr.sa_storage;
+ }
+
+ operator struct sockaddr_storage * ()
+ {
+ return &m_socket_addr.sa_storage;
+ }
+
+protected:
+ typedef union sockaddr_tag
+ {
+ struct sockaddr sa;
+ struct sockaddr_in sa_ipv4;
+ struct sockaddr_in6 sa_ipv6;
+ struct sockaddr_storage sa_storage;
+ } sockaddr_t;
+
+ //------------------------------------------------------------------
+ // Classes that inherit from SocketAddress can see and modify these
+ //------------------------------------------------------------------
+ sockaddr_t m_socket_addr;
+};
+
+
+} // namespace lldb_private
+
+
+#endif // liblldb_SocketAddress_h_
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=135488&r1=135487&r2=135488&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jul 19 11:44:54 2011
@@ -367,6 +367,7 @@
26D265BC136B4269002EEE45 /* lldb-public.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A14133BEC76005B64B7 /* lldb-public.h */; settings = {ATTRIBUTES = (Public, ); }; };
26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */; };
26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */; };
+ 26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */; };
26DB3E161379E7AD0080DC73 /* ABIMacOSX_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E071379E7AD0080DC73 /* ABIMacOSX_arm.cpp */; };
26DB3E1C1379E7AD0080DC73 /* ABIMacOSX_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E0F1379E7AD0080DC73 /* ABIMacOSX_i386.cpp */; };
26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E131379E7AD0080DC73 /* ABISysV_x86_64.cpp */; };
@@ -1040,6 +1041,8 @@
26D5E160135BAEB0006EA0A7 /* OptionGroupArchitecture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupArchitecture.h; path = include/lldb/Interpreter/OptionGroupArchitecture.h; sourceTree = ""; };
26D5E161135BB040006EA0A7 /* OptionGroupPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupPlatform.h; path = include/lldb/Interpreter/OptionGroupPlatform.h; sourceTree = ""; };
26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupPlatform.cpp; path = source/Interpreter/OptionGroupPlatform.cpp; sourceTree = ""; };
+ 26D7E45B13D5E2F9007FD12B /* SocketAddress.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SocketAddress.h; path = include/lldb/Host/SocketAddress.h; sourceTree = ""; };
+ 26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SocketAddress.cpp; path = source/Host/common/SocketAddress.cpp; sourceTree = ""; };
26D9FDC612F784E60003F2EE /* EmulateInstruction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulateInstruction.h; path = include/lldb/Core/EmulateInstruction.h; sourceTree = ""; };
26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmulateInstruction.cpp; path = source/Core/EmulateInstruction.cpp; sourceTree = ""; };
26DAFD9711529BC7005A394E /* ExecutionContextScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionContextScope.h; path = include/lldb/Target/ExecutionContextScope.h; sourceTree = ""; };
@@ -2293,6 +2296,8 @@
26BC7DD410F1B7D500F91463 /* Host.h */,
26BC7DD510F1B7D500F91463 /* Mutex.h */,
26BC7DD610F1B7D500F91463 /* Predicate.h */,
+ 26D7E45B13D5E2F9007FD12B /* SocketAddress.h */,
+ 26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */,
2689B0A4113EE3CD00A4AEDB /* Symbols.h */,
268DA871130095D000C9483A /* Terminal.h */,
26B4E26E112F35F700AB3F64 /* TimeValue.h */,
@@ -3349,6 +3354,7 @@
265205AC13D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp in Sources */,
2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */,
2676045A13D49D2300AB1B6A /* ProcessControl-mig.defs in Sources */,
+ 26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=135488&r1=135487&r2=135488&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Tue Jul 19 11:44:54 2011
@@ -71,11 +71,10 @@
m_fd_recv (-1),
m_fd_send_type (eFDTypeFile),
m_fd_recv_type (eFDTypeFile),
+ m_udp_send_sockaddr (),
m_should_close_fd (false),
m_socket_timeout_usec(0)
{
- memset (&m_udp_send_sockaddr, 0, sizeof(m_udp_send_sockaddr));
-
LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor ()", this);
@@ -87,10 +86,10 @@
m_fd_recv (fd),
m_fd_send_type (eFDTypeFile),
m_fd_recv_type (eFDTypeFile),
+ m_udp_send_sockaddr (),
m_should_close_fd (owns_fd),
m_socket_timeout_usec(0)
{
- memset (&m_udp_send_sockaddr, 0, sizeof(m_udp_send_sockaddr));
LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", this, fd, owns_fd);
@@ -285,8 +284,8 @@
if (SetSocketReceiveTimeout (timeout_usec))
{
status = eConnectionStatusSuccess;
- sockaddr_t from = m_udp_send_sockaddr;
- socklen_t from_len = m_udp_send_sockaddr.sa.sa_len;
+ SocketAddress from (m_udp_send_sockaddr);
+ socklen_t from_len = m_udp_send_sockaddr.GetLength();
bytes_read = ::recvfrom (m_fd_recv, dst, dst_len, 0, (struct sockaddr *)&from, &from_len);
}
break;
@@ -401,13 +400,13 @@
break;
case eFDTypeSocketUDP: // Unconnected UDP socket requiring sendto/recvfrom
- assert (m_udp_send_sockaddr.sa_storage.ss_family != 0);
+ assert (m_udp_send_sockaddr.GetFamily() != 0);
bytes_sent = ::sendto (m_fd_send,
src,
src_len,
0,
- &m_udp_send_sockaddr.sa,
- m_udp_send_sockaddr.sa.sa_len);
+ m_udp_send_sockaddr,
+ m_udp_send_sockaddr.GetLength());
break;
}
@@ -896,10 +895,7 @@
if (m_fd_send != -1)
{
- ::memset (&m_udp_send_sockaddr, 0, sizeof(m_udp_send_sockaddr));
- ::memcpy (&m_udp_send_sockaddr,
- service_info_ptr->ai_addr,
- service_info_ptr->ai_addrlen);
+ m_udp_send_sockaddr = service_info_ptr;
break;
}
else
@@ -977,18 +973,12 @@
ConnectionFileDescriptor::GetSocketPort (int fd)
{
// We bound to port zero, so we need to figure out which port we actually bound to
- sockaddr_t sock_addr;
- socklen_t sock_addr_len = sizeof (sock_addr);
- if (::getsockname (fd, &sock_addr.sa, &sock_addr_len) == 0)
- {
- switch (sock_addr.sa.sa_family)
- {
- case AF_INET: return sock_addr.sa_ipv4.sin_port;
- case AF_INET6: return sock_addr.sa_ipv6.sin6_port;
- }
- }
- return 0;
+ SocketAddress sock_addr;
+ socklen_t sock_addr_len = sock_addr.GetMaxLength ();
+ if (::getsockname (fd, sock_addr, &sock_addr_len) == 0)
+ return sock_addr.GetPort ();
+ return 0;
}
// If the read file descriptor is a socket, then return
Added: lldb/trunk/source/Host/common/SocketAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SocketAddress.cpp?rev=135488&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/SocketAddress.cpp (added)
+++ lldb/trunk/source/Host/common/SocketAddress.cpp Tue Jul 19 11:44:54 2011
@@ -0,0 +1,126 @@
+//===-- SocketAddress.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/SocketAddress.h"
+#include
+
+// C Includes
+#include
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// SocketAddress constructor
+//----------------------------------------------------------------------
+SocketAddress::SocketAddress()
+{
+ Clear ();
+}
+
+//----------------------------------------------------------------------
+// SocketAddress copy constructor
+//----------------------------------------------------------------------
+SocketAddress::SocketAddress (const SocketAddress& rhs) :
+ m_socket_addr (rhs.m_socket_addr)
+{
+}
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+SocketAddress::~SocketAddress()
+{
+}
+
+void
+SocketAddress::Clear ()
+{
+ memset (&m_socket_addr, 0, sizeof(m_socket_addr));
+}
+
+bool
+SocketAddress::IsValid () const
+{
+ return GetLength () != 0;
+}
+
+socklen_t
+SocketAddress::GetLength () const
+{
+ return m_socket_addr.sa.sa_len;
+}
+
+socklen_t
+SocketAddress::GetMaxLength ()
+{
+ return sizeof (sockaddr_t);
+}
+
+void
+SocketAddress::SetLength (socklen_t len)
+{
+ m_socket_addr.sa.sa_len = len;
+}
+
+sa_family_t
+SocketAddress::GetFamily () const
+{
+ return m_socket_addr.sa.sa_family;
+}
+
+void
+SocketAddress::SetFamily (sa_family_t family)
+{
+ m_socket_addr.sa.sa_family = family;
+}
+
+in_port_t
+SocketAddress::GetPort () const
+{
+ switch (GetFamily())
+ {
+ case AF_INET: return m_socket_addr.sa_ipv4.sin_port;
+ case AF_INET6: return m_socket_addr.sa_ipv6.sin6_port;
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------
+// SocketAddress assignment operator
+//----------------------------------------------------------------------
+const SocketAddress&
+SocketAddress::operator=(const SocketAddress& rhs)
+{
+ if (this != &rhs)
+ m_socket_addr = rhs.m_socket_addr;
+ return *this;
+}
+
+const SocketAddress&
+SocketAddress::operator=(const struct addrinfo *addr_info)
+{
+ Clear();
+ if (addr_info &&
+ addr_info->ai_addr &&
+ addr_info->ai_addrlen > 0&&
+ addr_info->ai_addrlen <= sizeof m_socket_addr)
+ {
+ ::memcpy (&m_socket_addr,
+ addr_info->ai_addr,
+ addr_info->ai_addrlen);
+ }
+ return *this;
+}
+
+
+
From gclayton at apple.com Tue Jul 19 11:49:23 2011
From: gclayton at apple.com (Greg Clayton)
Date: Tue, 19 Jul 2011 09:49:23 -0700
Subject: [Lldb-commits] [lldb] r135363 - in /lldb/trunk:
include/lldb/Core/ include/lldb/Target/ source/ source/Core/
source/Plugins/Process/MacOSX-Kernel/
source/Plugins/Process/MacOSX-User/source/
source/Plugins/Process/gdb-remote/ source/Target/
In-Reply-To: <4E24D085.80704@crhc.illinois.edu>
References: <20110717203625.CCCBF2A6C12C@llvm.org>
<4E24D085.80704@crhc.illinois.edu>
Message-ID: <8ED2AD49-44A8-47AD-9BB7-B5496FD6964D@apple.com>
I added a new SocketAddress class in the host layer for you and modified the ConnectionFileDescriptor to use it:
% svn commit
Sending include/lldb/Core/ConnectionFileDescriptor.h
Adding include/lldb/Host/SocketAddress.h
Sending lldb.xcodeproj/project.pbxproj
Sending source/Core/ConnectionFileDescriptor.cpp
Adding source/Host/common/SocketAddress.cpp
Transmitting file data .....
Committed revision 135488.
We can now isolate all host specific changes into "SocketAddress.cpp". I left our simple implementation as:
socklen_t
SocketAddress::GetLength () const
{
return m_socket_addr.sa.sa_len;
}
Feel free to add #ifdef stuff and "do the right thing" for linux.
In LLDB we would like to have the Host layer (all files in "lldb/include/lldb/Host/*" and "source/Host/*" abstract us from the host layer where we need it. This is the perfect case right here. We currently haven't run into anything that we haven't been able to take care of with this type of abtraction (we haven't required autoconf, nor do I really want it if we can avoid it).
Let me know if this works for you,
Greg Clayton
On Jul 18, 2011, at 5:32 PM, Matt Johnson wrote:
> Hi all,
>
> struct sockaddr and struct sockaddr_in don't have sa_len and sin_len members, respectively in glibc/Ubuntu 11.04, breaking the build on r135363:
>
> ConnectionFileDescriptor.cpp: In member function ?virtual size_t lldb_private::ConnectionFileDescriptor::Read(void*, size_t, uint32_t, lldb::ConnectionStatus&, lldb_private::Error*)?:
> ConnectionFileDescriptor.cpp:289:57: error: ?struct sockaddr? has no member named ?sa_len?
> ConnectionFileDescriptor.cpp: In member function ?virtual size_t lldb_private::ConnectionFileDescriptor::Write(const void*, size_t, lldb::ConnectionStatus&, lldb_private::Error*)?:
> ConnectionFileDescriptor.cpp:410:59: error: ?struct sockaddr? has no member named ?sa_len?
> ConnectionFileDescriptor.cpp: In member function ?lldb::ConnectionStatus lldb_private::ConnectionFileDescriptor::ConnectUDP(const char*, lldb_private::Error*)?:
> ConnectionFileDescriptor.cpp:850:13: error: ?struct sockaddr_in? has no member named ?sin_len?
>
> glibc provides equivalent functionality to sa_len with a macro SA_LEN, which looks at the sa_family member to determine the length (see http://lists.debian.org/debian-ipv6/2001/06/msg00015.html). Fixing the build under glibc would involve #ifdefing out the first use of sa_len and the only use of sin_len, and replacing the second use of sa_len with the SA_LEN() macro.
>
> I'm not submitting a patch yet because I wanted to ask how we want to test for sa_len and sin_len. Other projects have done it using autoconf macros (see http://archives.seul.org/or/cvs/Jan-2009/msg00014.html http://hackage.haskell.org/trac/ghc/ticket/2326 ), but I can't figure out on inspection exactly how lldb's Makefile is generated. I suspect it relies on llvm's configure script, but am not sure. If so, that would be the appropriate place to put the member checks, but this may require lldb to roll forward its frozen llvm version.
>
> Thoughts?
>
> Best,
> Matt
>
From granata.enrico at gmail.com Tue Jul 19 13:03:26 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Tue, 19 Jul 2011 18:03:26 -0000
Subject: [Lldb-commits] [lldb] r135494 - in /lldb/trunk: include/lldb/
include/lldb/Core/ lldb.xcodeproj/ source/Commands/ source/Core/
source/Expression/ source/Plugins/Disassembler/llvm/
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/
test/functionalities/data-formatter/data-formatter-categories/
Message-ID: <20110719180326.4CDAA2A6C12E@llvm.org>
Author: enrico
Date: Tue Jul 19 13:03:25 2011
New Revision: 135494
URL: http://llvm.org/viewvc/llvm-project?rev=135494&view=rev
Log:
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
Added:
lldb/trunk/include/lldb/Core/FormatClasses.h
lldb/trunk/source/Core/FormatClasses.cpp
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Commands/CommandObjectType.h
lldb/trunk/source/Core/DataExtractor.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/FormatManager.cpp
lldb/trunk/source/Expression/ClangExpressionParser.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Expression/IRDynamicChecks.cpp
lldb/trunk/source/Expression/IRForTarget.cpp
lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/main.cpp
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Tue Jul 19 13:03:25 2011
@@ -501,10 +501,7 @@
static uint32_t
GetCount();
};
-
- static lldb::FormatCategorySP
- SummaryFormats(const char* category_name = NULL);
-
+
static bool
GetSummaryFormat(ValueObject& vobj,
lldb::SummaryFormatSP& entry);
Added: lldb/trunk/include/lldb/Core/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=135494&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (added)
+++ lldb/trunk/include/lldb/Core/FormatClasses.h Tue Jul 19 13:03:25 2011
@@ -0,0 +1,244 @@
+//===-- FormatClasses.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_FormatClasses_h_
+#define lldb_FormatClasses_h_
+
+// C Includes
+
+#include
+#include
+
+// C++ Includes
+#include
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+namespace lldb_private {
+
+struct ValueFormat
+{
+ bool m_cascades;
+ bool m_skip_pointers;
+ bool m_skip_references;
+ lldb::Format m_format;
+ ValueFormat (lldb::Format f = lldb::eFormatInvalid,
+ bool casc = false,
+ bool skipptr = false,
+ bool skipref = false) :
+ m_cascades(casc),
+ m_skip_pointers(skipptr),
+ m_skip_references(skipref),
+ m_format (f)
+ {
+ }
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+ typedef bool(*ValueCallback)(void*, const char*, const ValueFormat::SharedPointer&);
+
+ ~ValueFormat()
+ {
+ }
+
+ bool
+ Cascades()
+ {
+ return m_cascades;
+ }
+ bool
+ SkipsPointers()
+ {
+ return m_skip_pointers;
+ }
+ bool
+ SkipsReferences()
+ {
+ return m_skip_references;
+ }
+
+ lldb::Format
+ GetFormat()
+ {
+ return m_format;
+ }
+
+ std::string
+ FormatObject(lldb::ValueObjectSP object);
+
+};
+
+struct SummaryFormat
+{
+ bool m_cascades;
+ bool m_skip_pointers;
+ bool m_skip_references;
+ bool m_dont_show_children;
+ bool m_dont_show_value;
+ bool m_show_members_oneliner;
+
+ SummaryFormat(bool casc = false,
+ bool skipptr = false,
+ bool skipref = false,
+ bool nochildren = true,
+ bool novalue = true,
+ bool oneliner = false) :
+ m_cascades(casc),
+ m_skip_pointers(skipptr),
+ m_skip_references(skipref),
+ m_dont_show_children(nochildren),
+ m_dont_show_value(novalue),
+ m_show_members_oneliner(oneliner)
+ {
+ }
+
+ bool
+ Cascades()
+ {
+ return m_cascades;
+ }
+ bool
+ SkipsPointers()
+ {
+ return m_skip_pointers;
+ }
+ bool
+ SkipsReferences()
+ {
+ return m_skip_references;
+ }
+
+ bool
+ DoesPrintChildren() const
+ {
+ return !m_dont_show_children;
+ }
+
+ bool
+ DoesPrintValue() const
+ {
+ return !m_dont_show_value;
+ }
+
+ bool
+ IsOneliner() const
+ {
+ return m_show_members_oneliner;
+ }
+
+ virtual
+ ~SummaryFormat()
+ {
+ }
+
+ virtual std::string
+ FormatObject(lldb::ValueObjectSP object) = 0;
+
+ virtual std::string
+ GetDescription() = 0;
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+ typedef bool(*SummaryCallback)(void*, const char*, const SummaryFormat::SharedPointer&);
+ typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const SummaryFormat::SharedPointer&);
+
+};
+
+// simple string-based summaries, using ${var to show data
+struct StringSummaryFormat : public SummaryFormat
+{
+ std::string m_format;
+
+ StringSummaryFormat(bool casc = false,
+ bool skipptr = false,
+ bool skipref = false,
+ bool nochildren = true,
+ bool novalue = true,
+ bool oneliner = false,
+ std::string f = "") :
+ SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner),
+ m_format(f)
+ {
+ }
+
+ std::string
+ GetFormat()
+ {
+ return m_format;
+ }
+
+ virtual
+ ~StringSummaryFormat()
+ {
+ }
+
+ virtual std::string
+ FormatObject(lldb::ValueObjectSP object);
+
+ virtual std::string
+ GetDescription();
+
+};
+
+// Python-based summaries, running script code to show data
+struct ScriptSummaryFormat : public SummaryFormat
+{
+ std::string m_function_name;
+ std::string m_python_script;
+
+ ScriptSummaryFormat(bool casc = false,
+ bool skipptr = false,
+ bool skipref = false,
+ bool nochildren = true,
+ bool novalue = true,
+ bool oneliner = false,
+ std::string fname = "",
+ std::string pscri = "") :
+ SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner),
+ m_function_name(fname),
+ m_python_script(pscri)
+ {
+ }
+
+ std::string
+ GetFunctionName()
+ {
+ return m_function_name;
+ }
+
+ std::string
+ GetPythonScript()
+ {
+ return m_python_script;
+ }
+
+ virtual
+ ~ScriptSummaryFormat()
+ {
+ }
+
+ virtual std::string
+ FormatObject(lldb::ValueObjectSP object);
+
+ virtual std::string
+ GetDescription();
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+
+};
+
+} // namespace lldb_private
+
+#endif // lldb_FormatClasses_h_
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Tue Jul 19 13:03:25 2011
@@ -43,6 +43,7 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/Communication.h"
+#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/InputReaderStack.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/RegularExpression.h"
@@ -69,380 +70,10 @@
~IFormatChangeListener() {}
};
-
-struct ValueFormat
-{
- bool m_cascades;
- bool m_skip_pointers;
- bool m_skip_references;
- lldb::Format m_format;
- ValueFormat (lldb::Format f = lldb::eFormatInvalid,
- bool casc = false,
- bool skipptr = false,
- bool skipref = false) :
- m_cascades(casc),
- m_skip_pointers(skipptr),
- m_skip_references(skipref),
- m_format (f)
- {
- }
- typedef lldb::SharedPtr::Type SharedPointer;
- typedef bool(*ValueCallback)(void*, const char*, const ValueFormat::SharedPointer&);
-
- ~ValueFormat()
- {
- }
-
- bool
- Cascades()
- {
- return m_cascades;
- }
- bool
- SkipsPointers()
- {
- return m_skip_pointers;
- }
- bool
- SkipsReferences()
- {
- return m_skip_references;
- }
-
- lldb::Format
- GetFormat()
- {
- return m_format;
- }
-
- std::string
- FormatObject(lldb::ValueObjectSP object)
- {
- if (!object.get())
- return "NULL";
-
- StreamString sstr;
-
- if (ClangASTType::DumpTypeValue (object->GetClangAST(), // The clang AST
- object->GetClangType(), // The clang type to display
- &sstr,
- m_format, // Format to display this type with
- object->GetDataExtractor(), // Data to extract from
- 0, // Byte offset into "data"
- object->GetByteSize(), // Byte size of item in "data"
- object->GetBitfieldBitSize(), // Bitfield bit size
- object->GetBitfieldBitOffset())) // Bitfield bit offset
- return (sstr.GetString());
- else
- {
- return ("unsufficient data for value");
- }
-
- }
-
-};
-
-struct SummaryFormat
-{
- bool m_cascades;
- bool m_skip_pointers;
- bool m_skip_references;
- bool m_dont_show_children;
- bool m_dont_show_value;
- bool m_show_members_oneliner;
- bool m_is_system;
-
- uint32_t m_priority;
-
- SummaryFormat(bool casc = false,
- bool skipptr = false,
- bool skipref = false,
- bool nochildren = true,
- bool novalue = true,
- bool oneliner = false,
- bool system = false,
- uint32_t priority = 2) :
- m_cascades(casc),
- m_skip_pointers(skipptr),
- m_skip_references(skipref),
- m_dont_show_children(nochildren),
- m_dont_show_value(novalue),
- m_show_members_oneliner(oneliner),
- m_is_system(system),
- m_priority(priority)
- {
- }
-
- bool
- Cascades()
- {
- return m_cascades;
- }
- bool
- SkipsPointers()
- {
- return m_skip_pointers;
- }
- bool
- SkipsReferences()
- {
- return m_skip_references;
- }
-
- bool
- DoesPrintChildren() const
- {
- return !m_dont_show_children;
- }
-
- bool
- DoesPrintValue() const
- {
- return !m_dont_show_value;
- }
-
- bool
- IsOneliner() const
- {
- return m_show_members_oneliner;
- }
-
- bool
- IsSystem() const
- {
- return m_is_system;
- }
-
- uint32_t
- GetPriority() const
- {
- return m_priority;
- }
-
- void
- SetPriority(uint32_t newprio)
- {
- m_priority = newprio;
- }
-
- virtual
- ~SummaryFormat()
- {
- }
-
- virtual std::string
- FormatObject(lldb::ValueObjectSP object) = 0;
-
- virtual std::string
- GetDescription() = 0;
-
- typedef lldb::SharedPtr::Type SharedPointer;
- typedef bool(*SummaryCallback)(void*, const char*, const SummaryFormat::SharedPointer&);
- typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const SummaryFormat::SharedPointer&);
-
-};
-
-// simple string-based summaries, using ${var to show data
-struct StringSummaryFormat : public SummaryFormat
-{
- std::string m_format;
-
- StringSummaryFormat(bool casc = false,
- bool skipptr = false,
- bool skipref = false,
- bool nochildren = true,
- bool novalue = true,
- bool oneliner = false,
- bool system = false,
- std::string f = "",
- uint32_t priority = 2) :
- SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner,system, priority),
- m_format(f)
- {
- }
-
- std::string
- GetFormat()
- {
- return m_format;
- }
-
- virtual
- ~StringSummaryFormat()
- {
- }
-
- virtual std::string
- FormatObject(lldb::ValueObjectSP object);
-
- virtual std::string
- GetDescription()
- {
- StreamString sstr;
- sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(),
- m_cascades ? "" : " (not cascading)",
- m_dont_show_children ? "" : " (show children)",
- m_dont_show_value ? " (hide value)" : "",
- m_show_members_oneliner ? " (one-line printout)" : "",
- m_skip_pointers ? " (skip pointers)" : "",
- m_skip_references ? " (skip references)" : "",
- m_is_system ? " (system)" : "");
- return sstr.GetString();
- }
-
-};
-
-// Python-based summaries, running script code to show data
-struct ScriptSummaryFormat : public SummaryFormat
-{
- std::string m_function_name;
- std::string m_python_script;
-
- ScriptSummaryFormat(bool casc = false,
- bool skipptr = false,
- bool skipref = false,
- bool nochildren = true,
- bool novalue = true,
- bool oneliner = false,
- bool system = false,
- std::string fname = "",
- std::string pscri = "",
- uint32_t priority = 2) :
- SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner,system,priority),
- m_function_name(fname),
- m_python_script(pscri)
- {
- }
-
- std::string
- GetFunctionName()
- {
- return m_function_name;
- }
-
- std::string
- GetPythonScript()
- {
- return m_python_script;
- }
-
- virtual
- ~ScriptSummaryFormat()
- {
- }
-
- virtual std::string
- FormatObject(lldb::ValueObjectSP object)
- {
- return std::string(ScriptInterpreterPython::CallPythonScriptFunction(m_function_name.c_str(),
- object).c_str());
- }
-
- virtual std::string
- GetDescription()
- {
- StreamString sstr;
- sstr.Printf ("%s%s%s%s%s%s%s\n%s", m_cascades ? "" : " (not cascading)",
- m_dont_show_children ? "" : " (show children)",
- m_dont_show_value ? " (hide value)" : "",
- m_show_members_oneliner ? " (one-line printout)" : "",
- m_skip_pointers ? " (skip pointers)" : "",
- m_skip_references ? " (skip references)" : "",
- m_is_system ? " (system)" : "",
- m_python_script.c_str());
- return sstr.GetString();
-
- }
-
- typedef lldb::SharedPtr::Type SharedPointer;
-
-};
-
-/*struct SummaryFormat
-{
- std::string m_format;
- bool m_dont_show_children;
- bool m_dont_show_value;
- bool m_show_members_oneliner;
- bool m_cascades;
- bool m_skip_references;
- bool m_skip_pointers;
- SummaryFormat(std::string f = "",
- bool c = false,
- bool nochildren = true,
- bool novalue = true,
- bool oneliner = false,
- bool skipptr = false,
- bool skipref = false) :
- m_format(f),
- m_dont_show_children(nochildren),
- m_dont_show_value(novalue),
- m_show_members_oneliner(oneliner),
- m_cascades(c),
- m_skip_references(skipref),
- m_skip_pointers(skipptr)
- {
- }
-
- bool
- DoesPrintChildren() const
- {
- return !m_dont_show_children;
- }
-
- bool
- DoesPrintValue() const
- {
- return !m_dont_show_value;
- }
-
- bool
- IsOneliner() const
- {
- return m_show_members_oneliner;
- }
-
- typedef lldb::SharedPtr::Type SharedPointer;
- typedef bool(*SummaryCallback)(void*, const char*, const SummaryFormat::SharedPointer&);
- typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const SummaryFormat::SharedPointer&);
-
-};
-
-struct ScriptFormat
-{
- std::string m_function_name;
- std::string m_python_script;
- bool m_cascades;
- bool m_skip_references;
- bool m_skip_pointers;
- ScriptFormat (std::string n,
- std::string s = "",
- bool c = false,
- bool skipptr = false,
- bool skipref = false) :
- m_function_name (n),
- m_python_script(s),
- m_cascades (c),
- m_skip_references(skipref),
- m_skip_pointers(skipptr)
- {
- }
-
- typedef lldb::SharedPtr::Type SharedPointer;
- typedef bool(*ScriptCallback)(void*, const char*, const ScriptFormat::SharedPointer&);
-
- ~ScriptFormat()
- {
- }
-
-};*/
-
template
class FormatNavigator;
-
-class FormatManager;
-
+
template
class FormatMap
{
@@ -500,7 +131,7 @@
if (iter == m_map.end())
return false;
m_map.erase(name);
- if(listener)
+ if (listener)
listener->Changed();
return true;
}
@@ -510,7 +141,7 @@
{
Mutex::Locker(m_map_mutex);
m_map.clear();
- if(listener)
+ if (listener)
listener->Changed();
}
@@ -536,7 +167,7 @@
for (pos = m_map.begin(); pos != end; pos++)
{
KeyType type = pos->first;
- if(!callback(param, type, pos->second))
+ if (!callback(param, type, pos->second))
break;
}
}
@@ -549,8 +180,6 @@
}
};
-
-class FormatCategory;
template
class FormatNavigator
@@ -650,7 +279,7 @@
if (!typePtr)
return false;
ConstString name(ClangASTType::GetTypeNameForQualType(type).c_str());
- if(vobj.GetBitfieldBitSize() > 0)
+ if (vobj.GetBitfieldBitSize() > 0)
{
// for bitfields, append size to the typename so one can custom format them
StreamString sstring;
@@ -687,7 +316,7 @@
*/
Error error;
ValueObject* target = vobj.Dereference(error).get();
- if(error.Fail() || !target)
+ if (error.Fail() || !target)
return false;
if (Get(*target, typePtr->getPointeeType(), entry, reason) && !entry->m_skip_pointers)
{
@@ -703,12 +332,12 @@
if (ClangASTContext::GetCompleteType(ast, vobj.GetClangType()) && !objc_class_type->isObjCId())
{
clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- if(class_interface_decl)
+ if (class_interface_decl)
{
//printf("down here\n");
clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
//printf("one further step and we're there...\n");
- if(superclass_interface_decl)
+ if (superclass_interface_decl)
{
//printf("the end is here\n");
clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl));
@@ -732,12 +361,12 @@
if (record->hasDefinition())
{
clang::CXXRecordDecl::base_class_iterator pos,end;
- if( record->getNumBases() > 0)
+ if (record->getNumBases() > 0)
{
end = record->bases_end();
for (pos = record->bases_begin(); pos != end; pos++)
{
- if((Get(vobj, pos->getType(), entry, reason)) && entry->m_cascades)
+ if ((Get(vobj, pos->getType(), entry, reason)) && entry->m_cascades)
{
reason |= lldb::eFormatterNavigatedBaseClasses;
return true;
@@ -749,7 +378,7 @@
end = record->vbases_end();
for (pos = record->vbases_begin(); pos != end; pos++)
{
- if((Get(vobj, pos->getType(), entry, reason)) && entry->m_cascades)
+ if ((Get(vobj, pos->getType(), entry, reason)) && entry->m_cascades)
{
reason |= lldb::eFormatterNavigatedBaseClasses;
return true;
@@ -781,6 +410,8 @@
bool
FormatNavigator::Delete(const char* type);
+class CategoryMap;
+
class FormatCategory
{
private:
@@ -799,6 +430,23 @@
Mutex m_mutex;
+ void
+ Enable(bool value = true)
+ {
+ Mutex::Locker(m_mutex);
+ m_enabled = value;
+ if (m_change_listener)
+ m_change_listener->Changed();
+ }
+
+ void
+ Disable()
+ {
+ Enable(false);
+ }
+
+ friend class CategoryMap;
+
public:
typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
@@ -829,22 +477,7 @@
{
return m_enabled;
}
-
- void
- Enable(bool value = true)
- {
- Mutex::Locker(m_mutex);
- m_enabled = value;
- if(m_change_listener)
- m_change_listener->Changed();
- }
-
- void
- Disable()
- {
- Enable(false);
- }
-
+
bool
Get(ValueObject& vobj,
lldb::SummaryFormatSP& entry,
@@ -856,7 +489,7 @@
return true;
bool regex = RegexSummary()->Get(vobj, entry, reason);
if (regex && reason)
- *reason |= lldb::eFormatterRegularExpressionSummary; // penalize regex summaries over normal ones
+ *reason |= lldb::eFormatterRegularExpressionSummary;
return regex;
}
@@ -876,79 +509,215 @@
return (del_sum || del_rex);
}
- void
- ChooseAsPreferential(const char* name);
-
typedef lldb::SharedPtr::Type SharedPointer;
};
-class FormatManager : public IFormatChangeListener
+class CategoryMap
{
private:
+ typedef const char* KeyType;
+ typedef FormatCategory ValueType;
+ typedef ValueType::SharedPointer ValueSP;
+ typedef std::list ActiveCategoriesList;
+ typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
- typedef FormatNavigator ValueNavigator;
-
- typedef FormatMap CategoryMap;
-
- typedef ValueNavigator::MapType ValueMap;
- typedef FormatMap NamedSummariesMap;
+ Mutex m_map_mutex;
+ IFormatChangeListener* listener;
- typedef std::list ActiveCategoriesList;
- typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
+ friend class FormatNavigator;
+ friend class FormatManager;
- ValueNavigator m_value_nav;
- NamedSummariesMap m_named_summaries_map;
- uint32_t m_last_revision;
- CategoryMap m_categories_map;
+public:
+ typedef std::map MapType;
+
+private:
+ MapType m_map;
ActiveCategoriesList m_active_categories;
-
- const char* m_default_category_name;
- const char* m_system_category_name;
-
- typedef CategoryMap::MapType::iterator CategoryMapIterator;
+
+ MapType& map()
+ {
+ return m_map;
+ }
+
+ ActiveCategoriesList& active_list()
+ {
+ return m_active_categories;
+ }
+
+ Mutex& mutex()
+ {
+ return m_map_mutex;
+ }
+
+public:
+
+ typedef MapType::iterator MapIterator;
+ typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
+
+ CategoryMap(IFormatChangeListener* lst = NULL) :
+ m_map_mutex(Mutex::eMutexTypeRecursive),
+ listener(lst),
+ m_map(),
+ m_active_categories()
+ {
+ }
+
+ void
+ Add(KeyType name,
+ const ValueSP& entry)
+ {
+ Mutex::Locker(m_map_mutex);
+ m_map[name] = entry;
+ if (listener)
+ listener->Changed();
+ }
bool
- Get_ExactMatch(ValueObject& vobj,
- lldb::SummaryFormatSP& entry)
+ Delete(KeyType name)
{
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- SummaryFormat::SharedPointer current_category_pick;
- uint32_t reason_to_pick_current;
+ Mutex::Locker(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ m_map.erase(name);
+ DisableCategory(name);
+ if (listener)
+ listener->Changed();
+ return true;
+ }
+
+ void
+ EnableCategory(KeyType category_name)
+ {
+ Mutex::Locker(m_map_mutex);
+ ValueSP category;
+ if (!Get(category_name,category))
+ return;
+ category->Enable();
+ m_active_categories.push_front(category);
+ }
+
+ class delete_matching_categories
+ {
+ FormatCategory::SharedPointer ptr;
+ public:
+ delete_matching_categories(FormatCategory::SharedPointer p) : ptr(p)
+ {}
- for (begin = m_active_categories.begin(); begin != end; begin++)
+ bool operator()(const FormatCategory::SharedPointer& other)
{
- FormatCategory::SharedPointer category = *begin;
- if ( category->Get(vobj, current_category_pick, &reason_to_pick_current) && reason_to_pick_current == lldb::eFormatterDirectChoice )
+ return ptr.get() == other.get();
+ }
+ };
+
+ void
+ DisableCategory(KeyType category_name)
+ {
+ Mutex::Locker(m_map_mutex);
+ ValueSP category;
+ if (!Get(category_name,category))
+ return;
+ category->Disable();
+ m_active_categories.remove_if(delete_matching_categories(category));
+ }
+
+ void
+ Clear()
+ {
+ Mutex::Locker(m_map_mutex);
+ m_map.clear();
+ m_active_categories.clear();
+ if (listener)
+ listener->Changed();
+ }
+
+ bool
+ Get(KeyType name,
+ ValueSP& entry)
+ {
+ Mutex::Locker(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ entry = iter->second;
+ return true;
+ }
+
+ void
+ LoopThrough(CallbackType callback, void* param)
+ {
+ if (callback)
+ {
+ Mutex::Locker(m_map_mutex);
+ MapIterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; pos++)
{
- entry = SummaryFormat::SharedPointer(current_category_pick);
- return true;
+ KeyType type = pos->first;
+ if (!callback(param, type, pos->second))
+ break;
}
}
- return false;
}
-
+
+ uint32_t
+ GetCount()
+ {
+ return m_map.size();
+ }
+
bool
- Get_AnyMatch(ValueObject& vobj,
- lldb::SummaryFormatSP& entry)
+ Get(ValueObject& vobj,
+ lldb::SummaryFormatSP& entry)
{
- ActiveCategoriesIterator begin, end = m_active_categories.end();
+ Mutex::Locker(m_map_mutex);
+
+ uint32_t reason_why;
+ bool first = true;
- SummaryFormat::SharedPointer current_category_pick;
+ ActiveCategoriesIterator begin, end = m_active_categories.end();
for (begin = m_active_categories.begin(); begin != end; begin++)
{
FormatCategory::SharedPointer category = *begin;
- if ( category->Get(vobj, current_category_pick, NULL) )
+ lldb::SummaryFormatSP current_format;
+ if (!category->Get(vobj, current_format, &reason_why))
+ continue;
+ if (reason_why == lldb::eFormatterDirectChoice)
{
- entry = SummaryFormat::SharedPointer(current_category_pick);
+ entry = current_format;
return true;
}
+ else if (first)
+ {
+ entry = current_format;
+ first = false;
+ }
}
- return false;
+ return !first;
}
+};
+
+
+class FormatManager : public IFormatChangeListener
+{
+private:
+
+ typedef FormatNavigator ValueNavigator;
+
+ typedef ValueNavigator::MapType ValueMap;
+ typedef FormatMap NamedSummariesMap;
+
+ ValueNavigator m_value_nav;
+ NamedSummariesMap m_named_summaries_map;
+ uint32_t m_last_revision;
+ CategoryMap m_categories_map;
+ const char* m_default_category_name;
+ const char* m_system_category_name;
+
+ typedef CategoryMap::MapType::iterator CategoryMapIterator;
+
public:
typedef bool (*CategoryCallback)(void*, const char*, const FormatCategory::SharedPointer&);
@@ -957,18 +726,14 @@
m_value_nav(this),
m_named_summaries_map(this),
m_last_revision(0),
- m_categories_map(this),
- m_active_categories()
+ m_categories_map(this)
{
// build default categories
m_default_category_name = ConstString("default").GetCString();
m_system_category_name = ConstString("system").GetCString();
-
- Category(m_default_category_name)->Enable();
- Category(m_system_category_name)->Enable();
-
+
// add some default stuff
// most formats, summaries, ... actually belong to the users' lldbinit file rather than here
SummaryFormat::SharedPointer string_format(new StringSummaryFormat(false,
@@ -977,9 +742,7 @@
true,
false,
false,
- true,
- "${var%s}",
- 1));
+ "${var%s}"));
SummaryFormat::SharedPointer string_array_format(new StringSummaryFormat(false,
@@ -988,19 +751,20 @@
false,
false,
false,
- true,
- "${var%s}",
- 1));
+ "${var%s}"));
lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]"));
- Summary(m_system_category_name)->Add(ConstString("char *").GetCString(), string_format);
- Summary(m_system_category_name)->Add(ConstString("const char *").GetCString(), string_format);
- RegexSummary(m_system_category_name)->Add(any_size_char_arr, string_array_format);
-
- m_active_categories.push_front(Category(m_system_category_name));
- m_active_categories.push_front(Category(m_default_category_name));
+ Category(m_system_category_name)->Summary()->Add(ConstString("char *").GetCString(), string_format);
+ Category(m_system_category_name)->Summary()->Add(ConstString("const char *").GetCString(), string_format);
+ Category(m_system_category_name)->RegexSummary()->Add(any_size_char_arr, string_array_format);
+
+ Category(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category
+
+ // the order of these two calls IS important, if you invert it "system" summaries will prevail over the user's
+ EnableCategory(m_system_category_name);
+ EnableCategory(m_default_category_name);
}
@@ -1012,62 +776,31 @@
void
EnableCategory(const char* category_name)
{
- Category(category_name)->Enable();
- m_active_categories.push_front(Category(category_name));
+ m_categories_map.EnableCategory(category_name);
}
- class delete_matching_categories
- {
- FormatCategory::SharedPointer ptr;
- public:
- delete_matching_categories(FormatCategory::SharedPointer p) : ptr(p)
- {}
-
- bool operator()(const FormatCategory::SharedPointer& other)
- {
- return ptr.get() == other.get();
- }
- };
-
void
DisableCategory(const char* category_name)
{
- Category(category_name)->Disable();
- m_active_categories.remove_if(delete_matching_categories(Category(category_name)));
+ m_categories_map.DisableCategory(category_name);
}
void
LoopThroughCategories(CategoryCallback callback, void* param)
{
- CategoryMapIterator begin, end = m_categories_map.m_map.end();
-
- for (begin = m_categories_map.m_map.begin(); begin != end; begin++)
- {
- if (!callback(param, begin->first, begin->second))
- return;
- }
+ m_categories_map.LoopThrough(callback, param);
}
FormatCategory::SummaryNavigatorSP
Summary(const char* category_name = NULL)
{
- if (!category_name)
- return Summary(m_default_category_name);
- lldb::FormatCategorySP category;
- if (m_categories_map.Get(category_name, category))
- return category->Summary();
- return FormatCategory::SummaryNavigatorSP();
+ return Category(category_name)->Summary();
}
FormatCategory::RegexSummaryNavigatorSP
RegexSummary(const char* category_name = NULL)
{
- if (!category_name)
- return RegexSummary(m_default_category_name);
- lldb::FormatCategorySP category;
- if (m_categories_map.Get(category_name, category))
- return category->RegexSummary();
- return FormatCategory::RegexSummaryNavigatorSP();
+ return Category(category_name)->RegexSummary();
}
lldb::FormatCategorySP
@@ -1086,9 +819,7 @@
Get(ValueObject& vobj,
lldb::SummaryFormatSP& entry)
{
- if ( Get_ExactMatch(vobj,entry) )
- return true;
- return Get_AnyMatch(vobj,entry);
+ return m_categories_map.Get(vobj, entry);
}
static bool
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Tue Jul 19 13:03:25 2011
@@ -492,16 +492,14 @@
// this enum determines how a FormatNavigator picked a specific format for a datatype
// these values can be used together (e.g. eFormatterStrippedPointerReference | eFormatterNavigatedBaseClasses
- // if you went from DerivedType& to BaseType to find a valid format). the priority rules are embedded in the
- // ordering of these values (i.e. if you want to make a choice look really bad, give it a high value in this
- // enum). eFormatterDirectChoice should always be left at 0 because it's our favorite choice all the time
+ // if you went from DerivedType& to BaseType to find a valid format)
typedef enum FormatterChoiceCriterion
{
eFormatterDirectChoice = 0x00000000,
eFormatterStrippedPointerReference = 0x00000001,
eFormatterNavigatedTypedefs = 0x00000002,
eFormatterNavigatedBaseClasses = 0x00000004,
- eFormatterRegularExpressionSummary = 0x00000004
+ eFormatterRegularExpressionSummary = 0x00000008
} FormatterChoiceCriterion;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jul 19 13:03:25 2011
@@ -419,6 +419,7 @@
94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; };
9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; };
9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; };
+ 94A9112E13D5DF210046D8A6 /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; };
9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; };
@@ -1215,6 +1216,8 @@
9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = ""; };
9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeHierarchyNavigator.cpp; path = source/Symbol/TypeHierarchyNavigator.cpp; sourceTree = ""; };
9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; };
+ 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = ""; };
+ 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = ""; };
961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FuncUnwinders.cpp; path = source/Symbol/FuncUnwinders.cpp; sourceTree = ""; };
961FABB91235DE1600F93A47 /* UnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindPlan.cpp; path = source/Symbol/UnwindPlan.cpp; sourceTree = ""; };
961FABBA1235DE1600F93A47 /* UnwindTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindTable.cpp; path = source/Symbol/UnwindTable.cpp; sourceTree = ""; };
@@ -1990,6 +1993,8 @@
26BC7D6310F1B77400F91463 /* FileSpecList.h */,
26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */,
26BC7D6410F1B77400F91463 /* Flags.h */,
+ 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */,
+ 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */,
9415F61613B2C0DC00A52B36 /* FormatManager.h */,
9415F61713B2C0EF00A52B36 /* FormatManager.cpp */,
26F7305F139D8FC900FD51C7 /* History.h */,
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Jul 19 13:03:25 2011
@@ -192,7 +192,7 @@
// now I have a valid format, let's add it to every type
- for(int i = 0; i < argc; i++) {
+ for (int i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
ConstString typeCS(typeA);
if (typeCS)
@@ -537,7 +537,6 @@
options->m_no_children,
options->m_no_value,
options->m_one_liner,
- options->m_is_system,
std::string(funct_name),
options->m_user_source.CopyList(" ")));
@@ -659,7 +658,6 @@
m_python_script = "";
m_python_function = "";
m_is_add_script = false;
- m_is_system = false;
m_category = NULL;
}
@@ -730,7 +728,6 @@
m_options.m_no_children,
m_options.m_no_value,
m_options.m_one_liner,
- m_options.m_is_system,
std::string(funct_name),
" " + m_options.m_python_function + "(valobj,dict)"));
}
@@ -773,7 +770,6 @@
m_options.m_no_children,
m_options.m_no_value,
m_options.m_one_liner,
- m_options.m_is_system,
std::string(funct_name),
" " + m_options.m_python_script));
}
@@ -786,11 +782,10 @@
m_options.m_no_value,
m_options.m_one_liner,
m_options.m_regex,
- m_options.m_is_system,
m_options.m_name,
m_options.m_category);
- for(int i = 0; i < argc; i++) {
+ for (int i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
if (typeA && *typeA)
options->m_target_types << typeA;
@@ -880,7 +875,6 @@
m_options.m_no_children,
m_options.m_no_value,
m_options.m_one_liner,
- m_options.m_is_system,
format_cstr));
if (error.Fail())
@@ -892,7 +886,7 @@
// now I have a valid format, let's add it to every type
- for(int i = 0; i < argc; i++) {
+ for (int i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
if (!typeA || typeA[0] == '\0')
{
@@ -1039,9 +1033,12 @@
CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name,
SummaryFormatSP entry,
SummaryFormatType type,
- const char* category,
+ const char* category_name,
Error* error)
{
+ lldb::FormatCategorySP category;
+ Debugger::Formatting::Categories::Get(ConstString(category_name), category);
+
if (type == eRegexSummary)
{
RegularExpressionSP typeRX(new RegularExpression());
@@ -1052,8 +1049,8 @@
return false;
}
- Debugger::Formatting::SummaryFormats(category)->RegexSummary()->Delete(type_name.GetCString());
- Debugger::Formatting::SummaryFormats(category)->RegexSummary()->Add(typeRX, entry);
+ category->RegexSummary()->Delete(type_name.GetCString());
+ category->RegexSummary()->Add(typeRX, entry);
return true;
}
@@ -1065,7 +1062,7 @@
}
else
{
- Debugger::Formatting::SummaryFormats(category)->Summary()->Add(type_name.GetCString(), entry);
+ category->Summary()->Add(type_name.GetCString(), entry);
return true;
}
}
@@ -1226,7 +1223,10 @@
return result.Succeeded();
}
- bool delete_category = Debugger::Formatting::SummaryFormats(m_options.m_category)->Delete(typeCS.GetCString());
+ lldb::FormatCategorySP category;
+ Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category);
+
+ bool delete_category = category->Delete(typeCS.GetCString());
bool delete_named = Debugger::Formatting::NamedSummaryFormats::Delete(typeCS);
if (delete_category || delete_named)
@@ -1347,14 +1347,20 @@
if (m_options.m_delete_all)
Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL);
- else if (command.GetArgumentCount() > 0)
- {
- const char* cat_name = command.GetArgumentAtIndex(0);
- ConstString cat_nameCS(cat_name);
- Debugger::Formatting::SummaryFormats(cat_nameCS.GetCString())->Clear();
- }
+
else
- Debugger::Formatting::SummaryFormats()->Clear();
+ {
+ lldb::FormatCategorySP category;
+ if (command.GetArgumentCount() > 0)
+ {
+ const char* cat_name = command.GetArgumentAtIndex(0);
+ ConstString cat_nameCS(cat_name);
+ Debugger::Formatting::Categories::Get(cat_nameCS, category);
+ }
+ else
+ Debugger::Formatting::Categories::Get(ConstString(NULL), category);
+ category->Clear();
+ }
Debugger::Formatting::NamedSummaryFormats::Clear();
@@ -1523,7 +1529,7 @@
CommandArgumentData type_style_arg;
type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlain;
+ type_style_arg.arg_repetition = eArgRepeatPlus;
type_arg.push_back (type_style_arg);
@@ -1540,24 +1546,27 @@
{
const size_t argc = command.GetArgumentCount();
- if (argc != 1)
+ if (argc < 1)
{
- result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
- const char* typeA = command.GetArgumentAtIndex(0);
- ConstString typeCS(typeA);
-
- if (!typeCS)
+ for (int i = argc - 1; i >= 0; i--)
{
- result.AppendError("empty category name not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
+ const char* typeA = command.GetArgumentAtIndex(i);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ Debugger::Formatting::Categories::Enable(typeCS);
}
- Debugger::Formatting::Categories::Enable(typeCS);
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -1581,7 +1590,7 @@
CommandArgumentData type_style_arg;
type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlain;
+ type_style_arg.arg_repetition = eArgRepeatPlus;
type_arg.push_back (type_style_arg);
@@ -1598,36 +1607,42 @@
{
const size_t argc = command.GetArgumentCount();
- if (argc != 1)
+ if (argc < 1)
{
- result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.AppendErrorWithFormat ("%s takes 1 or more arg.\n", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
- const char* typeA = command.GetArgumentAtIndex(0);
- ConstString typeCS(typeA);
+ bool success = true;
- if (!typeCS)
+ // the order is not relevant here
+ for (int i = argc - 1; i >= 0; i--)
{
- result.AppendError("empty category name not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
+ const char* typeA = command.GetArgumentAtIndex(i);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ if (!Debugger::Formatting::Categories::Delete(typeCS))
+ success = false; // keep deleting even if we hit an error
}
-
- if (Debugger::Formatting::Categories::Delete(typeCS))
+ if (success)
{
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
else
{
- result.AppendErrorWithFormat ("cannot delete category %s.\n", typeA);
+ result.AppendError("cannot delete one or more categories\n");
result.SetStatus(eReturnStatusFailed);
return false;
- }
+ }
}
-
};
//-------------------------------------------------------------------------
@@ -1647,7 +1662,7 @@
CommandArgumentData type_style_arg;
type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlain;
+ type_style_arg.arg_repetition = eArgRepeatPlus;
type_arg.push_back (type_style_arg);
@@ -1664,24 +1679,28 @@
{
const size_t argc = command.GetArgumentCount();
- if (argc != 1)
+ if (argc < 1)
{
- result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
- const char* typeA = command.GetArgumentAtIndex(0);
- ConstString typeCS(typeA);
-
- if (!typeCS)
+ // the order is not relevant here
+ for (int i = argc - 1; i >= 0; i--)
{
- result.AppendError("empty category name not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
+ const char* typeA = command.GetArgumentAtIndex(i);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ Debugger::Formatting::Categories::Disable(typeCS);
}
-
- Debugger::Formatting::Categories::Disable(typeCS);
+
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
Modified: lldb/trunk/source/Commands/CommandObjectType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.h?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.h (original)
+++ lldb/trunk/source/Commands/CommandObjectType.h Tue Jul 19 13:03:25 2011
@@ -39,8 +39,6 @@
bool m_one_liner;
bool m_regex;
- bool m_is_system;
-
ConstString* m_name;
const char* m_category;
@@ -52,7 +50,6 @@
bool novl,
bool onel,
bool regx,
- bool syst,
ConstString* name,
const char* catg) :
m_skip_pointers(sptr),
@@ -64,7 +61,6 @@
m_no_value(novl),
m_one_liner(onel),
m_regex(regx),
- m_is_system(syst),
m_name(name),
m_category(catg)
{
@@ -130,7 +126,6 @@
std::string m_python_script;
std::string m_python_function;
bool m_is_add_script;
- bool m_is_system;
const char* m_category;
};
Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Tue Jul 19 13:03:25 2011
@@ -754,7 +754,7 @@
if (bitfield_bit_offset > 0)
uval64 >>= bitfield_bit_offset;
uint64_t bitfield_mask = ((1ul << bitfield_bit_size) - 1);
- if(!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64)
+ if (!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64)
return uval64;
uval64 &= bitfield_mask;
}
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Tue Jul 19 13:03:25 2011
@@ -1755,12 +1755,6 @@
return GetFormatManager().Value().GetCount();
}
-lldb::FormatCategorySP
-Debugger::Formatting::SummaryFormats(const char* category_name)
-{
- return GetFormatManager().Category(category_name);
-}
-
bool
Debugger::Formatting::GetSummaryFormat(ValueObject& vobj,
lldb::SummaryFormatSP& entry)
@@ -1804,15 +1798,10 @@
Debugger::Formatting::Categories::Enable(ConstString& category)
{
if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false)
- {
- //GetFormatManager().Category(category.GetCString())->Enable();
GetFormatManager().EnableCategory(category.GetCString());
- }
else
{
- //GetFormatManager().Category(category.GetCString())->Disable();
GetFormatManager().DisableCategory(category.GetCString());
- //GetFormatManager().Category(category.GetCString())->Enable();
GetFormatManager().EnableCategory(category.GetCString());
}
}
@@ -1821,10 +1810,7 @@
Debugger::Formatting::Categories::Disable(ConstString& category)
{
if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true)
- {
- //GetFormatManager().Category(category.GetCString())->Disable();
GetFormatManager().DisableCategory(category.GetCString());
- }
}
void
Added: lldb/trunk/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=135494&view=auto
==============================================================================
--- lldb/trunk/source/Core/FormatClasses.cpp (added)
+++ lldb/trunk/source/Core/FormatClasses.cpp Tue Jul 19 13:03:25 2011
@@ -0,0 +1,140 @@
+//===-- FormatClasses.cpp ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+
+// C++ Includes
+#include
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatClasses.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Target/StackFrame.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+std::string
+ValueFormat::FormatObject(lldb::ValueObjectSP object)
+{
+ if (!object.get())
+ return "NULL";
+
+ StreamString sstr;
+
+ if (ClangASTType::DumpTypeValue (object->GetClangAST(), // The clang AST
+ object->GetClangType(), // The clang type to display
+ &sstr,
+ m_format, // Format to display this type with
+ object->GetDataExtractor(), // Data to extract from
+ 0, // Byte offset into "data"
+ object->GetByteSize(), // Byte size of item in "data"
+ object->GetBitfieldBitSize(), // Bitfield bit size
+ object->GetBitfieldBitOffset())) // Bitfield bit offset
+ return (sstr.GetString());
+ else
+ {
+ return ("unsufficient data for value");
+ }
+}
+
+std::string
+StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
+{
+ if (!object.get())
+ return "NULL";
+
+ StreamString s;
+ ExecutionContext exe_ctx;
+ object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx);
+ SymbolContext sc;
+ if (exe_ctx.frame)
+ sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
+
+ if (m_show_members_oneliner)
+ {
+ const uint32_t num_children = object->GetNumChildren();
+ if (num_children)
+ {
+ s.PutChar('(');
+
+ for (uint32_t idx=0; idxGetChildAtIndex(idx, true));
+ if (child_sp.get())
+ {
+ if (idx)
+ s.PutCString(", ");
+ s.PutCString(child_sp.get()->GetName().AsCString());
+ s.PutChar('=');
+ s.PutCString(child_sp.get()->GetPrintableRepresentation());
+ }
+ }
+
+ s.PutChar(')');
+
+ return s.GetString();
+ }
+ else
+ return "";
+
+ }
+ else
+ {
+ if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get()))
+ return s.GetString();
+ else
+ return "";
+ }
+}
+
+std::string
+StringSummaryFormat::GetDescription()
+{
+ StreamString sstr;
+ sstr.Printf ("`%s`%s%s%s%s%s%s", m_format.c_str(),
+ m_cascades ? "" : " (not cascading)",
+ m_dont_show_children ? "" : " (show children)",
+ m_dont_show_value ? " (hide value)" : "",
+ m_show_members_oneliner ? " (one-line printout)" : "",
+ m_skip_pointers ? " (skip pointers)" : "",
+ m_skip_references ? " (skip references)" : "");
+ return sstr.GetString();
+}
+
+std::string
+ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object)
+{
+ return std::string(ScriptInterpreterPython::CallPythonScriptFunction(m_function_name.c_str(),
+ object).c_str());
+}
+
+std::string
+ScriptSummaryFormat::GetDescription()
+{
+ StreamString sstr;
+ sstr.Printf ("%s%s%s%s%s%s\n%s", m_cascades ? "" : " (not cascading)",
+ m_dont_show_children ? "" : " (show children)",
+ m_dont_show_value ? " (hide value)" : "",
+ m_show_members_oneliner ? " (one-line printout)" : "",
+ m_skip_pointers ? " (skip pointers)" : "",
+ m_skip_references ? " (skip references)" : "",
+ m_python_script.c_str());
+ return sstr.GetString();
+
+}
+
+
Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Tue Jul 19 13:03:25 2011
@@ -184,7 +184,7 @@
if ( ::strcmp(type,regex->GetText()) == 0)
{
m_format_map.map().erase(pos);
- if(m_format_map.listener)
+ if (m_format_map.listener)
m_format_map.listener->Changed();
return true;
}
@@ -220,75 +220,4 @@
default:
return lldb::eFormatInvalid;
}
-}
-
-std::string
-StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
-{
- if (!object.get())
- return "NULL";
-
- StreamString s;
- ExecutionContext exe_ctx;
- object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx);
- SymbolContext sc;
- if (exe_ctx.frame)
- sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
-
- if (m_show_members_oneliner)
- {
- const uint32_t num_children = object->GetNumChildren();
- if (num_children)
- {
- s.PutChar('(');
-
- for (uint32_t idx=0; idxGetChildAtIndex(idx, true));
- if (child_sp.get())
- {
- if (idx)
- s.PutCString(", ");
- s.PutCString(child_sp.get()->GetName().AsCString());
- s.PutChar('=');
- s.PutCString(child_sp.get()->GetPrintableRepresentation());
- }
- }
-
- s.PutChar(')');
-
- return s.GetString();
- }
- else
- return "";
-
- }
- else
- {
- if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get()))
- return s.GetString();
- else
- return "";
- }
-}
-
-void
-FormatCategory::ChooseAsPreferential(const char* name)
-{
- Mutex::Locker(m_mutex);
- lldb::SummaryFormatSP format;
-
- uint32_t revision = Debugger::Formatting::ValueFormats::GetCurrentRevision();
-
- if ( Summary()->Get(name, format) )
- format->SetPriority(revision);
-
- format.reset();
-
- if ( RegexSummary()->Get(name, format) )
- format->SetPriority(revision);
-
- if(m_change_listener)
- m_change_listener->Changed();
-
-}
+}
\ No newline at end of file
Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Tue Jul 19 13:03:25 2011
@@ -506,7 +506,7 @@
}
else
{
- if(log)
+ if (log)
log->Printf("Found function %s for %s", function_name.c_str(), m_expr.FunctionName());
}
@@ -733,7 +733,7 @@
return ret;
}
- if(log)
+ if (log)
log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
std::pair func_range;
@@ -747,7 +747,7 @@
return ret;
}
- if(log)
+ if (log)
log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second);
if (!exe_ctx.target)
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Jul 19 13:03:25 2011
@@ -179,7 +179,7 @@
m_needs_object_ptr = true;
}
- else if(m_objectivec)
+ else if (m_objectivec)
{
const char *function_name = FunctionName();
Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original)
+++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Tue Jul 19 13:03:25 2011
@@ -307,7 +307,7 @@
{
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
- if(log)
+ if (log)
log->Printf("Instrumenting load/store instruction: %s\n",
PrintValue(inst).c_str());
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Jul 19 13:03:25 2011
@@ -253,7 +253,7 @@
{
next_value = cast_inst->getOperand(0);
}
- else if(load_inst)
+ else if (load_inst)
{
if (isa(load_inst->getPointerOperand()))
{
@@ -1064,7 +1064,7 @@
if (m_error_stream)
m_error_stream->Printf("Internal error [IRForTarget]: Couldn't change a static reference to an Objective-C selector to a dynamic reference\n");
- if(log)
+ if (log)
log->PutCString("Couldn't rewrite a reference to an Objective-C selector");
return false;
@@ -1198,7 +1198,7 @@
if (m_error_stream)
m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite the creation of a persistent variable\n");
- if(log)
+ if (log)
log->PutCString("Couldn't rewrite the creation of a persistent variable");
return false;
Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Tue Jul 19 13:03:25 2011
@@ -325,7 +325,7 @@
if (show_token)
{
- if(EDGetTokenString(&tokenStr, token))
+ if (EDGetTokenString(&tokenStr, token))
{
printTokenized = false;
break;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Tue Jul 19 13:03:25 2011
@@ -167,7 +167,7 @@
SymbolContextList contexts;
SymbolContext context;
- if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) &&
+ if ((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) &&
(!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts)))
return NULL;
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Tue Jul 19 13:03:25 2011
@@ -752,15 +752,15 @@
// able to find the child member
break;
}
- else if(end && *end == '-')
+ else if (end && *end == '-')
{
// this is most probably a BitField, let's take a look
char *real_end = NULL;
long final_index = ::strtol (end+1, &real_end, 0);
- if(real_end && *real_end == ']')
+ if (real_end && *real_end == ']')
{
// if the format given is [high-low], swap range
- if(child_index > final_index)
+ if (child_index > final_index)
{
long temp = child_index;
child_index = final_index;
Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Tue Jul 19 13:03:25 2011
@@ -339,7 +339,7 @@
// If our subplan knows why we stopped, even if it's done (which would forward the question to us)
// we answer yes.
- if(m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
+ if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
return true;
// Check if the breakpoint is one of ours.
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Tue Jul 19 13:03:25 2011
@@ -45,13 +45,18 @@
'stop reason = breakpoint'])
# This is the function to remove the custom formats in order to have a
- # clean slate for the next test case.
+ # clean slate for the next test case (most of these categories do not
+ # exist anymore, but we just make sure we delete all of them)
def cleanup():
self.runCmd('type format clear', check=False)
self.runCmd('type summary clear', check=False)
self.runCmd('type category delete Category1', check=False)
self.runCmd('type category delete Category2', check=False)
self.runCmd('type category delete NewCategory', check=False)
+ self.runCmd("type category delete CircleCategory", check=False)
+ self.runCmd("type category delete RectangleStarCategory", check=False)
+ self.runCmd("type category delete BaseCategory", check=False)
+
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
@@ -99,8 +104,8 @@
self.runCmd("type summary add -f \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1")
self.runCmd("type summary add -s \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2")
- self.runCmd("type category enable Category2")
- self.runCmd("type category enable Category1")
+ # check that enable A B is the same as enable B enable A
+ self.runCmd("type category enable Category1 Category2")
self.expect("frame variable r1 r2 r3",
substrs = ['r1 = Width = ',
@@ -149,8 +154,7 @@
'r3 = Width = '])
# Now add another summary to another category and switch back and forth
- self.runCmd("type category delete Category1")
- self.runCmd("type category delete Category2")
+ self.runCmd("type category delete Category1 Category2")
self.runCmd("type summary add Rectangle -f \"Category1\" -w Category1")
self.runCmd("type summary add Rectangle -f \"Category2\" -w Category2")
@@ -170,7 +174,7 @@
'r2 = Category2',
'r3 = Category2'])
- self.runCmd("type category disable Category1")
+ # Check that re-enabling an enabled category works
self.runCmd("type category enable Category1")
self.expect("frame variable r1 r2 r3",
@@ -245,6 +249,79 @@
'c2 = summary2',
'c3 = summary2'])
+ # Check that our order of priority works. Start by clearing categories
+ self.runCmd("type category delete Category1")
+
+ self.runCmd("type summary add Shape -w BaseCategory -f \"AShape\"")
+ self.runCmd("type category enable BaseCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['AShape',
+ 'AShape',
+ 'AShape',
+ 'AShape'])
+
+ self.runCmd("type summary add Circle -w CircleCategory -f \"ACircle\"")
+ self.runCmd("type summary add Rectangle -w RectangleCategory -f \"ARectangle\"")
+ self.runCmd("type category enable CircleCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ 'AShape',
+ 'ACircle',
+ 'AShape'])
+
+ self.runCmd("type summary add \"Rectangle *\" -w RectangleStarCategory -f \"ARectangleStar\"")
+ self.runCmd("type category enable RectangleStarCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ 'AShape',
+ 'ACircle',
+ 'ARectangleStar'])
+
+ self.runCmd("type category enable RectangleCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ 'ARectangle',
+ 'ACircle',
+ 'ARectangleStar'])
+
+ # Check that abruptly deleting an enabled category does not crash us
+ self.runCmd("type category delete RectangleCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ 'AShape',
+ 'ACircle',
+ 'ARectangleStar'])
+
+ # check that list commands work
+ self.expect("type category list",
+ substrs = ['RectangleStarCategory',
+ 'is enabled'])
+
+ self.expect("type summary list",
+ substrs = ['ARectangleStar'])
+
+ # Disable a category and check that it fallsback
+ self.runCmd("type category disable CircleCategory")
+
+ # check that list commands work
+ self.expect("type category list",
+ substrs = ['CircleCategory',
+ 'not enabled'])
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['AShape',
+ 'AShape',
+ 'AShape',
+ 'ARectangleStar'])
+
+ # Now delete all categories
+ self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory")
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/main.cpp?rev=135494&r1=135493&r2=135494&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/main.cpp (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/main.cpp Tue Jul 19 13:03:25 2011
@@ -11,13 +11,16 @@
#include
#include
-struct Rectangle {
+struct Shape
+{};
+
+struct Rectangle : public Shape {
int w;
int h;
Rectangle(int W = 3, int H = 5) : w(W), h(H) {}
};
-struct Circle {
+struct Circle : public Shape {
int r;
Circle(int R = 6) : r(R) {}
};
@@ -32,6 +35,9 @@
Circle c2(6);
Circle c3(7);
+ Circle *c_ptr = new Circle(8);
+ Rectangle *r_ptr = new Rectangle(9,7);
+
return 0; // Set break point at this line.
}
From johnny.chen at apple.com Tue Jul 19 14:39:02 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 19:39:02 -0000
Subject: [Lldb-commits] [lldb] r135503 -
/lldb/trunk/lldb.xcodeproj/project.pbxproj
Message-ID: <20110719193902.DBEF82A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 14:39:02 2011
New Revision: 135503
URL: http://llvm.org/viewvc/llvm-project?rev=135503&view=rev
Log:
Fix build error for StringSummaryFormat undefined symbols.
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=135503&r1=135502&r2=135503&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jul 19 14:39:02 2011
@@ -419,7 +419,6 @@
94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; };
9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; };
9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; };
- 94A9112E13D5DF210046D8A6 /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; };
9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; };
@@ -439,6 +438,7 @@
9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; };
9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; };
9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; };
+ B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; };
B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */; };
/* End PBXBuildFile section */
@@ -3360,6 +3360,7 @@
2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */,
2676045A13D49D2300AB1B6A /* ProcessControl-mig.defs in Sources */,
26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */,
+ B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
From johnny.chen at apple.com Tue Jul 19 14:48:13 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 19:48:13 -0000
Subject: [Lldb-commits] [lldb] r135508 - in /lldb/trunk: include/lldb/Core/
include/lldb/Expression/ include/lldb/Symbol/ include/lldb/Target/
source/Commands/ source/Core/ source/Expression/ source/Host/common/
Message-ID: <20110719194813.70F462A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 14:48:13 2011
New Revision: 135508
URL: http://llvm.org/viewvc/llvm-project?rev=135508&view=rev
Log:
Patch by Matt Johnson to silence G++ warnings!
Used hand merge to apply the diffs. I did not apply the diffs for FormatManager.h and
the diffs for memberwise initialization for ValueObject.cpp because they changed since.
I will ask my colleague to apply them later.
Modified:
lldb/trunk/include/lldb/Core/InputReaderEZ.h
lldb/trunk/include/lldb/Core/Value.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/ClangASTImporter.h
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/ClangExpressionParser.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Expression/IRForTarget.cpp
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/source/Host/common/Host.cpp
Modified: lldb/trunk/include/lldb/Core/InputReaderEZ.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/InputReaderEZ.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/InputReaderEZ.h (original)
+++ lldb/trunk/include/lldb/Core/InputReaderEZ.h Tue Jul 19 14:48:13 2011
@@ -26,11 +26,11 @@
private:
- static size_t Callback_Impl(void *baton,
- InputReader &reader,
- lldb::InputReaderAction notification,
- const char *bytes,
- size_t bytes_len);
+ static size_t Callback_Impl(void *baton,
+ InputReader &reader,
+ lldb::InputReaderAction notification,
+ const char *bytes,
+ size_t bytes_len);
public:
InputReaderEZ (Debugger &debugger) :
@@ -40,6 +40,7 @@
virtual
~InputReaderEZ ();
+ using InputReader::Initialize;
virtual Error
Initialize(void* baton,
lldb::InputReaderGranularity token_size = lldb::eInputReaderGranularityLine,
Modified: lldb/trunk/include/lldb/Core/Value.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Tue Jul 19 14:48:13 2011
@@ -47,7 +47,7 @@
eContextTypeClangType, // void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)")
eContextTypeRegisterInfo, // RegisterInfo *
eContextTypeLLDBType, // lldb_private::Type *
- eContextTypeVariable, // lldb_private::Variable *
+ eContextTypeVariable // lldb_private::Variable *
};
Value();
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Jul 19 14:48:13 2011
@@ -69,7 +69,7 @@
enum GetExpressionPathFormat
{
eDereferencePointers = 1,
- eHonorPointers,
+ eHonorPointers
};
enum ValueObjectRepresentationStyle
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Jul 19 14:48:13 2011
@@ -644,8 +644,8 @@
//----------------------------------------------------------------------
struct MaterialVars {
MaterialVars() :
- m_allocated_area(NULL),
- m_materialized_location(NULL)
+ m_allocated_area(0),
+ m_materialized_location(0)
{
}
Modified: lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h (original)
+++ lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h Tue Jul 19 14:48:13 2011
@@ -24,7 +24,7 @@
IRForTarget::StaticDataAllocator(),
m_process(process),
m_stream_string(StreamString::eBinary, process.GetAddressByteSize(), process.GetByteOrder()),
- m_allocation(NULL)
+ m_allocation(0)
{
}
@@ -46,18 +46,18 @@
if (m_allocation)
m_process.DeallocateMemory(m_allocation);
- m_allocation = NULL;
+ m_allocation = 0;
m_allocation = m_process.AllocateMemory(m_stream_string.GetSize(), lldb::ePermissionsReadable | lldb::ePermissionsWritable, err);
if (!err.Success())
- return NULL;
+ return 0;
if (m_allocation)
m_process.WriteMemory(m_allocation, m_stream_string.GetData(), m_stream_string.GetSize(), err);
if (!err.Success())
- return NULL;
+ return 0;
return m_allocation;
}
@@ -71,4 +71,4 @@
} // namespace lldb_private
-#endif
\ No newline at end of file
+#endif
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Jul 19 14:48:13 2011
@@ -50,7 +50,7 @@
eTypeIsTemplate = (1u << 14),
eTypeIsTypedef = (1u << 15),
eTypeIsVector = (1u << 16),
- eTypeIsScalar = (1u << 17),
+ eTypeIsScalar = (1u << 17)
};
typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Tue Jul 19 14:48:13 2011
@@ -24,8 +24,8 @@
{
public:
ClangASTImporter (clang::ASTContext *target_ctx) :
- m_target_ctx(target_ctx),
- m_file_manager(clang::FileSystemOptions())
+ m_file_manager(clang::FileSystemOptions()),
+ m_target_ctx(target_ctx)
{
}
@@ -161,4 +161,4 @@
}
-#endif
\ No newline at end of file
+#endif
Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Jul 19 14:48:13 2011
@@ -66,7 +66,7 @@
eTypeObjectFile, /// An intermediate object file
eTypeSharedLibrary, /// A shared library that can be used during execution
eTypeStubLibrary, /// A library that can be linked against but not used for execution
- eTypeUnknown,
+ eTypeUnknown
} Type;
typedef enum
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Jul 19 14:48:13 2011
@@ -883,7 +883,7 @@
{
if (idx < m_infos.size())
return m_infos[idx].GetProcessID();
- return NULL;
+ return 0;
}
bool
Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Jul 19 14:48:13 2011
@@ -463,14 +463,14 @@
OptionDefinition
CommandObjectExpression::CommandOptions::g_option_table[] =
{
- //{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
+//{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
//{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."},
-{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."},
-{ LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."},
-{ LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."},
-{ LLDB_OPT_SET_ALL, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
-{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."},
-{ LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, eArgTypeNone, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."},
-{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."},
+{ LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."},
+{ LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."},
+{ LLDB_OPT_SET_ALL, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
+{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."},
+{ LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, eArgTypeNone, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."},
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Jul 19 14:48:13 2011
@@ -192,7 +192,7 @@
// now I have a valid format, let's add it to every type
- for (int i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
ConstString typeCS(typeA);
if (typeCS)
@@ -542,7 +542,7 @@
Error error;
- for (int i = 0; i < options->m_target_types.GetSize(); i++)
+ for (size_t i = 0; i < options->m_target_types.GetSize(); i++)
{
const char *type_name = options->m_target_types.GetStringAtIndex(i);
CommandObjectTypeSummaryAdd::AddSummary(ConstString(type_name),
@@ -785,7 +785,7 @@
m_options.m_name,
m_options.m_category);
- for (int i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
if (typeA && *typeA)
options->m_target_types << typeA;
@@ -806,7 +806,7 @@
Error error;
- for (int i = 0; i < command.GetArgumentCount(); i++)
+ for (size_t i = 0; i < command.GetArgumentCount(); i++)
{
const char *type_name = command.GetArgumentAtIndex(i);
CommandObjectTypeSummaryAdd::AddSummary(ConstString(type_name),
@@ -886,7 +886,7 @@
// now I have a valid format, let's add it to every type
- for (int i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
if (!typeA || typeA[0] == '\0')
{
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Jul 19 14:48:13 2011
@@ -2356,7 +2356,7 @@
}
else
{
- for (int index = index_lower;
+ for (unsigned long index = index_lower;
index <= index_higher; index++)
{
ValueObjectSP child =
@@ -3091,4 +3091,4 @@
m_value_str.clear();
m_summary_str.clear();
m_object_desc_str.clear();
-}
\ No newline at end of file
+}
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Jul 19 14:48:13 2011
@@ -168,7 +168,7 @@
if (num_bytes > num_data_bytes)
num_bytes = num_data_bytes;
- for (off_t byte_idx = 0;
+ for (size_t byte_idx = 0;
byte_idx < num_bytes;
++byte_idx)
{
@@ -915,7 +915,7 @@
if (log)
log->PutCString("Not bothering to allocate a struct because no arguments are needed");
- m_material_vars->m_allocated_area = NULL;
+ m_material_vars->m_allocated_area = 0;
return true;
}
Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Tue Jul 19 14:48:13 2011
@@ -257,7 +257,7 @@
std::string triple = target->GetArchitecture().GetTriple().str();
int dash_count = 0;
- for (int i = 0; i < triple.size(); ++i)
+ for (size_t i = 0; i < triple.size(); ++i)
{
if (triple[i] == '-')
dash_count++;
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Jul 19 14:48:13 2011
@@ -413,8 +413,8 @@
{
lldb::addr_t struct_address;
- lldb::addr_t object_ptr = NULL;
- lldb::addr_t cmd_ptr = NULL;
+ lldb::addr_t object_ptr = 0;
+ lldb::addr_t cmd_ptr = 0;
PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr);
@@ -494,8 +494,8 @@
{
lldb::addr_t struct_address;
- lldb::addr_t object_ptr = NULL;
- lldb::addr_t cmd_ptr = NULL;
+ lldb::addr_t object_ptr = 0;
+ lldb::addr_t cmd_ptr = 0;
if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr))
return eExecutionSetupError;
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Jul 19 14:48:13 2011
@@ -52,16 +52,16 @@
ModulePass(ID),
m_resolve_vars(resolve_vars),
m_func_name(func_name),
- m_decl_map(decl_map),
m_module(NULL),
+ m_decl_map(decl_map),
+ m_data_allocator(data_allocator),
m_CFStringCreateWithBytes(NULL),
m_sel_registerName(NULL),
+ m_const_result(const_result),
m_error_stream(error_stream),
m_has_side_effects(false),
m_result_store(NULL),
m_result_is_pointer(false),
- m_const_result(const_result),
- m_data_allocator(data_allocator),
m_reloc_placeholder(NULL)
{
}
@@ -1918,7 +1918,7 @@
++ui)
users.push_back(*ui);
- for (int i = 0;
+ for (size_t i = 0;
i < users.size();
++i)
{
Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Jul 19 14:48:13 2011
@@ -913,7 +913,7 @@
{
char child_path[PATH_MAX];
const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name);
- if (child_path_len < sizeof(child_path) - 1)
+ if (child_path_len < (int)(sizeof(child_path) - 1))
{
// Don't resolve the file type or path
FileSpec child_path_spec (child_path, false);
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=135508&r1=135507&r2=135508&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Jul 19 14:48:13 2011
@@ -183,7 +183,7 @@
}
else
{
- status_cstr = "(???)";
+ status_cstr = "(\?\?\?)";
}
// Scope for pthread_cancel_disabler
From gclayton at apple.com Tue Jul 19 15:03:42 2011
From: gclayton at apple.com (Greg Clayton)
Date: Tue, 19 Jul 2011 20:03:42 -0000
Subject: [Lldb-commits] [lldb] r135511 - in /lldb/trunk:
include/lldb/Host/SocketAddress.h source/Core/ConnectionFileDescriptor.cpp
source/Host/common/SocketAddress.cpp
Message-ID: <20110719200342.B3F872A6C12D@llvm.org>
Author: gclayton
Date: Tue Jul 19 15:03:42 2011
New Revision: 135511
URL: http://llvm.org/viewvc/llvm-project?rev=135511&view=rev
Log:
Added some more functionality to SocketAddress and modified
ConnectionFileDescriptor to use it.
Modified:
lldb/trunk/include/lldb/Host/SocketAddress.h
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
lldb/trunk/source/Host/common/SocketAddress.cpp
Modified: lldb/trunk/include/lldb/Host/SocketAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/SocketAddress.h?rev=135511&r1=135510&r2=135511&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/SocketAddress.h (original)
+++ lldb/trunk/include/lldb/Host/SocketAddress.h Tue Jul 19 15:03:42 2011
@@ -28,9 +28,13 @@
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- SocketAddress();
- SocketAddress(const SocketAddress& rhs);
- ~SocketAddress();
+ SocketAddress ();
+ SocketAddress (const struct sockaddr &s);
+ SocketAddress (const struct sockaddr_in &s);
+ SocketAddress (const struct sockaddr_in6 &s);
+ SocketAddress (const struct sockaddr_storage &s);
+ SocketAddress (const SocketAddress& rhs);
+ ~SocketAddress ();
//------------------------------------------------------------------
// Operators
@@ -41,30 +45,99 @@
const SocketAddress&
operator=(const struct addrinfo *addr_info);
+ const SocketAddress&
+ operator=(const struct sockaddr &s);
+
+ const SocketAddress&
+ operator=(const struct sockaddr_in &s);
+
+ const SocketAddress&
+ operator=(const struct sockaddr_in6 &s);
+
+ const SocketAddress&
+ operator=(const struct sockaddr_storage &s);
+
+ //------------------------------------------------------------------
+ // Clear the contents of this socket address
+ //------------------------------------------------------------------
void
Clear ();
+ //------------------------------------------------------------------
+ // Get the length for the current socket address family
+ //------------------------------------------------------------------
socklen_t
GetLength () const;
+ //------------------------------------------------------------------
+ // Get the mex length for the the largest socket address supported.
+ //------------------------------------------------------------------
static socklen_t
GetMaxLength ();
+ //------------------------------------------------------------------
+ // Set the length manually if supported in the socket address
+ // structures
+ //------------------------------------------------------------------
void
SetLength (socklen_t len);
+ //------------------------------------------------------------------
+ // Get the socket address family
+ //------------------------------------------------------------------
sa_family_t
GetFamily () const;
+ //------------------------------------------------------------------
+ // Set the socket address family
+ //------------------------------------------------------------------
void
SetFamily (sa_family_t family);
+ //------------------------------------------------------------------
+ // Get the port if the socket address for the family has a port
+ //------------------------------------------------------------------
in_port_t
GetPort () const;
+ //------------------------------------------------------------------
+ // Set the port if the socket address for the family has a port.
+ // The family must be set correctly prior to calling this function.
+ //------------------------------------------------------------------
+ bool
+ SetPort (in_port_t port);
+
+ //------------------------------------------------------------------
+ // Set the socket address according to the first match from a call
+ // to getaddrinfo() (or equivalent functions for systems that don't
+ // have getaddrinfo(). If "addr_info_ptr" is not NULL, it will get
+ // filled in with the match that was used to populate this socket
+ // address.
+ //------------------------------------------------------------------
+ bool
+ SetAddress (const struct addrinfo *hints_ptr, // Optional hints where the family, protocol and other things can be specified.
+ const char *host, // Hostname ("foo.bar.com" or "foo" or IP address string ("123.234.12.1" or "2001:0db8:85a3:0000:0000:8a2e:0370:7334")
+ const char *service, // Protocol name ("tcp", "http", etc) or a raw port number string ("81")
+ struct addrinfo *addr_info_ptr); // If non-NULL, this will get filled in with the match
+
+ //------------------------------------------------------------------
+ // Quick way to set the SocketAddress to localhost given the family.
+ // Returns true if successful, false if "family" doesn't support
+ // localhost or if "family" is not supported by this class.
+ //------------------------------------------------------------------
+ bool
+ SetToLocalhost (sa_family_t family,
+ in_port_t port);
+
+ //------------------------------------------------------------------
+ // Returns true if there is a valid socket address in this object.
+ //------------------------------------------------------------------
bool
IsValid () const;
+ //------------------------------------------------------------------
+ // Direct access to all of the sockaddr structures
+ //------------------------------------------------------------------
struct sockaddr &
sockaddr ()
{
@@ -113,9 +186,14 @@
{
return m_socket_addr.sa_storage;
}
+
+
//------------------------------------------------------------------
// Conversion operators to allow getting the contents of this class
- // as a subclass
+ // as a pointer to the appropriate structure. This allows an instance
+ // of this class to be used in calls that take one of the sockaddr
+ // structure variants without having to manally use the correct
+ // accessor function.
//------------------------------------------------------------------
operator struct sockaddr * ()
@@ -158,6 +236,7 @@
return &m_socket_addr.sa_storage;
}
+
protected:
typedef union sockaddr_tag
{
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=135511&r1=135510&r2=135511&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Tue Jul 19 15:03:42 2011
@@ -697,37 +697,35 @@
// enable local address reuse
SetSocketOption (listen_port, SOL_SOCKET, SO_REUSEADDR, 1);
- struct sockaddr_in sa;
- ::memset (&sa, 0, sizeof sa);
- sa.sin_family = AF_INET;
- sa.sin_port = htons (listen_port_num);
- sa.sin_addr.s_addr = htonl (INADDR_ANY);
-
- int err = ::bind (listen_port, (struct sockaddr *) &sa, sizeof(sa));
- if (err == -1)
+ SocketAddress localhost;
+ if (localhost.SetToLocalhost (AF_INET, listen_port_num))
{
- if (error_ptr)
- error_ptr->SetErrorToErrno();
- Close (listen_port, NULL);
- return eConnectionStatusError;
- }
+ int err = ::bind (listen_port, localhost, localhost.GetLength());
+ if (err == -1)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorToErrno();
+ Close (listen_port, NULL);
+ return eConnectionStatusError;
+ }
- err = ::listen (listen_port, 1);
- if (err == -1)
- {
- if (error_ptr)
- error_ptr->SetErrorToErrno();
- Close (listen_port, NULL);
- return eConnectionStatusError;
- }
+ err = ::listen (listen_port, 1);
+ if (err == -1)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorToErrno();
+ Close (listen_port, NULL);
+ return eConnectionStatusError;
+ }
- m_fd_send = m_fd_recv = ::accept (listen_port, NULL, 0);
- if (m_fd_send == -1)
- {
- if (error_ptr)
- error_ptr->SetErrorToErrno();
- Close (listen_port, NULL);
- return eConnectionStatusError;
+ m_fd_send = m_fd_recv = ::accept (listen_port, NULL, 0);
+ if (m_fd_send == -1)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorToErrno();
+ Close (listen_port, NULL);
+ return eConnectionStatusError;
+ }
}
// We are done with the listen port
Modified: lldb/trunk/source/Host/common/SocketAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SocketAddress.cpp?rev=135511&r1=135510&r2=135511&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/SocketAddress.cpp (original)
+++ lldb/trunk/source/Host/common/SocketAddress.cpp Tue Jul 19 15:03:42 2011
@@ -22,11 +22,34 @@
//----------------------------------------------------------------------
// SocketAddress constructor
//----------------------------------------------------------------------
-SocketAddress::SocketAddress()
+SocketAddress::SocketAddress ()
{
Clear ();
}
+SocketAddress::SocketAddress (const struct sockaddr &s)
+{
+ m_socket_addr.sa = s;
+}
+
+
+SocketAddress::SocketAddress (const struct sockaddr_in &s)
+{
+ m_socket_addr.sa_ipv4 = s;
+}
+
+
+SocketAddress::SocketAddress (const struct sockaddr_in6 &s)
+{
+ m_socket_addr.sa_ipv6 = s;
+}
+
+
+SocketAddress::SocketAddress (const struct sockaddr_storage &s)
+{
+ m_socket_addr.sa_storage = s;
+}
+
//----------------------------------------------------------------------
// SocketAddress copy constructor
//----------------------------------------------------------------------
@@ -95,6 +118,22 @@
return 0;
}
+bool
+SocketAddress::SetPort (in_port_t port)
+{
+ switch (GetFamily())
+ {
+ case AF_INET:
+ m_socket_addr.sa_ipv4.sin_port = htons(port);
+ return true;
+
+ case AF_INET6:
+ m_socket_addr.sa_ipv6.sin6_port = htons(port);
+ return true;
+ }
+ return false;
+}
+
//----------------------------------------------------------------------
// SocketAddress assignment operator
//----------------------------------------------------------------------
@@ -122,5 +161,89 @@
return *this;
}
+const SocketAddress&
+SocketAddress::operator=(const struct sockaddr &s)
+{
+ m_socket_addr.sa = s;
+ return *this;
+}
+const SocketAddress&
+SocketAddress::operator=(const struct sockaddr_in &s)
+{
+ m_socket_addr.sa_ipv4 = s;
+ return *this;
+}
+
+const SocketAddress&
+SocketAddress::operator=(const struct sockaddr_in6 &s)
+{
+ m_socket_addr.sa_ipv6 = s;
+ return *this;
+}
+const SocketAddress&
+SocketAddress::operator=(const struct sockaddr_storage &s)
+{
+ m_socket_addr.sa_storage = s;
+ return *this;
+}
+
+bool
+SocketAddress::SetAddress (const struct addrinfo *hints_ptr,
+ const char *host,
+ const char *service,
+ struct addrinfo *addr_info_ptr)
+{
+ struct addrinfo *service_info_list = NULL;
+ int err = ::getaddrinfo (host, service, hints_ptr, &service_info_list);
+ if (err == 0 && service_info_list)
+ {
+ if (addr_info_ptr)
+ *addr_info_ptr = *service_info_list;
+ *this = service_info_list;
+ }
+ else
+ Clear();
+
+ :: freeaddrinfo (service_info_list);
+
+ const bool is_valid = IsValid();
+ if (!is_valid)
+ {
+ if (addr_info_ptr)
+ ::memset (addr_info_ptr, 0, sizeof(struct addrinfo));
+ }
+ return IsValid();
+}
+
+
+bool
+SocketAddress::SetToLocalhost (sa_family_t family, in_port_t port)
+{
+ switch (family)
+ {
+ case AF_INET:
+ SetFamily (AF_INET);
+ if (SetPort (port))
+ {
+ m_socket_addr.sa_ipv4.sin_addr.s_addr = htonl (INADDR_ANY);
+ SetLength (sizeof(m_socket_addr.sa_ipv4));
+ return true;
+ }
+ break;
+
+ case AF_INET6:
+ SetFamily (AF_INET6);
+ if (SetPort (port))
+ {
+ m_socket_addr.sa_ipv6.sin6_addr = in6addr_any;
+ SetLength (sizeof(m_socket_addr.sa_ipv6));
+ return true;
+ }
+ break;
+
+ }
+ Clear();
+ return false;
+}
From gclayton at apple.com Tue Jul 19 15:06:26 2011
From: gclayton at apple.com (Greg Clayton)
Date: Tue, 19 Jul 2011 20:06:26 -0000
Subject: [Lldb-commits] [lldb] r135512 -
/lldb/trunk/source/Host/common/SocketAddress.cpp
Message-ID: <20110719200626.C76262A6C12D@llvm.org>
Author: gclayton
Date: Tue Jul 19 15:06:26 2011
New Revision: 135512
URL: http://llvm.org/viewvc/llvm-project?rev=135512&view=rev
Log:
Avoid calling accessor function more than once when result is already in
a local.
Modified:
lldb/trunk/source/Host/common/SocketAddress.cpp
Modified: lldb/trunk/source/Host/common/SocketAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SocketAddress.cpp?rev=135512&r1=135511&r2=135512&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/SocketAddress.cpp (original)
+++ lldb/trunk/source/Host/common/SocketAddress.cpp Tue Jul 19 15:06:26 2011
@@ -214,7 +214,7 @@
if (addr_info_ptr)
::memset (addr_info_ptr, 0, sizeof(struct addrinfo));
}
- return IsValid();
+ return is_valid;
}
From johnso87 at crhc.illinois.edu Tue Jul 19 15:34:32 2011
From: johnso87 at crhc.illinois.edu (Matt Johnson)
Date: Tue, 19 Jul 2011 15:34:32 -0500
Subject: [Lldb-commits] [lldb] r135363 - in /lldb/trunk:
include/lldb/Core/ include/lldb/Target/ source/ source/Core/
source/Plugins/Process/MacOSX-Kernel/
source/Plugins/Process/MacOSX-User/source/
source/Plugins/Process/gdb-remote/ source/Target/
In-Reply-To: <8ED2AD49-44A8-47AD-9BB7-B5496FD6964D@apple.com>
References: <20110717203625.CCCBF2A6C12C@llvm.org>
<4E24D085.80704@crhc.illinois.edu>
<8ED2AD49-44A8-47AD-9BB7-B5496FD6964D@apple.com>
Message-ID: <4E25EA58.1030606@crhc.illinois.edu>
On 07/19/2011 11:49 AM, Greg Clayton wrote:
> I added a new SocketAddress class in the host layer for you and modified the ConnectionFileDescriptor to use it:
>
> % svn commit
> Sending include/lldb/Core/ConnectionFileDescriptor.h
> Adding include/lldb/Host/SocketAddress.h
> Sending lldb.xcodeproj/project.pbxproj
> Sending source/Core/ConnectionFileDescriptor.cpp
> Adding source/Host/common/SocketAddress.cpp
> Transmitting file data .....
> Committed revision 135488.
>
> We can now isolate all host specific changes into "SocketAddress.cpp". I left our simple implementation as:
>
> socklen_t
> SocketAddress::GetLength () const
> {
> return m_socket_addr.sa.sa_len;
> }
>
> Feel free to add #ifdef stuff and "do the right thing" for linux.
>
Will do.
> In LLDB we would like to have the Host layer (all files in "lldb/include/lldb/Host/*" and "source/Host/*" abstract us from the host layer where we need it. This is the perfect case right here. We currently haven't run into anything that we haven't been able to take care of with this type of abtraction (we haven't required autoconf, nor do I really want it if we can avoid it).
>
> Let me know if this works for you,
>
That sounds great. I'm not an autotools zealot by any means; as long as
we can reasonably solve things at the preprocessor level (rather than
needing to try compiling test programs like autoconf does), I prefer to
do so as well. Making this another class in the Host layer is a better
fit for LLDB's architecture (and arguably, most C++ programs) than
putting more stuff in LLVM's configure.ac.
Thanks for doing this. I'll come up with a patch once I get a bit more
bandwidth and figure out if most/all Linux distros/libc's work the same
way as Ubuntu/glibc w.r.t. sockaddr and sockaddr_in.
> Greg Clayton
>
-Matt
> On Jul 18, 2011, at 5:32 PM, Matt Johnson wrote:
>
>> Hi all,
>>
>> struct sockaddr and struct sockaddr_in don't have sa_len and sin_len members, respectively in glibc/Ubuntu 11.04, breaking the build on r135363:
>>
>> ConnectionFileDescriptor.cpp: In member function ?virtual size_t lldb_private::ConnectionFileDescriptor::Read(void*, size_t, uint32_t, lldb::ConnectionStatus&, lldb_private::Error*)?:
>> ConnectionFileDescriptor.cpp:289:57: error: ?struct sockaddr? has no member named ?sa_len?
>> ConnectionFileDescriptor.cpp: In member function ?virtual size_t lldb_private::ConnectionFileDescriptor::Write(const void*, size_t, lldb::ConnectionStatus&, lldb_private::Error*)?:
>> ConnectionFileDescriptor.cpp:410:59: error: ?struct sockaddr? has no member named ?sa_len?
>> ConnectionFileDescriptor.cpp: In member function ?lldb::ConnectionStatus lldb_private::ConnectionFileDescriptor::ConnectUDP(const char*, lldb_private::Error*)?:
>> ConnectionFileDescriptor.cpp:850:13: error: ?struct sockaddr_in? has no member named ?sin_len?
>>
>> glibc provides equivalent functionality to sa_len with a macro SA_LEN, which looks at the sa_family member to determine the length (see http://lists.debian.org/debian-ipv6/2001/06/msg00015.html). Fixing the build under glibc would involve #ifdefing out the first use of sa_len and the only use of sin_len, and replacing the second use of sa_len with the SA_LEN() macro.
>>
>> I'm not submitting a patch yet because I wanted to ask how we want to test for sa_len and sin_len. Other projects have done it using autoconf macros (see http://archives.seul.org/or/cvs/Jan-2009/msg00014.html http://hackage.haskell.org/trac/ghc/ticket/2326 ), but I can't figure out on inspection exactly how lldb's Makefile is generated. I suspect it relies on llvm's configure script, but am not sure. If so, that would be the appropriate place to put the member checks, but this may require lldb to roll forward its frozen llvm version.
>>
>> Thoughts?
>>
>> Best,
>> Matt
>>
From granata.enrico at gmail.com Tue Jul 19 15:57:44 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Tue, 19 Jul 2011 20:57:44 -0000
Subject: [Lldb-commits] [lldb] r135523 - in /lldb/trunk:
include/lldb/Core/FormatManager.h source/Core/ValueObject.cpp
Message-ID: <20110719205744.8E86F2A6C12D@llvm.org>
Author: enrico
Date: Tue Jul 19 15:57:44 2011
New Revision: 135523
URL: http://llvm.org/viewvc/llvm-project?rev=135523&view=rev
Log:
Applied Matt Johnson patch to ValueObject and FormatManager
Modified:
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/source/Core/ValueObject.cpp
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135523&r1=135522&r2=135523&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Tue Jul 19 15:57:44 2011
@@ -77,19 +77,20 @@
template
class FormatMap
{
-private:
- typedef typename ValueType::SharedPointer ValueSP;
- Mutex m_map_mutex;
- IFormatChangeListener* listener;
-
friend class FormatNavigator;
friend class FormatManager;
-
+
public:
- typedef std::map MapType;
-private:
- MapType m_map;
+ typedef typename ValueType::SharedPointer ValueSP;
+ typedef std::map MapType;
+ typedef typename MapType::iterator MapIterator;
+ typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
+
+private:
+ MapType m_map;
+ Mutex m_map_mutex;
+ IFormatChangeListener* listener;
MapType& map()
{
@@ -102,9 +103,6 @@
}
public:
-
- typedef typename MapType::iterator MapIterator;
- typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
FormatMap(IFormatChangeListener* lst = NULL) :
m_map(),
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=135523&r1=135522&r2=135523&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Jul 19 15:57:44 2011
@@ -72,6 +72,11 @@
m_dynamic_value (NULL),
m_deref_valobj(NULL),
m_format (eFormatDefault),
+ m_last_format_mgr_revision(0),
+ m_last_summary_format(),
+ m_forced_summary_format(),
+ m_last_value_format(),
+ m_user_id_of_forced_summary(0),
m_value_is_valid (false),
m_value_did_change (false),
m_children_count_valid (false),
@@ -80,10 +85,6 @@
m_is_deref_of_parent (false),
m_is_array_item_for_pointer(false),
m_is_bitfield_for_scalar(false),
- m_last_format_mgr_revision(0),
- m_last_value_format(),
- m_last_summary_format(),
- m_forced_summary_format(),
m_dump_printable_counter(0)
{
m_manager->ManageObject(this);
@@ -111,6 +112,11 @@
m_dynamic_value (NULL),
m_deref_valobj(NULL),
m_format (eFormatDefault),
+ m_last_format_mgr_revision(0),
+ m_last_summary_format(),
+ m_forced_summary_format(),
+ m_last_value_format(),
+ m_user_id_of_forced_summary(0),
m_value_is_valid (false),
m_value_did_change (false),
m_children_count_valid (false),
@@ -119,10 +125,6 @@
m_is_deref_of_parent (false),
m_is_array_item_for_pointer(false),
m_is_bitfield_for_scalar(false),
- m_last_format_mgr_revision(0),
- m_last_value_format(),
- m_last_summary_format(),
- m_forced_summary_format(),
m_dump_printable_counter(0)
{
m_manager = new ValueObjectManager();
From johnny.chen at apple.com Tue Jul 19 16:49:34 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 21:49:34 -0000
Subject: [Lldb-commits] [lldb] r135526 - /lldb/trunk/scripts/lldb.swig
Message-ID: <20110719214934.A2B7F2A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 16:49:34 2011
New Revision: 135526
URL: http://llvm.org/viewvc/llvm-project?rev=135526&view=rev
Log:
Rearrange the %include SWIG directives into two groups. One is the pure .h headers and the other is the .i interface files.
The objective is to move the .h header into .i interface file eventually.
Modified:
lldb/trunk/scripts/lldb.swig
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135526&r1=135525&r2=135526&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Tue Jul 19 16:49:34 2011
@@ -197,38 +197,42 @@
%include "lldb/lldb-forward-rtti.h"
%include "lldb/lldb-types.h"
-%include "./Python/interface/SBAddress.i"
-%include "./Python/interface/SBBlock.i"
-%include "./Python/interface/SBBreakpoint.i"
-%include "./Python/interface/SBBreakpointLocation.i"
+/* Headers that are swigged directly. */
+%include "lldb/API/SBDefines.h"
%include "lldb/API/SBBroadcaster.h"
%include "lldb/API/SBCommandInterpreter.h"
%include "lldb/API/SBCommandReturnObject.h"
%include "lldb/API/SBCommunication.h"
-%include "./Python/interface/SBCompileUnit.i"
-%include "./Python/interface/SBDebugger.i"
%include "lldb/API/SBError.h"
-%include "./Python/interface/SBEvent.i"
%include "lldb/API/SBFileSpec.h"
-%include "./Python/interface/SBFrame.i"
-%include "./Python/interface/SBFunction.i"
%include "lldb/API/SBHostOS.h"
%include "lldb/API/SBInputReader.h"
%include "lldb/API/SBInstruction.h"
%include "lldb/API/SBInstructionList.h"
+%include "lldb/API/SBSourceManager.h"
+%include "lldb/API/SBStream.h"
+%include "lldb/API/SBStringList.h"
+%include "lldb/API/SBType.h"
+
+/* Python interface files with docstrings. */
+%include "./Python/interface/SBAddress.i"
+%include "./Python/interface/SBBlock.i"
+%include "./Python/interface/SBBreakpoint.i"
+%include "./Python/interface/SBBreakpointLocation.i"
+%include "./Python/interface/SBCompileUnit.i"
+%include "./Python/interface/SBDebugger.i"
+%include "./Python/interface/SBEvent.i"
+%include "./Python/interface/SBFrame.i"
+%include "./Python/interface/SBFunction.i"
%include "./Python/interface/SBLineEntry.i"
%include "./Python/interface/SBListener.i"
%include "./Python/interface/SBModule.i"
%include "./Python/interface/SBProcess.i"
-%include "lldb/API/SBSourceManager.h"
-%include "lldb/API/SBStream.h"
-%include "lldb/API/SBStringList.h"
%include "./Python/interface/SBSymbol.i"
%include "./Python/interface/SBSymbolContext.i"
%include "./Python/interface/SBSymbolContextList.i"
%include "./Python/interface/SBTarget.i"
%include "./Python/interface/SBThread.i"
-%include "lldb/API/SBType.h"
%include "./Python/interface/SBValue.i"
%include "./Python/interface/SBValueList.i"
From granata.enrico at gmail.com Tue Jul 19 17:35:10 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Tue, 19 Jul 2011 22:35:10 -0000
Subject: [Lldb-commits] [lldb] r135529 - in /lldb/trunk:
include/lldb/Core/FormatManager.h source/Commands/CommandObjectType.cpp
Message-ID: <20110719223510.A31F32A6C12D@llvm.org>
Author: enrico
Date: Tue Jul 19 17:35:10 2011
New Revision: 135529
URL: http://llvm.org/viewvc/llvm-project?rev=135529&view=rev
Log:
type category list now supports a regular expression argument that filters categories to only include the ones matching the regex
type summary list now supports a -w flag with a regular expression argument that filters categories to only include the ones matching the regex
in category and summary listings, categories are printed in a meaningful order:
- enabled ones first, in the order in which they are searched for summaries
- disabled ones, in an unspecified order
type summary list by default only expands non-empty enabled categories. to obtain a full listing, you must use the -w flag giving a "match-all" regex
Modified:
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/source/Commands/CommandObjectType.cpp
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135529&r1=135528&r2=135529&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Tue Jul 19 17:35:10 2011
@@ -507,6 +507,12 @@
return (del_sum || del_rex);
}
+ uint32_t
+ GetCount()
+ {
+ return Summary()->GetCount() + RegexSummary()->GetCount();
+ }
+
typedef lldb::SharedPtr::Type SharedPointer;
};
@@ -642,18 +648,59 @@
return true;
}
+ class match_category_to_name
+ {
+ private:
+ FormatCategory* addr;
+ public:
+
+ match_category_to_name(FormatCategory* ptr) : addr(ptr)
+ {}
+
+ bool operator()(std::pair map_entry)
+ {
+ if (addr == map_entry.second.get())
+ return true;
+ return false;
+ }
+ };
+
void
LoopThrough(CallbackType callback, void* param)
{
if (callback)
{
Mutex::Locker(m_map_mutex);
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
+
+ // loop through enabled categories in respective order
+ {
+ ActiveCategoriesIterator begin, end = m_active_categories.end();
+ for (begin = m_active_categories.begin(); begin != end; begin++)
+ {
+ FormatCategory::SharedPointer category = *begin;
+ const char* type;
+ MapIterator type_position =
+ std::find_if(m_map.begin(),m_map.end(),match_category_to_name(category.get()));
+ if (type_position != m_map.end())
+ type = type_position->first;
+ else
+ continue;
+ if (!callback(param, type, category))
+ break;
+ }
+ }
+
+ // loop through disabled categories in just any order
{
- KeyType type = pos->first;
- if (!callback(param, type, pos->second))
- break;
+ MapIterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; pos++)
+ {
+ if (pos->second->IsEnabled())
+ continue;
+ KeyType type = pos->first;
+ if (!callback(param, type, pos->second))
+ break;
+ }
}
}
}
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=135529&r1=135528&r2=135529&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Jul 19 17:35:10 2011
@@ -1390,18 +1390,82 @@
CommandObjectTypeSummaryList* self;
CommandReturnObject* result;
RegularExpression* regex;
+ RegularExpression* cate_regex;
CommandObjectTypeSummaryList_LoopCallbackParam(CommandObjectTypeSummaryList* S, CommandReturnObject* R,
- RegularExpression* X = NULL) : self(S), result(R), regex(X) {}
+ RegularExpression* X = NULL,
+ RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
};
class CommandObjectTypeSummaryList : public CommandObject
{
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ }
+
+ virtual
+ ~CommandOptions (){}
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'w':
+ m_category_regex = std::string(option_arg);
+ break;
+ default:
+ error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_category_regex = "";
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ std::string m_category_regex;
+
+ };
+
+ CommandOptions m_options;
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
public:
CommandObjectTypeSummaryList (CommandInterpreter &interpreter) :
CommandObject (interpreter,
"type summary list",
"Show a list of current summary styles.",
- NULL)
+ NULL), m_options(interpreter)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -1424,14 +1488,17 @@
const size_t argc = command.GetArgumentCount();
CommandObjectTypeSummaryList_LoopCallbackParam *param;
+ RegularExpression* cate_regex =
+ m_options.m_category_regex.empty() ? NULL :
+ new RegularExpression(m_options.m_category_regex.c_str());
if (argc == 1) {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
regex->Compile(command.GetArgumentAtIndex(0));
- param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex);
+ param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex,cate_regex);
}
else
- param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result);
+ param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,NULL,cate_regex);
Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param);
@@ -1449,6 +1516,9 @@
delete param;
}
+ if (cate_regex)
+ delete cate_regex;
+
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -1456,23 +1526,33 @@
private:
static bool
- PerCategoryCallback(void* param,
+ PerCategoryCallback(void* param_vp,
const char* cate_name,
const FormatCategory::SharedPointer& cate)
{
- CommandReturnObject* result = ((CommandObjectTypeSummaryList_LoopCallbackParam*)param)->result;
-
+ CommandObjectTypeSummaryList_LoopCallbackParam* param =
+ (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp;
+ CommandReturnObject* result = param->result;
+
+ // if the category is disabled or empty and there is no regex, just skip it
+ if ((cate->IsEnabled() == false || cate->GetCount() == 0) && param->cate_regex == NULL)
+ return true;
+
+ // if we have a regex and this category does not match it, just skip it
+ if(param->cate_regex != NULL && param->cate_regex->Execute(cate_name) == false)
+ return true;
+
result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
cate_name,
(cate->IsEnabled() ? "enabled" : "disabled"));
-
- cate->Summary()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
+
+ cate->Summary()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp);
if (cate->RegexSummary()->GetCount() > 0)
{
result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
- cate->RegexSummary()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param);
+ cate->RegexSummary()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp);
}
return true;
}
@@ -1512,6 +1592,13 @@
return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
}
+OptionDefinition
+CommandObjectTypeSummaryList::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "category-regex", 'w', required_argument, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
+ { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
//-------------------------------------------------------------------------
// CommandObjectTypeCategoryEnable
//-------------------------------------------------------------------------
@@ -1714,13 +1801,33 @@
class CommandObjectTypeCategoryList : public CommandObject
{
private:
+
+ struct CommandObjectTypeCategoryList_CallbackParam
+ {
+ CommandReturnObject* result;
+ RegularExpression* regex;
+
+ CommandObjectTypeCategoryList_CallbackParam(CommandReturnObject* res,
+ RegularExpression* rex = NULL) :
+ result(res),
+ regex(rex)
+ {
+ }
+
+ };
+
static bool
- PerCategoryCallback(void* param,
+ PerCategoryCallback(void* param_vp,
const char* cate_name,
const FormatCategory::SharedPointer& cate)
{
- CommandReturnObject* result = (CommandReturnObject*)param;
- result->GetOutputStream().Printf("Category %s is%s enabled\n",
+ CommandObjectTypeCategoryList_CallbackParam* param =
+ (CommandObjectTypeCategoryList_CallbackParam*)param_vp;
+ CommandReturnObject* result = param->result;
+ RegularExpression* regex = param->regex;
+
+ if (regex == NULL || regex->Execute(cate_name))
+ result->GetOutputStream().Printf("Category %s is%s enabled\n",
cate_name,
(cate->IsEnabled() ? "" : " not"));
return true;
@@ -1732,6 +1839,15 @@
"Provide a list of all existing categories.",
NULL)
{
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatOptional;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
}
~CommandObjectTypeCategoryList ()
@@ -1741,7 +1857,28 @@
bool
Execute (Args& command, CommandReturnObject &result)
{
- Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)&result);
+ const size_t argc = command.GetArgumentCount();
+ RegularExpression* regex = NULL;
+
+ if (argc == 0)
+ ;
+ else if (argc == 1)
+ regex = new RegularExpression(command.GetArgumentAtIndex(0));
+ else
+ {
+ result.AppendErrorWithFormat ("%s takes 0 or one arg.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ CommandObjectTypeCategoryList_CallbackParam param(&result,
+ regex);
+
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, ¶m);
+
+ if (regex)
+ delete regex;
+
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
From johnny.chen at apple.com Tue Jul 19 17:41:47 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 22:41:47 -0000
Subject: [Lldb-commits] [lldb] r135531 - in /lldb/trunk/scripts:
Python/interface/SBBroadcaster.i Python/interface/SBCommandInterpreter.i
Python/interface/SBCommandReturnObject.i Python/interface/SBCommunication.i
Python/interface/SBError.i Python/interface/SBFileSpec.i
Python/interface/SBHostOS.i Python/interface/SBInputReader.i
Python/interface/SBInstruction.i Python/interface/SBInstructionList.i
Python/interface/SBSourceManager.i Python/interface/SBStream.i
Python/interface/SBStringList.i Python/interface/SBType.i lldb.swig
Message-ID: <20110719224148.0986D2A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 17:41:47 2011
New Revision: 135531
URL: http://llvm.org/viewvc/llvm-project?rev=135531&view=rev
Log:
Move the rest of the SB headers to interface files.
They are not docstring'ed yet.
Added:
lldb/trunk/scripts/Python/interface/SBBroadcaster.i
lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
lldb/trunk/scripts/Python/interface/SBCommunication.i
lldb/trunk/scripts/Python/interface/SBError.i
lldb/trunk/scripts/Python/interface/SBFileSpec.i
lldb/trunk/scripts/Python/interface/SBHostOS.i
lldb/trunk/scripts/Python/interface/SBInputReader.i
lldb/trunk/scripts/Python/interface/SBInstruction.i
lldb/trunk/scripts/Python/interface/SBInstructionList.i
lldb/trunk/scripts/Python/interface/SBSourceManager.i
lldb/trunk/scripts/Python/interface/SBStream.i
lldb/trunk/scripts/Python/interface/SBStringList.i
lldb/trunk/scripts/Python/interface/SBType.i
Modified:
lldb/trunk/scripts/lldb.swig
Added: lldb/trunk/scripts/Python/interface/SBBroadcaster.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBroadcaster.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBBroadcaster.i (added)
+++ lldb/trunk/scripts/Python/interface/SBBroadcaster.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,51 @@
+//===-- SWIG Interface for SBBroadcaster ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBBroadcaster
+{
+public:
+ SBBroadcaster ();
+
+ SBBroadcaster (const char *name);
+
+ SBBroadcaster (const SBBroadcaster &rhs);
+
+ ~SBBroadcaster();
+
+ bool
+ IsValid () const;
+
+ void
+ Clear ();
+
+ 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 () const;
+
+ bool
+ EventTypeHasListeners (uint32_t event_type);
+
+ bool
+ RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i (added)
+++ lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,82 @@
+//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBCommandInterpreter
+{
+public:
+ enum
+ {
+ eBroadcastBitThreadShouldExit = (1 << 0),
+ eBroadcastBitResetPrompt = (1 << 1),
+ eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
+ eBroadcastBitAsynchronousOutputData = (1 << 3),
+ eBroadcastBitAsynchronousErrorData = (1 << 4)
+ };
+
+ SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
+
+ ~SBCommandInterpreter ();
+
+ static const char *
+ GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
+
+ static const char *
+ GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
+
+ bool
+ IsValid() const;
+
+ bool
+ CommandExists (const char *cmd);
+
+ bool
+ AliasExists (const char *cmd);
+
+ lldb::SBBroadcaster
+ GetBroadcaster ();
+
+ bool
+ HasCommands ();
+
+ bool
+ HasAliases ();
+
+ bool
+ HasAliasOptions ();
+
+ 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,
+ lldb::SBStringList &matches);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i (added)
+++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,68 @@
+//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBCommandReturnObject
+{
+public:
+
+ SBCommandReturnObject ();
+
+ SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
+
+ ~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);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ void
+ SetImmediateOutputFile (FILE *fh);
+
+ void
+ SetImmediateErrorFile (FILE *fh);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBCommunication.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommunication.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommunication.i (added)
+++ lldb/trunk/scripts/Python/interface/SBCommunication.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,80 @@
+//===-- SWIG Interface for SBCommunication ----------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+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 ();
+
+
+ bool
+ IsValid () const;
+
+ lldb::SBBroadcaster
+ GetBroadcaster ();
+
+ lldb::ConnectionStatus
+ AdoptFileDesriptor (int fd, bool owns_fd);
+
+ lldb::ConnectionStatus
+ Connect (const char *url);
+
+ lldb::ConnectionStatus
+ Disconnect ();
+
+ bool
+ IsConnected () const;
+
+ bool
+ GetCloseOnEOF ();
+
+ void
+ SetCloseOnEOF (bool b);
+
+ 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);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBError.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBError.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBError.i (added)
+++ lldb/trunk/scripts/Python/interface/SBError.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,60 @@
+//===-- SWIG Interface for SBError ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBError {
+public:
+ SBError ();
+
+ SBError (const lldb::SBError &rhs);
+
+ ~SBError();
+
+ 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;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBFileSpec.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFileSpec.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFileSpec.i (added)
+++ lldb/trunk/scripts/Python/interface/SBFileSpec.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,50 @@
+//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBFileSpec
+{
+public:
+ SBFileSpec ();
+
+ SBFileSpec (const lldb::SBFileSpec &rhs);
+
+ SBFileSpec (const char *path);// Deprected, use SBFileSpec (const char *path, bool resolve)
+
+ SBFileSpec (const char *path, bool resolve);
+
+ ~SBFileSpec ();
+
+ bool
+ IsValid() const;
+
+ bool
+ Exists () const;
+
+ bool
+ ResolveExecutableLocation ();
+
+ 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);
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBHostOS.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBHostOS.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBHostOS.i (added)
+++ lldb/trunk/scripts/Python/interface/SBHostOS.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,41 @@
+//===-- SWIG Interface for SBHostOS -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+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);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBInputReader.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInputReader.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInputReader.i (added)
+++ lldb/trunk/scripts/Python/interface/SBInputReader.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,53 @@
+//===-- SWIG Interface for SBInputREader ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+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::SBInputReader &rhs);
+
+ ~SBInputReader ();
+
+ SBError
+ Initialize (SBDebugger &debugger,
+ Callback callback,
+ void *callback_baton,
+ lldb::InputReaderGranularity granularity,
+ const char *end_token,
+ const char *prompt,
+ bool echo);
+
+ bool
+ IsValid () const;
+
+ bool
+ IsActive () const;
+
+ bool
+ IsDone () const;
+
+ void
+ SetIsDone (bool value);
+
+ InputReaderGranularity
+ GetGranularity ();
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBInstruction.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstruction.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInstruction.i (added)
+++ lldb/trunk/scripts/Python/interface/SBInstruction.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,55 @@
+//===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include
+
+// There's a lot to be fixed here, but need to wait for underlying insn implementation
+// to be revised & settle down first.
+
+namespace lldb {
+
+class SBInstruction
+{
+public:
+
+ SBInstruction ();
+
+ SBInstruction (const SBInstruction &rhs);
+
+ ~SBInstruction ();
+
+ bool
+ IsValid();
+
+ SBAddress
+ GetAddress();
+
+ size_t
+ GetByteSize ();
+
+ bool
+ DoesBranch ();
+
+ void
+ Print (FILE *out);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options);
+
+ bool
+ DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'arm-apple-darwin'
+
+ bool
+ TestEmulation (lldb::SBStream &output_stream, const char *test_file);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBInstructionList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstructionList.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInstructionList.i (added)
+++ lldb/trunk/scripts/Python/interface/SBInstructionList.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,49 @@
+//===-- SWIG Interface for SBInstructionList --------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include
+
+namespace lldb {
+
+class SBInstructionList
+{
+public:
+
+ SBInstructionList ();
+
+ SBInstructionList (const SBInstructionList &rhs);
+
+ ~SBInstructionList ();
+
+ bool
+ IsValid () const;
+
+ size_t
+ GetSize ();
+
+ lldb::SBInstruction
+ GetInstructionAtIndex (uint32_t idx);
+
+ void
+ Clear ();
+
+ void
+ AppendInstruction (lldb::SBInstruction inst);
+
+ void
+ Print (FILE *out);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ DumpEmulationForAllInstructions (const char *triple);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBSourceManager.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSourceManager.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSourceManager.i (added)
+++ lldb/trunk/scripts/Python/interface/SBSourceManager.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,28 @@
+//===-- SWIG Interface for SBSourceManager ----------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBSourceManager
+{
+public:
+ SBSourceManager (const lldb::SBSourceManager &rhs);
+
+ ~SBSourceManager();
+
+ size_t
+ DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file,
+ uint32_t line,
+ uint32_t context_before,
+ uint32_t context_after,
+ const char* current_line_cstr,
+ lldb::SBStream &s);
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBStream.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBStream.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBStream.i (added)
+++ lldb/trunk/scripts/Python/interface/SBStream.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,55 @@
+//===-- SWIG Interface for SBStream -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include
+
+namespace lldb {
+
+class SBStream
+{
+public:
+
+ SBStream ();
+
+ ~SBStream ();
+
+ bool
+ IsValid() const;
+
+ // If this stream is not redirected to a file, it will maintain a local
+ // cache for the stream data which can be accessed using this accessor.
+ const char *
+ GetData ();
+
+ // If this stream is not redirected to a file, it will maintain a local
+ // cache for the stream output whose length can be accessed using this
+ // accessor.
+ size_t
+ GetSize();
+
+ void
+ Printf (const char *format, ...);
+
+ void
+ RedirectToFile (const char *path, bool append);
+
+ void
+ RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership);
+
+ void
+ RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
+
+ // If the stream is redirected to a file, forget about the file and if
+ // ownership of the file was transfered to this object, close the file.
+ // If the stream is backed by a local cache, clear this cache.
+ void
+ Clear ();
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBStringList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBStringList.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBStringList.i (added)
+++ lldb/trunk/scripts/Python/interface/SBStringList.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,44 @@
+//===-- SWIG Interface for SBStringList -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBStringList
+{
+public:
+
+ SBStringList ();
+
+ SBStringList (const lldb::SBStringList &rhs);
+
+ ~SBStringList ();
+
+ bool
+ IsValid() const;
+
+ void
+ AppendString (const char *str);
+
+ void
+ AppendList (const char **strv, int strc);
+
+ void
+ AppendList (const lldb::SBStringList &strings);
+
+ uint32_t
+ GetSize () const;
+
+ const char *
+ GetStringAtIndex (size_t idx);
+
+ void
+ Clear ();
+};
+
+} // namespace lldb
Added: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=135531&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (added)
+++ lldb/trunk/scripts/Python/interface/SBType.i Tue Jul 19 17:41:47 2011
@@ -0,0 +1,99 @@
+//===-- SWIG Interface for SBType -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBTypeMember;
+
+class SBType
+{
+public:
+
+ SBType (void *ast = NULL, void *clang_type = NULL);
+
+ SBType (const SBType &rhs);
+
+ ~SBType ();
+
+ bool
+ IsValid();
+
+ const char *
+ GetName();
+
+ uint64_t
+ GetByteSize();
+
+ uint64_t
+ GetNumberChildren (bool omit_empty_base_classes);
+
+ bool
+ GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMember &member);
+
+ uint32_t
+ GetChildIndexForName (bool omit_empty_base_classes, const char *name);
+
+ bool
+ IsAPointerType ();
+
+ SBType
+ GetPointeeType ();
+
+ static bool
+ IsPointerType (void *opaque_type);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+class SBTypeMember
+{
+public:
+
+ SBTypeMember ();
+
+ SBTypeMember (const SBTypeMember &rhs);
+
+ ~SBTypeMember ();
+
+ bool
+ IsBaseClass ();
+
+ bool
+ IsValid ();
+
+ void
+ Clear();
+
+ bool
+ IsBitfield ();
+
+ size_t
+ GetBitfieldWidth ();
+
+ size_t
+ GetBitfieldOffset ();
+
+ size_t
+ GetOffset ();
+
+ const char *
+ GetName ();
+
+ SBType
+ GetType();
+
+ SBType
+ GetParentType();
+
+ void
+ SetName (const char *name);
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=135531&r1=135530&r2=135531&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Tue Jul 19 17:41:47 2011
@@ -197,42 +197,42 @@
%include "lldb/lldb-forward-rtti.h"
%include "lldb/lldb-types.h"
-/* Headers that are swigged directly. */
+/* Forward declaration of SB classes. */
%include "lldb/API/SBDefines.h"
-%include "lldb/API/SBBroadcaster.h"
-%include "lldb/API/SBCommandInterpreter.h"
-%include "lldb/API/SBCommandReturnObject.h"
-%include "lldb/API/SBCommunication.h"
-%include "lldb/API/SBError.h"
-%include "lldb/API/SBFileSpec.h"
-%include "lldb/API/SBHostOS.h"
-%include "lldb/API/SBInputReader.h"
-%include "lldb/API/SBInstruction.h"
-%include "lldb/API/SBInstructionList.h"
-%include "lldb/API/SBSourceManager.h"
-%include "lldb/API/SBStream.h"
-%include "lldb/API/SBStringList.h"
-%include "lldb/API/SBType.h"
/* Python interface files with docstrings. */
%include "./Python/interface/SBAddress.i"
%include "./Python/interface/SBBlock.i"
%include "./Python/interface/SBBreakpoint.i"
%include "./Python/interface/SBBreakpointLocation.i"
+%include "./Python/interface/SBBroadcaster.i"
+%include "./Python/interface/SBCommandInterpreter.i"
+%include "./Python/interface/SBCommandReturnObject.i"
+%include "./Python/interface/SBCommunication.i"
%include "./Python/interface/SBCompileUnit.i"
%include "./Python/interface/SBDebugger.i"
+%include "./Python/interface/SBError.i"
%include "./Python/interface/SBEvent.i"
+%include "./Python/interface/SBFileSpec.i"
%include "./Python/interface/SBFrame.i"
%include "./Python/interface/SBFunction.i"
+%include "./Python/interface/SBHostOS.i"
+%include "./Python/interface/SBInputReader.i"
+%include "./Python/interface/SBInstruction.i"
+%include "./Python/interface/SBInstructionList.i"
%include "./Python/interface/SBLineEntry.i"
%include "./Python/interface/SBListener.i"
%include "./Python/interface/SBModule.i"
%include "./Python/interface/SBProcess.i"
+%include "./Python/interface/SBSourceManager.i"
+%include "./Python/interface/SBStream.i"
+%include "./Python/interface/SBStringList.i"
%include "./Python/interface/SBSymbol.i"
%include "./Python/interface/SBSymbolContext.i"
%include "./Python/interface/SBSymbolContextList.i"
%include "./Python/interface/SBTarget.i"
%include "./Python/interface/SBThread.i"
+%include "./Python/interface/SBType.i"
%include "./Python/interface/SBValue.i"
%include "./Python/interface/SBValueList.i"
From johnny.chen at apple.com Tue Jul 19 18:24:36 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 23:24:36 -0000
Subject: [Lldb-commits] [lldb] r135536 -
/lldb/trunk/scripts/Python/interface/SBStream.i
Message-ID: <20110719232436.71E5C2A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 18:24:36 2011
New Revision: 135536
URL: http://llvm.org/viewvc/llvm-project?rev=135536&view=rev
Log:
Add some docstrings for SBStream class.
Modified:
lldb/trunk/scripts/Python/interface/SBStream.i
Modified: lldb/trunk/scripts/Python/interface/SBStream.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBStream.i?rev=135536&r1=135535&r2=135536&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBStream.i (original)
+++ lldb/trunk/scripts/Python/interface/SBStream.i Tue Jul 19 18:24:36 2011
@@ -11,6 +11,33 @@
namespace lldb {
+%feature("docstring",
+"Represents a destination for streaming data output to. By default, a string
+stream is created.
+
+For example (from test/source-manager/TestSourceManager.py),
+
+ # Create the filespec for 'main.c'.
+ filespec = lldb.SBFileSpec('main.c', False)
+ source_mgr = self.dbg.GetSourceManager()
+ # Use a string stream as the destination.
+ stream = lldb.SBStream()
+ source_mgr.DisplaySourceLinesWithLineNumbers(filespec,
+ self.line,
+ 2, # context before
+ 2, # context after
+ '=>', # prefix for current line
+ stream)
+
+ # 2
+ # 3 int main(int argc, char const *argv[]) {
+ # => 4 printf('Hello world.\\n'); // Set break point at this line.
+ # 5 return 0;
+ # 6 }
+ self.expect(stream.GetData(), 'Source code displayed correctly',
+ exe=False,
+ patterns = ['=> %d.*Hello world' % self.line])
+") SBStream;
class SBStream
{
public:
@@ -22,14 +49,22 @@
bool
IsValid() const;
- // If this stream is not redirected to a file, it will maintain a local
- // cache for the stream data which can be accessed using this accessor.
+ %feature("docstring", "
+ //--------------------------------------------------------------------------
+ /// If this stream is not redirected to a file, it will maintain a local
+ /// cache for the stream data which can be accessed using this accessor.
+ //--------------------------------------------------------------------------
+ ") GetData;
const char *
GetData ();
- // If this stream is not redirected to a file, it will maintain a local
- // cache for the stream output whose length can be accessed using this
- // accessor.
+ %feature("docstring", "
+ //--------------------------------------------------------------------------
+ /// If this stream is not redirected to a file, it will maintain a local
+ /// cache for the stream output whose length can be accessed using this
+ /// accessor.
+ //--------------------------------------------------------------------------
+ ") GetSize;
size_t
GetSize();
@@ -45,9 +80,13 @@
void
RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
- // If the stream is redirected to a file, forget about the file and if
- // ownership of the file was transfered to this object, close the file.
- // If the stream is backed by a local cache, clear this cache.
+ %feature("docstring", "
+ //--------------------------------------------------------------------------
+ /// If the stream is redirected to a file, forget about the file and if
+ /// ownership of the file was transfered to this object, close the file.
+ /// If the stream is backed by a local cache, clear this cache.
+ //--------------------------------------------------------------------------
+ ") Clear;
void
Clear ();
};
From johnny.chen at apple.com Tue Jul 19 18:35:10 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Tue, 19 Jul 2011 23:35:10 -0000
Subject: [Lldb-commits] [lldb] r135539 -
/lldb/trunk/scripts/Python/interface/SBSourceManager.i
Message-ID: <20110719233510.BC6E42A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 18:35:10 2011
New Revision: 135539
URL: http://llvm.org/viewvc/llvm-project?rev=135539&view=rev
Log:
Add some docstrings for SBSourceManager class.
Modified:
lldb/trunk/scripts/Python/interface/SBSourceManager.i
Modified: lldb/trunk/scripts/Python/interface/SBSourceManager.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSourceManager.i?rev=135539&r1=135538&r2=135539&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSourceManager.i (original)
+++ lldb/trunk/scripts/Python/interface/SBSourceManager.i Tue Jul 19 18:35:10 2011
@@ -9,6 +9,32 @@
namespace lldb {
+%feature("docstring",
+"Represents a central authority for displaying source code.
+
+For example (from test/source-manager/TestSourceManager.py),
+
+ # Create the filespec for 'main.c'.
+ filespec = lldb.SBFileSpec('main.c', False)
+ source_mgr = self.dbg.GetSourceManager()
+ # Use a string stream as the destination.
+ stream = lldb.SBStream()
+ source_mgr.DisplaySourceLinesWithLineNumbers(filespec,
+ self.line,
+ 2, # context before
+ 2, # context after
+ '=>', # prefix for current line
+ stream)
+
+ # 2
+ # 3 int main(int argc, char const *argv[]) {
+ # => 4 printf('Hello world.\\n'); // Set break point at this line.
+ # 5 return 0;
+ # 6 }
+ self.expect(stream.GetData(), 'Source code displayed correctly',
+ exe=False,
+ patterns = ['=> %d.*Hello world' % self.line])
+") SBSourceManager;
class SBSourceManager
{
public:
From johnny.chen at apple.com Tue Jul 19 19:11:54 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 00:11:54 -0000
Subject: [Lldb-commits] [lldb] r135542 -
/lldb/trunk/test/python_api/event/TestEvents.py
Message-ID: <20110720001154.414FD2A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 19:11:54 2011
New Revision: 135542
URL: http://llvm.org/viewvc/llvm-project?rev=135542&view=rev
Log:
Minor change; add an assertTrue stmt.
Modified:
lldb/trunk/test/python_api/event/TestEvents.py
Modified: lldb/trunk/test/python_api/event/TestEvents.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=135542&r1=135541&r2=135542&view=diff
==============================================================================
--- lldb/trunk/test/python_api/event/TestEvents.py (original)
+++ lldb/trunk/test/python_api/event/TestEvents.py Tue Jul 19 19:11:54 2011
@@ -150,6 +150,7 @@
# Now launch the process, and do not stop at entry point.
error = lldb.SBError()
process = target.Launch (listener, None, None, None, None, None, None, 0, False, error)
+ self.assertTrue(error.Success())
self.assertTrue(process, PROCESS_IS_VALID)
# Get a handle on the process's broadcaster.
From johnny.chen at apple.com Tue Jul 19 19:14:20 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 00:14:20 -0000
Subject: [Lldb-commits] [lldb] r135544 -
/lldb/trunk/test/python_api/event/TestEvents.py
Message-ID: <20110720001420.98E1A2A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 19:14:20 2011
New Revision: 135544
URL: http://llvm.org/viewvc/llvm-project?rev=135544&view=rev
Log:
A more succinct assertTrue.
Modified:
lldb/trunk/test/python_api/event/TestEvents.py
Modified: lldb/trunk/test/python_api/event/TestEvents.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=135544&r1=135543&r2=135544&view=diff
==============================================================================
--- lldb/trunk/test/python_api/event/TestEvents.py (original)
+++ lldb/trunk/test/python_api/event/TestEvents.py Tue Jul 19 19:14:20 2011
@@ -150,8 +150,7 @@
# Now launch the process, and do not stop at entry point.
error = lldb.SBError()
process = target.Launch (listener, None, None, None, None, None, None, 0, False, error)
- self.assertTrue(error.Success())
- self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
# Get a handle on the process's broadcaster.
broadcaster = process.GetBroadcaster()
From johnny.chen at apple.com Tue Jul 19 19:23:11 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 00:23:11 -0000
Subject: [Lldb-commits] [lldb] r135547 -
/lldb/trunk/scripts/Python/interface/SBError.i
Message-ID: <20110720002311.A6B7E2A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 19:23:11 2011
New Revision: 135547
URL: http://llvm.org/viewvc/llvm-project?rev=135547&view=rev
Log:
Add some docstrings for SBError class.
Modified:
lldb/trunk/scripts/Python/interface/SBError.i
Modified: lldb/trunk/scripts/Python/interface/SBError.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBError.i?rev=135547&r1=135546&r2=135547&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBError.i (original)
+++ lldb/trunk/scripts/Python/interface/SBError.i Tue Jul 19 19:23:11 2011
@@ -9,6 +9,53 @@
namespace lldb {
+%feature("docstring",
+"Represents a container for holding any error code.
+
+For example (from test/python_api/hello_world/TestHelloWorld.py),
+
+ def hello_world_attach_with_id_api(self):
+ '''Create target, spawn a process, and attach to it by id.'''
+
+ target = self.dbg.CreateTarget(self.exe)
+
+ # Spawn a new process and don't display the stdout if not in TraceOn() mode.
+ import subprocess
+ popen = subprocess.Popen([self.exe, 'abc', 'xyz'],
+ stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
+
+ listener = lldb.SBListener('my.attach.listener')
+ error = lldb.SBError()
+ process = target.AttachToProcessWithID(listener, popen.pid, error)
+
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+
+ # Let's check the stack traces of the attached process.
+ import lldbutil
+ stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+ self.expect(stacktraces, exe=False,
+ substrs = ['main.c:%d' % self.line2,
+ '(int)argc=3'])
+
+ listener = lldb.SBListener('my.attach.listener')
+ error = lldb.SBError()
+ process = target.AttachToProcessWithID(listener, popen.pid, error)
+
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+
+checks that after the attach, there is no error condition by asserting
+that error.Success() is True and we get back a valid process object.
+
+And (from test/python_api/event/TestEvent.py),
+
+ # Now launch the process, and do not stop at entry point.
+ error = lldb.SBError()
+ process = target.Launch(listener, None, None, None, None, None, None, 0, False, error)
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+
+checks that after calling the target.Launch() method there's no error
+condition and we get back a void process object.
+") SBError;
class SBError {
public:
SBError ();
From johnny.chen at apple.com Tue Jul 19 20:06:37 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 01:06:37 -0000
Subject: [Lldb-commits] [lldb] r135553 -
/lldb/trunk/scripts/Python/interface/SBFileSpec.i
Message-ID: <20110720010637.5FE262A6C12D@llvm.org>
Author: johnny
Date: Tue Jul 19 20:06:37 2011
New Revision: 135553
URL: http://llvm.org/viewvc/llvm-project?rev=135553&view=rev
Log:
Add some docstrings for SBFileSpec class.
Modified:
lldb/trunk/scripts/Python/interface/SBFileSpec.i
Modified: lldb/trunk/scripts/Python/interface/SBFileSpec.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFileSpec.i?rev=135553&r1=135552&r2=135553&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFileSpec.i (original)
+++ lldb/trunk/scripts/Python/interface/SBFileSpec.i Tue Jul 19 20:06:37 2011
@@ -9,6 +9,27 @@
namespace lldb {
+%feature("docstring",
+"Represents a file specfication that divides the path into a directory and
+basename. The string values of the paths are put into uniqued string pools
+for fast comparisons and efficient memory usage.
+
+For example, the following code
+
+ lineEntry = context.GetLineEntry()
+ self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory',
+ exe=False,
+ substrs = [self.mydir])
+ self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename',
+ exe=False,
+ substrs = ['main.c'])
+ self.assertTrue(lineEntry.GetLine() == self.line,
+ 'The line entry's line number should match ')
+
+gets the line entry from the symbol context when a thread is stopped.
+It gets the file spec corresponding to the line entry and checks that
+the filename and the directory matches wat we expect.
+") SBFileSpec;
class SBFileSpec
{
public:
From gclayton at apple.com Tue Jul 19 20:32:51 2011
From: gclayton at apple.com (Greg Clayton)
Date: Wed, 20 Jul 2011 01:32:51 -0000
Subject: [Lldb-commits] [lldb] r135557 - in
/lldb/trunk/source/Plugins/Process/MacOSX-Kernel: CommunicationKDP.cpp
CommunicationKDP.h RegisterContextKDP_arm.cpp RegisterContextKDP_i386.cpp
RegisterContextKDP_i386.h RegisterContextKDP_x86_64.cpp
RegisterContextKDP_x86_64.h
Message-ID: <20110720013251.23E042A6C12D@llvm.org>
Author: gclayton
Date: Tue Jul 19 20:32:50 2011
New Revision: 135557
URL: http://llvm.org/viewvc/llvm-project?rev=135557&view=rev
Log:
Added register reading support for ARM, i386 and x86_64.
Modified:
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Tue Jul 19 20:32:50 2011
@@ -409,7 +409,6 @@
DataExtractor reply_packet;
if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
{
- // Reset the sequence ID to zero for reattach
uint32_t offset = 8;
m_kdp_version_version = reply_packet.GetU32 (&offset);
m_kdp_version_feature = reply_packet.GetU32 (&offset);
@@ -453,7 +452,6 @@
DataExtractor reply_packet;
if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
{
- // Reset the sequence ID to zero for reattach
uint32_t offset = 8;
m_kdp_hostinfo_cpu_mask = reply_packet.GetU32 (&offset);
m_kdp_hostinfo_cpu_type = reply_packet.GetU32 (&offset);
@@ -507,7 +505,6 @@
DataExtractor reply_packet;
if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
{
- // Reset the sequence ID to zero for reattach
uint32_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
uint32_t src_len = reply_packet.GetByteSize() - 12;
@@ -530,6 +527,41 @@
return 0;
}
+
+uint32_t
+CommunicationKDP::SendRequestWriteMemory (lldb::addr_t addr,
+ const void *src,
+ uint32_t src_len,
+ Error &error)
+{
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
+ bool use_64 = (GetVersion() >= 11);
+ uint32_t command_addr_byte_size = use_64 ? 8 : 4;
+ const CommandType command = use_64 ? eCommandTypeWriteMemory64 : eCommandTypeWriteMemory;
+ // Size is header + address size + uint32_t length
+ const uint32_t command_length = 8 + command_addr_byte_size + 4;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ request_packet.PutMaxHex64 (addr, command_addr_byte_size);
+ request_packet.PutHex32 (src_len);
+ request_packet.PutBytesAsRawHex8(src, src_len);
+
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ {
+ uint32_t offset = 8;
+ uint32_t kdp_error = reply_packet.GetU32 (&offset);
+ if (kdp_error)
+ error.SetErrorStringWithFormat ("kdp write memory failed (error %u)", kdp_error);
+ else
+ {
+ error.Clear();
+ return src_len;
+ }
+ }
+ return 0;
+}
+
const char *
CommunicationKDP::GetCommandAsCString (uint8_t command)
{
@@ -603,7 +635,16 @@
// Dump request reply packets
switch (command)
{
+ // Commands that return a single 32 bit error
case eCommandTypeConnect:
+ case eCommandTypeWriteMemory:
+ case eCommandTypeWriteMemory64:
+ case eCommandTypeBreakpointSet:
+ case eCommandTypeBreakpointRemove:
+ case eCommandTypeBreakpointSet64:
+ case eCommandTypeBreakpointRemove64:
+ case eCommandTypeWriteRegisters:
+ case eCommandTypeLoad:
{
const uint32_t error = packet.GetU32 (&offset);
s.Printf(" (error=0x%8.8x)", error);
@@ -613,7 +654,12 @@
case eCommandTypeDisconnect:
case eCommandTypeReattach:
case eCommandTypeHostReboot:
+ case eCommandTypeSuspend:
+ case eCommandTypeResume:
+ case eCommandTypeException:
+ case eCommandTypeTermination:
// No return value for the reply, just the header to ack
+ s.PutCString(" ()");
break;
case eCommandTypeHostInfo:
@@ -649,31 +695,36 @@
case eCommandTypeReadMemory:
case eCommandTypeReadMemory64:
- case eCommandTypeReadRegisters:
{
const uint32_t error = packet.GetU32 (&offset);
- const uint32_t count = packet.GetByteSize() - 12;
+ const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x <0x%x>:\n", error, count);
if (count > 0)
DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, count), count, 32, LLDB_INVALID_ADDRESS);
}
break;
+ case eCommandTypeReadRegisters:
+ {
+ const uint32_t error = packet.GetU32 (&offset);
+ const uint32_t count = packet.GetByteSize() - offset;
+ s.Printf(" (error = 0x%8.8x <0x%x> regs:\n", error, count);
+ if (count > 0)
+ packet.Dump (&s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ m_addr_byte_size, // Size of each item in bytes
+ count / m_addr_byte_size, // Number of items
+ 16 / m_addr_byte_size, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+ 0, 0); // No bitfields
+ }
+ break;
+
case eCommandTypeMaxBytes:
- case eCommandTypeWriteMemory:
- case eCommandTypeWriteRegisters:
- case eCommandTypeLoad:
case eCommandTypeImagePath:
- case eCommandTypeSuspend:
- case eCommandTypeResume:
- case eCommandTypeException:
- case eCommandTypeTermination:
- case eCommandTypeBreakpointSet:
- case eCommandTypeBreakpointRemove:
- case eCommandTypeWriteMemory64:
- case eCommandTypeBreakpointSet64:
- case eCommandTypeBreakpointRemove64:
case eCommandTypeKernelVersion:
+ s.Printf(" (add support for dumping this packet reply!!!");
break;
}
@@ -707,6 +758,16 @@
}
break;
+ case eCommandTypeWriteMemory:
+ {
+ const uint32_t addr = packet.GetU32 (&offset);
+ const uint32_t size = packet.GetU32 (&offset);
+ s.Printf(" (addr = 0x%8.8x, size=%u, bytes:\n", addr, size);
+ if (size > 0)
+ DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
+ }
+ break;
+
case eCommandTypeReadMemory64:
{
const uint64_t addr = packet.GetU64 (&offset);
@@ -715,6 +776,16 @@
}
break;
+ case eCommandTypeWriteMemory64:
+ {
+ const uint64_t addr = packet.GetU64 (&offset);
+ const uint32_t size = packet.GetU32 (&offset);
+ s.Printf(" (addr = 0x%16.16llx, size=%u, bytes:", addr, size);
+ if (size > 0)
+ DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
+ }
+ break;
+
case eCommandTypeReadRegisters:
{
const uint32_t cpu = packet.GetU32 (&offset);
@@ -723,9 +794,26 @@
}
break;
- case eCommandTypeMaxBytes:
- case eCommandTypeWriteMemory:
case eCommandTypeWriteRegisters:
+ {
+ const uint32_t cpu = packet.GetU32 (&offset);
+ const uint32_t flavor = packet.GetU32 (&offset);
+ const uint32_t nbytes = packet.GetByteSize() - offset;
+ s.Printf(" (cpu = %u, flavor=%u, regs:\n", cpu, flavor);
+ if (nbytes > 0)
+ packet.Dump (&s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ m_addr_byte_size, // Size of each item in bytes
+ nbytes / m_addr_byte_size, // Number of items
+ 16 / m_addr_byte_size, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+ 0, 0); // No bitfields
+ }
+ break;
+
+ case eCommandTypeMaxBytes:
+
case eCommandTypeLoad:
case eCommandTypeImagePath:
case eCommandTypeSuspend:
@@ -743,10 +831,10 @@
}
break;
- case eCommandTypeWriteMemory64:
case eCommandTypeBreakpointSet64:
case eCommandTypeBreakpointRemove64:
case eCommandTypeKernelVersion:
+
break;
}
}
@@ -790,7 +878,6 @@
DataExtractor reply_packet;
if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
{
- // Reset the sequence ID to zero for reattach
uint32_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
uint32_t src_len = reply_packet.GetByteSize() - 12;
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Tue Jul 19 20:32:50 2011
@@ -156,21 +156,22 @@
uint32_t
SendRequestReadMemory (lldb::addr_t addr,
- void *buf,
- uint32_t size,
+ void *dst,
+ uint32_t dst_size,
lldb_private::Error &error);
uint32_t
+ SendRequestWriteMemory (lldb::addr_t addr,
+ const void *src,
+ uint32_t src_len,
+ lldb_private::Error &error);
+
+ uint32_t
SendRequestReadRegisters (uint32_t cpu,
uint32_t flavor,
void *dst,
uint32_t dst_size,
lldb_private::Error &error);
-// size_t
-// SendRequestWriteMemory (lldb::addr_t addr,
-// const void *buf,
-// size_t size,
-// lldb_private::Error &error);
uint32_t
GetVersion ();
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp Tue Jul 19 20:32:50 2011
@@ -20,7 +20,7 @@
using namespace lldb_private;
-RegisterContextKDP_arm::RegisterContextKDP_arm(ThreadKDP &thread, uint32_t concrete_frame_idx) :
+RegisterContextKDP_arm::RegisterContextKDP_arm (ThreadKDP &thread, uint32_t concrete_frame_idx) :
RegisterContextDarwin_arm (thread, concrete_frame_idx),
m_kdp_thread (thread)
{
@@ -34,10 +34,7 @@
RegisterContextKDP_arm::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid,
- GPRRegSet,
- &gpr, sizeof(gpr),
- error))
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
{
if (error.Success())
return 0;
@@ -48,18 +45,36 @@
int
RegisterContextKDP_arm::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
+ Error error;
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
+ {
+ if (error.Success())
+ return 0;
+ }
return -1;
}
int
RegisterContextKDP_arm::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
+ Error error;
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
+ {
+ if (error.Success())
+ return 0;
+ }
return -1;
}
int
RegisterContextKDP_arm::DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
{
+ Error error;
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
+ {
+ if (error.Success())
+ return 0;
+ }
return -1;
}
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp Tue Jul 19 20:32:50 2011
@@ -9,19 +9,20 @@
// C Includes
-#include
-
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "RegisterContextKDP_i386.h"
+#include "ProcessKDP.h"
+#include "ThreadKDP.h"
using namespace lldb;
using namespace lldb_private;
-RegisterContextKDP_i386::RegisterContextKDP_i386(Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContextDarwin_i386 (thread, concrete_frame_idx)
+RegisterContextKDP_i386::RegisterContextKDP_i386 (ThreadKDP &thread, uint32_t concrete_frame_idx) :
+ RegisterContextDarwin_i386 (thread, concrete_frame_idx),
+ m_kdp_thread (thread)
{
}
@@ -32,22 +33,37 @@
int
RegisterContextKDP_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
- mach_msg_type_number_t count = GPRWordCount;
- return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
+ Error error;
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
+ {
+ if (error.Success())
+ return 0;
+ }
+ return -1;
}
int
RegisterContextKDP_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
- mach_msg_type_number_t count = FPUWordCount;
- return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
+ Error error;
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
+ {
+ if (error.Success())
+ return 0;
+ }
+ return -1;
}
int
RegisterContextKDP_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
- mach_msg_type_number_t count = EXCWordCount;
- return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
+ Error error;
+ if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
+ {
+ if (error.Success())
+ return 0;
+ }
+ return -1;
}
int
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h Tue Jul 19 20:32:50 2011
@@ -16,10 +16,12 @@
// Project includes
#include "Plugins/Process/Utility/RegisterContextDarwin_i386.h"
+class ThreadKDP;
+
class RegisterContextKDP_i386 : public RegisterContextDarwin_i386
{
public:
- RegisterContextKDP_i386 (lldb_private::Thread &thread,
+ RegisterContextKDP_i386 (ThreadKDP &thread,
uint32_t concrete_frame_idx);
virtual
@@ -44,6 +46,8 @@
int
DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
+
+ ThreadKDP &m_kdp_thread;
};
#endif // liblldb_RegisterContextKDP_i386_h_
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp Tue Jul 19 20:32:50 2011
@@ -9,19 +9,20 @@
// C Includes
-#include
-
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "RegisterContextKDP_x86_64.h"
+#include "ProcessKDP.h"
+#include "ThreadKDP.h"
using namespace lldb;
using namespace lldb_private;
-RegisterContextKDP_x86_64::RegisterContextKDP_x86_64(Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContextDarwin_x86_64 (thread, concrete_frame_idx)
+RegisterContextKDP_x86_64::RegisterContextKDP_x86_64 (ThreadKDP &thread, uint32_t concrete_frame_idx) :
+ RegisterContextDarwin_x86_64 (thread, concrete_frame_idx),
+ m_kdp_thread (thread)
{
}
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h?rev=135557&r1=135556&r2=135557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h Tue Jul 19 20:32:50 2011
@@ -16,11 +16,13 @@
// Project includes
#include "Plugins/Process/Utility/RegisterContextDarwin_x86_64.h"
+class ThreadKDP;
+
class RegisterContextKDP_x86_64 : public RegisterContextDarwin_x86_64
{
public:
- RegisterContextKDP_x86_64 (lldb_private::Thread &thread,
+ RegisterContextKDP_x86_64 (ThreadKDP &thread,
uint32_t concrete_frame_idx);
virtual
@@ -45,6 +47,8 @@
int
DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
+
+ ThreadKDP &m_kdp_thread;
};
#endif // liblldb_RegisterContextKDP_x86_64_h_
From gclayton at apple.com Tue Jul 19 21:22:21 2011
From: gclayton at apple.com (Greg Clayton)
Date: Wed, 20 Jul 2011 02:22:21 -0000
Subject: [Lldb-commits] [lldb] r135560 -
/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
Message-ID: <20110720022221.6D3EF2A6C12D@llvm.org>
Author: gclayton
Date: Tue Jul 19 21:22:21 2011
New Revision: 135560
URL: http://llvm.org/viewvc/llvm-project?rev=135560&view=rev
Log:
Remove extra launch arguments.
Modified:
lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=135560&r1=135559&r2=135560&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Jul 19 21:22:21 2011
@@ -89,16 +89,6 @@
ReferencedContainer = "container:lldb.xcodeproj">
-
-
-
-
-
-
Author: gclayton
Date: Tue Jul 19 22:41:06 2011
New Revision: 135563
URL: http://llvm.org/viewvc/llvm-project?rev=135563&view=rev
Log:
Added KDP resume, suspend, set/remove breakpoint, and kernel version support.
Also we now display a live update of the kexts that we are loading.
Modified:
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=135563&r1=135562&r2=135563&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Jul 19 22:41:06 2011
@@ -198,9 +198,12 @@
case eInputReaderActivate:
if (!batch_mode)
{
- StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
- out_stream->Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:");
- out_stream->Flush();
+ StreamSP async_strm_sp(reader.GetDebugger().GetAsyncOutputStream());
+ if (async_strm_sp)
+ {
+ async_strm_sp->PutCString("Enter expressions, then terminate with an empty line to evaluate:\n");
+ async_strm_sp->Flush();
+ }
}
// Fall through
case eInputReaderReactivate:
@@ -228,9 +231,12 @@
reader.SetIsDone (true);
if (!batch_mode)
{
- StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream();
- out_stream->Printf("%s\n", "Expression evaluation cancelled.");
- out_stream->Flush();
+ StreamSP async_strm_sp (reader.GetDebugger().GetAsyncOutputStream());
+ if (async_strm_sp)
+ {
+ async_strm_sp->PutCString("Expression evaluation cancelled.\n");
+ async_strm_sp->Flush();
+ }
}
break;
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp?rev=135563&r1=135562&r2=135563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp Tue Jul 19 22:41:06 2011
@@ -10,6 +10,7 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -499,8 +500,25 @@
if (!ReadKextSummaries (kext_summary_addr, count, kext_summaries))
return false;
+ Stream *s = &m_process->GetTarget().GetDebugger().GetOutputStream();
for (uint32_t i = 0; i < count; i++)
{
+ if (s)
+ {
+ const uint8_t *u = (const uint8_t *)kext_summaries[i].uuid.GetBytes();
+ if (u)
+ {
+ s->Printf("Loading kext: %2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X 0x%16.16llx \"%s\"...\n",
+ u[ 0], u[ 1], u[ 2], u[ 3], u[ 4], u[ 5], u[ 6], u[ 7],
+ u[ 8], u[ 9], u[10], u[11], u[12], u[13], u[14], u[15],
+ kext_summaries[i].address, kext_summaries[i].name);
+ }
+ else
+ {
+ s->Printf("0x%16.16llx \"%s\"...\n", kext_summaries[i].address, kext_summaries[i].name);
+ }
+ }
+
DataExtractor data; // Load command data
if (ReadMachHeader (kext_summaries[i], &data))
{
@@ -868,7 +886,7 @@
{
if (log == NULL)
return;
- uint8_t *u = (uint8_t *)uuid.GetBytes();
+ const uint8_t *u = (uint8_t *)uuid.GetBytes();
if (address == LLDB_INVALID_ADDRESS)
{
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=135563&r1=135562&r2=135563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Tue Jul 19 22:41:06 2011
@@ -469,6 +469,33 @@
return false;
}
+const char *
+CommunicationKDP::GetKernelVersion ()
+{
+ if (m_kernel_version.empty())
+ SendRequestKernelVersion ();
+ return m_kernel_version.c_str();
+}
+
+bool
+CommunicationKDP::SendRequestKernelVersion ()
+{
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
+ const CommandType command = eCommandTypeKernelVersion;
+ const uint32_t command_length = 8;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ {
+ const char *kernel_version_cstr = reply_packet.PeekCStr(8);
+ if (kernel_version_cstr && kernel_version_cstr[0])
+ m_kernel_version.assign (kernel_version_cstr);
+ return true;
+ }
+ return false;
+}
+
bool
CommunicationKDP::SendRequestDisconnect ()
{
@@ -700,7 +727,14 @@
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x <0x%x>:\n", error, count);
if (count > 0)
- DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, count), count, 32, LLDB_INVALID_ADDRESS);
+ packet.Dump (&s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatBytesWithASCII, // Format to use
+ 1, // Size of each item in bytes
+ count, // Number of items
+ 16, // Number per line
+ m_last_read_memory_addr, // Don't show addresses before each line
+ 0, 0); // No bitfields
}
break;
@@ -721,9 +755,26 @@
}
break;
+ case eCommandTypeKernelVersion:
+ {
+ const char *kernel_version = packet.PeekCStr(8);
+ s.Printf(" (version = \"%s\")", kernel_version);
+ }
+ break;
+
case eCommandTypeMaxBytes:
+ {
+ const uint32_t max_bytes = packet.GetU32 (&offset);
+ s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
+ }
+ break;
case eCommandTypeImagePath:
- case eCommandTypeKernelVersion:
+ {
+ const char *path = packet.GetCStr(&offset);
+ s.Printf(" (path = \"%s\")", path);
+ }
+ break;
+ default:
s.Printf(" (add support for dumping this packet reply!!!");
break;
@@ -747,7 +798,19 @@
case eCommandTypeHostInfo:
case eCommandTypeVersion:
case eCommandTypeRegions:
+ case eCommandTypeKernelVersion:
+ case eCommandTypeMaxBytes:
+ case eCommandTypeImagePath:
+ case eCommandTypeSuspend:
// No args, just the header in the request...
+ s.PutCString(" ()");
+ break;
+
+ case eCommandTypeResume:
+ {
+ const uint32_t cpu_mask = packet.GetU32 (&offset);
+ s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
+ }
break;
case eCommandTypeReadMemory:
@@ -755,6 +818,7 @@
const uint32_t addr = packet.GetU32 (&offset);
const uint32_t size = packet.GetU32 (&offset);
s.Printf(" (addr = 0x%8.8x, size=%u)", addr, size);
+ m_last_read_memory_addr = addr;
}
break;
@@ -773,6 +837,7 @@
const uint64_t addr = packet.GetU64 (&offset);
const uint32_t size = packet.GetU32 (&offset);
s.Printf(" (addr = 0x%16.16llx, size=%u)", addr, size);
+ m_last_read_memory_addr = addr;
}
break;
@@ -812,16 +877,71 @@
}
break;
- case eCommandTypeMaxBytes:
+
+ case eCommandTypeBreakpointSet:
+ case eCommandTypeBreakpointRemove:
+ {
+ const uint32_t addr = packet.GetU32 (&offset);
+ s.Printf(" (addr = 0x%8.8x)", addr);
+ }
+ break;
+
+ case eCommandTypeBreakpointSet64:
+ case eCommandTypeBreakpointRemove64:
+ {
+ const uint64_t addr = packet.GetU64 (&offset);
+ s.Printf(" (addr = 0x%16.16llx)", addr);
+ }
+ break;
+
case eCommandTypeLoad:
- case eCommandTypeImagePath:
- case eCommandTypeSuspend:
- case eCommandTypeResume:
+ {
+ const char *path = packet.GetCStr(&offset);
+ s.Printf(" (path = \"%s\")", path);
+ }
+ break;
+
case eCommandTypeException:
+ {
+ const uint32_t count = packet.GetU32 (&offset);
+
+ s.Printf(" (count = %u:", count);
+ for (uint32_t i=0; i= 11);
+ uint32_t command_addr_byte_size = use_64 ? 8 : 4;
+ const CommandType command = set ? (use_64 ? eCommandTypeBreakpointSet64 : eCommandTypeBreakpointSet ):
+ (use_64 ? eCommandTypeBreakpointRemove64 : eCommandTypeBreakpointRemove);
+
+ const uint32_t command_length = 8 + command_addr_byte_size;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ request_packet.PutMaxHex64 (addr, command_addr_byte_size);
+
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ return true;
+ return false;
+}
+
+bool
+CommunicationKDP::SendRequestSuspend ()
+{
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
+ const CommandType command = eCommandTypeSuspend;
+ const uint32_t command_length = 8;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ return true;
+ return false;
+}
+
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=135563&r1=135562&r2=135563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Tue Jul 19 22:41:06 2011
@@ -65,6 +65,11 @@
eCommandTypeKernelVersion
} CommandType;
+ enum
+ {
+ eFeatureLocalBreakpointsSupported = (1u << 0),
+ };
+
typedef enum
{
KDP_PROTERR_SUCCESS = 0,
@@ -173,12 +178,21 @@
uint32_t dst_size,
lldb_private::Error &error);
+ const char *
+ GetKernelVersion ();
+
uint32_t
GetVersion ();
uint32_t
GetFeatureFlags ();
+ bool
+ LocalBreakpointsAreSupported ()
+ {
+ return (GetFeatureFlags() & eFeatureLocalBreakpointsSupported) != 0;
+ }
+
uint32_t
GetCPUMask ();
@@ -188,6 +202,16 @@
uint32_t
GetCPUSubtype ();
+ // If cpu_mask is zero, then we will resume all CPUs
+ bool
+ SendRequestResume (uint32_t cpu_mask = 0);
+
+ bool
+ SendRequestSuspend ();
+
+ bool
+ SendRequestBreakpoint (bool set, lldb::addr_t addr);
+
protected:
typedef std::list packet_collection;
@@ -216,6 +240,8 @@
bool
SendRequestHostInfo ();
+ bool
+ SendRequestKernelVersion ();
void
DumpPacket (lldb_private::Stream &s,
@@ -280,6 +306,8 @@
uint32_t m_kdp_hostinfo_cpu_mask;
uint32_t m_kdp_hostinfo_cpu_type;
uint32_t m_kdp_hostinfo_cpu_subtype;
+ std::string m_kernel_version;
+ lldb::addr_t m_last_read_memory_addr; // Last memory read address for logging
private:
//------------------------------------------------------------------
// For CommunicationKDP only
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=135563&r1=135562&r2=135563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Tue Jul 19 22:41:06 2011
@@ -14,6 +14,7 @@
// C++ Includes
// Other libraries and framework includes
#include "lldb/Core/ConnectionFileDescriptor.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
@@ -183,10 +184,19 @@
ArchSpec kernel_arch;
kernel_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
m_target.SetArchitecture(kernel_arch);
-
SetID (1);
UpdateThreadListIfNeeded ();
SetPrivateState (eStateStopped);
+ StreamSP async_strm_sp(m_target.GetDebugger().GetAsyncOutputStream());
+ if (async_strm_sp)
+ {
+ const char *kernel_version = m_comm.GetKernelVersion ();
+ if (kernel_version)
+ {
+ async_strm_sp->Printf ("KDP connected to %s\n", kernel_version);
+ async_strm_sp->Flush();
+ }
+ }
}
}
else
@@ -237,24 +247,6 @@
return error;
}
-size_t
-ProcessKDP::AttachInputReaderCallback (void *baton,
- InputReader *reader,
- lldb::InputReaderAction notification,
- const char *bytes,
- size_t bytes_len)
-{
- if (notification == eInputReaderGotToken)
- {
-// ProcessKDP *process = (ProcessKDP *)baton;
-// if (process->m_waiting_for_attach)
-// process->m_waiting_for_attach = false;
- reader->SetIsDone(true);
- return 1;
- }
- return 0;
-}
-
Error
ProcessKDP::DoAttachToProcessWithName (const char *process_name, bool wait_for_launch)
{
@@ -286,7 +278,8 @@
ProcessKDP::DoResume ()
{
Error error;
- error.SetErrorString ("ProcessKDP::DoResume () is not implemented yet");
+ if (!m_comm.SendRequestResume ())
+ error.SetErrorString ("KDP resume failed");
return error;
}
@@ -354,15 +347,8 @@
}
else
{
- // TODO: add the ability to halt a running kernel
- error.SetErrorString ("halt not supported in kdp-remote plug-in");
-// if (!m_comm.SendInterrupt (locker, 2, caused_stop, timed_out))
-// {
-// if (timed_out)
-// error.SetErrorString("timed out sending interrupt packet");
-// else
-// error.SetErrorString("unknown error sending interrupt packet");
-// }
+ if (!m_comm.SendRequestSuspend ())
+ error.SetErrorString ("KDP halt failed");
}
return error;
}
@@ -574,12 +560,26 @@
Error
ProcessKDP::EnableBreakpoint (BreakpointSite *bp_site)
{
+ if (m_comm.LocalBreakpointsAreSupported ())
+ {
+ Error error;
+ if (!m_comm.SendRequestBreakpoint(true, bp_site->GetLoadAddress()))
+ error.SetErrorString ("KDP set breakpoint failed");
+ return error;
+ }
return EnableSoftwareBreakpoint (bp_site);
}
Error
ProcessKDP::DisableBreakpoint (BreakpointSite *bp_site)
{
+ if (m_comm.LocalBreakpointsAreSupported ())
+ {
+ Error error;
+ if (!m_comm.SendRequestBreakpoint(false, bp_site->GetLoadAddress()))
+ error.SetErrorString ("KDP remove breakpoint failed");
+ return error;
+ }
return DisableSoftwareBreakpoint (bp_site);
}
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h?rev=135563&r1=135562&r2=135563&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h Tue Jul 19 22:41:06 2011
@@ -265,13 +265,6 @@
lldb::StateType
SetThreadStopInfo (StringExtractor& stop_packet);
- static size_t
- AttachInputReaderCallback (void *baton,
- lldb_private::InputReader *reader,
- lldb::InputReaderAction notification,
- const char *bytes,
- size_t bytes_len);
-
private:
//------------------------------------------------------------------
// For ProcessKDP only
From johnny.chen at apple.com Wed Jul 20 13:29:32 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 18:29:32 -0000
Subject: [Lldb-commits] [lldb] r135597 -
/lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
Message-ID: <20110720182932.8E79C2A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 13:29:32 2011
New Revision: 135597
URL: http://llvm.org/viewvc/llvm-project?rev=135597&view=rev
Log:
Skip the remaining -Y? (skipping ? layers of summaries) tests if using a known version
of Apple gcc build which produces wrong namespace for std::string in debug info.
Modified:
lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py?rev=135597&r1=135596&r2=135597&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py Wed Jul 20 13:29:32 2011
@@ -129,6 +129,22 @@
'm_child2 = Level 4',
'}'])
+ # Bad debugging info on SnowLeopard gcc (Apple Inc. build 5666).
+ # Skip the following tests if the condition is met.
+ if self.getCompiler().endswith('gcc') and not self.getCompiler().endswith('llvm-gcc'):
+ import re, lldbutil
+ gcc_version_output = system([lldbutil.which(self.getCompiler()), "-v"])[1]
+ #print "my output:", gcc_version_output
+ for line in gcc_version_output.split(os.linesep):
+ m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
+ #print "line:", line
+ if m:
+ gcc_build = int(m.group(1))
+ #print "gcc build:", gcc_build
+ if gcc_build >= 5666:
+ # rdar://problem/9804600"
+ self.skipTest("rdar://problem/9804600 wrong namespace for std::string in debug info")
+
# Expand same expression, skipping 3 layers of summaries
self.expect('frame variable data1.m_child1->m_child2 -T -Y3',
substrs = ['(DeepData_3) data1.m_child1->m_child2 = {',
From johnny.chen at apple.com Wed Jul 20 14:29:08 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 19:29:08 -0000
Subject: [Lldb-commits] [lldb] r135606 - /lldb/trunk/docs/code-signing.txt
Message-ID: <20110720192908.AC2522A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 14:29:08 2011
New Revision: 135606
URL: http://llvm.org/viewvc/llvm-project?rev=135606&view=rev
Log:
Minor modification.
Modified:
lldb/trunk/docs/code-signing.txt
Modified: lldb/trunk/docs/code-signing.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/code-signing.txt?rev=135606&r1=135605&r2=135606&view=diff
==============================================================================
--- lldb/trunk/docs/code-signing.txt (original)
+++ lldb/trunk/docs/code-signing.txt Wed Jul 20 14:29:08 2011
@@ -18,7 +18,7 @@
Identity Type = Self Signed Root
Certificate Type = Code Signing
-- Click Continue
+- Click Create
- Click Continue
- Click Done
- Click on the "My Certificates"
From johnny.chen at apple.com Wed Jul 20 15:28:36 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 20:28:36 -0000
Subject: [Lldb-commits] [lldb] r135615 - /lldb/trunk/docs/code-signing.txt
Message-ID: <20110720202836.5BACE2A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 15:28:36 2011
New Revision: 135615
URL: http://llvm.org/viewvc/llvm-project?rev=135615&view=rev
Log:
Add a note.
Modified:
lldb/trunk/docs/code-signing.txt
Modified: lldb/trunk/docs/code-signing.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/code-signing.txt?rev=135615&r1=135614&r2=135615&view=diff
==============================================================================
--- lldb/trunk/docs/code-signing.txt (original)
+++ lldb/trunk/docs/code-signing.txt Wed Jul 20 15:28:36 2011
@@ -32,6 +32,7 @@
The next steps are necessary on SnowLeopard, but are probably because of a bug
how Keychain Access makes certificates.
+[Note: These also apply for Lion.]
- 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
From johnny.chen at apple.com Wed Jul 20 17:29:58 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 22:29:58 -0000
Subject: [Lldb-commits] [lldb] r135630 -
/lldb/trunk/scripts/Python/interface/SBBroadcaster.i
Message-ID: <20110720222958.67F572A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 17:29:58 2011
New Revision: 135630
URL: http://llvm.org/viewvc/llvm-project?rev=135630&view=rev
Log:
Add docstring for SBBroadcaster class.
Modified:
lldb/trunk/scripts/Python/interface/SBBroadcaster.i
Modified: lldb/trunk/scripts/Python/interface/SBBroadcaster.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBroadcaster.i?rev=135630&r1=135629&r2=135630&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBBroadcaster.i (original)
+++ lldb/trunk/scripts/Python/interface/SBBroadcaster.i Wed Jul 20 17:29:58 2011
@@ -9,6 +9,17 @@
namespace lldb {
+%feature("docstring",
+"Represents an entity which can broadcast events. A default broadcaster is
+associated with an SBCommandInterpreter, SBProcess, and SBTarget. For
+example, use
+
+ broadcaster = process.GetBroadcaster()
+
+to retrieve the process's broadcaster.
+
+See also SBEvent for example usage of interacting with a broadcaster."
+) SBBroadcaster;
class SBBroadcaster
{
public:
From johnny.chen at apple.com Wed Jul 20 17:50:58 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Wed, 20 Jul 2011 22:50:58 -0000
Subject: [Lldb-commits] [lldb] r135631 -
/lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
Message-ID: <20110720225058.65EE72A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 17:50:58 2011
New Revision: 135631
URL: http://llvm.org/viewvc/llvm-project?rev=135631&view=rev
Log:
Add docstring for SBCommandInterpreter class.
Modified:
lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
Modified: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i?rev=135631&r1=135630&r2=135631&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i (original)
+++ lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i Wed Jul 20 17:50:58 2011
@@ -9,6 +9,50 @@
namespace lldb {
+%feature("docstring",
+"SBCommandInterpreter handles/interprets commands for lldb. You get the
+command interpreter from the SBDebugger instance. For example (from test/
+python_api/interpreter/TestCommandInterpreterAPI.py),
+
+ def command_interpreter_api(self):
+ '''Test the SBCommandInterpreter APIs.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Retrieve the associated command interpreter from our debugger.
+ ci = self.dbg.GetCommandInterpreter()
+ self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
+
+ # Exercise some APIs....
+
+ self.assertTrue(ci.HasCommands())
+ self.assertTrue(ci.HasAliases())
+ self.assertTrue(ci.HasAliasOptions())
+ self.assertTrue(ci.CommandExists('breakpoint'))
+ self.assertTrue(ci.CommandExists('target'))
+ self.assertTrue(ci.CommandExists('platform'))
+ self.assertTrue(ci.AliasExists('file'))
+ self.assertTrue(ci.AliasExists('run'))
+ self.assertTrue(ci.AliasExists('bt'))
+
+ res = lldb.SBCommandReturnObject()
+ ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
+ self.assertTrue(res.Succeeded())
+ ci.HandleCommand('process launch', res)
+ self.assertTrue(res.Succeeded())
+
+ process = ci.GetProcess()
+ self.assertTrue(process)
+
+ ...
+
+The HandleCommand() instance method takes two args: the command string and
+an SBCommandReturnObject instance which encapsulates the result of command
+execution.
+") SBCommandInterpreter;
class SBCommandInterpreter
{
public:
From johnny.chen at apple.com Wed Jul 20 19:32:12 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Thu, 21 Jul 2011 00:32:12 -0000
Subject: [Lldb-commits] [lldb] r135642 -
/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
Message-ID: <20110721003212.54A0E2A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 19:32:12 2011
New Revision: 135642
URL: http://llvm.org/viewvc/llvm-project?rev=135642&view=rev
Log:
Add docstring for SBCommandReturnObject class.
Modified:
lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
Modified: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i?rev=135642&r1=135641&r2=135642&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i (original)
+++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i Wed Jul 20 19:32:12 2011
@@ -9,6 +9,13 @@
namespace lldb {
+%feature("docstring",
+"Represents a container which holds the result from command execution.
+It works with SBCommandInterpreter.HandleCommand() to encapsulate the result
+of command execution.
+
+See SBCommandInterpreter for example usage of SBCommandReturnObject."
+) SBCommandReturnObject;
class SBCommandReturnObject
{
public:
From johnny.chen at apple.com Wed Jul 20 19:48:02 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Thu, 21 Jul 2011 00:48:02 -0000
Subject: [Lldb-commits] [lldb] r135647 -
/lldb/trunk/scripts/Python/interface/SBInstructionList.i
Message-ID: <20110721004802.C3AA22A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 19:48:02 2011
New Revision: 135647
URL: http://llvm.org/viewvc/llvm-project?rev=135647&view=rev
Log:
Add docstring for SBInstructionList class.
Modified:
lldb/trunk/scripts/Python/interface/SBInstructionList.i
Modified: lldb/trunk/scripts/Python/interface/SBInstructionList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstructionList.i?rev=135647&r1=135646&r2=135647&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInstructionList.i (original)
+++ lldb/trunk/scripts/Python/interface/SBInstructionList.i Wed Jul 20 19:48:02 2011
@@ -11,6 +11,20 @@
namespace lldb {
+%feature("docstring",
+"Represents a list of machine instructions. SBFunction and SBSymbol have
+GetInstructions() methods which return SBInstructionList instances.
+
+SBInstructionList supports instruction (SBInstruction instance) iteration.
+For example (see also SBDebugger for a more complete example),
+
+def disassemble_instructions (insts):
+ for i in insts:
+ print i
+
+defines a method which takes an SBInstructionList instance and prints out
+the machine instructions in assembly format."
+) SBInstructionList;
class SBInstructionList
{
public:
From johnny.chen at apple.com Wed Jul 20 19:50:55 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Thu, 21 Jul 2011 00:50:55 -0000
Subject: [Lldb-commits] [lldb] r135648 -
/lldb/trunk/scripts/Python/interface/SBInstructionList.i
Message-ID: <20110721005055.28D812A6C12D@llvm.org>
Author: johnny
Date: Wed Jul 20 19:50:54 2011
New Revision: 135648
URL: http://llvm.org/viewvc/llvm-project?rev=135648&view=rev
Log:
Change docstring wording: from 'method' to 'function'.
Modified:
lldb/trunk/scripts/Python/interface/SBInstructionList.i
Modified: lldb/trunk/scripts/Python/interface/SBInstructionList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstructionList.i?rev=135648&r1=135647&r2=135648&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInstructionList.i (original)
+++ lldb/trunk/scripts/Python/interface/SBInstructionList.i Wed Jul 20 19:50:54 2011
@@ -22,7 +22,7 @@
for i in insts:
print i
-defines a method which takes an SBInstructionList instance and prints out
+defines a function which takes an SBInstructionList instance and prints out
the machine instructions in assembly format."
) SBInstructionList;
class SBInstructionList
From gclayton at apple.com Wed Jul 20 20:12:01 2011
From: gclayton at apple.com (Greg Clayton)
Date: Thu, 21 Jul 2011 01:12:01 -0000
Subject: [Lldb-commits] [lldb] r135652 - in /lldb/trunk/source/Plugins:
DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
Process/MacOSX-Kernel/CommunicationKDP.cpp
Process/MacOSX-Kernel/CommunicationKDP.h
Process/MacOSX-Kernel/ProcessKDP.cpp
Message-ID: <20110721011201.B0DC12A6C12D@llvm.org>
Author: gclayton
Date: Wed Jul 20 20:12:01 2011
New Revision: 135652
URL: http://llvm.org/viewvc/llvm-project?rev=135652&view=rev
Log:
More KDP fixes and logging cleanup.
Modified:
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp?rev=135652&r1=135651&r2=135652&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp Wed Jul 20 20:12:01 2011
@@ -525,6 +525,14 @@
ParseLoadCommands (data, kext_summaries[i]);
}
+ if (s)
+ {
+ if (kext_summaries[i].module_sp)
+ s->Printf(" found kext: %s/%s\n",
+ kext_summaries[i].module_sp->GetFileSpec().GetDirectory().AsCString(),
+ kext_summaries[i].module_sp->GetFileSpec().GetFilename().AsCString());
+ }
+
if (log)
kext_summaries[i].PutToLog (log.get());
}
@@ -599,6 +607,11 @@
const size_t count = image_infos.size() * m_kext_summary_header.entry_size;
DataBufferHeap data(count, 0);
Error error;
+
+ Stream *s = &m_process->GetTarget().GetDebugger().GetOutputStream();
+
+ if (s)
+ s->Printf ("Reading %u kext summaries...\n", image_infos_count);
const bool prefer_file_cache = false;
const size_t bytes_read = m_process->GetTarget().ReadMemory (kext_summary_addr,
prefer_file_cache,
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=135652&r1=135651&r2=135652&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Wed Jul 20 20:12:01 2011
@@ -44,7 +44,6 @@
m_byte_order (eByteOrderLittle),
m_packet_timeout (1),
m_sequence_mutex (Mutex::eMutexTypeRecursive),
- m_public_is_running (false),
m_private_is_running (false),
m_session_key (0u),
m_request_sequence_id (0u),
@@ -259,31 +258,31 @@
uint8_t reply_command = packet.GetU8(&offset);
switch (reply_command)
{
- case ePacketTypeReply | eCommandTypeConnect:
- case ePacketTypeReply | eCommandTypeDisconnect:
- case ePacketTypeReply | eCommandTypeHostInfo:
- case ePacketTypeReply | eCommandTypeVersion:
- case ePacketTypeReply | eCommandTypeMaxBytes:
- case ePacketTypeReply | eCommandTypeReadMemory:
- case ePacketTypeReply | eCommandTypeWriteMemory:
- case ePacketTypeReply | eCommandTypeReadRegisters:
- case ePacketTypeReply | eCommandTypeWriteRegisters:
- case ePacketTypeReply | eCommandTypeLoad:
- case ePacketTypeReply | eCommandTypeImagePath:
- case ePacketTypeReply | eCommandTypeSuspend:
- case ePacketTypeReply | eCommandTypeResume:
- case ePacketTypeReply | eCommandTypeException:
- case ePacketTypeReply | eCommandTypeTermination:
- case ePacketTypeReply | eCommandTypeBreakpointSet:
- case ePacketTypeReply | eCommandTypeBreakpointRemove:
- case ePacketTypeReply | eCommandTypeRegions:
- case ePacketTypeReply | eCommandTypeReattach:
- case ePacketTypeReply | eCommandTypeHostReboot:
- case ePacketTypeReply | eCommandTypeReadMemory64:
- case ePacketTypeReply | eCommandTypeWriteMemory64:
- case ePacketTypeReply | eCommandTypeBreakpointSet64:
- case ePacketTypeReply | eCommandTypeBreakpointRemove64:
- case ePacketTypeReply | eCommandTypeKernelVersion:
+ case ePacketTypeReply | KDP_CONNECT:
+ case ePacketTypeReply | KDP_DISCONNECT:
+ case ePacketTypeReply | KDP_HOSTINFO:
+ case ePacketTypeReply | KDP_VERSION:
+ case ePacketTypeReply | KDP_MAXBYTES:
+ case ePacketTypeReply | KDP_READMEM:
+ case ePacketTypeReply | KDP_WRITEMEM:
+ case ePacketTypeReply | KDP_READREGS:
+ case ePacketTypeReply | KDP_WRITEREGS:
+ case ePacketTypeReply | KDP_LOAD:
+ case ePacketTypeReply | KDP_IMAGEPATH:
+ case ePacketTypeReply | KDP_SUSPEND:
+ case ePacketTypeReply | KDP_RESUMECPUS:
+ case ePacketTypeReply | KDP_EXCEPTION:
+ case ePacketTypeReply | KDP_TERMINATION:
+ case ePacketTypeReply | KDP_BREAKPOINT_SET:
+ case ePacketTypeReply | KDP_BREAKPOINT_REMOVE:
+ case ePacketTypeReply | KDP_REGIONS:
+ case ePacketTypeReply | KDP_REATTACH:
+ case ePacketTypeReply | KDP_HOSTREBOOT:
+ case ePacketTypeReply | KDP_READMEM64:
+ case ePacketTypeReply | KDP_WRITEMEM64:
+ case ePacketTypeReply | KDP_BREAKPOINT_SET64:
+ case ePacketTypeReply | KDP_BREAKPOINT_REMOVE64:
+ case ePacketTypeReply | KDP_KERNELVERSION:
{
offset = 2;
const uint16_t length = packet.GetU16 (&offset);
@@ -331,7 +330,7 @@
if (greeting == NULL)
greeting = "";
- const CommandType command = eCommandTypeConnect;
+ const CommandType command = KDP_CONNECT;
// Length is 82 uint16_t and the length of the greeting C string with the terminating NULL
const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -361,7 +360,7 @@
CommunicationKDP::SendRequestReattach (uint16_t reply_port)
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeReattach;
+ const CommandType command = KDP_REATTACH;
// Length is 8 bytes for the header plus 2 bytes for the reply UDP port
const uint32_t command_length = 8 + 2;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -402,7 +401,7 @@
CommunicationKDP::SendRequestVersion ()
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeVersion;
+ const CommandType command = KDP_VERSION;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
@@ -417,6 +416,35 @@
return false;
}
+#if 0 // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
+const char *
+CommunicationKDP::GetImagePath ()
+{
+ if (m_image_path.empty())
+ SendRequestImagePath();
+ return m_image_path.c_str();
+}
+
+bool
+CommunicationKDP::SendRequestImagePath ()
+{
+ PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
+ const CommandType command = KDP_IMAGEPATH;
+ const uint32_t command_length = 8;
+ const uint32_t request_sequence_id = m_request_sequence_id;
+ MakeRequestPacketHeader (command, request_packet, command_length);
+ DataExtractor reply_packet;
+ if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ {
+ const char *path = reply_packet.PeekCStr(8);
+ if (path && path[0])
+ m_kernel_version.assign (path);
+ return true;
+ }
+ return false;
+}
+#endif
+
uint32_t
CommunicationKDP::GetCPUMask ()
{
@@ -445,7 +473,7 @@
CommunicationKDP::SendRequestHostInfo ()
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeHostInfo;
+ const CommandType command = KDP_HOSTINFO;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
@@ -481,7 +509,7 @@
CommunicationKDP::SendRequestKernelVersion ()
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeKernelVersion;
+ const CommandType command = KDP_KERNELVERSION;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
@@ -500,7 +528,7 @@
CommunicationKDP::SendRequestDisconnect ()
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeDisconnect;
+ const CommandType command = KDP_DISCONNECT;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
@@ -522,7 +550,7 @@
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
bool use_64 = (GetVersion() >= 11);
uint32_t command_addr_byte_size = use_64 ? 8 : 4;
- const CommandType command = use_64 ? eCommandTypeReadMemory64 : eCommandTypeReadMemory;
+ const CommandType command = use_64 ? KDP_READMEM64 : KDP_READMEM;
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + command_addr_byte_size + 4;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -564,7 +592,7 @@
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
bool use_64 = (GetVersion() >= 11);
uint32_t command_addr_byte_size = use_64 ? 8 : 4;
- const CommandType command = use_64 ? eCommandTypeWriteMemory64 : eCommandTypeWriteMemory;
+ const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + command_addr_byte_size + 4;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -594,31 +622,31 @@
{
switch (command)
{
- case eCommandTypeConnect: return "KDP_CONNECT";
- case eCommandTypeDisconnect: return "KDP_DISCONNECT";
- case eCommandTypeHostInfo: return "KDP_HOSTINFO";
- case eCommandTypeVersion: return "KDP_VERSION";
- case eCommandTypeMaxBytes: return "KDP_MAXBYTES";
- case eCommandTypeReadMemory: return "KDP_READMEM";
- case eCommandTypeWriteMemory: return "KDP_WRITEMEM";
- case eCommandTypeReadRegisters: return "KDP_READREGS";
- case eCommandTypeWriteRegisters: return "KDP_WRITEREGS";
- case eCommandTypeLoad: return "KDP_LOAD";
- case eCommandTypeImagePath: return "KDP_IMAGEPATH";
- case eCommandTypeSuspend: return "KDP_SUSPEND";
- case eCommandTypeResume: return "KDP_RESUMECPUS";
- case eCommandTypeException: return "KDP_EXCEPTION";
- case eCommandTypeTermination: return "KDP_TERMINATION";
- case eCommandTypeBreakpointSet: return "KDP_BREAKPOINT_SET";
- case eCommandTypeBreakpointRemove: return "KDP_BREAKPOINT_REMOVE";
- case eCommandTypeRegions: return "KDP_REGIONS";
- case eCommandTypeReattach: return "KDP_REATTACH";
- case eCommandTypeHostReboot: return "KDP_HOSTREBOOT";
- case eCommandTypeReadMemory64: return "KDP_READMEM64";
- case eCommandTypeWriteMemory64: return "KDP_WRITEMEM64";
- case eCommandTypeBreakpointSet64: return "KDP_BREAKPOINT64_SET";
- case eCommandTypeBreakpointRemove64: return "KDP_BREAKPOINT64_REMOVE";
- case eCommandTypeKernelVersion: return "KDP_KERNELVERSION";
+ case KDP_CONNECT: return "KDP_CONNECT";
+ case KDP_DISCONNECT: return "KDP_DISCONNECT";
+ case KDP_HOSTINFO: return "KDP_HOSTINFO";
+ case KDP_VERSION: return "KDP_VERSION";
+ case KDP_MAXBYTES: return "KDP_MAXBYTES";
+ case KDP_READMEM: return "KDP_READMEM";
+ case KDP_WRITEMEM: return "KDP_WRITEMEM";
+ case KDP_READREGS: return "KDP_READREGS";
+ case KDP_WRITEREGS: return "KDP_WRITEREGS";
+ case KDP_LOAD: return "KDP_LOAD";
+ case KDP_IMAGEPATH: return "KDP_IMAGEPATH";
+ case KDP_SUSPEND: return "KDP_SUSPEND";
+ case KDP_RESUMECPUS: return "KDP_RESUMECPUS";
+ case KDP_EXCEPTION: return "KDP_EXCEPTION";
+ case KDP_TERMINATION: return "KDP_TERMINATION";
+ case KDP_BREAKPOINT_SET: return "KDP_BREAKPOINT_SET";
+ case KDP_BREAKPOINT_REMOVE: return "KDP_BREAKPOINT_REMOVE";
+ case KDP_REGIONS: return "KDP_REGIONS";
+ case KDP_REATTACH: return "KDP_REATTACH";
+ case KDP_HOSTREBOOT: return "KDP_HOSTREBOOT";
+ case KDP_READMEM64: return "KDP_READMEM64";
+ case KDP_WRITEMEM64: return "KDP_WRITEMEM64";
+ case KDP_BREAKPOINT_SET64: return "KDP_BREAKPOINT64_SET";
+ case KDP_BREAKPOINT_REMOVE64: return "KDP_BREAKPOINT64_REMOVE";
+ case KDP_KERNELVERSION: return "KDP_KERNELVERSION";
}
return NULL;
}
@@ -663,33 +691,33 @@
switch (command)
{
// Commands that return a single 32 bit error
- case eCommandTypeConnect:
- case eCommandTypeWriteMemory:
- case eCommandTypeWriteMemory64:
- case eCommandTypeBreakpointSet:
- case eCommandTypeBreakpointRemove:
- case eCommandTypeBreakpointSet64:
- case eCommandTypeBreakpointRemove64:
- case eCommandTypeWriteRegisters:
- case eCommandTypeLoad:
+ case KDP_CONNECT:
+ case KDP_WRITEMEM:
+ case KDP_WRITEMEM64:
+ case KDP_BREAKPOINT_SET:
+ case KDP_BREAKPOINT_REMOVE:
+ case KDP_BREAKPOINT_SET64:
+ case KDP_BREAKPOINT_REMOVE64:
+ case KDP_WRITEREGS:
+ case KDP_LOAD:
{
const uint32_t error = packet.GetU32 (&offset);
s.Printf(" (error=0x%8.8x)", error);
}
break;
- case eCommandTypeDisconnect:
- case eCommandTypeReattach:
- case eCommandTypeHostReboot:
- case eCommandTypeSuspend:
- case eCommandTypeResume:
- case eCommandTypeException:
- case eCommandTypeTermination:
+ case KDP_DISCONNECT:
+ case KDP_REATTACH:
+ case KDP_HOSTREBOOT:
+ case KDP_SUSPEND:
+ case KDP_RESUMECPUS:
+ case KDP_EXCEPTION:
+ case KDP_TERMINATION:
// No return value for the reply, just the header to ack
s.PutCString(" ()");
break;
- case eCommandTypeHostInfo:
+ case KDP_HOSTINFO:
{
const uint32_t cpu_mask = packet.GetU32 (&offset);
const uint32_t cpu_type = packet.GetU32 (&offset);
@@ -698,7 +726,7 @@
}
break;
- case eCommandTypeVersion:
+ case KDP_VERSION:
{
const uint32_t version = packet.GetU32 (&offset);
const uint32_t feature = packet.GetU32 (&offset);
@@ -706,7 +734,7 @@
}
break;
- case eCommandTypeRegions:
+ case KDP_REGIONS:
{
const uint32_t region_count = packet.GetU32 (&offset);
s.Printf(" (count = %u", region_count);
@@ -720,8 +748,8 @@
}
break;
- case eCommandTypeReadMemory:
- case eCommandTypeReadMemory64:
+ case KDP_READMEM:
+ case KDP_READMEM64:
{
const uint32_t error = packet.GetU32 (&offset);
const uint32_t count = packet.GetByteSize() - offset;
@@ -738,7 +766,7 @@
}
break;
- case eCommandTypeReadRegisters:
+ case KDP_READREGS:
{
const uint32_t error = packet.GetU32 (&offset);
const uint32_t count = packet.GetByteSize() - offset;
@@ -755,20 +783,20 @@
}
break;
- case eCommandTypeKernelVersion:
+ case KDP_KERNELVERSION:
{
const char *kernel_version = packet.PeekCStr(8);
s.Printf(" (version = \"%s\")", kernel_version);
}
break;
- case eCommandTypeMaxBytes:
+ case KDP_MAXBYTES:
{
const uint32_t max_bytes = packet.GetU32 (&offset);
s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
}
break;
- case eCommandTypeImagePath:
+ case KDP_IMAGEPATH:
{
const char *path = packet.GetCStr(&offset);
s.Printf(" (path = \"%s\")", path);
@@ -785,7 +813,7 @@
// Dump request packets
switch (command)
{
- case eCommandTypeConnect:
+ case KDP_CONNECT:
{
const uint16_t reply_port = packet.GetU16 (&offset);
const uint16_t exc_port = packet.GetU16 (&offset);
@@ -793,27 +821,27 @@
}
break;
- case eCommandTypeDisconnect:
- case eCommandTypeHostReboot:
- case eCommandTypeHostInfo:
- case eCommandTypeVersion:
- case eCommandTypeRegions:
- case eCommandTypeKernelVersion:
- case eCommandTypeMaxBytes:
- case eCommandTypeImagePath:
- case eCommandTypeSuspend:
+ case KDP_DISCONNECT:
+ case KDP_HOSTREBOOT:
+ case KDP_HOSTINFO:
+ case KDP_VERSION:
+ case KDP_REGIONS:
+ case KDP_KERNELVERSION:
+ case KDP_MAXBYTES:
+ case KDP_IMAGEPATH:
+ case KDP_SUSPEND:
// No args, just the header in the request...
s.PutCString(" ()");
break;
- case eCommandTypeResume:
+ case KDP_RESUMECPUS:
{
const uint32_t cpu_mask = packet.GetU32 (&offset);
s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
}
break;
- case eCommandTypeReadMemory:
+ case KDP_READMEM:
{
const uint32_t addr = packet.GetU32 (&offset);
const uint32_t size = packet.GetU32 (&offset);
@@ -822,7 +850,7 @@
}
break;
- case eCommandTypeWriteMemory:
+ case KDP_WRITEMEM:
{
const uint32_t addr = packet.GetU32 (&offset);
const uint32_t size = packet.GetU32 (&offset);
@@ -832,7 +860,7 @@
}
break;
- case eCommandTypeReadMemory64:
+ case KDP_READMEM64:
{
const uint64_t addr = packet.GetU64 (&offset);
const uint32_t size = packet.GetU32 (&offset);
@@ -841,7 +869,7 @@
}
break;
- case eCommandTypeWriteMemory64:
+ case KDP_WRITEMEM64:
{
const uint64_t addr = packet.GetU64 (&offset);
const uint32_t size = packet.GetU32 (&offset);
@@ -851,7 +879,7 @@
}
break;
- case eCommandTypeReadRegisters:
+ case KDP_READREGS:
{
const uint32_t cpu = packet.GetU32 (&offset);
const uint32_t flavor = packet.GetU32 (&offset);
@@ -859,7 +887,7 @@
}
break;
- case eCommandTypeWriteRegisters:
+ case KDP_WRITEREGS:
{
const uint32_t cpu = packet.GetU32 (&offset);
const uint32_t flavor = packet.GetU32 (&offset);
@@ -878,16 +906,16 @@
break;
- case eCommandTypeBreakpointSet:
- case eCommandTypeBreakpointRemove:
+ case KDP_BREAKPOINT_SET:
+ case KDP_BREAKPOINT_REMOVE:
{
const uint32_t addr = packet.GetU32 (&offset);
s.Printf(" (addr = 0x%8.8x)", addr);
}
break;
- case eCommandTypeBreakpointSet64:
- case eCommandTypeBreakpointRemove64:
+ case KDP_BREAKPOINT_SET64:
+ case KDP_BREAKPOINT_REMOVE64:
{
const uint64_t addr = packet.GetU64 (&offset);
s.Printf(" (addr = 0x%16.16llx)", addr);
@@ -895,14 +923,14 @@
break;
- case eCommandTypeLoad:
+ case KDP_LOAD:
{
const char *path = packet.GetCStr(&offset);
s.Printf(" (path = \"%s\")", path);
}
break;
- case eCommandTypeException:
+ case KDP_EXCEPTION:
{
const uint32_t count = packet.GetU32 (&offset);
@@ -936,7 +964,7 @@
}
break;
- case eCommandTypeTermination:
+ case KDP_TERMINATION:
{
const uint32_t term_code = packet.GetU32 (&offset);
const uint32_t exit_code = packet.GetU32 (&offset);
@@ -944,7 +972,7 @@
}
break;
- case eCommandTypeReattach:
+ case KDP_REATTACH:
{
const uint16_t reply_port = packet.GetU16 (&offset);
s.Printf(" (reply_port=%u)", reply_port);
@@ -982,7 +1010,7 @@
Error &error)
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeReadRegisters;
+ const CommandType command = KDP_READREGS;
// Size is header + 4 byte cpu and 4 byte flavor
const uint32_t command_length = 8 + 4 + 4;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -1024,7 +1052,7 @@
if (cpu_mask == 0)
cpu_mask = GetCPUMask();
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeResume;
+ const CommandType command = KDP_RESUMECPUS;
const uint32_t command_length = 12;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
@@ -1042,8 +1070,8 @@
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
bool use_64 = (GetVersion() >= 11);
uint32_t command_addr_byte_size = use_64 ? 8 : 4;
- const CommandType command = set ? (use_64 ? eCommandTypeBreakpointSet64 : eCommandTypeBreakpointSet ):
- (use_64 ? eCommandTypeBreakpointRemove64 : eCommandTypeBreakpointRemove);
+ const CommandType command = set ? (use_64 ? KDP_BREAKPOINT_SET64 : KDP_BREAKPOINT_SET ):
+ (use_64 ? KDP_BREAKPOINT_REMOVE64 : KDP_BREAKPOINT_REMOVE);
const uint32_t command_length = 8 + command_addr_byte_size;
const uint32_t request_sequence_id = m_request_sequence_id;
@@ -1060,7 +1088,7 @@
CommunicationKDP::SendRequestSuspend ()
{
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
- const CommandType command = eCommandTypeSuspend;
+ const CommandType command = KDP_SUSPEND;
const uint32_t command_length = 8;
const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=135652&r1=135651&r2=135652&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Wed Jul 20 20:12:01 2011
@@ -38,36 +38,36 @@
typedef lldb_private::StreamBuffer<1024> PacketStreamType;
typedef enum
{
- eCommandTypeConnect = 0u,
- eCommandTypeDisconnect,
- eCommandTypeHostInfo,
- eCommandTypeVersion,
- eCommandTypeMaxBytes,
- eCommandTypeReadMemory,
- eCommandTypeWriteMemory,
- eCommandTypeReadRegisters,
- eCommandTypeWriteRegisters,
- eCommandTypeLoad,
- eCommandTypeImagePath,
- eCommandTypeSuspend,
- eCommandTypeResume,
- eCommandTypeException,
- eCommandTypeTermination,
- eCommandTypeBreakpointSet,
- eCommandTypeBreakpointRemove,
- eCommandTypeRegions,
- eCommandTypeReattach,
- eCommandTypeHostReboot,
- eCommandTypeReadMemory64,
- eCommandTypeWriteMemory64,
- eCommandTypeBreakpointSet64,
- eCommandTypeBreakpointRemove64,
- eCommandTypeKernelVersion
+ KDP_CONNECT = 0u,
+ KDP_DISCONNECT,
+ KDP_HOSTINFO,
+ KDP_VERSION,
+ KDP_MAXBYTES,
+ KDP_READMEM,
+ KDP_WRITEMEM,
+ KDP_READREGS,
+ KDP_WRITEREGS,
+ KDP_LOAD,
+ KDP_IMAGEPATH,
+ KDP_SUSPEND,
+ KDP_RESUMECPUS,
+ KDP_EXCEPTION,
+ KDP_TERMINATION,
+ KDP_BREAKPOINT_SET,
+ KDP_BREAKPOINT_REMOVE,
+ KDP_REGIONS,
+ KDP_REATTACH,
+ KDP_HOSTREBOOT,
+ KDP_READMEM64,
+ KDP_WRITEMEM64,
+ KDP_BREAKPOINT_SET64,
+ KDP_BREAKPOINT_REMOVE64,
+ KDP_KERNELVERSION,
} CommandType;
enum
{
- eFeatureLocalBreakpointsSupported = (1u << 0),
+ KDP_FEATURE_BP = (1u << 0),
};
typedef enum
@@ -181,6 +181,10 @@
const char *
GetKernelVersion ();
+ // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
+ // const char *
+ // GetImagePath ();
+
uint32_t
GetVersion ();
@@ -190,7 +194,7 @@
bool
LocalBreakpointsAreSupported ()
{
- return (GetFeatureFlags() & eFeatureLocalBreakpointsSupported) != 0;
+ return (GetFeatureFlags() & KDP_FEATURE_BP) != 0;
}
uint32_t
@@ -213,7 +217,6 @@
SendRequestBreakpoint (bool set, lldb::addr_t addr);
protected:
- typedef std::list packet_collection;
bool
SendRequestPacketNoLock (const PacketStreamType &request_packet);
@@ -243,6 +246,10 @@
bool
SendRequestKernelVersion ();
+ // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
+ //bool
+ //SendRequestImagePath ();
+
void
DumpPacket (lldb_private::Stream &s,
const void *data,
@@ -307,6 +314,7 @@
uint32_t m_kdp_hostinfo_cpu_type;
uint32_t m_kdp_hostinfo_cpu_subtype;
std::string m_kernel_version;
+ //std::string m_image_path; // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
lldb::addr_t m_last_read_memory_addr; // Last memory read address for logging
private:
//------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=135652&r1=135651&r2=135652&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Wed Jul 20 20:12:01 2011
@@ -190,12 +190,17 @@
StreamSP async_strm_sp(m_target.GetDebugger().GetAsyncOutputStream());
if (async_strm_sp)
{
- const char *kernel_version = m_comm.GetKernelVersion ();
- if (kernel_version)
+ const char *cstr;
+ if ((cstr = m_comm.GetKernelVersion ()) != NULL)
{
- async_strm_sp->Printf ("KDP connected to %s\n", kernel_version);
+ async_strm_sp->Printf ("Version: %s\n", cstr);
async_strm_sp->Flush();
}
+// if ((cstr = m_comm.GetImagePath ()) != NULL)
+// {
+// async_strm_sp->Printf ("Image Path: %s\n", cstr);
+// async_strm_sp->Flush();
+// }
}
}
}
@@ -491,8 +496,6 @@
// Interrupt if our inferior is running...
if (m_comm.IsConnected())
{
- m_comm.SendRequestDisconnect();
-
if (m_public_state.GetValue() == eStateAttaching)
{
// We are being asked to halt during an attach. We need to just close
@@ -501,6 +504,9 @@
}
else
{
+ DisableAllBreakpointSites ();
+
+ m_comm.SendRequestDisconnect();
StringExtractor response;
// TODO: Send kill packet?
@@ -563,8 +569,18 @@
if (m_comm.LocalBreakpointsAreSupported ())
{
Error error;
- if (!m_comm.SendRequestBreakpoint(true, bp_site->GetLoadAddress()))
- error.SetErrorString ("KDP set breakpoint failed");
+ if (!bp_site->IsEnabled())
+ {
+ if (m_comm.SendRequestBreakpoint(true, bp_site->GetLoadAddress()))
+ {
+ bp_site->SetEnabled(true);
+ bp_site->SetType (BreakpointSite::eExternal);
+ }
+ else
+ {
+ error.SetErrorString ("KDP set breakpoint failed");
+ }
+ }
return error;
}
return EnableSoftwareBreakpoint (bp_site);
@@ -576,8 +592,21 @@
if (m_comm.LocalBreakpointsAreSupported ())
{
Error error;
- if (!m_comm.SendRequestBreakpoint(false, bp_site->GetLoadAddress()))
- error.SetErrorString ("KDP remove breakpoint failed");
+ if (bp_site->IsEnabled())
+ {
+ BreakpointSite::Type bp_type = bp_site->GetType();
+ if (bp_type == BreakpointSite::eExternal)
+ {
+ if (m_comm.SendRequestBreakpoint(false, bp_site->GetLoadAddress()))
+ bp_site->SetEnabled(false);
+ else
+ error.SetErrorString ("KDP remove breakpoint failed");
+ }
+ else
+ {
+ error = DisableSoftwareBreakpoint (bp_site);
+ }
+ }
return error;
}
return DisableSoftwareBreakpoint (bp_site);
From granata.enrico at gmail.com Wed Jul 20 20:40:18 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Thu, 21 Jul 2011 01:40:18 -0000
Subject: [Lldb-commits] [lldb] r135653 - in /lldb/trunk/examples/summaries:
./ essentials lldb
Message-ID: <20110721014018.2DB792A6C12D@llvm.org>
Author: enrico
Date: Wed Jul 20 20:40:17 2011
New Revision: 135653
URL: http://llvm.org/viewvc/llvm-project?rev=135653&view=rev
Log:
essentials contains two small summaries that you might really want to use; lldb contains some basic summaries for use in debugging LLDB itself. to use them, you must type category enable lldb
Added:
lldb/trunk/examples/summaries/
lldb/trunk/examples/summaries/essentials
lldb/trunk/examples/summaries/lldb
Added: lldb/trunk/examples/summaries/essentials
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/essentials?rev=135653&view=auto
==============================================================================
--- lldb/trunk/examples/summaries/essentials (added)
+++ lldb/trunk/examples/summaries/essentials Wed Jul 20 20:40:17 2011
@@ -0,0 +1,2 @@
+type summary add -f "${var._M_dataplus._M_p}" std::string
+type summary add -f "\"${var%@}\"" "NSString *"
Added: lldb/trunk/examples/summaries/lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/lldb?rev=135653&view=auto
==============================================================================
--- lldb/trunk/examples/summaries/lldb (added)
+++ lldb/trunk/examples/summaries/lldb Wed Jul 20 20:40:17 2011
@@ -0,0 +1,12 @@
+type summary add -f "Type: ${var.m_type%E}, Code: ${var.m_code}, Message: ${var.m_string}" lldb_private::Error -w lldb
+type summary add -f "${var.m_string}" lldb_private::ConstString -w lldb
+type summary add -f "${var.m_language%E}" lldb_private::Language -w lldb
+type summary add -f "${var.m_re}" lldb_private::RegularExpression -w lldb
+type summary add -f "UserID(${var.m_uid})" lldb_private::UserID -w lldb
+type summary add -f "${var.m_name}" lldb_private::ValueObject -w lldb
+type summary add -f "${var.ptr_.m_name}" lldb_private::ValueObjectSP -w lldb
+type summary add -f "${var.m_reg_info.name}" lldb_private::ValueObjectRegister -w lldb
+type summary add -f "{${var.m_expr_text}}" lldb_private::ClangExpression -w lldb
+type summary add -f "Command name: ${var.m_cmd_name}" lldb_private::CommandObject -w lldb
+type summary add -f "${var.m_type.m_name} ${var.m_name}" lldb_private::Variable -w lldb
+type summary add -f "ID: ${var.m_stop_id}, ${var.m_description}" lldb_private::StopInfo -w lldb
From jingham at apple.com Wed Jul 20 20:54:41 2011
From: jingham at apple.com (Jim Ingham)
Date: Thu, 21 Jul 2011 01:54:41 -0000
Subject: [Lldb-commits] [lldb] r135655 - in
/lldb/trunk/tools/debugserver/source/MacOSX: MachThread.cpp MachThread.h
MachThreadList.cpp
Message-ID: <20110721015441.A4F0C2A6C12D@llvm.org>
Author: jingham
Date: Wed Jul 20 20:54:41 2011
New Revision: 135655
URL: http://llvm.org/viewvc/llvm-project?rev=135655&view=rev
Log:
If we are telling only one thread to run in debugserver, and that thread has been suspended from outside
the debugger, resume it before running so we will actually make progress.
Modified:
lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp
lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h
lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=135655&r1=135654&r2=135655&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Wed Jul 20 20:54:41 2011
@@ -48,7 +48,7 @@
-uint32_t
+void
MachThread::Suspend()
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
@@ -60,27 +60,69 @@
if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
err.LogThreaded("::thread_suspend (%4.4x)", m_tid);
}
- return SuspendCount();
}
-uint32_t
-MachThread::Resume()
+void
+MachThread::Resume(bool others_stopped)
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
if (ThreadIDIsValid(m_tid))
{
- RestoreSuspendCount();
+ SetSuspendCountBeforeResume(others_stopped);
}
- return SuspendCount();
}
bool
-MachThread::RestoreSuspendCount()
+MachThread::SetSuspendCountBeforeResume(bool others_stopped)
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
DNBError err;
if (ThreadIDIsValid(m_tid) == false)
return false;
+
+ size_t times_to_resume;
+
+ if (others_stopped)
+ {
+ times_to_resume = GetBasicInfo()->suspend_count;
+ m_suspendCount = - (times_to_resume - m_suspendCount);
+ }
+ else
+ {
+ times_to_resume = m_suspendCount;
+ m_suspendCount = 0;
+ }
+
+ if (times_to_resume > 0)
+ {
+ while (times_to_resume > 0)
+ {
+ err = ::thread_resume (m_tid);
+ if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
+ err.LogThreaded("::thread_resume (%4.4x)", m_tid);
+ if (err.Success())
+ --times_to_resume;
+ else
+ {
+ if (GetBasicInfo())
+ times_to_resume = m_basicInfo.suspend_count;
+ else
+ times_to_resume = 0;
+ return false; // ???
+ }
+ }
+ }
+ return true;
+}
+
+bool
+MachThread::RestoreSuspendCountAfterStop ()
+{
+ DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
+ DNBError err;
+ if (ThreadIDIsValid(m_tid) == false)
+ return false;
+
if (m_suspendCount > 0)
{
while (m_suspendCount > 0)
@@ -100,20 +142,17 @@
}
}
}
- // We don't currently really support resuming a thread that was externally
- // suspended. If/when we do, we will need to make the code below work and
- // m_suspendCount will need to become signed instead of unsigned.
-// else if (m_suspendCount < 0)
-// {
-// while (m_suspendCount < 0)
-// {
-// err = ::thread_suspend (m_tid);
-// if (err.Success())
-// ++m_suspendCount;
-// if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
-// err.LogThreaded("::thread_suspend (%4.4x)", m_tid);
-// }
-// }
+ else if (m_suspendCount < 0)
+ {
+ while (m_suspendCount < 0)
+ {
+ err = ::thread_suspend (m_tid);
+ if (err.Success())
+ ++m_suspendCount;
+ if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
+ err.LogThreaded("::thread_suspend (%4.4x)", m_tid);
+ }
+ }
return true;
}
@@ -317,7 +356,7 @@
}
void
-MachThread::ThreadWillResume(const DNBThreadResumeAction *thread_action)
+MachThread::ThreadWillResume(const DNBThreadResumeAction *thread_action, bool others_stopped)
{
if (thread_action->addr != INVALID_NUB_ADDRESS)
SetPC (thread_action->addr);
@@ -327,12 +366,13 @@
{
case eStateStopped:
case eStateSuspended:
+ assert (others_stopped == false);
Suspend();
break;
case eStateRunning:
case eStateStepping:
- Resume();
+ Resume(others_stopped);
break;
default:
break;
@@ -437,7 +477,7 @@
// We may have suspended this thread so the primary thread could step
// without worrying about race conditions, so lets restore our suspend
// count.
- RestoreSuspendCount();
+ RestoreSuspendCountAfterStop();
// Update the basic information for a thread
MachThread::GetBasicInfo(m_tid, &m_basicInfo);
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h?rev=135655&r1=135654&r2=135655&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h Wed Jul 20 20:54:41 2011
@@ -49,10 +49,10 @@
uint32_t SequenceID() const { return m_seq_id; }
static bool ThreadIDIsValid(thread_t thread);
- uint32_t Resume();
- uint32_t Suspend();
- uint32_t SuspendCount() const { return m_suspendCount; }
- bool RestoreSuspendCount();
+ void Resume(bool others_stopped);
+ void Suspend();
+ bool SetSuspendCountBeforeResume(bool others_stopped);
+ bool RestoreSuspendCountAfterStop();
bool GetRegisterState(int flavor, bool force);
bool SetRegisterState(int flavor);
@@ -69,7 +69,7 @@
nub_state_t GetState();
void SetState(nub_state_t state);
- void ThreadWillResume (const DNBThreadResumeAction *thread_action);
+ void ThreadWillResume (const DNBThreadResumeAction *thread_action, bool others_stopped = false);
bool ShouldStop(bool &step_more);
bool IsStepping();
bool ThreadDidStop();
@@ -119,7 +119,8 @@
PThreadMutex m_state_mutex; // Multithreaded protection for m_state
nub_break_t m_breakID; // Breakpoint that this thread is (stopped)/was(running) at (NULL for none)
struct thread_basic_info m_basicInfo; // Basic information for a thread used to see if a thread is valid
- uint32_t m_suspendCount; // The current suspend count
+ int32_t m_suspendCount; // The current suspend count > 0 means we have suspended m_suspendCount times,
+ // < 0 means we have resumed it m_suspendCount times.
MachException::Data m_stop_exception; // The best exception that describes why this thread is stopped
std::auto_ptr m_arch_ap; // Arch specific information for register state and more
const DNBRegisterSetInfo *const m_reg_sets; // Register set information for this thread
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=135655&r1=135654&r2=135655&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Wed Jul 20 20:54:41 2011
@@ -321,10 +321,34 @@
// Update our thread list, because sometimes libdispatch or the kernel
// will spawn threads while a task is suspended.
MachThreadList::collection new_threads;
+
+ // First figure out if we were planning on running only one thread, and if so force that thread to resume.
+ bool run_one_thread;
+ nub_thread_t solo_thread = INVALID_NUB_THREAD;
+ if (thread_actions.GetSize() > 0
+ && thread_actions.NumActionsWithState(eStateStepping) + thread_actions.NumActionsWithState (eStateRunning) == 1)
+ {
+ run_one_thread = true;
+ const DNBThreadResumeAction *action_ptr = thread_actions.GetFirst();
+ size_t num_actions = thread_actions.GetSize();
+ for (size_t i = 0; i < num_actions; i++, action_ptr++)
+ {
+ if (action_ptr->state == eStateStepping || action_ptr->state == eStateRunning)
+ {
+ solo_thread = action_ptr->tid;
+ break;
+ }
+ }
+ }
+ else
+ run_one_thread = false;
UpdateThreadList(process, true, &new_threads);
DNBThreadResumeAction resume_new_threads = { -1, eStateRunning, 0, INVALID_NUB_ADDRESS };
+ // If we are planning to run only one thread, any new threads should be suspended.
+ if (run_one_thread)
+ resume_new_threads.state = eStateSuspended;
const uint32_t num_new_threads = new_threads.size();
const uint32_t num_threads = m_threads.size();
@@ -347,7 +371,10 @@
const DNBThreadResumeAction *thread_action = thread_actions.GetActionForThread (thread->ThreadID(), true);
// There must always be a thread action for every thread.
assert (thread_action);
- thread->ThreadWillResume (thread_action);
+ bool others_stopped = false;
+ if (solo_thread == thread->ThreadID())
+ others_stopped = true;
+ thread->ThreadWillResume (thread_action, others_stopped);
}
}
From johnny.chen at apple.com Thu Jul 21 14:00:59 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Thu, 21 Jul 2011 19:00:59 -0000
Subject: [Lldb-commits] [lldb] r135695 -
/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
Message-ID: <20110721190059.9DC622A6C12D@llvm.org>
Author: johnny
Date: Thu Jul 21 14:00:59 2011
New Revision: 135695
URL: http://llvm.org/viewvc/llvm-project?rev=135695&view=rev
Log:
Initialize the all important automatic variable 'lldb::ConnectionStatus status' before
invoking the Read(...) method to read in bytes. Similar to r135461.
Modified:
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=135695&r1=135694&r2=135695&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Thu Jul 21 14:00:59 2011
@@ -187,7 +187,7 @@
bool timed_out = false;
while (IsConnected() && !timed_out)
{
- lldb::ConnectionStatus status;
+ lldb::ConnectionStatus status = eConnectionStatusNoConnection;
size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error);
if (log)
From johnny.chen at apple.com Thu Jul 21 14:31:59 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Thu, 21 Jul 2011 19:31:59 -0000
Subject: [Lldb-commits] [lldb] r135699 -
/lldb/trunk/test/python_api/value/TestValueAPI.py
Message-ID: <20110721193159.E87112A6C12D@llvm.org>
Author: johnny
Date: Thu Jul 21 14:31:59 2011
New Revision: 135699
URL: http://llvm.org/viewvc/llvm-project?rev=135699&view=rev
Log:
Add test scenario for exercising SBValue API: TypeIsPointerType() and GetByteSize().
Modified:
lldb/trunk/test/python_api/value/TestValueAPI.py
Modified: lldb/trunk/test/python_api/value/TestValueAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/TestValueAPI.py?rev=135699&r1=135698&r2=135699&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/TestValueAPI.py (original)
+++ lldb/trunk/test/python_api/value/TestValueAPI.py Thu Jul 21 14:31:59 2011
@@ -64,6 +64,16 @@
self.assertTrue(value, VALID_VARIABLE)
self.DebugSBValue(value)
+ # SBValue::TypeIsPointerType() should return true.
+ self.assertTrue(value.TypeIsPointerType())
+
+ # Verify the SBValue::GetByteSize() API is working correctly.
+ arch = self.getArchitecture()
+ if arch == 'i386':
+ self.assertTrue(value.GetByteSize() == 4)
+ elif arch == 'x86_64':
+ self.assertTrue(value.GetByteSize() == 8)
+
# Get child at index 5 => 'Friday'.
child = value.GetChildAtIndex(5, lldb.eNoDynamicValues, True)
self.assertTrue(child, VALID_VARIABLE)
From johnny.chen at apple.com Thu Jul 21 18:02:00 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Thu, 21 Jul 2011 23:02:00 -0000
Subject: [Lldb-commits] [lldb] r135716 -
/lldb/trunk/test/python_api/value/TestValueAPI.py
Message-ID: <20110721230200.906CF2A6C12D@llvm.org>
Author: johnny
Date: Thu Jul 21 18:02:00 2011
New Revision: 135716
URL: http://llvm.org/viewvc/llvm-project?rev=135716&view=rev
Log:
Add test scenario of SBValue APIs for the 'days_of_week' global variable.
Modified:
lldb/trunk/test/python_api/value/TestValueAPI.py
Modified: lldb/trunk/test/python_api/value/TestValueAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/TestValueAPI.py?rev=135716&r1=135715&r2=135716&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/TestValueAPI.py (original)
+++ lldb/trunk/test/python_api/value/TestValueAPI.py Thu Jul 21 18:02:00 2011
@@ -59,6 +59,13 @@
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0)
+ # Get global variable 'days_of_week'.
+ list = target.FindGlobalVariables('days_of_week', 1)
+ days_of_week = list.GetValueAtIndex(0)
+ self.assertTrue(days_of_week, VALID_VARIABLE)
+ self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE)
+ self.DebugSBValue(days_of_week)
+
# Get variable 'str_ptr'.
value = frame0.FindVariable('str_ptr')
self.assertTrue(value, VALID_VARIABLE)
From granata.enrico at gmail.com Thu Jul 21 19:16:09 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Fri, 22 Jul 2011 00:16:09 -0000
Subject: [Lldb-commits] [lldb] r135731 - in /lldb/trunk: include/lldb/
include/lldb/Core/ include/lldb/Interpreter/ lldb.xcodeproj/ source/API/
source/Commands/ source/Core/ source/Interpreter/
test/functionalities/data-formatter/data-formatter-categories/
test/functionalities/data-formatter/data-formatter-cpp/
test/functionalities/data-formatter/data-formatter-synth/ www/
Message-ID: <20110722001609.9FEB22A6C12D@llvm.org>
Author: enrico
Date: Thu Jul 21 19:16:08 2011
New Revision: 135731
URL: http://llvm.org/viewvc/llvm-project?rev=135731&view=rev
Log:
when typing a summary string you can use the %S symbol to explicitly indicate that you want the summary to be used to print the target object
(e.g. ${var%S}). this might already be the default if your variable is of an aggregate type
new feature: synthetic filters. you can restrict the number of children for your variables to only a meaningful subset
- the restricted list of children obeys the typical rules (e.g. summaries prevail over children)
- one-line summaries show only the filtered (synthetic) children, if you type an expanded summary string, or you use Python scripts, all the real children are accessible
- to provide a synthetic children list use the "type synth add" command, as in:
type synth add foo_type --child varA --child varB[0] --child varC->packet->flags[1-4]
(you can use ., ->, single-item array operator [N] and bitfield operator [N-M]; array slice access is not supported, giving simplified names to expression paths is not supported)
- a new -S option to frame variable and target variable lets you override synthetic children and instead show real ones
Added:
lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/
lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/main.cpp
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/FormatClasses.h
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/include/lldb/lldb-forward-rtti.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/FormatClasses.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/main.cpp
lldb/trunk/www/varformats.html
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Jul 21 19:16:08 2011
@@ -505,6 +505,9 @@
static bool
GetSummaryFormat(ValueObject& vobj,
lldb::SummaryFormatSP& entry);
+ static bool
+ GetSyntheticFilter(ValueObject& vobj,
+ lldb::SyntheticFilterSP& entry);
class NamedSummaryFormats
{
Modified: lldb/trunk/include/lldb/Core/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/Core/FormatClasses.h Thu Jul 21 19:16:08 2011
@@ -17,6 +17,7 @@
// C++ Includes
#include
+#include
// Other libraries and framework includes
@@ -55,23 +56,23 @@
}
bool
- Cascades()
+ Cascades() const
{
return m_cascades;
}
bool
- SkipsPointers()
+ SkipsPointers() const
{
return m_skip_pointers;
}
bool
- SkipsReferences()
+ SkipsReferences() const
{
return m_skip_references;
}
lldb::Format
- GetFormat()
+ GetFormat() const
{
return m_format;
}
@@ -80,6 +81,57 @@
FormatObject(lldb::ValueObjectSP object);
};
+
+struct SyntheticFilter
+{
+ bool m_cascades;
+ bool m_skip_pointers;
+ bool m_skip_references;
+ std::vector m_expression_paths;
+
+ SyntheticFilter(bool casc = false,
+ bool skipptr = false,
+ bool skipref = false) :
+ m_cascades(casc),
+ m_skip_pointers(skipptr),
+ m_skip_references(skipref),
+ m_expression_paths()
+ {
+ }
+
+ void
+ AddExpressionPath(std::string path)
+ {
+ bool need_add_dot = true;
+ if (path[0] == '.' ||
+ (path[0] == '-' && path[1] == '>') ||
+ path[0] == '[')
+ need_add_dot = false;
+ // add a '.' symbol to help forgetful users
+ if(!need_add_dot)
+ m_expression_paths.push_back(path);
+ else
+ m_expression_paths.push_back(std::string(".") + path);
+ }
+
+ int
+ GetCount() const
+ {
+ return m_expression_paths.size();
+ }
+
+ const std::string&
+ GetExpressionPathAtIndex(int i) const
+ {
+ return m_expression_paths[i];
+ }
+
+ std::string
+ GetDescription();
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+ typedef bool(*SyntheticFilterCallback)(void*, const char*, const SyntheticFilter::SharedPointer&);
+};
struct SummaryFormat
{
@@ -106,17 +158,17 @@
}
bool
- Cascades()
+ Cascades() const
{
return m_cascades;
}
bool
- SkipsPointers()
+ SkipsPointers() const
{
return m_skip_pointers;
}
bool
- SkipsReferences()
+ SkipsReferences() const
{
return m_skip_references;
}
@@ -174,7 +226,7 @@
}
std::string
- GetFormat()
+ GetFormat() const
{
return m_format;
}
@@ -213,13 +265,13 @@
}
std::string
- GetFunctionName()
+ GetFunctionName() const
{
return m_function_name;
}
std::string
- GetPythonScript()
+ GetPythonScript() const
{
return m_python_script;
}
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Jul 21 19:16:08 2011
@@ -415,12 +415,15 @@
private:
typedef FormatNavigator SummaryNavigator;
typedef FormatNavigator RegexSummaryNavigator;
+ typedef FormatNavigator FilterNavigator;
typedef SummaryNavigator::MapType SummaryMap;
typedef RegexSummaryNavigator::MapType RegexSummaryMap;
+ typedef FilterNavigator::MapType FilterMap;
SummaryNavigator::SharedPointer m_summary_nav;
RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
+ FilterNavigator::SharedPointer m_filter_nav;
bool m_enabled;
@@ -428,6 +431,8 @@
Mutex m_mutex;
+ std::string m_name;
+
void
Enable(bool value = true)
{
@@ -449,13 +454,17 @@
typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP;
+ typedef FilterNavigator::SharedPointer FilterNavigatorSP;
- FormatCategory(IFormatChangeListener* clist) :
+ FormatCategory(IFormatChangeListener* clist,
+ std::string name) :
m_summary_nav(new SummaryNavigator(clist)),
m_regex_summary_nav(new RegexSummaryNavigator(clist)),
+ m_filter_nav(new FilterNavigator(clist)),
m_enabled(false),
m_change_listener(clist),
- m_mutex(Mutex::eMutexTypeRecursive)
+ m_mutex(Mutex::eMutexTypeRecursive),
+ m_name(name)
{}
SummaryNavigatorSP
@@ -470,6 +479,12 @@
return RegexSummaryNavigatorSP(m_regex_summary_nav);
}
+ FilterNavigatorSP
+ Filter()
+ {
+ return FilterNavigatorSP(m_filter_nav);
+ }
+
bool
IsEnabled() const
{
@@ -491,15 +506,27 @@
return regex;
}
+ bool
+ Get(ValueObject& vobj,
+ lldb::SyntheticFilterSP& entry,
+ uint32_t* reason = NULL)
+ {
+ if (!IsEnabled())
+ return false;
+ return (Filter()->Get(vobj, entry, reason));
+ }
+
+ // just a shortcut for Summary()->Clear; RegexSummary()->Clear()
void
- Clear()
+ ClearSummaries()
{
m_summary_nav->Clear();
m_regex_summary_nav->Clear();
}
+ // just a shortcut for (Summary()->Delete(name) || RegexSummary()->Delete(name))
bool
- Delete(const char* name)
+ DeleteSummaries(const char* name)
{
bool del_sum = m_summary_nav->Delete(name);
bool del_rex = m_regex_summary_nav->Delete(name);
@@ -513,6 +540,12 @@
return Summary()->GetCount() + RegexSummary()->GetCount();
}
+ std::string
+ GetName()
+ {
+ return m_name;
+ }
+
typedef lldb::SharedPtr::Type SharedPointer;
};
@@ -648,23 +681,6 @@
return true;
}
- class match_category_to_name
- {
- private:
- FormatCategory* addr;
- public:
-
- match_category_to_name(FormatCategory* ptr) : addr(ptr)
- {}
-
- bool operator()(std::pair map_entry)
- {
- if (addr == map_entry.second.get())
- return true;
- return false;
- }
- };
-
void
LoopThrough(CallbackType callback, void* param)
{
@@ -678,13 +694,7 @@
for (begin = m_active_categories.begin(); begin != end; begin++)
{
FormatCategory::SharedPointer category = *begin;
- const char* type;
- MapIterator type_position =
- std::find_if(m_map.begin(),m_map.end(),match_category_to_name(category.get()));
- if (type_position != m_map.end())
- type = type_position->first;
- else
- continue;
+ const char* type = category->GetName().c_str();
if (!callback(param, type, category))
break;
}
@@ -741,6 +751,38 @@
}
return !first;
}
+
+ bool
+ Get(ValueObject& vobj,
+ lldb::SyntheticFilterSP& entry)
+ {
+ Mutex::Locker(m_map_mutex);
+
+ uint32_t reason_why;
+ bool first = true;
+
+ ActiveCategoriesIterator begin, end = m_active_categories.end();
+
+ for (begin = m_active_categories.begin(); begin != end; begin++)
+ {
+ FormatCategory::SharedPointer category = *begin;
+ lldb::SyntheticFilterSP current_format;
+ if (!category->Get(vobj, current_format, &reason_why))
+ continue;
+ if (reason_why == lldb::eFormatterDirectChoice)
+ {
+ entry = current_format;
+ return true;
+ }
+ else if (first)
+ {
+ entry = current_format;
+ first = false;
+ }
+ }
+ return !first;
+ }
+
};
@@ -856,7 +898,7 @@
lldb::FormatCategorySP category;
if (m_categories_map.Get(category_name, category))
return category;
- Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this)));
+ Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name)));
return Category(category_name);
}
@@ -866,6 +908,12 @@
{
return m_categories_map.Get(vobj, entry);
}
+ bool
+ Get(ValueObject& vobj,
+ lldb::SyntheticFilterSP& entry)
+ {
+ return m_categories_map.Get(vobj, entry);
+ }
static bool
GetFormatFromCString (const char *format_cstr,
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Jul 21 19:16:08 2011
@@ -466,7 +466,7 @@
const ConstString &
GetName() const;
- lldb::ValueObjectSP
+ virtual lldb::ValueObjectSP
GetChildAtIndex (uint32_t idx, bool can_create);
virtual lldb::ValueObjectSP
@@ -546,8 +546,14 @@
GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
lldb::ValueObjectSP
+ GetSyntheticExpressionPathChild(const char* expression, bool can_create);
+
+ lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
+ lldb::ValueObjectSP
+ GetSyntheticValue (lldb::SyntheticValueType use_synthetic);
+
virtual lldb::ValueObjectSP
CreateConstantValue (const ConstString &name);
@@ -592,6 +598,7 @@
bool show_location,
bool use_objc,
lldb::DynamicValueType use_dynamic,
+ bool use_synthetic,
bool scope_already_checked,
bool flat_output,
uint32_t omit_summary_depth);
@@ -727,6 +734,7 @@
std::vector m_children;
std::map m_synthetic_children;
ValueObject *m_dynamic_value;
+ ValueObject *m_synthetic_value;
lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
// as an independent ValueObjectConstResult, which isn't managed by us.
ValueObject *m_deref_valobj;
@@ -736,6 +744,7 @@
lldb::SummaryFormatSP m_last_summary_format;
lldb::SummaryFormatSP m_forced_summary_format;
lldb::ValueFormatSP m_last_value_format;
+ lldb::SyntheticFilterSP m_last_synthetic_filter;
lldb::user_id_t m_user_id_of_forced_summary;
bool m_value_is_valid:1,
m_value_did_change:1,
@@ -744,7 +753,8 @@
m_pointers_point_to_load_addrs:1,
m_is_deref_of_parent:1,
m_is_array_item_for_pointer:1,
- m_is_bitfield_for_scalar:1;
+ m_is_bitfield_for_scalar:1,
+ m_is_expression_path_child:1;
// used to prevent endless looping into GetpPrintableRepresentation()
uint32_t m_dump_printable_counter;
@@ -782,6 +792,9 @@
virtual void
CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
+ virtual void
+ CalculateSyntheticValue (lldb::SyntheticValueType use_synthetic);
+
// Should only be called by ValueObject::GetChildAtIndex()
// Returns a ValueObject managed by this ValueObject's manager.
virtual ValueObject *
Added: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=135731&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (added)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Thu Jul 21 19:16:08 2011
@@ -0,0 +1,122 @@
+//===-- ValueObjectSyntheticFilter.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_ValueObjectSyntheticFilter_h_
+#define liblldb_ValueObjectSyntheticFilter_h_
+
+// C Includes
+// C++ Includes
+#include
+#include
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ValueObject.h"
+
+namespace lldb_private {
+
+//----------------------------------------------------------------------
+// A ValueObject that represents memory at a given address, viewed as some
+// set lldb type.
+//----------------------------------------------------------------------
+class ValueObjectSyntheticFilter : public ValueObject
+{
+public:
+ virtual
+ ~ValueObjectSyntheticFilter();
+
+ virtual size_t
+ GetByteSize();
+
+ virtual clang::ASTContext *
+ GetClangAST ();
+
+ virtual lldb::clang_type_t
+ GetClangType ();
+
+ virtual ConstString
+ GetTypeName();
+
+ virtual uint32_t
+ CalculateNumChildren();
+
+ virtual lldb::ValueType
+ GetValueType() const;
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (uint32_t idx, bool can_create);
+
+ virtual lldb::ValueObjectSP
+ GetChildMemberWithName (const ConstString &name, bool can_create);
+
+ virtual uint32_t
+ GetIndexOfChildWithName (const ConstString &name);
+
+ virtual bool
+ IsInScope ();
+
+ virtual bool
+ IsDynamic ()
+ {
+ if (m_parent)
+ return m_parent->IsDynamic();
+ else
+ return false;
+ }
+
+ virtual ValueObject *
+ GetParent()
+ {
+ if (m_parent)
+ return m_parent->GetParent();
+ else
+ return NULL;
+ }
+
+ virtual const ValueObject *
+ GetParent() const
+ {
+ if (m_parent)
+ return m_parent->GetParent();
+ else
+ return NULL;
+ }
+
+ void
+ SetOwningSP (lldb::ValueObjectSP &owning_sp)
+ {
+ if (m_owning_valobj_sp == owning_sp)
+ return;
+
+ assert (m_owning_valobj_sp.get() == NULL);
+ m_owning_valobj_sp = owning_sp;
+ }
+
+protected:
+ virtual bool
+ UpdateValue ();
+
+ Address m_address; ///< The variable that this value object is based upon
+ lldb::TypeSP m_type_sp;
+ lldb::ValueObjectSP m_owning_valobj_sp;
+ lldb::SyntheticValueType m_use_synthetic;
+ lldb::SyntheticFilterSP m_synth_filter;
+
+private:
+ friend class ValueObject;
+ ValueObjectSyntheticFilter (ValueObject &parent, lldb::SyntheticFilterSP filter);
+
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN (ValueObjectSyntheticFilter);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ValueObjectSyntheticFilter_h_
Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h Thu Jul 21 19:16:08 2011
@@ -54,6 +54,7 @@
uint32_t max_depth;
uint32_t ptr_depth;
lldb::DynamicValueType use_dynamic;
+ bool use_synth;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Jul 21 19:16:08 2011
@@ -324,6 +324,12 @@
eDynamicDontRunTarget = 2
} DynamicValueType;
+ typedef enum SyntheticValueType
+ {
+ eNoSyntheticFilter = 0,
+ eUseSyntheticFilter = 1
+ } SyntheticValueType;
+
typedef enum AccessType
{
eAccessNone,
Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward-rtti.h (original)
+++ lldb/trunk/include/lldb/lldb-forward-rtti.h Thu Jul 21 19:16:08 2011
@@ -67,6 +67,7 @@
typedef SharedPtr::Type SummaryFormatSP;
typedef SharedPtr::Type SymbolFileSP;
typedef SharedPtr::Type SymbolContextSpecifierSP;
+ typedef SharedPtr::Type SyntheticFilterSP;
typedef SharedPtr::Type TargetSP;
typedef SharedPtr::Type ThreadSP;
typedef SharedPtr::Type ThreadPlanSP;
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Thu Jul 21 19:16:08 2011
@@ -144,6 +144,7 @@
class SymbolFile;
class SymbolVendor;
class Symtab;
+class SyntheticFilter;
class Target;
class TargetList;
class Thread;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jul 21 19:16:08 2011
@@ -419,6 +419,7 @@
94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; };
9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; };
9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; };
+ 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */; };
9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; };
@@ -1218,6 +1219,8 @@
9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; };
94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = ""; };
94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = ""; };
+ 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = ""; };
+ 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectSyntheticFilter.cpp; path = source/Core/ValueObjectSyntheticFilter.cpp; sourceTree = ""; };
961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FuncUnwinders.cpp; path = source/Symbol/FuncUnwinders.cpp; sourceTree = ""; };
961FABB91235DE1600F93A47 /* UnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindPlan.cpp; path = source/Symbol/UnwindPlan.cpp; sourceTree = ""; };
961FABBA1235DE1600F93A47 /* UnwindTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindTable.cpp; path = source/Symbol/UnwindTable.cpp; sourceTree = ""; };
@@ -2079,6 +2082,8 @@
4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */,
2643343A1110F63C00CDB6C6 /* ValueObjectRegister.h */,
264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */,
+ 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */,
+ 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */,
26BC7D8510F1B77400F91463 /* ValueObjectVariable.h */,
26BC7E9D10F1B85900F91463 /* ValueObjectVariable.cpp */,
26BC7D8610F1B77400F91463 /* VMRange.h */,
@@ -3361,6 +3366,7 @@
2676045A13D49D2300AB1B6A /* ProcessControl-mig.defs in Sources */,
26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */,
B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */,
+ 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Thu Jul 21 19:16:08 2011
@@ -648,6 +648,8 @@
lldb::DynamicValueType use_dynamic = eNoDynamicValues;
bool scope_already_checked = false;
bool flat_output = false;
+ bool use_synthetic = true;
+ uint32_t no_summary_depth = 0;
ValueObject::DumpValueObject (description.ref(),
m_opaque_sp.get(),
m_opaque_sp->GetName().GetCString(),
@@ -656,10 +658,11 @@
max_depth,
show_types, show_location,
use_objc,
- use_dynamic,
+ use_dynamic,
+ use_synthetic,
scope_already_checked,
flat_output,
- 0);
+ no_summary_depth);
}
else
description.Printf ("No value");
Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Jul 21 19:16:08 2011
@@ -334,6 +334,7 @@
false, // Show locations of variables, no since this is a host address which we don't care to see
m_options.print_object, // Print the objective C object?
use_dynamic,
+ true, // Use synthetic children if available
true, // Scope is already checked. Const results are always in scope.
false, // Don't flatten output
0); // Always use summaries (you might want an option --no-summary like there is for frame variable)
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Jul 21 19:16:08 2011
@@ -499,7 +499,8 @@
m_varobj_options.show_types,
m_varobj_options.show_location,
m_varobj_options.use_objc,
- m_varobj_options.use_dynamic,
+ m_varobj_options.use_dynamic,
+ m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.no_summary_depth);
@@ -552,6 +553,7 @@
m_varobj_options.show_location,
m_varobj_options.use_objc,
m_varobj_options.use_dynamic,
+ m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.no_summary_depth);
@@ -643,6 +645,7 @@
m_varobj_options.show_location,
m_varobj_options.use_objc,
m_varobj_options.use_dynamic,
+ m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.no_summary_depth);
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Thu Jul 21 19:16:08 2011
@@ -657,6 +657,7 @@
m_varobj_options.show_location,
m_varobj_options.use_objc,
m_varobj_options.use_dynamic,
+ m_varobj_options.use_synth,
scope_already_checked,
m_varobj_options.flat_output,
0);
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Jul 21 19:16:08 2011
@@ -488,6 +488,7 @@
m_varobj_options.show_location,
m_varobj_options.use_objc,
m_varobj_options.use_dynamic,
+ m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.no_summary_depth);
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Jul 21 19:16:08 2011
@@ -1226,7 +1226,7 @@
lldb::FormatCategorySP category;
Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category);
- bool delete_category = category->Delete(typeCS.GetCString());
+ bool delete_category = category->DeleteSummaries(typeCS.GetCString());
bool delete_named = Debugger::Formatting::NamedSummaryFormats::Delete(typeCS);
if (delete_category || delete_named)
@@ -1359,7 +1359,7 @@
}
else
Debugger::Formatting::Categories::Get(ConstString(NULL), category);
- category->Clear();
+ category->ClearSummaries();
}
Debugger::Formatting::NamedSummaryFormats::Clear();
@@ -1885,6 +1885,670 @@
};
+//-------------------------------------------------------------------------
+// CommandObjectTypeSynthList
+//-------------------------------------------------------------------------
+
+bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticFilter::SharedPointer& entry);
+
+class CommandObjectTypeSynthList;
+
+struct CommandObjectTypeSynthList_LoopCallbackParam {
+ CommandObjectTypeSynthList* self;
+ CommandReturnObject* result;
+ RegularExpression* regex;
+ RegularExpression* cate_regex;
+ CommandObjectTypeSynthList_LoopCallbackParam(CommandObjectTypeSynthList* S, CommandReturnObject* R,
+ RegularExpression* X = NULL,
+ RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
+};
+
+class CommandObjectTypeSynthList : public CommandObject
+{
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ }
+
+ virtual
+ ~CommandOptions (){}
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'w':
+ m_category_regex = std::string(option_arg);
+ break;
+ default:
+ error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_category_regex = "";
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ std::string m_category_regex;
+
+ };
+
+ CommandOptions m_options;
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+public:
+ CommandObjectTypeSynthList (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type synth list",
+ "Show a list of current synthetic providers.",
+ NULL), m_options(interpreter)
+ {
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatOptional;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+ }
+
+ ~CommandObjectTypeSynthList ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ CommandObjectTypeSynthList_LoopCallbackParam *param;
+ RegularExpression* cate_regex =
+ m_options.m_category_regex.empty() ? NULL :
+ new RegularExpression(m_options.m_category_regex.c_str());
+
+ if (argc == 1) {
+ RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
+ regex->Compile(command.GetArgumentAtIndex(0));
+ param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,regex,cate_regex);
+ }
+ else
+ param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,NULL,cate_regex);
+
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param);
+
+ if (cate_regex)
+ delete cate_regex;
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+
+private:
+
+ static bool
+ PerCategoryCallback(void* param_vp,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+
+ CommandObjectTypeSynthList_LoopCallbackParam* param =
+ (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp;
+ CommandReturnObject* result = param->result;
+
+ // if the category is disabled or empty and there is no regex, just skip it
+ if ((cate->IsEnabled() == false || cate->Filter()->GetCount() == 0) && param->cate_regex == NULL)
+ return true;
+
+ // if we have a regex and this category does not match it, just skip it
+ if(param->cate_regex != NULL && param->cate_regex->Execute(cate_name) == false)
+ return true;
+
+ result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
+ cate_name,
+ (cate->IsEnabled() ? "enabled" : "disabled"));
+
+ cate->Filter()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp);
+
+ return true;
+ }
+
+ bool
+ LoopCallback (const char* type,
+ const SyntheticFilter::SharedPointer& entry,
+ RegularExpression* regex,
+ CommandReturnObject *result)
+ {
+ if (regex == NULL || regex->Execute(type))
+ result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
+ return true;
+ }
+
+ friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticFilter::SharedPointer& entry);
+};
+
+bool
+CommandObjectTypeSynthList_LoopCallback (void* pt2self,
+ const char* type,
+ const SyntheticFilter::SharedPointer& entry)
+{
+ CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self;
+ return param->self->LoopCallback(type, entry, param->regex, param->result);
+}
+
+
+OptionDefinition
+CommandObjectTypeSynthList::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "category-regex", 'w', required_argument, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
+ { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeSynthDelete
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeSynthDelete : public CommandObject
+{
+private:
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ }
+
+ virtual
+ ~CommandOptions (){}
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'a':
+ m_delete_all = true;
+ break;
+ case 'w':
+ m_category = ConstString(option_arg).GetCString();
+ break;
+ default:
+ error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_delete_all = false;
+ m_category = NULL;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ bool m_delete_all;
+ const char* m_category;
+
+ };
+
+ CommandOptions m_options;
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+ static bool
+ PerCategoryCallback(void* param,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+ const char* name = (const char*)param;
+ cate->Filter()->Delete(name);
+ return true;
+ }
+
+public:
+ CommandObjectTypeSynthDelete (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type synth delete",
+ "Delete an existing synthetic provider for a type.",
+ NULL), m_options(interpreter)
+ {
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatPlain;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+
+ }
+
+ ~CommandObjectTypeSynthDelete ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ if (argc != 1)
+ {
+ result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ const char* typeA = command.GetArgumentAtIndex(0);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty typenames not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ if (m_options.m_delete_all)
+ {
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString());
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return result.Succeeded();
+ }
+
+ lldb::FormatCategorySP category;
+ Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category);
+
+ bool delete_category = category->Filter()->Delete(typeCS.GetCString());
+
+ if (delete_category)
+ {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return result.Succeeded();
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("no custom synthetic provider for %s.\n", typeA);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ }
+};
+
+OptionDefinition
+CommandObjectTypeSynthDelete::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Delete from every category."},
+ { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."},
+ { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeSynthClear
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeSynthClear : public CommandObject
+{
+private:
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ }
+
+ virtual
+ ~CommandOptions (){}
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'a':
+ m_delete_all = true;
+ break;
+ default:
+ error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_delete_all = false;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ bool m_delete_all;
+ bool m_delete_named;
+ };
+
+ CommandOptions m_options;
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+ static bool
+ PerCategoryCallback(void* param,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+ cate->Filter()->Clear();
+ return true;
+
+ }
+
+public:
+ CommandObjectTypeSynthClear (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type synth clear",
+ "Delete all existing synthetic providers.",
+ NULL), m_options(interpreter)
+ {
+ }
+
+ ~CommandObjectTypeSynthClear ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+
+ if (m_options.m_delete_all)
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL);
+
+ else
+ {
+ lldb::FormatCategorySP category;
+ if (command.GetArgumentCount() > 0)
+ {
+ const char* cat_name = command.GetArgumentAtIndex(0);
+ ConstString cat_nameCS(cat_name);
+ Debugger::Formatting::Categories::Get(cat_nameCS, category);
+ }
+ else
+ Debugger::Formatting::Categories::Get(ConstString(NULL), category);
+ category->Filter()->Clear();
+ }
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+
+};
+
+OptionDefinition
+CommandObjectTypeSynthClear::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Clear every category."},
+ { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeSynthAdd
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeSynthAdd : public CommandObject
+{
+
+private:
+
+ class CommandOptions : public Options
+ {
+ typedef std::vector option_vector;
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ }
+
+ virtual
+ ~CommandOptions (){}
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+ bool success;
+
+ switch (short_option)
+ {
+ case 'C':
+ m_cascade = Args::StringToBoolean(option_arg, true, &success);
+ if (!success)
+ error.SetErrorStringWithFormat("Invalid value for cascade: %s.\n", option_arg);
+ break;
+ case 'c':
+ m_expr_paths.push_back(option_arg);
+ break;
+ case 'p':
+ m_skip_pointers = true;
+ break;
+ case 'r':
+ m_skip_references = true;
+ break;
+ case 'w':
+ m_category = ConstString(option_arg).GetCString();
+ break;
+ default:
+ error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_cascade = true;
+ m_expr_paths.clear();
+ m_skip_pointers = false;
+ m_skip_references = false;
+ m_category = NULL;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ bool m_cascade;
+ bool m_skip_references;
+ bool m_skip_pointers;
+ option_vector m_expr_paths;
+ const char* m_category;
+
+ typedef option_vector::iterator ExpressionPathsIterator;
+ };
+
+ CommandOptions m_options;
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+public:
+ CommandObjectTypeSynthAdd (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type synth add",
+ "Add a new synthetic provider for a type.",
+ NULL), m_options (interpreter)
+ {
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatPlus;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+
+ }
+
+ ~CommandObjectTypeSynthAdd ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ if (argc < 1)
+ {
+ result.AppendErrorWithFormat ("%s takes one or more args.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ if (m_options.m_expr_paths.size() == 0)
+ {
+ result.AppendErrorWithFormat ("%s needs one or more children.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ SyntheticFilterSP entry;
+
+ entry.reset(new SyntheticFilter(m_options.m_cascade,
+ m_options.m_skip_pointers,
+ m_options.m_skip_references));
+
+ // go through the expression paths
+ CommandOptions::ExpressionPathsIterator begin, end = m_options.m_expr_paths.end();
+
+ for (begin = m_options.m_expr_paths.begin(); begin != end; begin++)
+ entry->AddExpressionPath(*begin);
+
+
+ // now I have a valid provider, let's add it to every type
+
+ lldb::FormatCategorySP category;
+ Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category);
+
+ for (size_t i = 0; i < argc; i++) {
+ const char* typeA = command.GetArgumentAtIndex(i);
+ ConstString typeCS(typeA);
+ if (typeCS)
+ category->Filter()->Add(typeCS.GetCString(), entry);
+ else
+ {
+ result.AppendError("empty typenames not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return result.Succeeded();
+ }
+};
+
+OptionDefinition
+CommandObjectTypeSynthAdd::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean, "If true, cascade to derived typedefs."},
+ { LLDB_OPT_SET_ALL, false, "child", 'c', required_argument, NULL, 0, eArgTypeName, "Include this expression path in the synthetic view."},
+ { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for pointers-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for references-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
+ { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
class CommandObjectTypeFormat : public CommandObjectMultiword
{
public:
@@ -1906,6 +2570,27 @@
}
};
+class CommandObjectTypeSynth : public CommandObjectMultiword
+{
+public:
+ CommandObjectTypeSynth (CommandInterpreter &interpreter) :
+ CommandObjectMultiword (interpreter,
+ "type synth",
+ "A set of commands for operating on synthetic type representations",
+ "type synth [] ")
+ {
+ LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeSynthAdd (interpreter)));
+ LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeSynthClear (interpreter)));
+ LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTypeSynthDelete (interpreter)));
+ LoadSubCommand ("list", CommandObjectSP (new CommandObjectTypeSynthList (interpreter)));
+ }
+
+
+ ~CommandObjectTypeSynth ()
+ {
+ }
+};
+
class CommandObjectTypeCategory : public CommandObjectMultiword
{
public:
@@ -1961,6 +2646,7 @@
LoadSubCommand ("category", CommandObjectSP (new CommandObjectTypeCategory (interpreter)));
LoadSubCommand ("format", CommandObjectSP (new CommandObjectTypeFormat (interpreter)));
LoadSubCommand ("summary", CommandObjectSP (new CommandObjectTypeSummary (interpreter)));
+ LoadSubCommand ("synth", CommandObjectSP (new CommandObjectTypeSynth (interpreter)));
}
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Jul 21 19:16:08 2011
@@ -733,8 +733,12 @@
// if this is a V, print the value using the default format
if (*format_name == 'V')
*val_obj_display = ValueObject::eDisplayValue;
+ // if this is an L, print the location of the value
if (*format_name == 'L')
*val_obj_display = ValueObject::eDisplayLocation;
+ // if this is an S, print the summary after all
+ if (*format_name == 'S')
+ *val_obj_display = ValueObject::eDisplaySummary;
}
// a good custom format tells us to print the value using it
else
@@ -1761,6 +1765,12 @@
{
return GetFormatManager().Get(vobj, entry);
}
+bool
+Debugger::Formatting::GetSyntheticFilter(ValueObject& vobj,
+ lldb::SyntheticFilterSP& entry)
+{
+ return GetFormatManager().Get(vobj, entry);
+}
bool
Debugger::Formatting::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry)
@@ -1791,7 +1801,7 @@
void
Debugger::Formatting::Categories::Clear(ConstString &category)
{
- GetFormatManager().Category(category.GetCString())->Clear();
+ GetFormatManager().Category(category.GetCString())->ClearSummaries();
}
void
Modified: lldb/trunk/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatClasses.cpp (original)
+++ lldb/trunk/source/Core/FormatClasses.cpp Thu Jul 21 19:16:08 2011
@@ -66,14 +66,15 @@
if (m_show_members_oneliner)
{
- const uint32_t num_children = object->GetNumChildren();
+ ValueObjectSP synth_vobj = object->GetSyntheticValue(lldb::eUseSyntheticFilter);
+ const uint32_t num_children = synth_vobj->GetNumChildren();
if (num_children)
{
s.PutChar('(');
for (uint32_t idx=0; idxGetChildAtIndex(idx, true));
+ lldb::ValueObjectSP child_sp(synth_vobj->GetChildAtIndex(idx, true));
if (child_sp.get())
{
if (idx)
@@ -137,4 +138,21 @@
}
-
+std::string
+SyntheticFilter::GetDescription()
+{
+ StreamString sstr;
+ sstr.Printf("%s%s%s {\n",
+ m_cascades ? "" : " (not cascading)",
+ m_skip_pointers ? " (skip pointers)" : "",
+ m_skip_references ? " (skip references)" : "");
+
+ for (int i = 0; i < GetCount(); i++)
+ {
+ sstr.Printf(" %s\n",
+ GetExpressionPathAtIndex(i).c_str());
+ }
+
+ sstr.Printf("}");
+ return sstr.GetString();
+}
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Jul 21 19:16:08 2011
@@ -26,6 +26,7 @@
#include "lldb/Core/ValueObjectDynamicValue.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectMemory.h"
+#include "lldb/Core/ValueObjectSyntheticFilter.h"
#include "lldb/Host/Endian.h"
@@ -70,12 +71,14 @@
m_children (),
m_synthetic_children (),
m_dynamic_value (NULL),
+ m_synthetic_value(NULL),
m_deref_valobj(NULL),
m_format (eFormatDefault),
m_last_format_mgr_revision(0),
m_last_summary_format(),
m_forced_summary_format(),
m_last_value_format(),
+ m_last_synthetic_filter(),
m_user_id_of_forced_summary(0),
m_value_is_valid (false),
m_value_did_change (false),
@@ -85,6 +88,7 @@
m_is_deref_of_parent (false),
m_is_array_item_for_pointer(false),
m_is_bitfield_for_scalar(false),
+ m_is_expression_path_child(false),
m_dump_printable_counter(0)
{
m_manager->ManageObject(this);
@@ -110,12 +114,14 @@
m_children (),
m_synthetic_children (),
m_dynamic_value (NULL),
+ m_synthetic_value(NULL),
m_deref_valobj(NULL),
m_format (eFormatDefault),
m_last_format_mgr_revision(0),
m_last_summary_format(),
m_forced_summary_format(),
m_last_value_format(),
+ m_last_synthetic_filter(),
m_user_id_of_forced_summary(0),
m_value_is_valid (false),
m_value_did_change (false),
@@ -125,6 +131,7 @@
m_is_deref_of_parent (false),
m_is_array_item_for_pointer(false),
m_is_bitfield_for_scalar(false),
+ m_is_expression_path_child(false),
m_dump_printable_counter(0)
{
m_manager = new ValueObjectManager();
@@ -209,14 +216,13 @@
if (m_last_summary_format.get())
m_last_summary_format.reset((StringSummaryFormat*)NULL);
if (m_last_value_format.get())
- m_last_value_format.reset((ValueFormat*)NULL);
- Debugger::Formatting::ValueFormats::Get(*this, m_last_value_format);
- // to find a summary we look for a direct summary, then if there is none
- // we look for a regex summary. if there is none we look for a system
- // summary (direct), and if also that fails, we look for a system
- // regex summary
+ m_last_value_format.reset(/*(ValueFormat*)NULL*/);
+ if (m_last_synthetic_filter.get())
+ m_last_synthetic_filter.reset(/*(SyntheticFilter*)NULL*/);
+ Debugger::Formatting::ValueFormats::Get(*this, m_last_value_format);
Debugger::Formatting::GetSummaryFormat(*this, m_last_summary_format);
+ Debugger::Formatting::GetSyntheticFilter(*this, m_last_synthetic_filter);
m_last_format_mgr_revision = Debugger::Formatting::ValueFormats::GetCurrentRevision();
@@ -1423,6 +1429,63 @@
return synthetic_child_sp;
}
+// your expression path needs to have a leading . or ->
+// (unless it somehow "looks like" an array, in which case it has
+// a leading [ symbol). while the [ is meaningful and should be shown
+// to the user, . and -> are just parser design, but by no means
+// added information for the user.. strip them off
+static const char*
+SkipLeadingExpressionPathSeparators(const char* expression)
+{
+ if (!expression || !expression[0])
+ return expression;
+ if (expression[0] == '.')
+ return expression+1;
+ if (expression[0] == '-' && expression[1] == '>')
+ return expression+2;
+ return expression;
+}
+
+lldb::ValueObjectSP
+ValueObject::GetSyntheticExpressionPathChild(const char* expression, bool can_create)
+{
+ ValueObjectSP synthetic_child_sp;
+ ConstString name_const_string(expression);
+ // Check if we have already created a synthetic array member in this
+ // valid object. If we have we will re-use it.
+ synthetic_child_sp = GetSyntheticChild (name_const_string);
+ if (!synthetic_child_sp)
+ {
+ // We haven't made a synthetic array member for expression yet, so
+ // lets make one and cache it for any future reference.
+ synthetic_child_sp = GetValueForExpressionPath(expression);
+
+ // Cache the value if we got one back...
+ if (synthetic_child_sp.get())
+ {
+ AddSyntheticChild(name_const_string, synthetic_child_sp.get());
+ synthetic_child_sp->SetName(SkipLeadingExpressionPathSeparators(expression));
+ synthetic_child_sp->m_is_expression_path_child = true;
+ }
+ }
+ return synthetic_child_sp;
+}
+
+void
+ValueObject::CalculateSyntheticValue (lldb::SyntheticValueType use_synthetic)
+{
+ if (use_synthetic == lldb::eNoSyntheticFilter)
+ return;
+
+ UpdateFormatsIfNeeded();
+
+ if (m_last_synthetic_filter.get() == NULL)
+ return;
+
+ m_synthetic_value = new ValueObjectSyntheticFilter(*this, m_last_synthetic_filter);
+
+}
+
void
ValueObject::CalculateDynamicValue (lldb::DynamicValueType use_dynamic)
{
@@ -1483,6 +1546,29 @@
return ValueObjectSP();
}
+// GetDynamicValue() returns a NULL SharedPointer if the object is not dynamic
+// or we do not really want a dynamic VO. this method instead returns this object
+// itself when making it synthetic has no meaning. this makes it much simpler
+// to replace the SyntheticValue for the ValueObject
+ValueObjectSP
+ValueObject::GetSyntheticValue (SyntheticValueType use_synthetic)
+{
+ if (use_synthetic == lldb::eNoSyntheticFilter)
+ return GetSP();
+
+ UpdateFormatsIfNeeded();
+
+ if (m_last_synthetic_filter.get() == NULL)
+ return GetSP();
+
+ CalculateSyntheticValue(use_synthetic);
+
+ if (m_synthetic_value)
+ return m_synthetic_value->GetSP();
+ else
+ return GetSP();
+}
+
bool
ValueObject::GetBaseClassPath (Stream &s)
{
@@ -2398,6 +2484,7 @@
bool show_location,
bool use_objc,
lldb::DynamicValueType use_dynamic,
+ bool use_synth,
bool scope_already_checked,
bool flat_output,
uint32_t omit_summary_depth
@@ -2545,7 +2632,10 @@
if (print_children && (!entry || entry->DoesPrintChildren() || !sum_cstr))
{
- const uint32_t num_children = valobj->GetNumChildren();
+ ValueObjectSP synth_vobj = valobj->GetSyntheticValue(use_synth ?
+ lldb::eUseSyntheticFilter :
+ lldb::eNoSyntheticFilter);
+ const uint32_t num_children = synth_vobj->GetNumChildren();
if (num_children)
{
if (flat_output)
@@ -2562,7 +2652,7 @@
for (uint32_t idx=0; idxGetChildAtIndex(idx, true));
+ ValueObjectSP child_sp(synth_vobj->GetChildAtIndex(idx, true));
if (child_sp.get())
{
DumpValueObject (s,
@@ -2575,6 +2665,7 @@
show_location,
false,
use_dynamic,
+ use_synth,
true,
flat_output,
omit_summary_depth > 1 ? omit_summary_depth - 1 : 0);
Added: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=135731&view=auto
==============================================================================
--- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (added)
+++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Thu Jul 21 19:16:08 2011
@@ -0,0 +1,170 @@
+//===-- ValueObjectSyntheticFilter.cpp -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "lldb/Core/ValueObjectSyntheticFilter.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/FormatClasses.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObject.h"
+
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/Variable.h"
+
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+
+using namespace lldb_private;
+
+ValueObjectSyntheticFilter::ValueObjectSyntheticFilter (ValueObject &parent, lldb::SyntheticFilterSP filter) :
+ ValueObject(parent),
+ m_address (),
+ m_type_sp(),
+m_use_synthetic (lldb::eUseSyntheticFilter),
+ m_synth_filter(filter)
+{
+ SetName (parent.GetName().AsCString());
+}
+
+ValueObjectSyntheticFilter::~ValueObjectSyntheticFilter()
+{
+ m_owning_valobj_sp.reset();
+}
+
+lldb::clang_type_t
+ValueObjectSyntheticFilter::GetClangType ()
+{
+ if (m_type_sp)
+ return m_value.GetClangType();
+ else
+ return m_parent->GetClangType();
+}
+
+ConstString
+ValueObjectSyntheticFilter::GetTypeName()
+{
+ const bool success = UpdateValueIfNeeded();
+ if (success && m_type_sp)
+ return ClangASTType::GetConstTypeName (GetClangType());
+ else
+ return m_parent->GetTypeName();
+}
+
+uint32_t
+ValueObjectSyntheticFilter::CalculateNumChildren()
+{
+ const bool success = UpdateValueIfNeeded();
+ if (!success)
+ return 0;
+ if (m_synth_filter.get())
+ return m_synth_filter->GetCount();
+ return 0;
+ if (success && m_type_sp)
+ return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
+ else
+ return m_parent->GetNumChildren();
+}
+
+clang::ASTContext *
+ValueObjectSyntheticFilter::GetClangAST ()
+{
+ const bool success = UpdateValueIfNeeded(false);
+ if (success && m_type_sp)
+ return m_type_sp->GetClangAST();
+ else
+ return m_parent->GetClangAST ();
+}
+
+size_t
+ValueObjectSyntheticFilter::GetByteSize()
+{
+ const bool success = UpdateValueIfNeeded();
+ if (success && m_type_sp)
+ return m_value.GetValueByteSize(GetClangAST(), NULL);
+ else
+ return m_parent->GetByteSize();
+}
+
+lldb::ValueType
+ValueObjectSyntheticFilter::GetValueType() const
+{
+ return m_parent->GetValueType();
+}
+
+bool
+ValueObjectSyntheticFilter::UpdateValue ()
+{
+ SetValueIsValid (false);
+ m_error.Clear();
+
+ if (!m_parent->UpdateValueIfNeeded())
+ {
+ // our parent could not update.. as we are meaningless without a parent, just stop
+ if (m_error.Success() && m_parent->GetError().Fail())
+ m_error = m_parent->GetError();
+ return false;
+ }
+
+ SetValueIsValid(true);
+ return true;
+}
+
+lldb::ValueObjectSP
+ValueObjectSyntheticFilter::GetChildAtIndex (uint32_t idx, bool can_create)
+{
+ if (!m_synth_filter.get())
+ return lldb::ValueObjectSP();
+ if (idx >= m_synth_filter->GetCount())
+ return lldb::ValueObjectSP();
+ return m_parent->GetSyntheticExpressionPathChild(m_synth_filter->GetExpressionPathAtIndex(idx).c_str(), can_create);
+}
+
+lldb::ValueObjectSP
+ValueObjectSyntheticFilter::GetChildMemberWithName (const ConstString &name, bool can_create)
+{
+ if (!m_synth_filter.get())
+ return lldb::ValueObjectSP();
+ uint32_t idx = GetIndexOfChildWithName(name);
+ if (idx >= m_synth_filter->GetCount())
+ return lldb::ValueObjectSP();
+ return m_parent->GetSyntheticExpressionPathChild(name.GetCString(), can_create);
+}
+
+uint32_t
+ValueObjectSyntheticFilter::GetIndexOfChildWithName (const ConstString &name)
+{
+ const char* name_cstr = name.GetCString();
+ for (int i = 0; i < m_synth_filter->GetCount(); i++)
+ {
+ const char* expr_cstr = m_synth_filter->GetExpressionPathAtIndex(i).c_str();
+ if (::strcmp(name_cstr, expr_cstr))
+ return i;
+ }
+ return UINT32_MAX;
+}
+
+bool
+ValueObjectSyntheticFilter::IsInScope ()
+{
+ return m_parent->IsInScope();
+}
+
Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Thu Jul 21 19:16:08 2011
@@ -31,7 +31,8 @@
g_option_table[] =
{
{ LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types,
- 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
+ 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
+ { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
{ LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
{ LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
{ LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."},
@@ -105,7 +106,12 @@
else
no_summary_depth = 1;
break;
-
+
+ case 'S':
+ use_synth = Args::StringToBoolean(option_arg, true, &success);
+ if (!success)
+ error.SetErrorStringWithFormat("Invalid synthetic-type '%s'.\n", option_arg);
+ break;
default:
error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
break;
@@ -124,6 +130,7 @@
use_objc = false;
max_depth = UINT32_MAX;
ptr_depth = 0;
+ use_synth = true;
Target *target = interpreter.GetExecutionContext().target;
if (target != NULL)
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Thu Jul 21 19:16:08 2011
@@ -319,8 +319,23 @@
'AShape',
'ARectangleStar'])
+ # check that synthetic children work into categories
+ self.runCmd("type synth add Rectangle --child w --category RectangleCategory")
+ self.runCmd("type category enable RectangleCategory")
+ self.runCmd("type summary add Rectangle -f \" \" -e --category RectangleCategory")
+ self.expect('frame variable r2',
+ substrs = ['w = 9'])
+ self.runCmd("type summary add Rectangle -f \" \" -e")
+ self.expect('frame variable r2', matching=False,
+ substrs = ['h = 16'])
+
# Now delete all categories
- self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory")
+ self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory")
+
+ # last of all, check that a deleted category with synth does not blow us up
+ self.expect('frame variable r2',
+ substrs = ['w = 9',
+ 'h = 16'])
if __name__ == '__main__':
import atexit
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Thu Jul 21 19:16:08 2011
@@ -182,7 +182,25 @@
self.expect("frame variable cool_pointer",
substrs = ['3,0,0'])
+ # test special symbols for formatting variables into summaries
+ self.runCmd("type summary add -f \"cool object @ ${var%L}\" i_am_cool")
+ self.runCmd("type summary delete \"i_am_cool [5]\"")
+ # this test might fail if the compiler tries to store
+ # these values into registers.. hopefully this is not
+ # going to be the case
+ self.expect("frame variable cool_array",
+ substrs = ['[0] = cool object @ 0x',
+ '[1] = cool object @ 0x',
+ '[2] = cool object @ 0x',
+ '[3] = cool object @ 0x',
+ '[4] = cool object @ 0x'])
+
+ self.runCmd("type summary add -f \"goofy\" i_am_cool")
+ self.runCmd("type summary add -f \"${var.second_cool%S}\" i_am_cooler")
+
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
if __name__ == '__main__':
import atexit
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/main.cpp?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/main.cpp (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/main.cpp Thu Jul 21 19:16:08 2011
@@ -110,6 +110,8 @@
char strarr[32] = "Hello world!";
char* strptr = "Hello world!";
+
+ i_am_cooler the_coolest_guy(1,2,3.14,6.28,'E','G');
return 0; // Set break point at this line.
}
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/Makefile?rev=135731&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/Makefile Thu Jul 21 19:16:08 2011
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=135731&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Thu Jul 21 19:16:08 2011
@@ -0,0 +1,203 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class DataFormatterTestCase(TestBase):
+
+ mydir = os.path.join("functionalities", "data-formatter", "data-formatter-synth")
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDsym()
+ self.data_formatter_commands()
+
+ def test_with_dwarf_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDwarf()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Pick some values and check that the basics work
+ self.runCmd("type synth add BagOfInts --child x --child z")
+ self.expect("frame variable int_bag",
+ substrs = ['x = 6',
+ 'z = 8'])
+
+ # Check we can still access the missing child by summary
+ self.runCmd("type summary add BagOfInts -f \"y=${var.y}\"")
+ self.expect('frame variable int_bag',
+ substrs = ['y=7'])
+
+ # Even if we have synth children, the summary prevails
+ self.expect("frame variable int_bag", matching=False,
+ substrs = ['x = 6',
+ 'z = 8'])
+
+ # Summary+Synth must work together
+ self.runCmd("type summary add BagOfInts -f \"y=${var.y}\" -e")
+ self.expect('frame variable int_bag',
+ substrs = ['y=7',
+ 'x = 6',
+ 'z = 8'])
+
+ # Same output, but using Python
+ self.runCmd("type summary add BagOfInts -s \"return 'y='+valobj.GetChildMemberWithName('y').GetValue()\" -e")
+ self.expect('frame variable int_bag',
+ substrs = ['y=7',
+ 'x = 6',
+ 'z = 8'])
+
+ # If I skip summaries, still give me the artificial children
+ self.expect("frame variable int_bag -Y1",
+ substrs = ['x = 6',
+ 'z = 8'])
+
+ # Delete synth and check that the view reflects it immediately
+ self.runCmd("type synth delete BagOfInts")
+ self.expect("frame variable int_bag",
+ substrs = ['x = 6',
+ 'y = 7',
+ 'z = 8'])
+
+ # Add the synth again and check that it's honored deeper in the hierarchy
+ self.runCmd("type synth add BagOfInts --child x --child z")
+ self.expect('frame variable bag_bag',
+ substrs = ['x = y=70 {',
+ 'x = 69',
+ 'z = 71',
+ 'y = y=67 {',
+ 'x = 66',
+ 'z = 68'])
+ self.expect('frame variable bag_bag', matching=False,
+ substrs = ['y = 70',
+ 'y = 67'])
+
+ # Check that a synth can expand nested stuff
+ self.runCmd("type synth add BagOfBags --child x.y --child y.z")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.y = 70',
+ 'y.z = 68'])
+
+ # ...even if we get -> and . wrong
+ self.runCmd("type synth add BagOfBags --child x.y --child \"y->z\"")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.y = 70',
+ 'y->z = 68'])
+
+ # ...even bitfields
+ self.runCmd("type synth add BagOfBags --child x.y --child \"y->z[1-2]\"")
+ self.expect('frame variable bag_bag -T',
+ substrs = ['x.y = 70',
+ '(int:2) y->z[1-2] = 2'])
+
+ # ...even if we format the bitfields
+ self.runCmd("type synth add BagOfBags --child x.y --child \"y->y[0-0]\"")
+ self.runCmd("type format add \"int:1\" -f bool")
+ self.expect('frame variable bag_bag -T',
+ substrs = ['x.y = 70',
+ '(int:1) y->y[0-0] = true'])
+
+ # ...even if we use one-liner summaries
+ self.runCmd("type summary add -c BagOfBags")
+ self.expect('frame variable bag_bag',
+ substrs = ['(BagOfBags) bag_bag = (x.y=70, y->y[0-0]=true)'])
+
+ self.runCmd("type summary delete BagOfBags")
+
+ # now check we are dynamic (and arrays work)
+ self.runCmd("type synth add Plenty --child bitfield --child array[0] --child array[2]")
+ self.expect('frame variable plenty_of_stuff',
+ substrs = ['bitfield = 1',
+ 'array[0] = 5',
+ 'array[2] = 3'])
+
+ self.runCmd("n")
+ self.expect('frame variable plenty_of_stuff',
+ substrs = ['bitfield = 17',
+ 'array[0] = 5',
+ 'array[2] = 3'])
+
+ # skip synthetic children
+ self.expect('frame variable plenty_of_stuff -S no',
+ substrs = ['some_values = 0x0',
+ 'array = 0x',
+ 'array_size = 5'])
+
+
+ # check flat printing with synthetic children
+ self.expect('frame variable plenty_of_stuff --flat',
+ substrs = ['plenty_of_stuff.bitfield = 17',
+ '*(plenty_of_stuff.array) = 5',
+ '*(plenty_of_stuff.array) = 3'])
+
+ # check that we do not lose location information for our children
+ self.expect('frame variable plenty_of_stuff -L',
+ substrs = ['0x',
+ ': bitfield = 17'])
+
+ # check we work across pointer boundaries
+ self.expect('frame variable plenty_of_stuff.some_values -P1',
+ substrs = ['(BagOfInts *) plenty_of_stuff.some_values',
+ 'x = 5',
+ 'z = 7'])
+
+ # but not if we don't want to
+ self.runCmd("type synth add BagOfInts --child x --child z -p")
+ self.expect('frame variable plenty_of_stuff.some_values -P1',
+ substrs = ['(BagOfInts *) plenty_of_stuff.some_values',
+ 'x = 5',
+ 'y = 6',
+ 'z = 7'])
+
+ # check we're dynamic even if nested
+ self.runCmd("type synth add BagOfBags --child x.z")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.z = 71'])
+
+ self.runCmd("n")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.z = 12'])
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/main.cpp?rev=135731&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/main.cpp Thu Jul 21 19:16:08 2011
@@ -0,0 +1,83 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include
+#include
+#include
+
+struct BagOfInts
+{
+ int x;
+ int y;
+ int z;
+ BagOfInts(int X) :
+ x(X),
+ y(X+1),
+ z(X+2) {}
+};
+
+struct BagOfFloats
+{
+ float x;
+ float y;
+ float z;
+ BagOfFloats(float X) :
+ x(X+0.334),
+ y(X+0.500),
+ z(X+0.667) {}
+};
+
+struct BagOfBags
+{
+ BagOfInts x;
+ BagOfInts y;
+ BagOfFloats z;
+ BagOfFloats q;
+ BagOfBags() :
+ x('E'),
+ y('B'),
+ z(1.1),
+ q(20.11) {}
+};
+
+struct Plenty
+{
+ BagOfInts *some_values;
+ int* array;
+ int array_size;
+ int bitfield;
+
+ Plenty(int N, bool flagA, bool flagB) :
+ some_values(new BagOfInts(N)),
+ array(new int[N]),
+ array_size(N),
+ bitfield( (flagA ? 0x01 : 0x00) | (flagB ? 0x10 : 0x00) )
+ {
+ for (int j = 0; j < N; j++)
+ array[j] = N-j;
+ }
+};
+
+int main (int argc, const char * argv[])
+{
+ BagOfInts int_bag(6);
+ BagOfFloats float_bag(2.71);
+
+ BagOfBags bag_bag;
+
+ Plenty plenty_of_stuff(5,true,false);
+
+ plenty_of_stuff.bitfield = 0x11; // Set break point at this line.
+
+ bag_bag.x.z = 12;
+
+ return 0;
+
+}
+
Modified: lldb/trunk/www/varformats.html
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=135731&r1=135730&r2=135731&view=diff
==============================================================================
--- lldb/trunk/www/varformats.html (original)
+++ lldb/trunk/www/varformats.html Thu Jul 21 19:16:08 2011
@@ -495,20 +495,38 @@
in fact it has a similar effect. If you add a % sign
followed by any one format name or abbreviation from the
above table after an expression path, the resulting
- object will be displyed using the chosen format (this is
- applicable to non-aggregate types only, with a few
- special exceptions discussed below).
- There are two more special format symbols that you can
- use only as part of a summary string: %V
- and %@. The first one tells LLDB to ignore
- summary strings for the type of the object referred by
- the expression path and instead print the object's
- value. The second is only applicable to Objective-C
- classes, and tells LLDB to get the object's description
- from the Objective-C runtime. By default, if no format
- is provided, LLDB will try to get the object's summary,
- and if empty the object's value. If neither can be
- obtained, nothing will be displayed.
+ object will be displyed using the chosen format.
+
+ You can also use some other special format markers, not available
+ for type formatters, but which carry a special meaning when used in this
+ context:
+
+
+
+
+ | Symbol |
+ Description |
+
+
+ | %S |
+ Use this object's summary (the default for aggregate types) |
+
+
+ | %V |
+ Use this object's value (the default for non-aggregate types) |
+
+
+ | %@ |
+ Use a language-runtime specific description (for C++ this does nothing,
+ for Objective-C it calls the NSPrintForDebugger API) |
+
+
+ | %L |
+ Use this object's location (memory address, register name, ...) |
+
+
+
+
As previously said, pointers and values are treated the
same way when getting to their members in an expression
path. However, if your expression path leads to a
From johnny.chen at apple.com Thu Jul 21 19:47:58 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Fri, 22 Jul 2011 00:47:58 -0000
Subject: [Lldb-commits] [lldb] r135736 - in /lldb/trunk/test: lldbutil.py
python_api/value/TestValueAPI.py python_api/value/main.c
Message-ID: <20110722004758.681672A6C12D@llvm.org>
Author: johnny
Date: Thu Jul 21 19:47:58 2011
New Revision: 135736
URL: http://llvm.org/viewvc/llvm-project?rev=135736&view=rev
Log:
Add BasicFormatter and ChildVisitingFormatter utility classes to the lldbutil.py module
which provide some convenient ways to print an SBValue object. Use that in TestValueAPI.py
to print the 'days_of_week' char* array variable.
For an example:
cvf = lldbutil.ChildVisitingFormatter(indent=2)
print cvf.format(days_of_week)
produces:
(const char *[7]) days_of_week = 0x00000001026a5060 (location)
(const char *) [0] = "Sunday"
(const char *) [1] = "Monday"
(const char *) [2] = "Tuesday"
(const char *) [3] = "Wednesday"
(const char *) [4] = "Thursday"
(const char *) [5] = "Friday"
(const char *) [6] = "Saturday"
Modified:
lldb/trunk/test/lldbutil.py
lldb/trunk/test/python_api/value/TestValueAPI.py
lldb/trunk/test/python_api/value/main.c
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=135736&r1=135735&r2=135736&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Thu Jul 21 19:47:58 2011
@@ -527,3 +527,39 @@
...
"""
return get_registers(frame, "exception state")
+
+# ===============================
+# Utility functions for SBValue's
+# ===============================
+
+class BasicFormatter(object):
+ def format(self, value, buffer=None, indent=0):
+ if not buffer:
+ output = StringIO.StringIO()
+ else:
+ output = buffer
+ sum = value.GetSummary()
+ if value.GetNumChildren() > 0 and sum == None:
+ sum = "%s (location)" % value.GetLocation()
+ print >> output, "{indentation}({type}) {name} = {summary}".format(
+ indentation = ' ' * indent,
+ type = value.GetTypeName(),
+ name = value.GetName(),
+ summary = sum)
+ return output.getvalue()
+
+class ChildVisitingFormatter(BasicFormatter):
+ def __init__(self, indent=2):
+ """Default indentation of 2 SPC's."""
+ self.indentation = indent
+ def format(self, value, buffer=None):
+ if not buffer:
+ output = StringIO.StringIO()
+ else:
+ output = buffer
+
+ BasicFormatter.format(self, value, buffer=output)
+ for child in value:
+ BasicFormatter.format(self, child, buffer=output, indent=self.indentation)
+
+ return output.getvalue()
Modified: lldb/trunk/test/python_api/value/TestValueAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/TestValueAPI.py?rev=135736&r1=135735&r2=135736&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/TestValueAPI.py (original)
+++ lldb/trunk/test/python_api/value/TestValueAPI.py Thu Jul 21 19:47:58 2011
@@ -66,6 +66,12 @@
self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE)
self.DebugSBValue(days_of_week)
+ fmt = lldbutil.BasicFormatter()
+ cvf = lldbutil.ChildVisitingFormatter(indent=2)
+ if self.TraceOn():
+ print fmt.format(days_of_week)
+ print cvf.format(days_of_week)
+
# Get variable 'str_ptr'.
value = frame0.FindVariable('str_ptr')
self.assertTrue(value, VALID_VARIABLE)
Modified: lldb/trunk/test/python_api/value/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/main.c?rev=135736&r1=135735&r2=135736&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/main.c (original)
+++ lldb/trunk/test/python_api/value/main.c Thu Jul 21 19:47:58 2011
@@ -10,6 +10,8 @@
// This simple program is to test the lldb Python API SBValue.GetChildAtIndex().
+int g_my_int = 100;
+
const char *days_of_week[7] = { "Sunday",
"Monday",
"Tuesday",
From johnny.chen at apple.com Thu Jul 21 19:51:54 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Fri, 22 Jul 2011 00:51:54 -0000
Subject: [Lldb-commits] [lldb] r135737 - /lldb/trunk/test/lldbutil.py
Message-ID: <20110722005154.5E71D2A6C12D@llvm.org>
Author: johnny
Date: Thu Jul 21 19:51:54 2011
New Revision: 135737
URL: http://llvm.org/viewvc/llvm-project?rev=135737&view=rev
Log:
Fix comment.
Modified:
lldb/trunk/test/lldbutil.py
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=135737&r1=135736&r2=135737&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Thu Jul 21 19:51:54 2011
@@ -528,9 +528,9 @@
"""
return get_registers(frame, "exception state")
-# ===============================
-# Utility functions for SBValue's
-# ===============================
+# ======================================
+# Utility classes/functions for SBValues
+# ======================================
class BasicFormatter(object):
def format(self, value, buffer=None, indent=0):
From gclayton at apple.com Fri Jul 22 11:46:35 2011
From: gclayton at apple.com (Greg Clayton)
Date: Fri, 22 Jul 2011 16:46:35 -0000
Subject: [Lldb-commits] [lldb] r135770 - in /lldb/trunk:
include/lldb/API/SBAddress.h include/lldb/API/SBTarget.h
scripts/Python/interface/SBAddress.i scripts/Python/interface/SBTarget.i
source/API/SBAddress.cpp source/API/SBModule.cpp source/API/SBTarget.cpp
test/python_api/default-constructor/sb_target.py
Message-ID: <20110722164635.DE10D2A6C12D@llvm.org>
Author: gclayton
Date: Fri Jul 22 11:46:35 2011
New Revision: 135770
URL: http://llvm.org/viewvc/llvm-project?rev=135770&view=rev
Log:
Make the SBAddress class easier to use when using the public
API.
SBTarget changes include changing:
bool
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr,
lldb::SBAddress& addr);
to be:
lldb::SBAddress
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr);
SBAddress can how contruct itself using a load address and a target
which can be used to resolve the address:
SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
This will actually just call the new SetLoadAddress accessor:
void
SetLoadAddress (lldb::addr_t load_addr,
lldb::SBTarget &target);
This function will always succeed in making a SBAddress object
that can be used in API calls (even if "target" isn't valid).
If "target" is valid and there are sections currently loaded,
then it will resolve the address to a section offset address if
it can. Else an address with a NULL section and an offset that is
the "load_addr" that was passed in. We do this because a load address
might be from the heap or stack.
Modified:
lldb/trunk/include/lldb/API/SBAddress.h
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/scripts/Python/interface/SBAddress.i
lldb/trunk/scripts/Python/interface/SBTarget.i
lldb/trunk/source/API/SBAddress.cpp
lldb/trunk/source/API/SBModule.cpp
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/test/python_api/default-constructor/sb_target.py
Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Fri Jul 22 11:46:35 2011
@@ -23,6 +23,9 @@
SBAddress (const lldb::SBAddress &rhs);
+ // Create an address by resolving a load address using the supplied target
+ SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
+
~SBAddress ();
#ifndef SWIG
@@ -42,6 +45,9 @@
addr_t
GetLoadAddress (const lldb::SBTarget &target) const;
+ void
+ SetLoadAddress (lldb::addr_t load_addr,
+ lldb::SBTarget &target);
bool
OffsetAddress (addr_t offset);
@@ -74,15 +80,15 @@
const lldb_private::Address *
operator->() const;
- const lldb_private::Address &
- operator*() const;
+ lldb_private::Address *
+ get ();
lldb_private::Address &
- operator*();
+ ref();
+
+ const lldb_private::Address &
+ ref() const;
- lldb_private::Address *
- get ();
-
#endif
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Jul 22 11:46:35 2011
@@ -11,6 +11,7 @@
#define LLDB_SBTarget_h_
#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBAddress.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBFileSpec.h"
@@ -296,9 +297,8 @@
void
Clear ();
- bool
- ResolveLoadAddress (lldb::addr_t vm_addr,
- lldb::SBAddress& addr);
+ lldb::SBAddress
+ ResolveLoadAddress (lldb::addr_t vm_addr);
SBSymbolContext
ResolveSymbolContextForAddress (const SBAddress& addr,
Modified: lldb/trunk/scripts/Python/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBAddress.i (original)
+++ lldb/trunk/scripts/Python/interface/SBAddress.i Fri Jul 22 11:46:35 2011
@@ -50,6 +50,9 @@
SBAddress (const lldb::SBAddress &rhs);
+ // Create an address by resolving a load address using the supplied target
+ SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
+
~SBAddress ();
bool
@@ -64,6 +67,10 @@
addr_t
GetLoadAddress (const lldb::SBTarget &target) const;
+ void
+ SetLoadAddress (lldb::addr_t load_addr,
+ lldb::SBTarget &target);
+
bool
OffsetAddress (addr_t offset);
Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Fri Jul 22 11:46:35 2011
@@ -343,9 +343,8 @@
void
Clear ();
- bool
- ResolveLoadAddress (lldb::addr_t vm_addr,
- lldb::SBAddress& addr);
+ lldb::SBAddress
+ ResolveLoadAddress (lldb::addr_t vm_addr);
SBSymbolContext
ResolveSymbolContextForAddress (const SBAddress& addr,
Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Fri Jul 22 11:46:35 2011
@@ -39,6 +39,15 @@
m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get()));
}
+// Create an address by resolving a load address using the supplied target
+SBAddress::SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target) :
+ m_opaque_ap()
+{
+ SetLoadAddress (load_addr, target);
+}
+
+
+
SBAddress::~SBAddress ()
{
}
@@ -110,6 +119,24 @@
return addr;
}
+void
+SBAddress::SetLoadAddress (lldb::addr_t load_addr, lldb::SBTarget &target)
+{
+ // Create the address object if we don't already have one
+ ref();
+ if (target.IsValid())
+ *this = target.ResolveLoadAddress(load_addr);
+ else
+ m_opaque_ap->Clear();
+
+ // Check if we weren't were able to resolve a section offset address.
+ // If we weren't it is ok, the load address might be a location on the
+ // stack or heap, so we should just have an address with no section and
+ // a valid offset
+ if (!m_opaque_ap->IsValid())
+ m_opaque_ap->SetOffset(load_addr);
+}
+
bool
SBAddress::OffsetAddress (addr_t offset)
{
@@ -138,7 +165,7 @@
}
lldb_private::Address &
-SBAddress::operator*()
+SBAddress::ref ()
{
if (m_opaque_ap.get() == NULL)
m_opaque_ap.reset (new lldb_private::Address);
@@ -146,8 +173,11 @@
}
const lldb_private::Address &
-SBAddress::operator*() const
+SBAddress::ref () const
{
+ // "const SBAddress &addr" should already have checked "addr.IsValid()"
+ // prior to calling this function. In case you didn't we will assert
+ // and die to let you know.
assert (m_opaque_ap.get());
return *m_opaque_ap;
}
Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Fri Jul 22 11:46:35 2011
@@ -228,7 +228,7 @@
SBModule::ResolveFileAddress (lldb::addr_t vm_addr, SBAddress& addr)
{
if (m_opaque_sp && addr.IsValid())
- return m_opaque_sp->ResolveFileAddress (vm_addr, *addr);
+ return m_opaque_sp->ResolveFileAddress (vm_addr, addr.ref());
if (addr.IsValid())
addr->Clear();
@@ -240,7 +240,7 @@
{
SBSymbolContext sb_sc;
if (m_opaque_sp && addr.IsValid())
- m_opaque_sp->ResolveSymbolContextForAddress (*addr, resolve_scope, *sb_sc);
+ m_opaque_sp->ResolveSymbolContextForAddress (addr.ref(), resolve_scope, *sb_sc);
return sb_sc;
}
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Jul 22 11:46:35 2011
@@ -503,19 +503,23 @@
m_opaque_sp = target_sp;
}
-bool
-SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr,
- lldb::SBAddress& addr)
+lldb::SBAddress
+SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
{
- if (m_opaque_sp && addr.IsValid())
+ lldb::SBAddress sb_addr;
+ Address &addr = sb_addr.ref();
+ if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
- return m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, *addr);
+ if (m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr))
+ return sb_addr;
}
- if (addr.IsValid())
- addr->Clear();
- return false;
+ // We have a load address that isn't in a section, just return an address
+ // with the offset filled in (the address) and the section set to NULL
+ addr.SetSection(NULL);
+ addr.SetOffset(vm_addr);
+ return sb_addr;
}
SBSymbolContext
@@ -523,7 +527,7 @@
{
SBSymbolContext sc;
if (m_opaque_sp && addr.IsValid())
- m_opaque_sp->GetImages().ResolveSymbolContextForAddress (*addr, resolve_scope, sc.ref());
+ m_opaque_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
return sc;
}
Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=135770&r1=135769&r2=135770&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_target.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_target.py Fri Jul 22 11:46:35 2011
@@ -23,8 +23,7 @@
contextlist = lldb.SBSymbolContextList()
obj.FindFunctions("the_func", 0xff, True, contextlist)
obj.FindGlobalVariables("my_global_var", 1)
- address = lldb.SBAddress()
- obj.ResolveLoadAddress(0xffff, address)
+ address = obj.ResolveLoadAddress(0xffff)
obj.ResolveSymbolContextForAddress(address, 0)
obj.BreakpointCreateByLocation("filename", 20)
obj.BreakpointCreateByLocation(filespec, 20)
From granata.enrico at gmail.com Fri Jul 22 12:03:19 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Fri, 22 Jul 2011 17:03:19 -0000
Subject: [Lldb-commits] [lldb] r135773 - in /lldb/trunk:
include/lldb/Core/FormatManager.h include/lldb/lldb-private-log.h
source/Core/Debugger.cpp source/Core/ValueObject.cpp source/lldb-log.cpp
test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
Message-ID: <20110722170319.4D1FC2A6C12D@llvm.org>
Author: enrico
Date: Fri Jul 22 12:03:19 2011
New Revision: 135773
URL: http://llvm.org/viewvc/llvm-project?rev=135773&view=rev
Log:
some editing of data visualization error messages to make them more meaningful
debugging printfs() for data visualization turned into a meaningful log:
- introduced a new log category `types' in channel `lldb'
Modified:
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/lldb-private-log.h
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/lldb-log.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135773&r1=135772&r2=135773&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Fri Jul 22 12:03:19 2011
@@ -46,6 +46,7 @@
#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/InputReaderStack.h"
#include "lldb/Core/Listener.h"
+#include "lldb/Core/Log.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/SourceManager.h"
@@ -58,6 +59,8 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/TargetList.h"
+using lldb::LogSP;
+
namespace lldb_private {
class IFormatChangeListener
@@ -269,13 +272,22 @@
MapValueType& entry,
uint32_t& reason)
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
if (type.isNull())
+ {
+ if (log)
+ log->Printf("type is NULL, returning");
return false;
+ }
// clang::QualType type = q_type.getUnqualifiedType();
type.removeLocalConst(); type.removeLocalVolatile(); type.removeLocalRestrict();
const clang::Type* typePtr = type.getTypePtrOrNull();
if (!typePtr)
+ {
+ if (log)
+ log->Printf("type is NULL, returning");
return false;
+ }
ConstString name(ClangASTType::GetTypeNameForQualType(type).c_str());
if (vobj.GetBitfieldBitSize() > 0)
{
@@ -283,13 +295,24 @@
StreamString sstring;
sstring.Printf("%s:%d",name.AsCString(),vobj.GetBitfieldBitSize());
name = ConstString(sstring.GetData());
+ if (log)
+ log->Printf("appended bitfield info, final result is %s", name.GetCString());
}
- //printf("trying to get format for VO name %s of type %s\n",vobj.GetName().AsCString(),name.AsCString());
+ if (log)
+ log->Printf("trying to get format for VO name %s of type %s",vobj.GetName().AsCString(),name.AsCString());
if (Get(name.GetCString(), entry))
+ {
+ if (log)
+ log->Printf("direct match found, returning");
return true;
+ }
+ if (log)
+ log->Printf("no direct match");
// look for a "base type", whatever that means
if (typePtr->isReferenceType())
{
+ if (log)
+ log->Printf("stripping reference");
if (Get(vobj,type.getNonReferenceType(),entry, reason) && !entry->m_skip_references)
{
reason |= lldb::eFormatterStrippedPointerReference;
@@ -298,6 +321,8 @@
}
if (typePtr->isPointerType())
{
+ if (log)
+ log->Printf("stripping pointer");
if (Get(vobj, typePtr->getPointeeType(), entry, reason) && !entry->m_skip_pointers)
{
reason |= lldb::eFormatterStrippedPointerReference;
@@ -306,6 +331,8 @@
}
if (typePtr->isObjCObjectPointerType())
{
+ if (log)
+ log->Printf("stripping ObjC pointer");
/*
for some reason, C++ can quite easily obtain the type hierarchy for a ValueObject
even if the VO represent a pointer-to-class, as long as the typePtr is right
@@ -325,19 +352,21 @@
const clang::ObjCObjectType *objc_class_type = typePtr->getAs();
if (objc_class_type)
{
- //printf("working with ObjC\n");
+ if (log)
+ log->Printf("working with ObjC");
clang::ASTContext *ast = vobj.GetClangAST();
if (ClangASTContext::GetCompleteType(ast, vobj.GetClangType()) && !objc_class_type->isObjCId())
{
clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
if (class_interface_decl)
{
- //printf("down here\n");
+ if (log)
+ log->Printf("got an ObjCInterfaceDecl");
clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
- //printf("one further step and we're there...\n");
if (superclass_interface_decl)
{
- //printf("the end is here\n");
+ if (log)
+ log->Printf("got a parent class for this ObjC class");
clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl));
if (Get(vobj, ivar_qual_type, entry, reason) && entry->m_cascades)
{
@@ -351,6 +380,8 @@
// for C++ classes, navigate up the hierarchy
if (typePtr->isRecordType())
{
+ if (log)
+ log->Printf("working with C++");
clang::CXXRecordDecl* record = typePtr->getAsCXXRecordDecl();
if (record)
{
@@ -361,6 +392,8 @@
clang::CXXRecordDecl::base_class_iterator pos,end;
if (record->getNumBases() > 0)
{
+ if (log)
+ log->Printf("look into bases");
end = record->bases_end();
for (pos = record->bases_begin(); pos != end; pos++)
{
@@ -373,6 +406,8 @@
}
if (record->getNumVBases() > 0)
{
+ if (log)
+ log->Printf("look into VBases");
end = record->vbases_end();
for (pos = record->vbases_begin(); pos != end; pos++)
{
@@ -390,6 +425,8 @@
const clang::TypedefType* type_tdef = type->getAs();
if (type_tdef)
{
+ if (log)
+ log->Printf("stripping typedef");
if ((Get(vobj, type_tdef->getDecl()->getUnderlyingType(), entry, reason)) && entry->m_cascades)
{
reason |= lldb::eFormatterNavigatedTypedefs;
Modified: lldb/trunk/include/lldb/lldb-private-log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-log.h?rev=135773&r1=135772&r2=135773&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-log.h (original)
+++ lldb/trunk/include/lldb/lldb-private-log.h Fri Jul 22 12:03:19 2011
@@ -38,6 +38,7 @@
#define LIBLLDB_LOG_API (1u << 16)
#define LIBLLDB_LOG_SCRIPT (1u << 17)
#define LIBLLDB_LOG_COMMANDS (1U << 18)
+#define LIBLLDB_LOG_TYPES (1u << 19)
#define LIBLLDB_LOG_ALL (UINT32_MAX)
#define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\
LIBLLDB_LOG_THREAD |\
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=135773&r1=135772&r2=135773&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Fri Jul 22 12:03:19 2011
@@ -694,18 +694,12 @@
}
}
-// FIXME this should eventually be replaced by proper use of LLDB logging facilities
-//#define VERBOSE_FORMATPROMPT_OUTPUT
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
#define IFERROR_PRINT_IT if (error.Fail()) \
{ \
- printf("ERROR: %s\n",error.AsCString("unknown")); \
+ if (log) \
+ log->Printf("ERROR: %s\n", error.AsCString("unknown")); \
break; \
}
-#else // IFERROR_PRINT_IT
-#define IFERROR_PRINT_IT if (error.Fail()) \
-break;
-#endif // IFERROR_PRINT_IT
static bool
ScanFormatDescriptor(const char* var_name_begin,
@@ -715,36 +709,55 @@
lldb::Format* custom_format,
ValueObject::ValueObjectRepresentationStyle* val_obj_display)
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
*percent_position = ::strchr(var_name_begin,'%');
if (!*percent_position || *percent_position > var_name_end)
+ {
+ if (log)
+ log->Printf("no format descriptor in string, skipping");
*var_name_final = var_name_end;
+ }
else
{
*var_name_final = *percent_position;
char* format_name = new char[var_name_end-*var_name_final]; format_name[var_name_end-*var_name_final-1] = '\0';
memcpy(format_name, *var_name_final+1, var_name_end-*var_name_final-1);
+ if (log)
+ log->Printf("parsing %s as a format descriptor", format_name);
if ( !FormatManager::GetFormatFromCString(format_name,
true,
*custom_format) )
{
+ if (log)
+ log->Printf("%s is an unknown format", format_name);
// if this is an @ sign, print ObjC description
if (*format_name == '@')
*val_obj_display = ValueObject::eDisplayLanguageSpecific;
// if this is a V, print the value using the default format
- if (*format_name == 'V')
+ else if (*format_name == 'V')
*val_obj_display = ValueObject::eDisplayValue;
// if this is an L, print the location of the value
- if (*format_name == 'L')
+ else if (*format_name == 'L')
*val_obj_display = ValueObject::eDisplayLocation;
// if this is an S, print the summary after all
- if (*format_name == 'S')
+ else if (*format_name == 'S')
*val_obj_display = ValueObject::eDisplaySummary;
+ else if (log)
+ log->Printf("%s is an error, leaving the previous value alone", format_name);
}
// a good custom format tells us to print the value using it
else
+ {
+ if (log)
+ log->Printf("will display value for this VO");
*val_obj_display = ValueObject::eDisplayValue;
+ }
delete format_name;
}
+ if (log)
+ log->Printf("final format description outcome: custom_format = %d, val_obj_display = %d",
+ *custom_format,
+ *val_obj_display);
return true;
}
@@ -759,6 +772,7 @@
int64_t* index_lower,
int64_t* index_higher)
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
*open_bracket_position = ::strchr(var_name_begin,'[');
if (*open_bracket_position && *open_bracket_position < var_name_final)
{
@@ -769,6 +783,8 @@
*var_name_final_if_array_range = *open_bracket_position;
if (*close_bracket_position - *open_bracket_position == 1)
{
+ if (log)
+ log->Printf("[] detected.. going from 0 to end of data");
*index_lower = 0;
}
else if (*separator_position == NULL || *separator_position > var_name_end)
@@ -776,24 +792,34 @@
char *end = NULL;
*index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
*index_higher = *index_lower;
- //printf("got to read low=%d high same\n",bitfield_lower);
+ if (log)
+ log->Printf("[%d] detected, high index is same",index_lower);
}
else if (*close_bracket_position && *close_bracket_position < var_name_end)
{
char *end = NULL;
*index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
*index_higher = ::strtoul (*separator_position+1, &end, 0);
- //printf("got to read low=%d high=%d\n",bitfield_lower,bitfield_higher);
+ if (log)
+ log->Printf("[%d-%d] detected",index_lower,index_higher);
}
else
+ {
+ if (log)
+ log->Printf("expression is erroneous, cannot extract indices out of it");
return false;
+ }
if (*index_lower > *index_higher && *index_higher > 0)
{
+ if (log)
+ log->Printf("swapping indices");
int temp = *index_lower;
*index_lower = *index_higher;
*index_higher = temp;
}
}
+ else if (log)
+ log->Printf("no bracketed range, skipping entirely");
return true;
}
@@ -806,26 +832,30 @@
const char* var_name_final,
Error& error)
{
-
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
StreamString sstring;
VariableSP var_sp;
if (*do_deref_pointer)
+ {
+ if (log)
+ log->Printf("been told to deref_pointer by caller");
sstring.PutChar('*');
+ }
else if (vobj->IsDereferenceOfParent() && ClangASTContext::IsPointerType(vobj->GetParent()->GetClangType()) && !vobj->IsArrayItemForPointer())
{
+ if (log)
+ log->Printf("decided to deref_pointer myself");
sstring.PutChar('*');
*do_deref_pointer = true;
}
vobj->GetExpressionPath(sstring, true, ValueObject::eHonorPointers);
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("name to expand in phase 0: %s\n",sstring.GetData());
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("expression path to expand in phase 0: %s",sstring.GetData());
sstring.PutRawBytes(var_name_begin+3, var_name_final-var_name_begin-3);
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("name to expand in phase 1: %s\n",sstring.GetData());
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("expression path to expand in phase 1: %s",sstring.GetData());
std::string name = std::string(sstring.GetData());
ValueObjectSP target = frame->GetValueForVariableExpressionPath (name.c_str(),
eNoDynamicValues,
@@ -841,12 +871,12 @@
StackFrame* frame,
bool deref_pointer)
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
const char* ptr_deref_format = "[%d]";
std::auto_ptr ptr_deref_buffer(new char[10]);
::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index);
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("name to deref: %s\n",ptr_deref_buffer.get());
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("name to deref: %s",ptr_deref_buffer.get());
const char* first_unparsed;
ValueObject::GetValueForExpressionPathOptions options;
ValueObject::ExpressionPathEndResultType final_value_type;
@@ -860,20 +890,18 @@
&what_next);
if (!item)
{
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("ERROR: unparsed portion = %s, why stopping = %d,"
- " final_value_type %d\n",
+ if (log)
+ log->Printf("ERROR: unparsed portion = %s, why stopping = %d,"
+ " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type);
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
}
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
else
{
- printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
- " final_value_type %d\n",
+ if (log)
+ log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
+ " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type);
}
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
return item;
}
@@ -892,6 +920,7 @@
ValueObject* realvobj = NULL; // makes it super-easy to parse pointers
bool success = true;
const char *p;
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
for (p = format; *p != '\0'; ++p)
{
if (realvobj)
@@ -967,8 +996,8 @@
const RegisterInfo *reg_info = NULL;
RegisterContext *reg_ctx = NULL;
bool do_deref_pointer = false;
- ValueObject::ExpressionPathScanEndReason reason_to_stop;
- ValueObject::ExpressionPathEndResultType final_value_type;
+ ValueObject::ExpressionPathScanEndReason reason_to_stop = ValueObject::eEndOfString;
+ ValueObject::ExpressionPathEndResultType final_value_type = ValueObject::ePlain;
// Each variable must set success to true below...
bool var_success = false;
@@ -1050,9 +1079,8 @@
::memset(expr_path.get(), 0, var_name_final-var_name_begin-1);
memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3);
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("symbol to expand: %s\n",expr_path.get());
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("symbol to expand: %s",expr_path.get());
target = vobj->GetValueForExpressionPath(expr_path.get(),
&first_unparsed,
@@ -1063,21 +1091,19 @@
if (!target)
{
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("ERROR: unparsed portion = %s, why stopping = %d,"
- " final_value_type %d\n",
+ if (log)
+ log->Printf("ERROR: unparsed portion = %s, why stopping = %d,"
+ " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type);
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
break;
}
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
else
{
- printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
- " final_value_type %d\n",
+ if (log)
+ log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
+ " final_value_type %d",
first_unparsed, reason_to_stop, final_value_type);
}
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
}
else
break;
@@ -1103,26 +1129,31 @@
if ((is_array || is_pointer) && (!is_array_range) && val_obj_display == ValueObject::eDisplayValue) // this should be wrong, but there are some exceptions
{
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("I am into array || pointer && !range\n");
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("I am into array || pointer && !range");
// try to use the special cases
var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format);
if (!var_success)
s << "";
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("outcome was : %s\n", var_success ? "good" : "bad");
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("special cases did%s match", var_success ? "" : "n't");
break;
}
if (!is_array_range)
+ {
+ if (log)
+ log->Printf("dumping ordinary printable output");
var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format);
+ }
else
- {
+ {
+ if (log)
+ log->Printf("checking if I can handle as array");
if (!is_array && !is_pointer)
break;
-
+ if (log)
+ log->Printf("handle as array");
const char* special_directions = NULL;
StreamString special_directions_writer;
if (close_bracket_position && (var_name_end-close_bracket_position > 1))
@@ -1151,16 +1182,14 @@
if (!item)
{
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
- printf("ERROR\n");
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
+ if (log)
+ log->Printf("ERROR in getting child item at index %d", index_lower);
}
-#ifdef VERBOSE_FORMATPROMPT_OUTPUT
else
{
- printf("special_directions: %s\n",special_directions);
+ if (log)
+ log->Printf("special_directions for child item: %s",special_directions);
}
-#endif //VERBOSE_FORMATPROMPT_OUTPUT
if (!special_directions)
var_success &= item->DumpPrintableRepresentation(s,val_obj_display, custom_format);
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=135773&r1=135772&r2=135773&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Jul 22 12:03:19 2011
@@ -885,6 +885,9 @@
return m_value_str.c_str();
}
+// this call should only return pointers to data that needs no special memory management
+// (either because they are hardcoded strings, or because they are backed by some other
+// object); returning any new()-ed or malloc()-ed data here, will lead to leaks!
const char *
ValueObject::GetPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display,
lldb::Format custom_format)
@@ -921,10 +924,18 @@
if (val_obj_display == eDisplayValue)
return_value = GetSummaryAsCString();
else if (val_obj_display == eDisplaySummary)
- return_value = GetValueAsCString();
+ {
+ if (ClangASTContext::IsAggregateType (GetClangType()) == true)
+ {
+ // this thing has no value
+ return_value = "";
+ }
+ else
+ return_value = GetValueAsCString();
+ }
}
- return (return_value ? return_value : "");
+ return (return_value ? return_value : "");
}
@@ -980,7 +991,7 @@
ValueObjectSP child = GetChildAtIndex(low,true);
if (!child.get())
{
- s << "";
+ s << "";
continue;
}
child->DumpPrintableRepresentation(s, ValueObject::eDisplayValue, custom_format);
@@ -1018,7 +1029,7 @@
ValueObjectSP child = GetChildAtIndex(low,true);
if (!child.get())
{
- s << "";
+ s << "";
continue;
}
child->DumpPrintableRepresentation(s, ValueObject::eDisplayValue, format);
Modified: lldb/trunk/source/lldb-log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=135773&r1=135772&r2=135773&view=diff
==============================================================================
--- lldb/trunk/source/lldb-log.cpp (original)
+++ lldb/trunk/source/lldb-log.cpp Fri Jul 22 12:03:19 2011
@@ -134,6 +134,7 @@
else if (0 == ::strncasecmp(arg, "conn", 4)) flag_bits &= ~LIBLLDB_LOG_CONNECTION;
else if (0 == ::strncasecmp(arg, "host", 4)) flag_bits &= ~LIBLLDB_LOG_HOST;
else if (0 == ::strncasecmp(arg, "unwind", 6)) flag_bits &= ~LIBLLDB_LOG_UNWIND;
+ else if (0 == ::strncasecmp(arg, "types", 5)) flag_bits &= ~LIBLLDB_LOG_TYPES;
else
{
feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg);
@@ -200,6 +201,7 @@
else if (0 == ::strncasecmp(arg, "conn", 4)) flag_bits |= LIBLLDB_LOG_CONNECTION;
else if (0 == ::strncasecmp(arg, "host", 4)) flag_bits |= LIBLLDB_LOG_HOST;
else if (0 == ::strncasecmp(arg, "unwind", 6)) flag_bits |= LIBLLDB_LOG_UNWIND;
+ else if (0 == ::strncasecmp(arg, "types", 5)) flag_bits |= LIBLLDB_LOG_TYPES;
else
{
feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
@@ -238,5 +240,6 @@
"\tstep - log step related activities\n"
"\tunwind - log stack unwind activities\n"
"\tverbose - enable verbose logging\n"
- "\twatch - log watchpoint related activities\n");
+ "\twatch - log watchpoint related activities\n"
+ "\ttypes - log type system related activities\n");
}
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py?rev=135773&r1=135772&r2=135773&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py Fri Jul 22 12:03:19 2011
@@ -57,7 +57,7 @@
self.runCmd("type summary add -f \"${var%V}\" SomeData")
self.expect("frame variable data",
- substrs = ['error'])
+ substrs = ['no printable representation'])
# ${var%s}
self.runCmd("type summary add -f \"ptr = ${var%s}\" \"char *\"")
@@ -198,12 +198,13 @@
'{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}'])
# printing full array as an array
+ self.runCmd("log enable lldb types -f dummy.log")
self.runCmd("type summary add -f \"arr = ${var%uint32_t[]}\" \"int [5]\"")
self.expect("frame variable intarr",
substrs = ['intarr = arr =',
'0x00000001,0x00000001,0x00000002,0x00000003,0x00000005'])
-
+ self.runCmd("log disable lldb types")
self.expect("frame variable other.intarr",
substrs = ['intarr = arr =',
'0x00000009,0x00000008,0x00000007,0x00000006,0x00000005'])
From peter at pcc.me.uk Fri Jul 22 14:12:43 2011
From: peter at pcc.me.uk (Peter Collingbourne)
Date: Fri, 22 Jul 2011 19:12:43 -0000
Subject: [Lldb-commits] [lldb] r135790 - in /lldb/trunk:
include/lldb/Host/SocketAddress.h source/Core/ConnectionFileDescriptor.cpp
source/Host/common/SocketAddress.cpp
Message-ID: <20110722191243.129082A6C12D@llvm.org>
Author: pcc
Date: Fri Jul 22 14:12:42 2011
New Revision: 135790
URL: http://llvm.org/viewvc/llvm-project?rev=135790&view=rev
Log:
Add support for platforms without sa_len to SocketAddress, and modify
some code to use it
Modified:
lldb/trunk/include/lldb/Host/SocketAddress.h
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
lldb/trunk/source/Host/common/SocketAddress.cpp
Modified: lldb/trunk/include/lldb/Host/SocketAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/SocketAddress.h?rev=135790&r1=135789&r2=135790&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/SocketAddress.h (original)
+++ lldb/trunk/include/lldb/Host/SocketAddress.h Fri Jul 22 14:12:42 2011
@@ -76,13 +76,6 @@
GetMaxLength ();
//------------------------------------------------------------------
- // Set the length manually if supported in the socket address
- // structures
- //------------------------------------------------------------------
- void
- SetLength (socklen_t len);
-
- //------------------------------------------------------------------
// Get the socket address family
//------------------------------------------------------------------
sa_family_t
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=135790&r1=135789&r2=135790&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Fri Jul 22 14:12:42 2011
@@ -842,14 +842,10 @@
else
{
// Socket was created, now lets bind to the requested port
- struct sockaddr_in sin;
- ::memset (&sin, 0, sizeof(sin));
- sin.sin_len = sizeof(sin);
- sin.sin_family = AF_INET;
- sin.sin_port = 0;
- sin.sin_addr.s_addr = htonl (INADDR_ANY);
+ SocketAddress addr;
+ addr.SetToLocalhost (AF_INET, 0);
- if (::bind (m_fd_recv, (struct sockaddr *)&sin, sizeof(sin)) == -1)
+ if (::bind (m_fd_recv, addr, addr.GetLength()) == -1)
{
// Bind failed...
if (error_ptr)
Modified: lldb/trunk/source/Host/common/SocketAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SocketAddress.cpp?rev=135790&r1=135789&r2=135790&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/SocketAddress.cpp (original)
+++ lldb/trunk/source/Host/common/SocketAddress.cpp Fri Jul 22 14:12:42 2011
@@ -11,6 +11,7 @@
#include
// C Includes
+#include
#include
// C++ Includes
@@ -77,10 +78,25 @@
return GetLength () != 0;
}
+static socklen_t
+GetFamilyLength (sa_family_t family)
+{
+ switch (family)
+ {
+ case AF_INET: return sizeof(struct sockaddr_in);
+ case AF_INET6: return sizeof(struct sockaddr_in6);
+ }
+ assert(0 && "Unsupported address family");
+}
+
socklen_t
SocketAddress::GetLength () const
{
+#if defined(__APPLE__)
return m_socket_addr.sa.sa_len;
+#else
+ return GetFamilyLength (GetFamily());
+#endif
}
socklen_t
@@ -89,12 +105,6 @@
return sizeof (sockaddr_t);
}
-void
-SocketAddress::SetLength (socklen_t len)
-{
- m_socket_addr.sa.sa_len = len;
-}
-
sa_family_t
SocketAddress::GetFamily () const
{
@@ -105,6 +115,9 @@
SocketAddress::SetFamily (sa_family_t family)
{
m_socket_addr.sa.sa_family = family;
+#if defined(__APPLE__)
+ m_socket_addr.sa.sa_len = GetFamilyLength (family);
+#endif
}
in_port_t
@@ -228,7 +241,6 @@
if (SetPort (port))
{
m_socket_addr.sa_ipv4.sin_addr.s_addr = htonl (INADDR_ANY);
- SetLength (sizeof(m_socket_addr.sa_ipv4));
return true;
}
break;
@@ -238,7 +250,6 @@
if (SetPort (port))
{
m_socket_addr.sa_ipv6.sin6_addr = in6addr_any;
- SetLength (sizeof(m_socket_addr.sa_ipv6));
return true;
}
break;
From peter at pcc.me.uk Fri Jul 22 14:12:54 2011
From: peter at pcc.me.uk (Peter Collingbourne)
Date: Fri, 22 Jul 2011 19:12:54 -0000
Subject: [Lldb-commits] [lldb] r135791 - in
/lldb/trunk/source/Plugins/Process/Linux: ProcessLinux.cpp ProcessLinux.h
Message-ID: <20110722191254.1F66D2A6C12D@llvm.org>
Author: pcc
Date: Fri Jul 22 14:12:53 2011
New Revision: 135791
URL: http://llvm.org/viewvc/llvm-project?rev=135791&view=rev
Log:
Update ProcessLinux::CanDebug prototype
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=135791&r1=135790&r2=135791&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Fri Jul 22 14:12:53 2011
@@ -93,7 +93,7 @@
// Process protocol.
bool
-ProcessLinux::CanDebug(Target &target)
+ProcessLinux::CanDebug(Target &target, bool plugin_specified_by_name)
{
// For now we are just making sure the file exists for a given module
ModuleSP exe_module_sp(target.GetExecutableModule());
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h?rev=135791&r1=135790&r2=135791&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Fri Jul 22 14:12:53 2011
@@ -58,7 +58,7 @@
// Process protocol.
//------------------------------------------------------------------
virtual bool
- CanDebug(lldb_private::Target &target);
+ CanDebug(lldb_private::Target &target, bool plugin_specified_by_name);
virtual lldb_private::Error
WillLaunch(lldb_private::Module *module);
From peter at pcc.me.uk Fri Jul 22 14:13:02 2011
From: peter at pcc.me.uk (Peter Collingbourne)
Date: Fri, 22 Jul 2011 19:13:02 -0000
Subject: [Lldb-commits] [lldb] r135792 - in
/lldb/trunk/source/Plugins/Process/Utility: RegisterContextDarwin_arm.cpp
RegisterContextDarwin_x86_64.cpp
Message-ID: <20110722191302.8CAA02A6C12D@llvm.org>
Author: pcc
Date: Fri Jul 22 14:13:02 2011
New Revision: 135792
URL: http://llvm.org/viewvc/llvm-project?rev=135792&view=rev
Log:
Disable compilation of RegisterContextDarwin_arm.cpp on non-Darwin platforms,
and fix RegisterContextDarwin_x86_64.cpp build
RegisterContextDarwin_arm.cpp contains too much platform specific code
to easily fix.
Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp?rev=135792&r1=135791&r2=135792&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp Fri Jul 22 14:13:02 2011
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#if defined(__APPLE__)
+
#include "RegisterContextDarwin_arm.h"
// C Includes
@@ -1213,4 +1215,4 @@
return false;
}
-
+#endif
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp?rev=135792&r1=135791&r2=135792&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp Fri Jul 22 14:13:02 2011
@@ -9,6 +9,8 @@
// C Includes
+#include
+
// C++ Includes
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
From johnny.chen at apple.com Fri Jul 22 14:18:46 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Fri, 22 Jul 2011 19:18:46 -0000
Subject: [Lldb-commits] [lldb] r135793 -
/lldb/trunk/test/python_api/default-constructor/sb_address.py
Message-ID: <20110722191846.19CE52A6C12D@llvm.org>
Author: johnny
Date: Fri Jul 22 14:18:45 2011
New Revision: 135793
URL: http://llvm.org/viewvc/llvm-project?rev=135793&view=rev
Log:
Add new API for SBAddress to the fuzz test:
SetLoadAddress (lldb::addr_t load_addr,
lldb::SBTarget &target);
Modified:
lldb/trunk/test/python_api/default-constructor/sb_address.py
Modified: lldb/trunk/test/python_api/default-constructor/sb_address.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_address.py?rev=135793&r1=135792&r2=135793&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_address.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_address.py Fri Jul 22 14:18:45 2011
@@ -8,6 +8,7 @@
def fuzz_obj(obj):
obj.GetFileAddress()
obj.GetLoadAddress(lldb.SBTarget())
+ obj.SetLoadAddress(0xffff, lldb.SBTarget())
obj.OffsetAddress(sys.maxint)
obj.GetDescription(lldb.SBStream())
obj.Clear()
From johnny.chen at apple.com Fri Jul 22 17:01:35 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Fri, 22 Jul 2011 22:01:35 -0000
Subject: [Lldb-commits] [lldb] r135815 - in /lldb/trunk/test: lldbutil.py
python_api/value/TestValueAPI.py python_api/value/main.c
Message-ID: <20110722220135.DF05C2A6C12D@llvm.org>
Author: johnny
Date: Fri Jul 22 17:01:35 2011
New Revision: 135815
URL: http://llvm.org/viewvc/llvm-project?rev=135815&view=rev
Log:
Add an additional formatter class RecursiveDecentFormatter which prints the
value and the decendents. For an example,
rdf = lldbutil.RecursiveDecentFormatter(indent_child=2)
print rdf.format(g_table)
produces:
(const char **[2]) g_table = 0x00000001055a80f0 (location)
(const char **) [0] = 0x00000001055a8080
(const char *) *[0] = "Sunday"
(const char **) [1] = 0x00000001055a80c0
(const char *) *[1] = "Monday"
Modified:
lldb/trunk/test/lldbutil.py
lldb/trunk/test/python_api/value/TestValueAPI.py
lldb/trunk/test/python_api/value/main.c
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=135815&r1=135814&r2=135815&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Fri Jul 22 17:01:35 2011
@@ -533,25 +533,34 @@
# ======================================
class BasicFormatter(object):
+ """The basic formatter inspects the value object and prints the value."""
def format(self, value, buffer=None, indent=0):
if not buffer:
output = StringIO.StringIO()
else:
output = buffer
- sum = value.GetSummary()
- if value.GetNumChildren() > 0 and sum == None:
- sum = "%s (location)" % value.GetLocation()
- print >> output, "{indentation}({type}) {name} = {summary}".format(
+ # If there is a summary, it suffices.
+ val = value.GetSummary()
+ # Otherwise, get the value.
+ if val == None:
+ val = value.GetValue()
+ if val == None and value.GetNumChildren() > 0:
+ val = "%s (location)" % value.GetLocation()
+ print >> output, "{indentation}({type}) {name} = {value}".format(
indentation = ' ' * indent,
type = value.GetTypeName(),
name = value.GetName(),
- summary = sum)
+ value = val)
return output.getvalue()
class ChildVisitingFormatter(BasicFormatter):
- def __init__(self, indent=2):
- """Default indentation of 2 SPC's."""
- self.indentation = indent
+ """The child visiting formatter prints the value and its immediate children.
+
+ The constructor takes a keyword arg: indent_child, which defaults to 2.
+ """
+ def __init__(self, indent_child=2):
+ """Default indentation of 2 SPC's for the children."""
+ self.cindent = indent_child
def format(self, value, buffer=None):
if not buffer:
output = StringIO.StringIO()
@@ -560,6 +569,37 @@
BasicFormatter.format(self, value, buffer=output)
for child in value:
- BasicFormatter.format(self, child, buffer=output, indent=self.indentation)
+ BasicFormatter.format(self, child, buffer=output, indent=self.cindent)
+
+ return output.getvalue()
+
+class RecursiveDecentFormatter(BasicFormatter):
+ """The recursive decent formatter prints the value and the decendents.
+
+ The constructor takes two keyword args: indent_level, which defaults to 0,
+ and indent_child, which defaults to 2. The current indentation level is
+ determined by indent_level, while the immediate children has an additional
+ indentation by inden_child.
+ """
+ def __init__(self, indent_level=0, indent_child=2):
+ self.lindent = indent_level
+ self.cindent = indent_child
+ def format(self, value, buffer=None):
+ if not buffer:
+ output = StringIO.StringIO()
+ else:
+ output = buffer
+
+ BasicFormatter.format(self, value, buffer=output, indent=self.lindent)
+ new_indent = self.lindent + self.cindent
+ for child in value:
+ if child.GetSummary() != None:
+ BasicFormatter.format(self, child, buffer=output, indent=new_indent)
+ else:
+ if child.GetNumChildren() > 0:
+ rdf = RecursiveDecentFormatter(indent_level=new_indent)
+ rdf.format(child, buffer=output)
+ else:
+ BasicFormatter.format(self, child, buffer=output, indent=new_indent)
return output.getvalue()
Modified: lldb/trunk/test/python_api/value/TestValueAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/TestValueAPI.py?rev=135815&r1=135814&r2=135815&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/TestValueAPI.py (original)
+++ lldb/trunk/test/python_api/value/TestValueAPI.py Fri Jul 22 17:01:35 2011
@@ -66,11 +66,28 @@
self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE)
self.DebugSBValue(days_of_week)
+ # Get global variable 'weekdays'.
+ list = target.FindGlobalVariables('weekdays', 1)
+ weekdays = list.GetValueAtIndex(0)
+ self.assertTrue(weekdays, VALID_VARIABLE)
+ self.assertTrue(weekdays.GetNumChildren() == 5, VALID_VARIABLE)
+ self.DebugSBValue(weekdays)
+
+ # Get global variable 'g_table'.
+ list = target.FindGlobalVariables('g_table', 1)
+ g_table = list.GetValueAtIndex(0)
+ self.assertTrue(g_table, VALID_VARIABLE)
+ self.assertTrue(g_table.GetNumChildren() == 2, VALID_VARIABLE)
+ self.DebugSBValue(g_table)
+
fmt = lldbutil.BasicFormatter()
- cvf = lldbutil.ChildVisitingFormatter(indent=2)
+ cvf = lldbutil.ChildVisitingFormatter(indent_child=2)
+ rdf = lldbutil.RecursiveDecentFormatter(indent_child=2)
if self.TraceOn():
print fmt.format(days_of_week)
print cvf.format(days_of_week)
+ print cvf.format(weekdays)
+ print rdf.format(g_table)
# Get variable 'str_ptr'.
value = frame0.FindVariable('str_ptr')
Modified: lldb/trunk/test/python_api/value/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/main.c?rev=135815&r1=135814&r2=135815&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/main.c (original)
+++ lldb/trunk/test/python_api/value/main.c Fri Jul 22 17:01:35 2011
@@ -20,6 +20,14 @@
"Friday",
"Saturday" };
+const char *weekdays[5] = { "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday" };
+
+const char **g_table[2] = { days_of_week, weekdays };
+
int main (int argc, char const *argv[])
{
int i;
From jingham at apple.com Fri Jul 22 19:12:05 2011
From: jingham at apple.com (Jim Ingham)
Date: Sat, 23 Jul 2011 00:12:05 -0000
Subject: [Lldb-commits] [lldb] r135827 - in /lldb/trunk:
examples/summaries/lldb
source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Message-ID: <20110723001205.4EAF42A6C12D@llvm.org>
Author: jingham
Date: Fri Jul 22 19:12:05 2011
New Revision: 135827
URL: http://llvm.org/viewvc/llvm-project?rev=135827&view=rev
Log:
Don't delete & remake the exception breakpoints every time you need them. Make them once & enable/disable
them as appropriate.
Also reformatted the lldb summaries to make them easier to read, and added one. I'll do more as I get time.
Modified:
lldb/trunk/examples/summaries/lldb
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Modified: lldb/trunk/examples/summaries/lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/lldb?rev=135827&r1=135826&r2=135827&view=diff
==============================================================================
--- lldb/trunk/examples/summaries/lldb (original)
+++ lldb/trunk/examples/summaries/lldb Fri Jul 22 19:12:05 2011
@@ -1,12 +1,13 @@
-type summary add -f "Type: ${var.m_type%E}, Code: ${var.m_code}, Message: ${var.m_string}" lldb_private::Error -w lldb
-type summary add -f "${var.m_string}" lldb_private::ConstString -w lldb
-type summary add -f "${var.m_language%E}" lldb_private::Language -w lldb
-type summary add -f "${var.m_re}" lldb_private::RegularExpression -w lldb
-type summary add -f "UserID(${var.m_uid})" lldb_private::UserID -w lldb
-type summary add -f "${var.m_name}" lldb_private::ValueObject -w lldb
-type summary add -f "${var.ptr_.m_name}" lldb_private::ValueObjectSP -w lldb
-type summary add -f "${var.m_reg_info.name}" lldb_private::ValueObjectRegister -w lldb
-type summary add -f "{${var.m_expr_text}}" lldb_private::ClangExpression -w lldb
-type summary add -f "Command name: ${var.m_cmd_name}" lldb_private::CommandObject -w lldb
-type summary add -f "${var.m_type.m_name} ${var.m_name}" lldb_private::Variable -w lldb
-type summary add -f "ID: ${var.m_stop_id}, ${var.m_description}" lldb_private::StopInfo -w lldb
+type summary add -w lldb lldb_private::Error -f "Type: ${var.m_type%E}, Code: ${var.m_code}, Message: ${var.m_string}"
+type summary add -w lldb lldb_private::ConstString -f "${var.m_string}"
+type summary add -w lldb lldb_private::Language -f "${var.m_language%E}"
+type summary add -w lldb lldb_private::RegularExpression -f "${var.m_re}"
+type summary add -w lldb lldb_private::UserID -f "UserID(${var.m_uid})"
+type summary add -w lldb lldb_private::ValueObject -f "${var.m_name}"
+type summary add -w lldb lldb_private::ValueObjectSP -f "${var.ptr_.m_name}"
+type summary add -w lldb lldb_private::ValueObjectRegister -f "${var.m_reg_info.name}"
+type summary add -w lldb lldb_private::ClangExpression -f "{${var.m_expr_text}}"
+type summary add -w lldb lldb_private::CommandObject -f "Command name: ${var.m_cmd_name}"
+type summary add -w lldb lldb_private::Variable -f "${var.m_type.m_name} ${var.m_name}"
+type summary add -w lldb lldb_private::StopInfo -f "ID: ${var.m_stop_id}, ${var.m_description}"
+type summary add -w lldb lldb_private::FileSpec -f "file: ${var.m_filename} dir: ${var.m_directory}"
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=135827&r1=135826&r2=135827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Fri Jul 22 19:12:05 2011
@@ -265,12 +265,16 @@
"__cxa_throw",
eFunctionNameTypeBase,
true);
+ else
+ m_cxx_exception_bp_sp->SetEnabled (true);
if (!m_cxx_exception_alloc_bp_sp)
m_cxx_exception_alloc_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL,
"__cxa_allocate",
eFunctionNameTypeBase,
true);
+ else
+ m_cxx_exception_alloc_bp_sp->SetEnabled (true);
}
void
@@ -281,14 +285,12 @@
if (m_cxx_exception_bp_sp.get())
{
- m_process->GetTarget().RemoveBreakpointByID(m_cxx_exception_bp_sp->GetID());
- m_cxx_exception_bp_sp.reset();
+ m_cxx_exception_bp_sp->SetEnabled (false);
}
if (m_cxx_exception_alloc_bp_sp.get())
{
- m_process->GetTarget().RemoveBreakpointByID(m_cxx_exception_alloc_bp_sp->GetID());
- m_cxx_exception_bp_sp.reset();
+ m_cxx_exception_bp_sp->SetEnabled (false);
}
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=135827&r1=135826&r2=135827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Fri Jul 22 19:12:05 2011
@@ -284,8 +284,7 @@
if (m_objc_exception_bp_sp.get())
{
- m_process->GetTarget().RemoveBreakpointByID(m_objc_exception_bp_sp->GetID());
- m_objc_exception_bp_sp.reset();
+ m_objc_exception_bp_sp->SetEnabled (false);
}
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=135827&r1=135826&r2=135827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Fri Jul 22 19:12:05 2011
@@ -118,6 +118,8 @@
eFunctionNameTypeBase,
true);
}
+ else
+ m_objc_exception_bp_sp->SetEnabled (true);
}
struct BufStruct {
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=135827&r1=135826&r2=135827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Fri Jul 22 19:12:05 2011
@@ -480,6 +480,8 @@
eFunctionNameTypeBase,
true);
}
+ else
+ m_objc_exception_bp_sp->SetEnabled (true);
}
ClangUtilityFunction *
From granata.enrico at gmail.com Sat Jul 23 19:14:56 2011
From: granata.enrico at gmail.com (Enrico Granata)
Date: Sun, 24 Jul 2011 00:14:56 -0000
Subject: [Lldb-commits] [lldb] r135865 - in /lldb/trunk: include/lldb/
include/lldb/API/ include/lldb/Core/ include/lldb/Interpreter/
include/lldb/Utility/ lldb.xcodeproj/ scripts/ source/API/ source/Commands/
source/Core/ source/Interpreter/
test/functionalities/data-formatter/data-formatter-python-synth/
Message-ID: <20110724001456.D970F2A6C12D@llvm.org>
Author: enrico
Date: Sat Jul 23 19:14:56 2011
New Revision: 135865
URL: http://llvm.org/viewvc/llvm-project?rev=135865&view=rev
Log:
Python synthetic children:
- you can now define a Python class as a synthetic children producer for a type
the class must adhere to this "interface":
def __init__(self, valobj, dict):
def get_child_at_index(self, index):
def get_child_index(self, name):
then using type synth add -l className typeName
(e.g. type synth add -l fooSynthProvider foo)
(This is still WIP with lots to be added)
A small test case is available also as reference
Added:
lldb/trunk/include/lldb/Utility/PythonPointer.h
lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/
lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
Modified:
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/FormatClasses.h
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
lldb/trunk/include/lldb/lldb-forward-rtti.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/lldb.swig
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/FormatClasses.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
lldb/trunk/source/Interpreter/CommandObjectScript.cpp
lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=135865&r1=135864&r2=135865&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Sat Jul 23 19:14:56 2011
@@ -14,6 +14,10 @@
#include
+#ifndef SWIG
+class lldb_private::SyntheticScriptProvider;
+#endif
+
namespace lldb {
class SBValue
@@ -205,7 +209,9 @@
friend class SBFrame;
#ifndef SWIG
-
+ // need this to decapsulate the SP from here
+ friend class lldb_private::SyntheticScriptProvider;
+
// Mimic shared pointer...
lldb_private::ValueObject *
get() const;
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=135865&r1=135864&r2=135865&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Sat Jul 23 19:14:56 2011
@@ -477,6 +477,11 @@
class Formatting
{
public:
+
+ // use this call to force the FM to consider itself updated even when there is no apparent reason for that
+ static void
+ ForceUpdate();
+
class ValueFormats
{
public:
@@ -507,7 +512,7 @@
lldb::SummaryFormatSP& entry);
static bool
GetSyntheticFilter(ValueObject& vobj,
- lldb::SyntheticFilterSP& entry);
+ lldb::SyntheticChildrenSP& entry);
class NamedSummaryFormats
{
Modified: lldb/trunk/include/lldb/Core/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=135865&r1=135864&r2=135865&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/Core/FormatClasses.h Sat Jul 23 19:14:56 2011
@@ -12,6 +12,12 @@
// C Includes
+#if defined (__APPLE__)
+#include
+#else
+#include
+#endif
+
#include
#include
@@ -25,6 +31,7 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/API/SBValue.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -82,19 +89,90 @@
};
-struct SyntheticFilter
+class SyntheticChildrenFrontEnd
{
+protected:
+ lldb::ValueObjectSP m_backend;
+public:
+
+ SyntheticChildrenFrontEnd(lldb::ValueObjectSP be) :
+ m_backend(be)
+ {}
+
+ virtual
+ ~SyntheticChildrenFrontEnd()
+ {
+ }
+
+ virtual uint32_t
+ CalculateNumChildren() = 0;
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (uint32_t idx, bool can_create) = 0;
+
+ virtual uint32_t
+ GetIndexOfChildWithName (const ConstString &name) = 0;
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+
+};
+
+class SyntheticChildren
+{
+public:
bool m_cascades;
bool m_skip_pointers;
bool m_skip_references;
- std::vector m_expression_paths;
+public:
+ SyntheticChildren(bool casc = false,
+ bool skipptr = false,
+ bool skipref = false) :
+ m_cascades(casc),
+ m_skip_pointers(skipptr),
+ m_skip_references(skipref)
+ {
+ }
+ virtual
+ ~SyntheticChildren()
+ {
+ }
+
+ bool
+ Cascades() const
+ {
+ return m_cascades;
+ }
+ bool
+ SkipsPointers() const
+ {
+ return m_skip_pointers;
+ }
+ bool
+ SkipsReferences() const
+ {
+ return m_skip_references;
+ }
+
+ virtual std::string
+ GetDescription() = 0;
+
+ virtual SyntheticChildrenFrontEnd::SharedPointer
+ GetFrontEnd(lldb::ValueObjectSP backend) = 0;
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+ typedef bool(*SyntheticChildrenCallback)(void*, const char*, const SyntheticChildren::SharedPointer&);
+
+};
+
+class SyntheticFilter : public SyntheticChildren
+{
+ std::vector m_expression_paths;
+public:
SyntheticFilter(bool casc = false,
bool skipptr = false,
bool skipref = false) :
- m_cascades(casc),
- m_skip_pointers(skipptr),
- m_skip_references(skipref),
+ SyntheticChildren(casc, skipptr, skipref),
m_expression_paths()
{
}
@@ -129,10 +207,149 @@
std::string
GetDescription();
- typedef lldb::SharedPtr::Type SharedPointer;
- typedef bool(*SyntheticFilterCallback)(void*, const char*, const SyntheticFilter::SharedPointer&);
+ class FrontEnd : public SyntheticChildrenFrontEnd
+ {
+ private:
+ SyntheticFilter* filter;
+ public:
+
+ FrontEnd(SyntheticFilter* flt,
+ lldb::ValueObjectSP be) :
+ SyntheticChildrenFrontEnd(be),
+ filter(flt)
+ {}
+
+ virtual
+ ~FrontEnd()
+ {
+ }
+
+ virtual uint32_t
+ CalculateNumChildren()
+ {
+ return filter->GetCount();
+ }
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (uint32_t idx, bool can_create)
+ {
+ if (idx >= filter->GetCount())
+ return lldb::ValueObjectSP();
+ return m_backend->GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx).c_str(), can_create);
+ }
+
+ virtual uint32_t
+ GetIndexOfChildWithName (const ConstString &name)
+ {
+ const char* name_cstr = name.GetCString();
+ for (int i = 0; i < filter->GetCount(); i++)
+ {
+ const char* expr_cstr = filter->GetExpressionPathAtIndex(i).c_str();
+ if (::strcmp(name_cstr, expr_cstr))
+ return i;
+ }
+ return UINT32_MAX;
+ }
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+
+ };
+
+ virtual SyntheticChildrenFrontEnd::SharedPointer
+ GetFrontEnd(lldb::ValueObjectSP backend)
+ {
+ return SyntheticChildrenFrontEnd::SharedPointer(new FrontEnd(this, backend));
+ }
+
};
+class SyntheticScriptProvider : public SyntheticChildren
+{
+ std::string m_python_class;
+public:
+ SyntheticScriptProvider(bool casc = false,
+ bool skipptr = false,
+ bool skipref = false,
+ std::string pclass = "") :
+ SyntheticChildren(casc, skipptr, skipref),
+ m_python_class(pclass)
+ {
+ }
+
+
+ std::string
+ GetPythonClassName() { return m_python_class; }
+
+ std::string
+ GetDescription();
+
+ class FrontEnd : public SyntheticChildrenFrontEnd
+ {
+ private:
+ std::string m_python_class;
+ PyObject* m_wrapper;
+ ScriptInterpreter *m_interpreter;
+ public:
+
+ FrontEnd(std::string pclass,
+ lldb::ValueObjectSP be);
+
+ virtual
+ ~FrontEnd()
+ {
+ Py_XDECREF(m_wrapper);
+ }
+
+ virtual uint32_t
+ CalculateNumChildren()
+ {
+ if (m_wrapper == NULL)
+ return 0;
+ return m_interpreter->CalculateNumChildren(m_wrapper);
+ }
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (uint32_t idx, bool can_create)
+ {
+ if (m_wrapper == NULL)
+ return lldb::ValueObjectSP();
+
+ PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx);
+ if (py_return == NULL || py_return == Py_None)
+ {
+ Py_XDECREF(py_return);
+ return lldb::ValueObjectSP();
+ }
+
+ lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return);
+
+ if (py_return == NULL)
+ return lldb::ValueObjectSP();
+
+ return sb_ptr->m_opaque_sp;
+ }
+
+ virtual uint32_t
+ GetIndexOfChildWithName (const ConstString &name)
+ {
+ if (m_wrapper == NULL)
+ return UINT32_MAX;
+ return m_interpreter->GetIndexOfChildWithName(m_wrapper, name.GetCString());
+ }
+
+ typedef lldb::SharedPtr::Type SharedPointer;
+
+ };
+
+ virtual SyntheticChildrenFrontEnd::SharedPointer
+ GetFrontEnd(lldb::ValueObjectSP backend)
+ {
+ return SyntheticChildrenFrontEnd::SharedPointer(new FrontEnd(m_python_class, backend));
+ }
+
+};
+
+
struct SummaryFormat
{
bool m_cascades;
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=135865&r1=135864&r2=135865&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Sat Jul 23 19:14:56 2011
@@ -545,7 +545,7 @@
bool
Get(ValueObject& vobj,
- lldb::SyntheticFilterSP& entry,
+ lldb::SyntheticChildrenSP& entry,
uint32_t* reason = NULL)
{
if (!IsEnabled())
@@ -791,7 +791,7 @@
bool
Get(ValueObject& vobj,
- lldb::SyntheticFilterSP& entry)
+ lldb::SyntheticChildrenSP& entry)
{
Mutex::Locker(m_map_mutex);
@@ -803,7 +803,7 @@
for (begin = m_active_categories.begin(); begin != end; begin++)
{
FormatCategory::SharedPointer category = *begin;
- lldb::SyntheticFilterSP current_format;
+ lldb::SyntheticChildrenSP current_format;
if (!category->Get(vobj, current_format, &reason_why))
continue;
if (reason_why == lldb::eFormatterDirectChoice)
@@ -947,7 +947,7 @@
}
bool
Get(ValueObject& vobj,
- lldb::SyntheticFilterSP& entry)
+ lldb::SyntheticChildrenSP& entry)
{
return m_categories_map.Get(vobj, entry);
}
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=135865&r1=135864&r2=135865&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Sat Jul 23 19:14:56 2011
@@ -739,13 +739,14 @@
// as an independent ValueObjectConstResult, which isn't managed by us.
ValueObject *m_deref_valobj;
- lldb::Format m_format;
- uint32_t m_last_format_mgr_revision;
- lldb::SummaryFormatSP m_last_summary_format;
- lldb::SummaryFormatSP m_forced_summary_format;
- lldb::ValueFormatSP m_last_value_format;
- lldb::SyntheticFilterSP m_last_synthetic_filter;
- lldb::user_id_t m_user_id_of_forced_summary;
+ lldb::Format m_format;
+ uint32_t m_last_format_mgr_revision;
+ lldb::SummaryFormatSP m_last_summary_format;
+ lldb::SummaryFormatSP m_forced_summary_format;
+ lldb::ValueFormatSP m_last_value_format;
+ lldb::SyntheticChildrenSP m_last_synthetic_filter;
+ lldb::user_id_t m_user_id_of_forced_summary;
+
bool m_value_is_valid:1,
m_value_did_change:1,
m_children_count_valid:1,
Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=135865&r1=135864&r2=135865&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Sat Jul 23 19:14:56 2011
@@ -12,6 +12,7 @@
// C Includes
// C++ Includes
+#include