Re: [Lldb-commits] [PATCH] D13247: RenderScript command for printing allocation information

2015-10-06 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249380: RenderScript command for printing allocation 
information  (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D13247?vs=35968&id=36587#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13247

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -202,6 +202,8 @@
 
 void DumpKernels(Stream &strm) const;
 
+void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
+
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
 
 void SetBreakAllKernels(bool do_break, lldb::TargetSP target);
@@ -220,6 +222,9 @@
 
   protected:
 
+struct ScriptDetails;
+struct AllocationDetails;
+
 void InitSearchFilter(lldb::TargetSP target)
 {
 if (!m_filtersp)
@@ -230,6 +235,10 @@
 
 void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
 
+bool RefreshAllocation(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+bool EvalRSExpression(const char* expression, StackFrame* frame_ptr, uint64_t* result);
+
 lldb::BreakpointSP CreateKernelBreakpoint(const ConstString& name);
 
 void BreakOnModuleKernels(const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
@@ -256,9 +265,6 @@
 
 typedef std::shared_ptr RuntimeHookSP;
 
-struct ScriptDetails;
-struct AllocationDetails;
-
 lldb::ModuleSP m_libRS;
 lldb::ModuleSP m_libRSDriver;
 lldb::ModuleSP m_libRSCpuRef;
@@ -292,6 +298,18 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+//
+// Helper functions for jitting the runtime
+//
+bool JITDataPointer(AllocationDetails* allocation, StackFrame* frame_ptr,
+unsigned int x = 0, unsigned int y = 0, unsigned int z = 0);
+
+bool JITTypePointer(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+bool JITTypePacked(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+bool JITElementPacked(AllocationDetails* allocation, StackFrame* frame_ptr);
+
 // Search for a script detail object using a target address.
 // If a script does not currently exist this function will return nullptr.
 // If 'create' is true and there is no previous script with this address,
Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -25,7 +25,7 @@
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Target/RegisterContext.h"
-
+#include "lldb/Expression/UserExpression.h"
 #include "lldb/Symbol/VariableList.h"
 
 using namespace lldb;
@@ -130,26 +130,116 @@
 // allocation instance.
 struct RenderScriptRuntime::AllocationDetails
 {
-~AllocationDetails () {};
+   // Taken from rsDefines.h
+   enum DataKind
+   {
+   RS_KIND_USER,
+   RS_KIND_PIXEL_L = 7,
+   RS_KIND_PIXEL_A,
+   RS_KIND_PIXEL_LA,
+   RS_KIND_PIXEL_RGB,
+   RS_KIND_PIXEL_RGBA,
+   RS_KIND_PIXEL_DEPTH,
+   RS_KIND_PIXEL_YUV,
+   RS_KIND_INVALID = 100
+   };
+
+   // Taken from rsDefines.h
+   enum DataType
+   {
+   RS_TYPE_NONE = 0,
+   RS_TYPE_FLOAT_16,
+   RS_TYPE_FLOAT_32,
+   RS_TYPE_FLOAT_64,
+   RS_TYPE_SIGNED_8,
+   RS_TYPE_SIGNED_16,
+   RS_TYPE_SIGNED_32,
+   RS_TYPE_SIGNED_64,
+   RS_TYPE_UNSIGNED_8,
+   RS_TYPE_UNSIGNED_16,
+   RS_TYPE_UNSIGNED_32,
+   RS_TYPE_UNSIGNED_64,
+   RS_TYPE_BOOLEAN
+};
 
-enum DataType
+struct Dimension
 {
-eInt,
+uint32_t dim_1;
+uint32_t dim_2;
+uint32_t dim_3;
+uint32_t cubeMap;
+
+Dimension()
+{
+ dim_1 = 0;
+ dim_2 = 0;
+ dim_3 = 0;
+ cubeMap = 0;
+}
 };
 
-enum Dimension
+// Monotonically increasing from 1
+static unsigned int ID;
+
+// Maps Allocation DataType enum and vector size to printable strings
+// using 

[Lldb-commits] [lldb] r249380 - RenderScript command for printing allocation information

2015-10-06 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Oct  6 03:42:32 2015
New Revision: 249380

URL: http://llvm.org/viewvc/llvm-project?rev=249380&view=rev
Log:
RenderScript command for printing allocation information 

This patch adds a new command 'language renderscript allocation list' for 
printing the details of all loaded RS allocations.

In order to work out this information lldb JITs the runtime for the data it 
wants.
This has a penalty of a couple seconds latency, so is only done once for each 
allocation and the results cached.

If the user later wants to recalculate this information however, they can force 
lldb to do so with the --refresh flag.


Reviewed by: jingham, clayborg
Subscribers: lldb-commits, ADodds, domipheus, dean, tberghammer, danalbert, 
srhines 
Differential Revision: http://reviews.llvm.org/D13247

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=249380&r1=249379&r2=249380&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Tue Oct  6 03:42:32 2015
@@ -25,7 +25,7 @@
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Target/RegisterContext.h"
-
+#include "lldb/Expression/UserExpression.h"
 #include "lldb/Symbol/VariableList.h"
 
 using namespace lldb;
@@ -130,26 +130,116 @@ struct RenderScriptRuntime::ScriptDetail
 // allocation instance.
 struct RenderScriptRuntime::AllocationDetails
 {
-~AllocationDetails () {};
+   // Taken from rsDefines.h
+   enum DataKind
+   {
+   RS_KIND_USER,
+   RS_KIND_PIXEL_L = 7,
+   RS_KIND_PIXEL_A,
+   RS_KIND_PIXEL_LA,
+   RS_KIND_PIXEL_RGB,
+   RS_KIND_PIXEL_RGBA,
+   RS_KIND_PIXEL_DEPTH,
+   RS_KIND_PIXEL_YUV,
+   RS_KIND_INVALID = 100
+   };
+
+   // Taken from rsDefines.h
+   enum DataType
+   {
+   RS_TYPE_NONE = 0,
+   RS_TYPE_FLOAT_16,
+   RS_TYPE_FLOAT_32,
+   RS_TYPE_FLOAT_64,
+   RS_TYPE_SIGNED_8,
+   RS_TYPE_SIGNED_16,
+   RS_TYPE_SIGNED_32,
+   RS_TYPE_SIGNED_64,
+   RS_TYPE_UNSIGNED_8,
+   RS_TYPE_UNSIGNED_16,
+   RS_TYPE_UNSIGNED_32,
+   RS_TYPE_UNSIGNED_64,
+   RS_TYPE_BOOLEAN
+};
 
-enum DataType
+struct Dimension
 {
-eInt,
+uint32_t dim_1;
+uint32_t dim_2;
+uint32_t dim_3;
+uint32_t cubeMap;
+
+Dimension()
+{
+ dim_1 = 0;
+ dim_2 = 0;
+ dim_3 = 0;
+ cubeMap = 0;
+}
 };
 
-enum Dimension
+// Monotonically increasing from 1
+static unsigned int ID;
+
+// Maps Allocation DataType enum and vector size to printable strings
+// using mapping from RenderScript numerical types summary documentation
+static const char* RsDataTypeToString[][4];
+
+// Maps Allocation DataKind enum to printable strings
+static const char* RsDataKindToString[];
+
+// Give each allocation an ID as a way
+// for commands to reference it.
+const unsigned int id;
+
+empirical_type type;// Type of each data pointer 
stored by the allocation
+empirical_type type_kind;   // Defines pixel type if 
Allocation is created from an image
+empirical_type type_vec_size;   // Vector size of each data 
point, e.g '4' for uchar4
+empirical_type dimension;  // Dimensions of the Allocation
+empirical_type address; // Pointer to address of the RS 
Allocation
+empirical_type data_ptr;// Pointer to the data held by 
the Allocation
+empirical_type type_ptr;// Pointer to the RS Type of the 
Allocation
+empirical_type element_ptr; // Pointer to the RS Element of 
the Type
+empirical_type context; // Pointer to the RS Context of 
the Allocation
+
+// Give each allocation an id, so we can reference it in user commands.
+AllocationDetails(): id(ID++)
 {
-e1d,
-e2d,
-e3d,
-eCubeMap,
-};
+}
 
-empirical_type type;
-empirical_type dimension;
-empirical_type address;
-empirical_type dataPtr;
-empirical_type context;
+};
+
+unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
+
+const char* RenderScriptRuntime::AllocationDetails::RsDataKindToString[] =
+{
+   "User",
+   "Undefined", "Undefined", "Undefined", // Enum jumps from 0 to 7
+   "Undefined", "Undefin

[Lldb-commits] [PATCH] D13699: RenderScript command for printing allocation contents.

2015-10-13 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: clayborg, jingham.
EwanCrawford added subscribers: lldb-commits, domipheus, ADodds.
EwanCrawford set the repository for this revision to rL LLVM.

This patch adds the command 'language renderscript allocation dump ' for 
printing the contents of a RS allocation.
Displaying the coordinate of each element as well as its formatted value

e.g  (lldb) language renderscript allocation dump 1
Data (X, Y, Z):
(0, 0, 0) = {0 1}
(1, 0, 0) = {2 3}
(2, 0, 0) = {4 5}

A --file  option is also included, since for large allocations it may 
be more helpful to view this text as a file.


Repository:
  rL LLVM

http://reviews.llvm.org/D13699

Files:
  include/lldb/lldb-enumerations.h
  source/Core/DataExtractor.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -202,6 +202,8 @@
 
 void DumpKernels(Stream &strm) const;
 
+bool DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id);
+
 void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
 
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
@@ -298,6 +300,8 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+
 //
 // Helper functions for jitting the runtime
 //
@@ -310,6 +314,10 @@
 
 bool JITElementPacked(AllocationDetails* allocation, StackFrame* frame_ptr);
 
+bool JITAllocationSize(AllocationDetails* allocation, StackFrame* frame_ptr, const uint32_t elem_size);
+
+bool JITAllocationStride(AllocationDetails* allocation, StackFrame* frame_ptr);
+
 // Search for a script detail object using a target address.
 // If a script does not currently exist this function will return nullptr.
 // If 'create' is true and there is no previous script with this address,
Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Target/Process.h"
@@ -188,6 +189,9 @@
 // Maps Allocation DataKind enum to printable strings
 static const char* RsDataKindToString[];
 
+// Maps allocation types to format sizes for printing.
+static const unsigned int RSTypeToFormat[][3];
+
 // Give each allocation an ID as a way
 // for commands to reference it.
 const unsigned int id;
@@ -201,6 +205,8 @@
 empirical_type type_ptr;// Pointer to the RS Type of the Allocation
 empirical_type element_ptr; // Pointer to the RS Element of the Type
 empirical_type context; // Pointer to the RS Context of the Allocation
+empirical_type size;// Size of the allocation
+empirical_type stride;  // Stride between rows of the allocation
 
 // Give each allocation an id, so we can reference it in user commands.
 AllocationDetails(): id(ID++)
@@ -242,6 +248,31 @@
 {"bool", "bool2", "bool3", "bool4"}
 };
 
+// Used as an index into the RSTypeToFormat array elements
+enum TypeToFormatIndex {
+   eFormatSingle = 0,
+   eFormatVector,
+   eElementSize
+};
+
+// { format enum of single element, format enum of element vector, size of element}
+const unsigned int RenderScriptRuntime::AllocationDetails::RSTypeToFormat[][3] =
+{
+{eFormatHex, eFormatHex, 1}, // RS_TYPE_NONE
+{eFormatFloat, eFormatVectorOfFloat16, 2}, // RS_TYPE_FLOAT_16
+{eFormatFloat, eFormatVectorOfFloat32, sizeof(float)}, // RS_TYPE_FLOAT_32
+{eFormatFloat, eFormatVectorOfFloat64, sizeof(double)}, // RS_TYPE_FLOAT_64
+{eFormatDecimal, eFormatVectorOfSInt8, sizeof(int8_t)}, // RS_TYPE_SIGNED_8
+{eFormatDecimal, eFormatVectorOfSInt16, sizeof(int16_t)}, // RS_TYPE_SIGNED_16
+{eFormatDecimal, eFormatVectorOfSInt32, sizeof(int32_t)}, // RS_TYPE_SIGNED_32
+{eFormatDecimal, eFormatVectorOfSInt64, sizeof(int64_t)}, // RS_TYPE_SIGNED_64
+{eFo

Re: [Lldb-commits] [PATCH] D13699: RenderScript command for printing allocation contents.

2015-10-13 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

Hi Bruce,

I'm mapping rs types to data formatters in the struct 
`RenderScriptRuntime::AllocationDetails::RSTypeToFormat` on line 
RenderScriptRuntime.cpp:259.

Then using a `DataExtractor` to print using those formats on 
RenderScriptRuntime.cpp:1830

Is there another way you would suggest?


Repository:
  rL LLVM

http://reviews.llvm.org/D13699



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13699: RenderScript command for printing allocation contents.

2015-10-14 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250281: RenderScript command for printing allocation 
contents (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D13699?vs=37251&id=37324#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13699

Files:
  lldb/trunk/include/lldb/lldb-enumerations.h
  lldb/trunk/source/Core/DataExtractor.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/include/lldb/lldb-enumerations.h
===
--- lldb/trunk/include/lldb/lldb-enumerations.h
+++ lldb/trunk/include/lldb/lldb-enumerations.h
@@ -146,6 +146,7 @@
 eFormatVectorOfUInt32,
 eFormatVectorOfSInt64,
 eFormatVectorOfUInt64,
+eFormatVectorOfFloat16,
 eFormatVectorOfFloat32,
 eFormatVectorOfFloat64,
 eFormatVectorOfUInt128,
Index: lldb/trunk/source/Core/DataExtractor.cpp
===
--- lldb/trunk/source/Core/DataExtractor.cpp
+++ lldb/trunk/source/Core/DataExtractor.cpp
@@ -2012,6 +2012,12 @@
 s->PutChar('}');
 break;
 
+case eFormatVectorOfFloat16:
+s->PutChar('{');
+offset = Dump (s, offset, eFormatFloat,   2, item_byte_size / 2, item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0);
+s->PutChar('}');
+break;
+
 case eFormatVectorOfFloat32:
 s->PutChar('{');
 offset = Dump (s, offset, eFormatFloat,   4, item_byte_size / 4, item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);
Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -202,6 +202,8 @@
 
 void DumpKernels(Stream &strm) const;
 
+bool DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id);
+
 void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
 
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
@@ -298,6 +300,8 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+
 //
 // Helper functions for jitting the runtime
 //
@@ -310,6 +314,10 @@
 
 bool JITElementPacked(AllocationDetails* allocation, StackFrame* frame_ptr);
 
+bool JITAllocationSize(AllocationDetails* allocation, StackFrame* frame_ptr, const uint32_t elem_size);
+
+bool JITAllocationStride(AllocationDetails* allocation, StackFrame* frame_ptr);
+
 // Search for a script detail object using a target address.
 // If a script does not currently exist this function will return nullptr.
 // If 'create' is true and there is no previous script with this address,
Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Target/Process.h"
@@ -188,6 +189,9 @@
 // Maps Allocation DataKind enum to printable strings
 static const char* RsDataKindToString[];
 
+// Maps allocation types to format sizes for printing.
+static const unsigned int RSTypeToFormat[][3];
+
 // Give each allocation an ID as a way
 // for commands to reference it.
 const unsigned int id;
@@ -201,6 +205,8 @@
 empirical_type type_ptr;// Pointer to the RS Type of the Allocation
 empirical_type element_ptr; // Pointer to the RS Element of the Type
 empirical_type context; // Pointer to the RS Context of the Allocation
+empirical_type size;// Size of the allocation
+empirical_type stride;  // Stride between rows of the allocation
 
 // Give each allocation an id, so we can reference it in user commands.
 AllocationDetails(): id(ID++)
@@ -242,6 +248,31 @@
 {"bool", "bool2", "bool3", "bool4"}
 };
 
+// Used as an index into the RSTypeToFormat arr

[Lldb-commits] [lldb] r250281 - RenderScript command for printing allocation contents

2015-10-14 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Oct 14 04:02:20 2015
New Revision: 250281

URL: http://llvm.org/viewvc/llvm-project?rev=250281&view=rev
Log:
RenderScript command for printing allocation contents

This patch adds the command 'language renderscript allocation dump ' for 
printing the contents of a RS allocation.
Displaying the coordinate of each element as well as its formatted value

e.g (lldb) language renderscript allocation dump 1
  Data (X, Y, Z):
 (0, 0, 0) = {0 1}
 (1, 0, 0) = {2 3}
 (2, 0, 0) = {4 5}

A --file  option is also included, since for large allocations it may 
be more helpful to view this text as a file.

Reviewed by: jingham, clayborg
Subscribers: lldb-commits, ADodds, domipheus, brucem
Differential Revision: http://reviews.llvm.org/D13699

Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/DataExtractor.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=250281&r1=250280&r2=250281&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Oct 14 04:02:20 2015
@@ -146,6 +146,7 @@ namespace lldb {
 eFormatVectorOfUInt32,
 eFormatVectorOfSInt64,
 eFormatVectorOfUInt64,
+eFormatVectorOfFloat16,
 eFormatVectorOfFloat32,
 eFormatVectorOfFloat64,
 eFormatVectorOfUInt128,

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=250281&r1=250280&r2=250281&view=diff
==
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Wed Oct 14 04:02:20 2015
@@ -2012,6 +2012,12 @@ DataExtractor::Dump (Stream *s,
 s->PutChar('}');
 break;
 
+case eFormatVectorOfFloat16:
+s->PutChar('{');
+offset = Dump (s, offset, eFormatFloat,   2, item_byte_size / 
2, item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0);
+s->PutChar('}');
+break;
+
 case eFormatVectorOfFloat32:
 s->PutChar('{');
 offset = Dump (s, offset, eFormatFloat,   4, item_byte_size / 
4, item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=250281&r1=250280&r2=250281&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Oct 14 04:02:20 2015
@@ -14,6 +14,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Target/Process.h"
@@ -188,6 +189,9 @@ struct RenderScriptRuntime::AllocationDe
 // Maps Allocation DataKind enum to printable strings
 static const char* RsDataKindToString[];
 
+// Maps allocation types to format sizes for printing.
+static const unsigned int RSTypeToFormat[][3];
+
 // Give each allocation an ID as a way
 // for commands to reference it.
 const unsigned int id;
@@ -201,6 +205,8 @@ struct RenderScriptRuntime::AllocationDe
 empirical_type type_ptr;// Pointer to the RS Type of the 
Allocation
 empirical_type element_ptr; // Pointer to the RS Element of 
the Type
 empirical_type context; // Pointer to the RS Context of 
the Allocation
+empirical_type size;// Size of the allocation
+empirical_type stride;  // Stride between rows of the 
allocation
 
 // Give each allocation an id, so we can reference it in user commands.
 AllocationDetails(): id(ID++)
@@ -242,6 +248,31 @@ const char* RenderScriptRuntime::Allocat
 {"bool", "bool2", "bool3", "bool4"}
 };
 
+// Used as an index into the RSTypeToFormat array elements
+enum TypeToFormatIndex {
+   eFormatSingle = 0,
+   eFormatVector,
+   eElementSize
+};
+
+// { format enum of single element, format enum of element vector, size of 
element}
+const unsigned int RenderScriptRuntime::AllocationDetails::RSTypeToFormat[][3] 
=
+{
+{eFormatHex, eFormatHex, 1}, // RS_TYPE_NONE
+{eFormatFl

Re: [Lldb-commits] [PATCH] D13699: RenderScript command for printing allocation contents.

2015-10-14 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

Hi Pavel, 
 Thanks for letting me know, I'll look into it now.


Repository:
  rL LLVM

http://reviews.llvm.org/D13699



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13699: RenderScript command for printing allocation contents.

2015-10-14 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

No bother, thanks for reverting


Repository:
  rL LLVM

http://reviews.llvm.org/D13699



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D13730: Resubmit: RenderScript command for printing allocation contents

2015-10-14 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: granata.enrico, clayborg, jingham.
EwanCrawford added subscribers: lldb-commits, domipheus, labath.
EwanCrawford set the repository for this revision to rL LLVM.

Previous patch http://reviews.llvm.org/D13699 broke 
TestDataFormatterSmartArray.py
Resolved in in this patch by adding the new enum `eFormatVectorOfFloat16` to 
FormatManager.

I'm not too familiar with DataFormatter code, so +Enrico as he's code owner.



Repository:
  rL LLVM

http://reviews.llvm.org/D13730

Files:
  include/lldb/lldb-enumerations.h
  source/Commands/CommandObjectMemory.cpp
  source/Core/DataExtractor.cpp
  source/DataFormatters/FormatManager.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -202,6 +202,8 @@
 
 void DumpKernels(Stream &strm) const;
 
+bool DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id);
+
 void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
 
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
@@ -298,6 +300,8 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+
 //
 // Helper functions for jitting the runtime
 //
@@ -310,6 +314,10 @@
 
 bool JITElementPacked(AllocationDetails* allocation, StackFrame* frame_ptr);
 
+bool JITAllocationSize(AllocationDetails* allocation, StackFrame* frame_ptr, const uint32_t elem_size);
+
+bool JITAllocationStride(AllocationDetails* allocation, StackFrame* frame_ptr);
+
 // Search for a script detail object using a target address.
 // If a script does not currently exist this function will return nullptr.
 // If 'create' is true and there is no previous script with this address,
Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Target/Process.h"
@@ -188,6 +189,9 @@
 // Maps Allocation DataKind enum to printable strings
 static const char* RsDataKindToString[];
 
+// Maps allocation types to format sizes for printing.
+static const unsigned int RSTypeToFormat[][3];
+
 // Give each allocation an ID as a way
 // for commands to reference it.
 const unsigned int id;
@@ -201,6 +205,8 @@
 empirical_type type_ptr;// Pointer to the RS Type of the Allocation
 empirical_type element_ptr; // Pointer to the RS Element of the Type
 empirical_type context; // Pointer to the RS Context of the Allocation
+empirical_type size;// Size of the allocation
+empirical_type stride;  // Stride between rows of the allocation
 
 // Give each allocation an id, so we can reference it in user commands.
 AllocationDetails(): id(ID++)
@@ -242,6 +248,31 @@
 {"bool", "bool2", "bool3", "bool4"}
 };
 
+// Used as an index into the RSTypeToFormat array elements
+enum TypeToFormatIndex {
+   eFormatSingle = 0,
+   eFormatVector,
+   eElementSize
+};
+
+// { format enum of single element, format enum of element vector, size of element}
+const unsigned int RenderScriptRuntime::AllocationDetails::RSTypeToFormat[][3] =
+{
+{eFormatHex, eFormatHex, 1}, // RS_TYPE_NONE
+{eFormatFloat, eFormatVectorOfFloat16, 2}, // RS_TYPE_FLOAT_16
+{eFormatFloat, eFormatVectorOfFloat32, sizeof(float)}, // RS_TYPE_FLOAT_32
+{eFormatFloat, eFormatVectorOfFloat64, sizeof(double)}, // RS_TYPE_FLOAT_64
+{eFormatDecimal, eFormatVectorOfSInt8, sizeof(int8_t)}, // RS_TYPE_SIGNED_8
+{eFormatDecimal, eFormatVectorOfSInt16, sizeof(int16_t)}, // RS_TYPE_SIGNED_16
+{eFormatDecimal, eFormatVectorOfSInt32, sizeof(int32_t)}, // RS_TYPE_SIGNED_32
+{eFormatDecimal, eFormatVectorOfSInt64, sizeof(int64_t)}, // RS_TYPE_SIGNED_64
+{eFormatDecimal, eFormatVectorOfUInt8, sizeof(uint8_t)}, // RS_TYPE_UNSIGNED_8
+{eFormatDecimal, eFormatV

Re: [Lldb-commits] [PATCH] D13699: RenderScript command for printing allocation contents.

2015-10-15 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

Unfortunately there isn't a user-visible variable for the allocation. 
Information regarding the allocation as a whole is maintained by the runtime.

Within a RS kernel invocation the user only has access to the raw data at a 
specific cell in the allocation, which is available for data inspection.
More information about the allocation can be acquired within a kernel, but only 
by querying API functions.


Repository:
  rL LLVM

http://reviews.llvm.org/D13699



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r250499 - Resubmit: RenderScript command for printing allocation contents

2015-10-16 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Fri Oct 16 03:28:47 2015
New Revision: 250499

URL: http://llvm.org/viewvc/llvm-project?rev=250499&view=rev
Log:
Resubmit: RenderScript command for printing allocation contents 
 
Previous commit r250281 broke TestDataFormatterSmartArray.py
Resolved in in this patch by adding the new enum eFormatVectorOfFloat16 to 
FormatManager.

Differential Revision: http://reviews.llvm.org/D13730

Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Core/DataExtractor.cpp
lldb/trunk/source/DataFormatters/FormatManager.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=250499&r1=250498&r2=250499&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Oct 16 03:28:47 2015
@@ -146,6 +146,7 @@ namespace lldb {
 eFormatVectorOfUInt32,
 eFormatVectorOfSInt64,
 eFormatVectorOfUInt64,
+eFormatVectorOfFloat16,
 eFormatVectorOfFloat32,
 eFormatVectorOfFloat64,
 eFormatVectorOfUInt128,

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=250499&r1=250498&r2=250499&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Oct 16 03:28:47 2015
@@ -271,6 +271,7 @@ public:
 case eFormatVectorOfUInt32:
 case eFormatVectorOfSInt64:
 case eFormatVectorOfUInt64:
+case eFormatVectorOfFloat16:
 case eFormatVectorOfFloat32:
 case eFormatVectorOfFloat64:
 case eFormatVectorOfUInt128:

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=250499&r1=250498&r2=250499&view=diff
==
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Fri Oct 16 03:28:47 2015
@@ -2012,6 +2012,12 @@ DataExtractor::Dump (Stream *s,
 s->PutChar('}');
 break;
 
+case eFormatVectorOfFloat16:
+s->PutChar('{');
+offset = Dump (s, offset, eFormatFloat,   2, item_byte_size / 
2, item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0);
+s->PutChar('}');
+break;
+
 case eFormatVectorOfFloat32:
 s->PutChar('{');
 offset = Dump (s, offset, eFormatFloat,   4, item_byte_size / 
4, item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=250499&r1=250498&r2=250499&view=diff
==
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Fri Oct 16 03:28:47 2015
@@ -67,6 +67,7 @@ g_format_infos[] =
 { eFormatVectorOfUInt32 , '\0'  , "uint32_t[]"  },
 { eFormatVectorOfSInt64 , '\0'  , "int64_t[]"   },
 { eFormatVectorOfUInt64 , '\0'  , "uint64_t[]"  },
+{ eFormatVectorOfFloat16, '\0'  , "float16[]"   },
 { eFormatVectorOfFloat32, '\0'  , "float32[]"   },
 { eFormatVectorOfFloat64, '\0'  , "float64[]"   },
 { eFormatVectorOfUInt128, '\0'  , "uint128_t[]" },
@@ -534,6 +535,7 @@ FormatManager::GetSingleItemFormat(lldb:
 case eFormatVectorOfUInt128:
 return eFormatHex;
 
+case eFormatVectorOfFloat16:
 case eFormatVectorOfFloat32:
 case eFormatVectorOfFloat64:
 return eFormatFloat;

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=250499&r1=250498&r2=250499&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Fri Oct 16 03:28:47 2015
@@ -14,6 +

Re: [Lldb-commits] [PATCH] D13730: Resubmit: RenderScript command for printing allocation contents

2015-10-16 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250499: Resubmit: RenderScript command for printing 
allocation contents  (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D13730?vs=37356&id=37562#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13730

Files:
  lldb/trunk/include/lldb/lldb-enumerations.h
  lldb/trunk/source/Commands/CommandObjectMemory.cpp
  lldb/trunk/source/Core/DataExtractor.cpp
  lldb/trunk/source/DataFormatters/FormatManager.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -202,6 +202,8 @@
 
 void DumpKernels(Stream &strm) const;
 
+bool DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id);
+
 void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
 
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
@@ -298,6 +300,8 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+
 //
 // Helper functions for jitting the runtime
 //
@@ -310,6 +314,10 @@
 
 bool JITElementPacked(AllocationDetails* allocation, StackFrame* frame_ptr);
 
+bool JITAllocationSize(AllocationDetails* allocation, StackFrame* frame_ptr, const uint32_t elem_size);
+
+bool JITAllocationStride(AllocationDetails* allocation, StackFrame* frame_ptr);
+
 // Search for a script detail object using a target address.
 // If a script does not currently exist this function will return nullptr.
 // If 'create' is true and there is no previous script with this address,
Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Target/Process.h"
@@ -188,6 +189,9 @@
 // Maps Allocation DataKind enum to printable strings
 static const char* RsDataKindToString[];
 
+// Maps allocation types to format sizes for printing.
+static const unsigned int RSTypeToFormat[][3];
+
 // Give each allocation an ID as a way
 // for commands to reference it.
 const unsigned int id;
@@ -201,6 +205,8 @@
 empirical_type type_ptr;// Pointer to the RS Type of the Allocation
 empirical_type element_ptr; // Pointer to the RS Element of the Type
 empirical_type context; // Pointer to the RS Context of the Allocation
+empirical_type size;// Size of the allocation
+empirical_type stride;  // Stride between rows of the allocation
 
 // Give each allocation an id, so we can reference it in user commands.
 AllocationDetails(): id(ID++)
@@ -242,6 +248,31 @@
 {"bool", "bool2", "bool3", "bool4"}
 };
 
+// Used as an index into the RSTypeToFormat array elements
+enum TypeToFormatIndex {
+   eFormatSingle = 0,
+   eFormatVector,
+   eElementSize
+};
+
+// { format enum of single element, format enum of element vector, size of element}
+const unsigned int RenderScriptRuntime::AllocationDetails::RSTypeToFormat[][3] =
+{
+{eFormatHex, eFormatHex, 1}, // RS_TYPE_NONE
+{eFormatFloat, eFormatVectorOfFloat16, 2}, // RS_TYPE_FLOAT_16
+{eFormatFloat, eFormatVectorOfFloat32, sizeof(float)}, // RS_TYPE_FLOAT_32
+{eFormatFloat, eFormatVectorOfFloat64, sizeof(double)}, // RS_TYPE_FLOAT_64
+{eFormatDecimal, eFormatVectorOfSInt8, sizeof(int8_t)}, // RS_TYPE_SIGNED_8
+{eFormatDecimal, eFormatVectorOfSInt16, sizeof(int16_t)}, // RS_TYPE_SIGNED_16
+{eFormatDecimal, eFormatVectorOfSInt32, sizeof(int32_t)}, // RS_TYPE_SIGNED_32
+{eFormatDecimal, eFormatVectorOfSInt64, sizeof(int64_t)}, // RS_TYPE_SIGNED_64
+{eFormatDecimal, eFormatVectorOfUInt8, sizeof(uint8_t)}, // RS_TYPE_UNSIGNED_8
+{eFormatDecimal, eFormatVectorOfUInt16, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_16
+{eFormatDecimal,

[Lldb-commits] [PATCH] D13903: [RenderScript] New commands to save/load RS allocations to file.

2015-10-20 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: clayborg, jingham.
EwanCrawford added subscribers: lldb-commits, domipheus.
EwanCrawford set the repository for this revision to rL LLVM.

Patch adds command 'language renderscript allocation save' to store the 
contents of an allocation in a binary file. 
And 'language renderscript allocation load' to restore an allocation with the 
saved data from a binary file.

Binary file format contains a header `FileHeader` with meta information 
preceding the raw data.



Repository:
  rL LLVM

http://reviews.llvm.org/D13903

Files:
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -218,6 +218,10 @@
 
 virtual void ModulesDidLoad(const ModuleList &module_list );
 
+bool LoadAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr);
+
+bool SaveAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr);
+
 void Update();
 
 void Initiate();
@@ -264,7 +268,7 @@
 const HookDefn  *defn;
 lldb::BreakpointSP bp_sp;
 };
-
+
 typedef std::shared_ptr RuntimeHookSP;
 
 lldb::ModuleSP m_libRS;
@@ -301,6 +305,8 @@
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
 AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+std::shared_ptr GetAllocationData(AllocationDetails* allocation, StackFrame* frame_ptr);
+unsigned int GetElementSize(const AllocationDetails* allocation);
 
 //
 // Helper functions for jitting the runtime
Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -179,6 +179,18 @@
 }
 };
 
+// Header for reading and writing allocation contents
+// to a binary file.
+struct FileHeader
+{
+uint8_t ident[4];  // ASCII 'RSAD' identifying the file
+uint16_t hdr_size; // Header size in bytes, for backwards compatability
+uint16_t type; // DataType enum
+uint32_t kind; // DataKind enum
+uint32_t dims[3];  // Dimensions
+uint32_t element_size; // Size of a single element, including padding
+};
+
 // Monotonically increasing from 1
 static unsigned int ID;
 
@@ -1365,10 +1377,287 @@
 if (!JITElementPacked(allocation, frame_ptr))
 return false;
 
+// Use GetOffsetPointer() to infer size of the allocation
+const unsigned int element_size = GetElementSize(allocation);
+if (!JITAllocationSize(allocation, frame_ptr, element_size))
+return false;
+
 return true;
 }
 
+// Returns the size of a single allocation element including padding.
+// Assumes the relevant allocation information has already been jitted.
+unsigned int
+RenderScriptRuntime::GetElementSize(const AllocationDetails* allocation)
+{
+const AllocationDetails::DataType type = *allocation->type.get();
+assert(type >= AllocationDetails::RS_TYPE_NONE && type <= AllocationDetails::RS_TYPE_BOOLEAN
+   && "Invalid allocation type");
+
+const unsigned int vec_size = *allocation->type_vec_size.get();
+const unsigned int data_size = vec_size * AllocationDetails::RSTypeToFormat[type][eElementSize];
+const unsigned int padding = vec_size == 3 ? AllocationDetails::RSTypeToFormat[type][eElementSize] : 0;
+
+return data_size + padding;
+}
+
+// Given an allocation, this function copies the allocation contents from device into a buffer on the heap.
+// Returning a shared pointer to the buffer containing the data.
+std::shared_ptr
+RenderScriptRuntime::GetAllocationData(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+// JIT all the allocation details
+if (!allocation->data_ptr.isValid() || !allocation->type.isValid() || !allocation->type_vec_size.isValid()
+|| !allocation->size.isValid())
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetAllocationData - Allocation details not calculated yet, jitting info");
+
+if (!RefreshAllocation(allocation, frame_ptr))
+{
+if (log)
+log->Printf("RenderS

[Lldb-commits] [lldb] r250886 - [RenderScript] New commands to save/load RS allocations to file.

2015-10-21 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Oct 21 03:50:42 2015
New Revision: 250886

URL: http://llvm.org/viewvc/llvm-project?rev=250886&view=rev
Log:
[RenderScript] New commands to save/load RS allocations to file.

Patch adds command 'language renderscript allocation save' to store the 
contents of an allocation in a binary file.
And 'language renderscript allocation load' to restore an allocation with the 
saved data from a binary file.

Binary file format contains a header FileHeader with meta information preceding 
the raw data.


Reviewed by: jingham, clayborg
Subscribers: lldb-commits, domipheus
Differential Revision: http://reviews.llvm.org/D13903

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=250886&r1=250885&r2=250886&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Oct 21 03:50:42 2015
@@ -179,6 +179,18 @@ struct RenderScriptRuntime::AllocationDe
 }
 };
 
+// Header for reading and writing allocation contents
+// to a binary file.
+struct FileHeader
+{
+uint8_t ident[4];  // ASCII 'RSAD' identifying the file
+uint16_t hdr_size; // Header size in bytes, for backwards 
compatability
+uint16_t type; // DataType enum
+uint32_t kind; // DataKind enum
+uint32_t dims[3];  // Dimensions
+uint32_t element_size; // Size of a single element, including padding
+};
+
 // Monotonically increasing from 1
 static unsigned int ID;
 
@@ -1365,6 +1377,283 @@ RenderScriptRuntime::RefreshAllocation(A
 if (!JITElementPacked(allocation, frame_ptr))
 return false;
 
+// Use GetOffsetPointer() to infer size of the allocation
+const unsigned int element_size = GetElementSize(allocation);
+if (!JITAllocationSize(allocation, frame_ptr, element_size))
+return false;
+
+return true;
+}
+
+// Returns the size of a single allocation element including padding.
+// Assumes the relevant allocation information has already been jitted.
+unsigned int
+RenderScriptRuntime::GetElementSize(const AllocationDetails* allocation)
+{
+const AllocationDetails::DataType type = *allocation->type.get();
+assert(type >= AllocationDetails::RS_TYPE_NONE && type <= 
AllocationDetails::RS_TYPE_BOOLEAN
+   && "Invalid allocation 
type");
+
+const unsigned int vec_size = *allocation->type_vec_size.get();
+const unsigned int data_size = vec_size * 
AllocationDetails::RSTypeToFormat[type][eElementSize];
+const unsigned int padding = vec_size == 3 ? 
AllocationDetails::RSTypeToFormat[type][eElementSize] : 0;
+
+return data_size + padding;
+}
+
+// Given an allocation, this function copies the allocation contents from 
device into a buffer on the heap.
+// Returning a shared pointer to the buffer containing the data.
+std::shared_ptr
+RenderScriptRuntime::GetAllocationData(AllocationDetails* allocation, 
StackFrame* frame_ptr)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+// JIT all the allocation details
+if (!allocation->data_ptr.isValid() || !allocation->type.isValid() || 
!allocation->type_vec_size.isValid()
+|| !allocation->size.isValid())
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetAllocationData - Allocation 
details not calculated yet, jitting info");
+
+if (!RefreshAllocation(allocation, frame_ptr))
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetAllocationData - Couldn't 
JIT allocation details");
+return nullptr;
+}
+}
+
+assert(allocation->data_ptr.isValid() && allocation->type.isValid() && 
allocation->type_vec_size.isValid()
+   && allocation->size.isValid() && "Allocation information not 
available");
+
+// Allocate a buffer to copy data into
+const unsigned int size = *allocation->size.get();
+std::shared_ptr buffer(new uint8_t[size]);
+if (!buffer)
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetAllocationData - Couldn't 
allocate a %u byte buffer", size);
+return nullptr;
+}
+
+// Read the inferior memory
+Error error;
+lldb::addr_t data_ptr = *allocation->data_ptr.get();
+GetProcess()->ReadMemory(data_ptr, buffer.get(), size, erro

Re: [Lldb-commits] [PATCH] D13903: [RenderScript] New commands to save/load RS allocations to file.

2015-10-21 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250886: [RenderScript] New commands to save/load RS 
allocations to file. (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D13903?vs=37889&id=37972#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13903

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -218,6 +218,10 @@
 
 virtual void ModulesDidLoad(const ModuleList &module_list );
 
+bool LoadAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr);
+
+bool SaveAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr);
+
 void Update();
 
 void Initiate();
@@ -264,7 +268,7 @@
 const HookDefn  *defn;
 lldb::BreakpointSP bp_sp;
 };
-
+
 typedef std::shared_ptr RuntimeHookSP;
 
 lldb::ModuleSP m_libRS;
@@ -301,6 +305,8 @@
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
 AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+std::shared_ptr GetAllocationData(AllocationDetails* allocation, StackFrame* frame_ptr);
+unsigned int GetElementSize(const AllocationDetails* allocation);
 
 //
 // Helper functions for jitting the runtime
Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -179,6 +179,18 @@
 }
 };
 
+// Header for reading and writing allocation contents
+// to a binary file.
+struct FileHeader
+{
+uint8_t ident[4];  // ASCII 'RSAD' identifying the file
+uint16_t hdr_size; // Header size in bytes, for backwards compatability
+uint16_t type; // DataType enum
+uint32_t kind; // DataKind enum
+uint32_t dims[3];  // Dimensions
+uint32_t element_size; // Size of a single element, including padding
+};
+
 // Monotonically increasing from 1
 static unsigned int ID;
 
@@ -1365,6 +1377,283 @@
 if (!JITElementPacked(allocation, frame_ptr))
 return false;
 
+// Use GetOffsetPointer() to infer size of the allocation
+const unsigned int element_size = GetElementSize(allocation);
+if (!JITAllocationSize(allocation, frame_ptr, element_size))
+return false;
+
+return true;
+}
+
+// Returns the size of a single allocation element including padding.
+// Assumes the relevant allocation information has already been jitted.
+unsigned int
+RenderScriptRuntime::GetElementSize(const AllocationDetails* allocation)
+{
+const AllocationDetails::DataType type = *allocation->type.get();
+assert(type >= AllocationDetails::RS_TYPE_NONE && type <= AllocationDetails::RS_TYPE_BOOLEAN
+   && "Invalid allocation type");
+
+const unsigned int vec_size = *allocation->type_vec_size.get();
+const unsigned int data_size = vec_size * AllocationDetails::RSTypeToFormat[type][eElementSize];
+const unsigned int padding = vec_size == 3 ? AllocationDetails::RSTypeToFormat[type][eElementSize] : 0;
+
+return data_size + padding;
+}
+
+// Given an allocation, this function copies the allocation contents from device into a buffer on the heap.
+// Returning a shared pointer to the buffer containing the data.
+std::shared_ptr
+RenderScriptRuntime::GetAllocationData(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+// JIT all the allocation details
+if (!allocation->data_ptr.isValid() || !allocation->type.isValid() || !allocation->type_vec_size.isValid()
+|| !allocation->size.isValid())
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetAllocationData - Allocation details not calculated yet, jitting info");
+
+if (!RefreshAllocation(allocation, frame_ptr))
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetAllocationData - Couldn't JIT allocation details");
+return nullptr;
+}
+}
+
+assert(allocation->data_ptr.isValid() && alloca

[Lldb-commits] [lldb] r250891 - [RenderScript] Fix out of bounds warning.

2015-10-21 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Oct 21 05:27:10 2015
New Revision: 250891

URL: http://llvm.org/viewvc/llvm-project?rev=250891&view=rev
Log:
[RenderScript] Fix out of bounds warning.


Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=250891&r1=250890&r2=250891&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Oct 21 05:27:10 2015
@@ -1624,9 +1624,9 @@ RenderScriptRuntime::SaveAllocation(Stre
 head.hdr_size = 
static_cast(sizeof(AllocationDetails::FileHeader));
 head.type = static_cast(*alloc->type.get());
 head.kind = static_cast(*alloc->type_kind.get());
-head.dims[1] = static_cast(alloc->dimension.get()->dim_1);
-head.dims[2] = static_cast(alloc->dimension.get()->dim_2);
-head.dims[3] = static_cast(alloc->dimension.get()->dim_3);
+head.dims[0] = static_cast(alloc->dimension.get()->dim_1);
+head.dims[1] = static_cast(alloc->dimension.get()->dim_2);
+head.dims[2] = static_cast(alloc->dimension.get()->dim_3);
 head.element_size = static_cast(GetElementSize(alloc));
 
 // Write the file header


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13903: [RenderScript] New commands to save/load RS allocations to file.

2015-10-21 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

Thanks for spotting, comitted a quick fix


Repository:
  rL LLVM

http://reviews.llvm.org/D13903



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r251003 - [RenderScript] Support for mips64 runtime hook

2015-10-22 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Oct 22 04:01:05 2015
New Revision: 251003

URL: http://llvm.org/viewvc/llvm-project?rev=251003&view=rev
Log:
[RenderScript] Support for mips64 runtime hook

Previously we could not hook the RS runtime on mips64 architectures.

Patch implements ABI specific code for inspecting function arguments.

Author: Dean De Leo, d...@codeplay.com


Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=251003&r1=251002&r2=251003&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Thu Oct 22 04:01:05 2015
@@ -609,25 +609,30 @@ RenderScriptRuntime::GetArgSimple(Execut
 {
 const RegisterInfo* rArg = 
reg_ctx->GetRegisterInfoAtIndex(arg);
 RegisterValue rVal;
-reg_ctx->ReadRegister(rArg, rVal);
-(*data) = rVal.GetAsUInt32();
-success = true;
+success = reg_ctx->ReadRegister(rArg, rVal);
+if (success)
+{
+(*data) = rVal.GetAsUInt32();
+}
+else
+{
+if (log)
+log->Printf ("RenderScriptRuntime:: GetArgSimple - 
error reading ARM register: %d.", arg);
+}
 }
 else
 {
 uint64_t sp = reg_ctx->GetSP();
+uint32_t offset = (arg-4) * sizeof(uint32_t);
+process->ReadMemory(sp + offset, &data, sizeof(uint32_t), 
error);
+if (error.Fail())
+{
+if (log)
+log->Printf ("RenderScriptRuntime:: GetArgSimple - 
error reading ARM stack: %s.", error.AsCString());
+}
+else
 {
-uint32_t offset = (arg-4) * sizeof(uint32_t);
-process->ReadMemory(sp + offset, &data, sizeof(uint32_t), 
error);
-if (error.Fail())
-{
-if (log)
-log->Printf ("RenderScriptRuntime:: GetArgSimple - 
error reading ARM stack: %s.", error.AsCString());
-}
-else
-{
-success = true;
-}
+success = true;
 }
 }
 
@@ -660,6 +665,44 @@ RenderScriptRuntime::GetArgSimple(Execut
 }
 break;
 }
+case llvm::Triple::ArchType::mips64el:
+{
+// read from the registers
+if (arg < 8)
+{
+const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg 
+ 4);
+RegisterValue rVal;
+success = reg_ctx->ReadRegister(rArg, rVal);
+if (success)
+{
+(*data) = rVal.GetAsUInt64();
+}
+else
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetArgSimple - 
Mips64 - Error reading the argument #%d", arg);
+}
+}
+
+// read from the stack
+else
+{
+uint64_t sp = reg_ctx->GetSP();
+uint32_t offset = (arg - 8) * sizeof(uint64_t);
+process->ReadMemory(sp + offset, &data, sizeof(uint64_t), 
error);
+if (error.Fail())
+{
+if (log)
+log->Printf ("RenderScriptRuntime::GetArgSimple - 
Mips64 - Error reading Mips64 stack: %s.", error.AsCString());
+}
+else
+{
+success = true;
+}
+}
+
+break;
+}
 default:
 {
 // invalid architecture
@@ -841,10 +884,12 @@ RenderScriptRuntime::LoadRuntimeHooks(ll
 
 if (targetArchType != llvm::Triple::ArchType::x86
 && targetArchType != llvm::Triple::ArchType::arm
-&& targetArchType != llvm::Triple::ArchType::aarch64)
+&& targetArchType != llvm::Triple::ArchType::aarch64
+&& targetArchType != llvm::Triple::ArchType::mips64el
+)
 {
 if (log)
-log->Printf ("RenderScriptRuntime::LoadRuntimeHooks - Unable to 
hook runtime. Only X86, ARM supported currently.");
+log->Printf ("RenderScriptR

[Lldb-commits] [lldb] r251293 - [RenderScript] Add option to break on a specific kernel invocation

2015-10-26 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Mon Oct 26 09:04:37 2015
New Revision: 251293

URL: http://llvm.org/viewvc/llvm-project?rev=251293&view=rev
Log:
[RenderScript] Add option to break on a specific kernel invocation


Adds option -c  to the 'language renderscript kernel breakpoint set' 
command.

Breaks only on the invocation of the kernel with specified coordinate.
Implemented by adding a callback to the kernel breakpoint which checks the 
coordinates of every invocation.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=251293&r1=251292&r2=251293&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Mon Oct 26 09:04:37 2015
@@ -14,11 +14,13 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegularExpression.h"
 #include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/Options.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -2301,8 +2303,124 @@ RenderScriptRuntime::CreateKernelBreakpo
 return bp;
 }
 
+// Given an expression for a variable this function tries to calculate the 
variable's value.
+// If this is possible it returns true and sets the uint64_t parameter to the 
variables unsigned value.
+// Otherwise function returns false.
+bool
+RenderScriptRuntime::GetFrameVarAsUnsigned(const StackFrameSP frame_sp, const 
char* var_name, uint64_t& val)
+{
+Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+Error error;
+VariableSP var_sp;
+
+// Find variable in stack frame
+ValueObjectSP 
value_sp(frame_sp->GetValueForVariableExpressionPath(var_name,
+   
eNoDynamicValues,
+   
StackFrame::eExpressionPathOptionCheckPtrVsMember |
+   
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
+   var_sp,
+   error));
+if (!error.Success())
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetFrameVarAsUnsigned - Error, 
couldn't find '%s' in frame", var_name);
+
+return false;
+}
+
+// Find the unsigned int value for the variable
+bool success = false;
+val = value_sp->GetValueAsUnsigned(0, &success);
+if (!success)
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetFrameVarAsUnsigned - Error, 
couldn't parse '%s' as an unsigned int", var_name);
+
+return false;
+}
+
+return true;
+}
+
+// Callback when a kernel breakpoint hits and we're looking for a specific 
coordinate.
+// Baton parameter contains a pointer to the target coordinate we want to 
break on.
+// Function then checks the .expand frame for the current coordinate and 
breaks to user if it matches.
+// Parameter 'break_id' is the id of the Breakpoint which made the callback.
+// Parameter 'break_loc_id' is the id for the BreakpointLocation which was hit,
+// a single logical breakpoint can have multiple addresses.
+bool
+RenderScriptRuntime::KernelBreakpointHit(void *baton, StoppointCallbackContext 
*ctx,
+ user_id_t break_id, user_id_t 
break_loc_id)
+{
+Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | 
LIBLLDB_LOG_BREAKPOINTS));
+
+assert(baton && "Error: null baton in conditional kernel breakpoint 
callback");
+
+// Coordinate we want to stop on
+const int* target_coord = static_cast(baton);
+
+if (log)
+log->Printf("RenderScriptRuntime::KernelBreakpointHit - Break ID %" 
PRIu64 ", target coord (%d, %d, %d)",
+break_id, target_coord[0], target_coord[1], 
target_coord[2]);
+
+// Go up one stack frame to .expand kernel
+ExecutionContext context(ctx->exe_ctx_ref);
+ThreadSP thread_sp = context.GetThreadSP();
+if (!thread_sp->SetSelectedFrameByIndex(1))
+{
+if (log)
+log->Printf("RenderScriptRuntime::KernelBreakpointHit - 

[Lldb-commits] [lldb] r254294 - [RS] Support RenderScript struct allocations

2015-11-30 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Mon Nov 30 04:29:49 2015
New Revision: 254294

URL: http://llvm.org/viewvc/llvm-project?rev=254294&view=rev
Log:
[RS] Support RenderScript struct allocations

This patch adds functionality for dumping allocations of struct elements. This 
involves:

+ Jitting the runtime for details on all the struct fields.

+ Finding the name of the struct type by looking for a global variable of 
the same type, which will have been reflected back to the java host code.

+ Using this struct type name to pass into expression evaluation for pretty 
printing the data for the dump command.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=254294&r1=254293&r2=254294&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Mon Nov 30 04:29:49 2015
@@ -18,7 +18,9 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/Core/RegularExpression.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/Host/StringConvert.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Type.h"
@@ -133,42 +135,61 @@ struct RenderScriptRuntime::ScriptDetail
 empirical_type script;
 };
 
+// This Element class represents the Element object in RS,
+// defining the type associated with an Allocation.
+struct RenderScriptRuntime::Element
+{
+// Taken from rsDefines.h
+enum DataKind
+{
+RS_KIND_USER,
+RS_KIND_PIXEL_L = 7,
+RS_KIND_PIXEL_A,
+RS_KIND_PIXEL_LA,
+RS_KIND_PIXEL_RGB,
+RS_KIND_PIXEL_RGBA,
+RS_KIND_PIXEL_DEPTH,
+RS_KIND_PIXEL_YUV,
+RS_KIND_INVALID = 100
+};
+
+// Taken from rsDefines.h
+enum DataType
+{
+RS_TYPE_NONE = 0,
+RS_TYPE_FLOAT_16,
+RS_TYPE_FLOAT_32,
+RS_TYPE_FLOAT_64,
+RS_TYPE_SIGNED_8,
+RS_TYPE_SIGNED_16,
+RS_TYPE_SIGNED_32,
+RS_TYPE_SIGNED_64,
+RS_TYPE_UNSIGNED_8,
+RS_TYPE_UNSIGNED_16,
+RS_TYPE_UNSIGNED_32,
+RS_TYPE_UNSIGNED_64,
+RS_TYPE_BOOLEAN
+};
+
+std::vector children;   // Child Element 
fields for structs
+empirical_type element_ptr;// Pointer to the RS 
Element of the Type
+empirical_type type;   // Type of each data 
pointer stored by the allocation
+empirical_type type_kind;  // Defines pixel type 
if Allocation is created from an image
+empirical_type type_vec_size;  // Vector size of 
each data point, e.g '4' for uchar4
+empirical_type field_count;// Number of 
Subelements
+empirical_type datum_size; // Size of a single 
Element with padding
+empirical_type padding;// Number of padding 
bytes
+empirical_type array_size; // Number of items in 
array, only needed for strucrs
+ConstString type_name;   // Name of type, only 
needed for structs
+
+static const ConstString FallbackStructName; // Print this as the 
type name of a struct Element
+ // If we can't 
resolve the actual struct name
+};
+
 // This AllocationDetails class collects data associated with a single
 // allocation instance.
 struct RenderScriptRuntime::AllocationDetails
 {
-   // Taken from rsDefines.h
-   enum DataKind
-   {
-   RS_KIND_USER,
-   RS_KIND_PIXEL_L = 7,
-   RS_KIND_PIXEL_A,
-   RS_KIND_PIXEL_LA,
-   RS_KIND_PIXEL_RGB,
-   RS_KIND_PIXEL_RGBA,
-   RS_KIND_PIXEL_DEPTH,
-   RS_KIND_PIXEL_YUV,
-   RS_KIND_INVALID = 100
-   };
-
-   // Taken from rsDefines.h
-   enum DataType
-   {
-   RS_TYPE_NONE = 0,
-   RS_TYPE_FLOAT_16,
-   RS_TYPE_FLOAT_32,
-   RS_TYPE_FLOAT_64,
-   RS_TYPE_SIGNED_8,
-   RS_TYPE_SIGNED_16,
-   RS_TYPE_SIGNED_32,
-   RS_TYPE_SIGNED_64,
-   RS_TYPE_UNSIGNED_8,
-   RS_TYPE_UNSIGNED_16,
-   RS_TYPE_UNSIGNED_32,
-   RS_TYPE_UNSIGNED_64,
-   RS_TYPE_BOOLEAN
-};
-
 struct Dimension
 {
 uint32_t dim_1;
@@ -214,14 +235,11 @@ struct RenderScriptRuntime::AllocationDe
 // for commands to reference it.
 const uns

Re: [Lldb-commits] [PATCH] D15092: Fix hang in global static initialization

2015-12-01 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

Thanks for fixing this Adrian


Repository:
  rL LLVM

http://reviews.llvm.org/D15092



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D15116: Fix for evaluating a function with an ambiguous symbol

2015-12-01 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added a reviewer: spyffe.
EwanCrawford added a subscriber: lldb-commits.
EwanCrawford set the repository for this revision to rL LLVM.

I came across a bug for calling functions using expression evaluation, where 
the function name also matches a symbol from another compile unit.
The attached test case recreates it when compiled with gcc. Clang however 
doesn't seem to export a conflicting .rodata symbol so the bug doesn't appear.

Currently trying to call the function gives the following error in the test 
case.
   
```
 (lldb) expr overloaded_symbol(1)
 error: warning: got name from symbols: overloaded_symbol
 error: reference to 'overloaded_symbol' is ambiguous
 note: candidate found by name lookup is 'overloaded_symbol'
 note: candidate found by name lookup is 'overloaded_symbol'
 error: 1 errors parsing expression
```

This patch in the clang expression parser stops us turning the symbol into a 
global variable declaration if we've already found
a matching function. I'm not familiar with this code, so if there's a better 
way to fix this please let me know.

Repository:
  rL LLVM

http://reviews.llvm.org/D15116

Files:
  packages/Python/lldbsuite/test/expression_command/overloaded_symbol/Makefile
  
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py
  packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp
  
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1576,7 +1576,7 @@
 } while (0);
 }
 
-if (target && !context.m_found.variable && !namespace_decl)
+if (target && !context.m_found.variable && 
!context.m_found.function && !context.m_found.function_with_type_info && 
!namespace_decl)
 {
 // We couldn't find a non-symbol variable for this.  Now we'll 
hunt for a generic
 // data symbol, and -- if it is found -- treat it as a 
variable.
Index: 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp
===
--- 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp
+++ 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/overload.cpp
@@ -0,0 +1,6 @@
+const int overloaded_symbol = 2;
+
+int return_global()
+{
+return overloaded_symbol;
+}
Index: 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp
===
--- packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp
+++ packages/Python/lldbsuite/test/expression_command/overloaded_symbol/main.cpp
@@ -0,0 +1,12 @@
+int return_global();
+
+int overloaded_symbol(int x)
+{
+return x + 1;
+}
+
+int main()
+{
+int my_local = return_global(); // break here
+return overloaded_symbol(my_local);
+}
Index: 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py
===
--- 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py
+++ 
packages/Python/lldbsuite/test/expression_command/overloaded_symbol/TestCallSymbolConflict.py
@@ -0,0 +1,36 @@
+"""
+Test calling function which has a name conflicting with a .rodata symbol
+"""
+
+from __future__ import print_function
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class ExprCommandCallSymbolConfict(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+# Find the line number to break for main.c.
+self.line = line_number('main.cpp', '// break here')
+
+@expectedFlakeyDsym("llvm.org/pr20274")
+@expectedFailureWindows("llvm.org/pr24489: Name lookup not working 
correctly on Windows")
+def test(self):
+"""Test return value of call to function whose name conflicts with 
another symbol."""
+self.build()
+
+# Set breakpoint in main and run exe
+self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, 
num_expected_locations=-1, loc_exact=True)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# Function semantics are simply to return the incremented integer 
parameter
+self.expect("expr overloaded_symbol(5)", substrs = ['$0 = 6'])
Index: 
packages/Python/lldbsuite/tes

[Lldb-commits] [lldb] r254910 - [RenderScript] Mips64 allocations workaround

2015-12-07 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Mon Dec  7 07:50:32 2015
New Revision: 254910

URL: http://llvm.org/viewvc/llvm-project?rev=254910&view=rev
Log:
[RenderScript] Mips64 allocations workaround

Workaround for Mips64 compiler bug by using function pointers to call 
functions for expression evaluation. This avoids the emission of the JAL 
instruction, 
which can only jump within a particular range of the PC.

Author: Dean De Leo, d...@codeplay.com

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=254910&r1=254909&r2=254910&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Mon Dec  7 07:50:32 2015
@@ -1114,61 +1114,136 @@ RenderScriptRuntime::EvalRSExpression(co
 return true;
 }
 
-// Used to index expression format strings
-enum ExpressionStrings
+namespace // anonymous
 {
-   eExprGetOffsetPtr = 0,
-   eExprAllocGetType,
-   eExprTypeDimX,
-   eExprTypeDimY,
-   eExprTypeDimZ,
-   eExprTypeElemPtr,
-   eExprElementType,
-   eExprElementKind,
-   eExprElementVec,
-   eExprElementFieldCount,
-   eExprSubelementsId,
-   eExprSubelementsName,
-   eExprSubelementsArrSize
-};
-
-// Format strings containing the expressions we may need to evaluate.
-const char runtimeExpressions[][256] =
-{
- // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
- 
"(int*)_Z12GetOffsetPtrPKN7android12renderscript10AllocationE23RsAllocationCubemapFace(0x%lx,
 %u, %u, %u, 0, 0)",
-
- // Type* rsaAllocationGetType(Context*, Allocation*)
- "(void*)rsaAllocationGetType(0x%lx, 0x%lx)",
-
- // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
- // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; 
mHal.state.dimZ;
- // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
- // Need to specify 32 or 64 bit for uint_t since this differs between devices
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[0]", // X dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[1]", // Y dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[2]", // Z dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[5]", // Element ptr
-
- // rsaElementGetNativeData(Context*, Element*, uint32_t* elemData,size)
- // Pack mType; mKind; mNormalized; mVectorSize; NumSubElements into elemData
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[0]", // Type
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[1]", // Kind
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[3]", // Vector Size
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[4]", // Field Count
-
-  // rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t *ids, 
const char **names,
-  // size_t *arraySizes, uint32_t dataSize)
-  // Needed for Allocations of structs to gather details about 
fields/Subelements
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
ids[%u]", // Element* of field
-
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
names[%u]",   // Name of field
-
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
arr_size[%u]" // Array size of field
-};
+// max length of an expanded expression
+const int jit_max_expr_size = 768;
+
+// Format strings containing the expressions we may need to evaluate.
+const char runtimeExpressions[][256] =
+{
+ // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
+ 
"(int*)_Z12GetOffsetPtrPKN7android12renderscript10AllocationE23RsAllocationCubemapFace(0x%lx,
 %u, %u, %u, 0, 0)",
+
+ // Type* rsaAllocationGetType(Context*, Allocation*)
+ "(void*)rsaAllocationGetType(0x%lx, 0x%lx)",
+
+ // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
+ // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; 
mHal.state.dimZ;
+ // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
+ // Need to specify 32 or 64 bit for uint_t sinc

[Lldb-commits] [lldb] r255121 - [RenderScript] Add hook for destroyed allocations

2015-12-09 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Dec  9 10:01:58 2015
New Revision: 255121

URL: http://llvm.org/viewvc/llvm-project?rev=255121&view=rev
Log:
[RenderScript] Add hook for destroyed allocations

New hook for rsdAllocationDestroy() which is called when allocations are 
deleted.
LLDB should be aware of this so we can remove the allocation from our internal 
list.


Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=255121&r1=255120&r2=255121&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Dec  9 10:01:58 2015
@@ -556,6 +556,14 @@ const RenderScriptRuntime::HookDefn Rend
 RenderScriptRuntime::eModuleKindDriver, // type
 nullptr // handler
 },
+{
+"rsdAllocationDestroy", // name
+
"_Z20rsdAllocationDestroyPKN7android12renderscript7ContextEPNS0_10AllocationE", 
// symbol name 32bit
+
"_Z20rsdAllocationDestroyPKN7android12renderscript7ContextEPNS0_10AllocationE", 
// symbol name 64bit
+0, // version
+RenderScriptRuntime::eModuleKindDriver, // type
+&lldb_private::RenderScriptRuntime::CaptureAllocationDestroy // handler
+},
 };
 
 const size_t RenderScriptRuntime::s_runtimeHookCount = 
sizeof(s_runtimeHookDefns)/sizeof(s_runtimeHookDefns[0]);
@@ -857,6 +865,43 @@ RenderScriptRuntime::CaptureAllocationIn
 alloc->context = rs_context_u64;
 }
 
+void
+RenderScriptRuntime::CaptureAllocationDestroy(RuntimeHook* hook_info, 
ExecutionContext& context)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+// Context, Alloc
+uint64_t rs_context_u64 = 0U;
+uint64_t rs_alloc_u64 = 0U;
+
+bool success = GetArgSimple(context, 0, &rs_context_u64) && 
GetArgSimple(context, 1, &rs_alloc_u64);
+if (!success) // error case
+{
+if (log)
+log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Error 
while reading the function parameters");
+return; // abort
+}
+
+if (log)
+log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - 0x%" 
PRIx64 ", 0x%" PRIx64 ".",
+rs_context_u64, rs_alloc_u64);
+
+for (auto iter = m_allocations.begin(); iter != m_allocations.end(); 
++iter)
+{
+auto& allocation_ap = *iter; // get the unique pointer
+if (allocation_ap->address.isValid() && *allocation_ap->address.get() 
== rs_alloc_u64)
+{
+m_allocations.erase(iter);
+if (log)
+log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - 
Deleted allocation entry");
+return;
+}
+}
+
+if (log)
+log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Couldn't 
find destroyed allocation");
+}
+
 void 
 RenderScriptRuntime::CaptureScriptInit1(RuntimeHook* hook_info, 
ExecutionContext& context)
 {
@@ -2304,7 +2349,6 @@ RenderScriptRuntime::Status(Stream &strm
 strm.Indent(b.second->defn->name);
 strm.EOL();
 }
-strm.EOL();
 } 
 else
 {

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=255121&r1=255120&r2=255121&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 Wed Dec  9 10:01:58 2015
@@ -326,6 +326,7 @@ private:
 
 void CaptureScriptInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& 
context);
+void CaptureAllocationDestroy(RuntimeHook* hook_info, ExecutionContext& 
context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& 
context);
 
 AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r255238 - [RenderScript] Refactor condition deciding when to JIT RS runtime

2015-12-10 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Dec 10 04:20:39 2015
New Revision: 255238

URL: http://llvm.org/viewvc/llvm-project?rev=255238&view=rev
Log:
[RenderScript] Refactor condition deciding when to JIT RS runtime

Patch creates a member function that decides when to JIT all the details about 
an allocation.
By checking for zero pointers we can avoid the situation where we store 
uninitialised data from previously inspecting the allocation during creation.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=255238&r1=255237&r2=255238&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Thu Dec 10 04:20:39 2015
@@ -184,6 +184,13 @@ struct RenderScriptRuntime::Element
 
 static const ConstString &GetFallbackStructName();   // Print this as the 
type name of a struct Element
  // If we can't 
resolve the actual struct name
+
+bool shouldRefresh() const
+{
+const bool valid_ptr = element_ptr.isValid() && *element_ptr.get() != 
0x0;
+const bool valid_type = type.isValid() && type_vec_size.isValid() && 
type_kind.isValid();
+return !valid_ptr || !valid_type || !datum_size.isValid();
+}
 };
 
 // This AllocationDetails class collects data associated with a single
@@ -248,6 +255,13 @@ struct RenderScriptRuntime::AllocationDe
 AllocationDetails(): id(ID++)
 {
 }
+
+bool shouldRefresh() const
+{
+bool valid_ptrs = data_ptr.isValid() && *data_ptr.get() != 0x0;
+valid_ptrs = valid_ptrs && type_ptr.isValid() && *type_ptr.get() != 
0x0;
+return !valid_ptrs || !dimension.isValid() || !size.isValid() || 
element.shouldRefresh();
+}
 };
 
 
@@ -1871,8 +1885,7 @@ RenderScriptRuntime::GetAllocationData(A
 Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
 
 // JIT all the allocation details
-if (!allocation->data_ptr.isValid() || !allocation->element.type.isValid()
-|| !allocation->element.type_vec_size.isValid() || 
!allocation->size.isValid())
+if (allocation->shouldRefresh())
 {
 if (log)
 log->Printf("RenderScriptRuntime::GetAllocationData - Allocation 
details not calculated yet, jitting info");
@@ -1930,8 +1943,7 @@ RenderScriptRuntime::LoadAllocation(Stre
 log->Printf("RenderScriptRuntime::LoadAllocation - Found allocation 
0x%" PRIx64, *alloc->address.get());
 
 // JIT all the allocation details
-if (!alloc->data_ptr.isValid() || !alloc->element.type.isValid() || 
!alloc->element.datum_size.isValid()
-|| !alloc->element.type_vec_size.isValid() || !alloc->size.isValid())
+if (alloc->shouldRefresh())
 {
 if (log)
 log->Printf("RenderScriptRuntime::LoadAllocation - Allocation 
details not calculated yet, jitting info");
@@ -2044,8 +2056,7 @@ RenderScriptRuntime::SaveAllocation(Stre
 log->Printf("RenderScriptRuntime::SaveAllocation - Found allocation 
0x%" PRIx64, *alloc->address.get());
 
  // JIT all the allocation details
-if (!alloc->data_ptr.isValid() || !alloc->element.type.isValid() || 
!alloc->element.type_vec_size.isValid()
-|| !alloc->element.type_kind.isValid() || !alloc->dimension.isValid())
+if (alloc->shouldRefresh())
 {
 if (log)
 log->Printf("RenderScriptRuntime::SaveAllocation - Allocation 
details not calculated yet, jitting info");
@@ -2458,8 +2469,7 @@ RenderScriptRuntime::DumpAllocation(Stre
 log->Printf("RenderScriptRuntime::DumpAllocation - Found allocation 
0x%" PRIx64, *alloc->address.get());
 
 // Check we have information about the allocation, if not calculate it
-if (!alloc->data_ptr.isValid() || !alloc->element.type.isValid() ||
-!alloc->element.type_vec_size.isValid() || !alloc->dimension.isValid() 
|| !alloc->element.datum_size.isValid())
+if (alloc->shouldRefresh())
 {
 if (log)
 log->Printf("RenderScriptRuntime::DumpAllocation - Allocation 
details not calculated yet, jitting info");
@@ -2602,7 +2612,7 @@ RenderScriptRuntime::ListAllocations(Str
 for (auto &alloc : m_allocations)
 {
 // JIT the allocation info if we haven't done it, or the user forces 
us to.
-bool do_refresh = !alloc->data_ptr.isValid() || recompute;
+bool do_refresh = alloc->shouldRefresh() || recompute;
 
 // JIT current allocation information
 if (do_refresh && !Re

Re: [Lldb-commits] [PATCH] D15116: Fix for evaluating a function with an ambiguous symbol

2015-12-10 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

ping


Repository:
  rL LLVM

http://reviews.llvm.org/D15116



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r255338 - [RenderScript] Support for amd64 RS hooks

2015-12-11 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Fri Dec 11 07:49:21 2015
New Revision: 255338

URL: http://llvm.org/viewvc/llvm-project?rev=255338&view=rev
Log:
[RenderScript] Support for amd64 RS hooks

Adds support for reading a maximum of six integer arguments from a renderscript 
hook on X86_64.
Author: Luke Drummond 

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=255338&r1=255337&r2=255338&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Fri Dec 11 07:49:21 2015
@@ -612,6 +612,16 @@ RenderScriptRuntime::HookCallback(Runtim
 bool
 RenderScriptRuntime::GetArgSimple(ExecutionContext &context, uint32_t arg, 
uint64_t *data)
 {
+// Get a positional integer argument.
+// Given an ExecutionContext, ``context`` which should be a RenderScript
+// frame, get the value of the positional argument ``arg`` and save its 
value
+// to the address pointed to by ``data``.
+// returns true on success, false otherwise.
+// If unsuccessful, the value pointed to by ``data`` is undefined. 
Otherwise,
+// ``data`` will be set to the value of the the given ``arg``.
+// NOTE: only natural width integer arguments for the machine are 
supported.
+// Behaviour with non primitive arguments is undefined.
+
 if (!data)
 return false;
 
@@ -640,7 +650,7 @@ RenderScriptRuntime::GetArgSimple(Execut
 if (error.Fail())
 {
 if (log)
-log->Printf ("RenderScriptRuntime:: GetArgSimple - error 
reading X86 stack: %s.", error.AsCString());
+log->Printf("RenderScriptRuntime::GetArgSimple - error 
reading X86 stack: %s.", error.AsCString());
 }
 else
 {
@@ -650,6 +660,35 @@ RenderScriptRuntime::GetArgSimple(Execut
 
 break;
 }
+case llvm::Triple::ArchType::x86_64:
+{
+// amd64 has 6 integer registers, and 8 XMM registers for 
parameter passing.
+// Surplus args are spilled onto the stack.
+// rdi, rsi, rdx, rcx, r8, r9, (zmm0 - 7 for vectors)
+// ref: AMD64 ABI Draft 0.99.6 – October 7, 2013 – 10:35; 
Figure 3.4. Retrieved from
+// http://www.x86-64.org/documentation/abi.pdf
+if (arg > 5)
+{
+if (log)
+log->Warning("X86_64 register spill is not supported.");
+break;
+}
+const char * regnames[] = {"rdi", "rsi", "rdx", "rcx", "r8", "r9"};
+assert((sizeof(regnames) / sizeof(const char *)) > arg);
+const RegisterInfo *rArg = 
reg_ctx->GetRegisterInfoByName(regnames[arg]);
+RegisterValue rVal;
+success = reg_ctx->ReadRegister(rArg, rVal);
+if (success)
+{
+*data = rVal.GetAsUInt64(0u, &success);
+}
+else
+{
+if (log)
+log->Printf("RenderScriptRuntime::GetArgSimple - error 
reading x86_64 register: %d.", arg);
+}
+break;
+}
 case llvm::Triple::ArchType::arm:
 {
 // arm 32 bit
@@ -660,12 +699,12 @@ RenderScriptRuntime::GetArgSimple(Execut
 success = reg_ctx->ReadRegister(rArg, rVal);
 if (success)
 {
-(*data) = rVal.GetAsUInt32();
+(*data) = rVal.GetAsUInt32(0u, &success);
 }
 else
 {
 if (log)
-log->Printf ("RenderScriptRuntime:: GetArgSimple - 
error reading ARM register: %d.", arg);
+log->Printf("RenderScriptRuntime::GetArgSimple - error 
reading ARM register: %d.", arg);
 }
 }
 else
@@ -676,7 +715,7 @@ RenderScriptRuntime::GetArgSimple(Execut
 if (error.Fail())
 {
 if (log)
-log->Printf ("RenderScriptRuntime:: GetArgSimple - 
error reading ARM stack: %s.", error.AsCString());
+log->Printf("RenderScriptRuntime::GetArgSimple - error 
reading ARM stack: %s.", error.AsCString());
 }
 else
 {
@@ -697,7 +736,7 @@ RenderScriptRuntime::GetArgSimple(Execut
 success = reg_ctx->ReadRegister(rArg, rVal);
 if (success)

Re: [Lldb-commits] [PATCH] D15116: Fix for evaluating a function with an ambiguous symbol

2016-07-12 Thread Ewan Crawford via lldb-commits
EwanCrawford abandoned this revision.
EwanCrawford added a comment.

Thanks for getting around to looking at this Sean, i'd forgotten about it.
Unfortunately the patch seems to have gone stale as the test case no longer 
passes.
So i'm just going to close the review for now.


Repository:
  rL LLVM

http://reviews.llvm.org/D15116



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D15576: Inspect global static const variables

2015-12-16 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: tberghammer, clayborg.
EwanCrawford added a subscriber: lldb-commits.
EwanCrawford set the repository for this revision to rL LLVM.

This patch adds support for printing global static const variables which are 
given a DW_AT_const_value DWARF tag by clang.

Fix for bug https://llvm.org/bugs/show_bug.cgi?id=25653

Repository:
  rL LLVM

http://reviews.llvm.org/D15576

Files:
  packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
  packages/Python/lldbsuite/test/lang/c/global_variables/main.c
  source/Core/ValueObject.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4260,7 +4260,10 @@
 }
 else
 {
-scope = eValueTypeVariableLocal;
+if (location_is_const_value_data)
+scope = eValueTypeVariableStatic;
+else
+scope = eValueTypeVariableLocal;
 }
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -815,7 +815,7 @@
 bool is_declaration = false;
 //bool is_artificial = false;
 bool has_address = false;
-bool has_location = false;
+bool has_location_or_const_value = false;
 bool is_global_or_static_variable = false;
 
 DWARFFormValue specification_die_form;
@@ -860,7 +860,8 @@
 break;
 
 case DW_AT_location:
-has_location = true;
+case DW_AT_const_value:
+has_location_or_const_value = true;
 if (tag == DW_TAG_variable)
 {
 const DWARFDebugInfoEntry* parent_die = 
die.GetParent();
@@ -1035,7 +1036,7 @@
 break;
 
 case DW_TAG_variable:
-if (name && has_location && is_global_or_static_variable)
+if (name && has_location_or_const_value && 
is_global_or_static_variable)
 {
 globals.Insert (ConstString(name), DIERef(cu_offset, 
die.GetOffset()));
 // Be sure to include variables by their mangled and demangled
Index: source/Core/ValueObject.cpp
===
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -1135,6 +1135,7 @@
 if (m_data.GetByteSize())
 {
 data = m_data;
+error.Clear();
 return data.GetByteSize();
 }
 else
Index: packages/Python/lldbsuite/test/lang/c/global_variables/main.c
===
--- packages/Python/lldbsuite/test/lang/c/global_variables/main.c
+++ packages/Python/lldbsuite/test/lang/c/global_variables/main.c
@@ -10,6 +10,7 @@
 
 int g_common_1; // Not initialized on purpose to cause it to be undefined 
external in .o file
 int g_file_global_int = 42;
+static const int g_file_static_int = 2;
 const char *g_file_global_cstr = "g_file_global_cstr";
 static const char *g_file_static_cstr = "g_file_static_cstr";
 
@@ -16,7 +17,7 @@
 extern int g_a;
 int main (int argc, char const *argv[])
 {
-g_common_1 = g_file_global_int / 2;
+g_common_1 = g_file_global_int / g_file_static_int;
 static const char *g_func_static_cstr = "g_func_static_cstr";
 printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
 return g_file_global_int + g_a + g_common_1; // Set break point at this 
line.   break $source:$line; continue; var -global g_a -global g_global_int
Index: 
packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
===
--- 
packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
+++ 
packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
@@ -52,6 +52,7 @@
 # Check that GLOBAL scopes are indicated for the variables.
 self.expect("frame variable --show-types --scope --show-globals 
--no-args", VARIABLES_DISPLAYED_CORRECTLY,
 substrs = ['GLOBAL: (int) g_file_global_int = 42',
+   'STATIC: (const int) g_file_static_int = 2',
'GLOBAL: (const char *) g_file_global_cstr',
'"g_file_global_cstr"',
'STATIC: (const char *) g_file_static_cstr',


Index: source/Plugins/SymbolFile/DWARF/SymbolF

[Lldb-commits] [lldb] r255887 - Inspect DW_AT_const_value global static const variables

2015-12-17 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Dec 17 05:59:47 2015
New Revision: 255887

URL: http://llvm.org/viewvc/llvm-project?rev=255887&view=rev
Log:
Inspect DW_AT_const_value global static const variables

This patch adds support for printing global static const variables which are 
given a DW_AT_const_value DWARF tag by clang.

Fix for bug https://llvm.org/bugs/show_bug.cgi?id=25653

Reviewers: clayborg, tberghammer
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D15576

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py?rev=255887&r1=255886&r2=255887&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
 Thu Dec 17 05:59:47 2015
@@ -52,6 +52,7 @@ class GlobalVariablesTestCase(TestBase):
 # Check that GLOBAL scopes are indicated for the variables.
 self.expect("frame variable --show-types --scope --show-globals 
--no-args", VARIABLES_DISPLAYED_CORRECTLY,
 substrs = ['GLOBAL: (int) g_file_global_int = 42',
+   'STATIC: (const int) g_file_static_int = 2',
'GLOBAL: (const char *) g_file_global_cstr',
'"g_file_global_cstr"',
'STATIC: (const char *) g_file_static_cstr',

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c?rev=255887&r1=255886&r2=255887&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c 
Thu Dec 17 05:59:47 2015
@@ -10,13 +10,14 @@
 
 int g_common_1; // Not initialized on purpose to cause it to be undefined 
external in .o file
 int g_file_global_int = 42;
+static const int g_file_static_int = 2;
 const char *g_file_global_cstr = "g_file_global_cstr";
 static const char *g_file_static_cstr = "g_file_static_cstr";
 
 extern int g_a;
 int main (int argc, char const *argv[])
 {
-g_common_1 = g_file_global_int / 2;
+g_common_1 = g_file_global_int / g_file_static_int;
 static const char *g_func_static_cstr = "g_func_static_cstr";
 printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
 return g_file_global_int + g_a + g_common_1; // Set break point at this 
line.   break $source:$line; continue; var -global g_a -global g_global_int

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=255887&r1=255886&r2=255887&view=diff
==
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Dec 17 05:59:47 2015
@@ -1135,6 +1135,7 @@ ValueObject::GetData (DataExtractor& dat
 if (m_data.GetByteSize())
 {
 data = m_data;
+error.Clear();
 return data.GetByteSize();
 }
 else

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=255887&r1=255886&r2=255887&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Dec 17 
05:59:47 2015
@@ -815,7 +815,7 @@ DWARFCompileUnit::IndexPrivate (DWARFCom
 bool is_declaration = false;
 //bool is_artificial = false;
 bool has_address = false;
-bool has_location = false;
+bool has_location_or_const_value = false;
 bool is_global_or_static_variable = false;
 
 DWARFFormValue specification_die_form;
@@ -860,7 +860,8 @@ DWARFCompileUnit::IndexPrivate (DWARFCom
 break;
 
 case DW_AT_location:
-has_location = true;
+case DW_AT_const_value:
+has_location_or_const_value = true;
   

Re: [Lldb-commits] [PATCH] D15576: Inspect global static const variables

2015-12-17 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255887: Inspect DW_AT_const_value global static const 
variables (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D15576?vs=43017&id=43119#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15576

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
  lldb/trunk/source/Core/ValueObject.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/trunk/source/Core/ValueObject.cpp
===
--- lldb/trunk/source/Core/ValueObject.cpp
+++ lldb/trunk/source/Core/ValueObject.cpp
@@ -1135,6 +1135,7 @@
 if (m_data.GetByteSize())
 {
 data = m_data;
+error.Clear();
 return data.GetByteSize();
 }
 else
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4260,7 +4260,10 @@
 }
 else
 {
-scope = eValueTypeVariableLocal;
+if (location_is_const_value_data)
+scope = eValueTypeVariableStatic;
+else
+scope = eValueTypeVariableLocal;
 }
 }
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -815,7 +815,7 @@
 bool is_declaration = false;
 //bool is_artificial = false;
 bool has_address = false;
-bool has_location = false;
+bool has_location_or_const_value = false;
 bool is_global_or_static_variable = false;
 
 DWARFFormValue specification_die_form;
@@ -860,7 +860,8 @@
 break;
 
 case DW_AT_location:
-has_location = true;
+case DW_AT_const_value:
+has_location_or_const_value = true;
 if (tag == DW_TAG_variable)
 {
 const DWARFDebugInfoEntry* parent_die = 
die.GetParent();
@@ -1035,7 +1036,7 @@
 break;
 
 case DW_TAG_variable:
-if (name && has_location && is_global_or_static_variable)
+if (name && has_location_or_const_value && 
is_global_or_static_variable)
 {
 globals.Insert (ConstString(name), DIERef(cu_offset, 
die.GetOffset()));
 // Be sure to include variables by their mangled and demangled
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
@@ -10,13 +10,14 @@
 
 int g_common_1; // Not initialized on purpose to cause it to be undefined 
external in .o file
 int g_file_global_int = 42;
+static const int g_file_static_int = 2;
 const char *g_file_global_cstr = "g_file_global_cstr";
 static const char *g_file_static_cstr = "g_file_static_cstr";
 
 extern int g_a;
 int main (int argc, char const *argv[])
 {
-g_common_1 = g_file_global_int / 2;
+g_common_1 = g_file_global_int / g_file_static_int;
 static const char *g_func_static_cstr = "g_func_static_cstr";
 printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
 return g_file_global_int + g_a + g_common_1; // Set break point at this 
line.   break $source:$line; continue; var -global g_a -global g_global_int
Index: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
@@ -52,6 +52,7 @@
 # Check that GLOBAL scopes are indicated for the variables.
 self.expect("frame variable --show-types --scope --show-globals 
--no-args", VARIABLES_DISPLAYED_CORRECTLY,
 substrs = ['GLOBAL: (int) g_file_global_int = 42',
+   'STATIC: (const int) g_file_static_int = 2',
'GLOBAL: (const char *) g_file_global_cstr',
'"g_file_global_cstr"',
'

[Lldb-commits] [lldb] r255904 - [RenderScript] Support all RS allocation types

2015-12-17 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Dec 17 10:40:05 2015
New Revision: 255904

URL: http://llvm.org/viewvc/llvm-project?rev=255904&view=rev
Log:
[RenderScript] Support all RS allocation types 

Currently we can just inspect the details of the most common allocation types.
This patch allows us to support all the types defined by the RS runtime in its 
`RsDataType` enum.
Including handlers, matrices and packed graphical data.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=255904&r1=255903&r2=255904&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Thu Dec 17 10:40:05 2015
@@ -168,7 +168,29 @@ struct RenderScriptRuntime::Element
 RS_TYPE_UNSIGNED_16,
 RS_TYPE_UNSIGNED_32,
 RS_TYPE_UNSIGNED_64,
-RS_TYPE_BOOLEAN
+RS_TYPE_BOOLEAN,
+
+RS_TYPE_UNSIGNED_5_6_5,
+RS_TYPE_UNSIGNED_5_5_5_1,
+RS_TYPE_UNSIGNED_4_4_4_4,
+
+RS_TYPE_MATRIX_4X4,
+RS_TYPE_MATRIX_3X3,
+RS_TYPE_MATRIX_2X2,
+
+RS_TYPE_ELEMENT = 1000,
+RS_TYPE_TYPE,
+RS_TYPE_ALLOCATION,
+RS_TYPE_SAMPLER,
+RS_TYPE_SCRIPT,
+RS_TYPE_MESH,
+RS_TYPE_PROGRAM_FRAGMENT,
+RS_TYPE_PROGRAM_VERTEX,
+RS_TYPE_PROGRAM_RASTER,
+RS_TYPE_PROGRAM_STORE,
+RS_TYPE_FONT,
+
+RS_TYPE_INVALID = 1
 };
 
 std::vector children;   // Child Element 
fields for structs
@@ -302,7 +324,28 @@ const char* RenderScriptRuntime::Allocat
 {"ushort", "ushort2", "ushort3", "ushort4"},
 {"uint", "uint2", "uint3", "uint4"},
 {"ulong", "ulong2", "ulong3", "ulong4"},
-{"bool", "bool2", "bool3", "bool4"}
+{"bool", "bool2", "bool3", "bool4"},
+{"packed_565", "packed_565", "packed_565", "packed_565"},
+{"packed_5551", "packed_5551", "packed_5551", "packed_5551"},
+{"packed_", "packed_", "packed_", "packed_"},
+{"rs_matrix4x4", "rs_matrix4x4", "rs_matrix4x4", "rs_matrix4x4"},
+{"rs_matrix3x3", "rs_matrix3x3", "rs_matrix3x3", "rs_matrix3x3"},
+{"rs_matrix2x2", "rs_matrix2x2", "rs_matrix2x2", "rs_matrix2x2"},
+
+// Handlers
+{"RS Element", "RS Element", "RS Element", "RS Element"},
+{"RS Type", "RS Type", "RS Type", "RS Type"},
+{"RS Allocation", "RS Allocation", "RS Allocation", "RS Allocation"},
+{"RS Sampler", "RS Sampler", "RS Sampler", "RS Sampler"},
+{"RS Script", "RS Script", "RS Script", "RS Script"},
+
+// Deprecated
+{"RS Mesh", "RS Mesh", "RS Mesh", "RS Mesh"},
+{"RS Program Fragment", "RS Program Fragment", "RS Program Fragment", "RS 
Program Fragment"},
+{"RS Program Vertex", "RS Program Vertex", "RS Program Vertex", "RS 
Program Vertex"},
+{"RS Program Raster", "RS Program Raster", "RS Program Raster", "RS 
Program Raster"},
+{"RS Program Store", "RS Program Store", "RS Program Store", "RS Program 
Store"},
+{"RS Font", "RS Font", "RS Font", "RS Font"}
 };
 
 // Used as an index into the RSTypeToFormat array elements
@@ -327,7 +370,13 @@ const unsigned int RenderScriptRuntime::
 {eFormatDecimal, eFormatVectorOfUInt16, sizeof(uint16_t)}, // 
RS_TYPE_UNSIGNED_16
 {eFormatDecimal, eFormatVectorOfUInt32, sizeof(uint32_t)}, // 
RS_TYPE_UNSIGNED_32
 {eFormatDecimal, eFormatVectorOfUInt64, sizeof(uint64_t)}, // 
RS_TYPE_UNSIGNED_64
-{eFormatBoolean, eFormatBoolean, sizeof(bool)} // RS_TYPE_BOOL
+{eFormatBoolean, eFormatBoolean, 1}, // RS_TYPE_BOOL
+{eFormatHex, eFormatHex, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_5_6_5
+{eFormatHex, eFormatHex, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_5_5_5_1
+{eFormatHex, eFormatHex, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_4_4_4_4
+{eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 16}, // 
RS_TYPE_MATRIX_4X4
+{eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 9}, // 
RS_TYPE_MATRIX_3X3
+{eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 4} // 
RS_TYPE_MATRIX_2X2
 };
 
 //--
@@ -1896,12 +1945,12 @@ RenderScriptRuntime::SetElementSize(Elem
 {
 Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
 const Element::DataType type = *elem.type.get();
-assert(type >= Element::RS_TYPE_NONE && type <= Element::RS_TYPE_BOOLEAN
+assert(type >= Element::RS_TYPE_NONE && type <= Element::RS_TYPE_FONT
  

[Lldb-commits] [lldb] r256833 - Revert r256769

2016-01-05 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Jan  5 07:18:46 2016
New Revision: 256833

URL: http://llvm.org/viewvc/llvm-project?rev=256833&view=rev
Log:
Revert r256769

Reverts "Use correct format identifiers to print something meaningful."

Original format specifiers were correct.
Instead use void* casts to remove warnings, since this is what the %p specifier 
expects.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=256833&r1=256832&r2=256833&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Tue Jan  5 07:18:46 2016
@@ -2231,7 +2231,7 @@ RenderScriptRuntime::SaveAllocation(Stre
 // Write allocation data to file
 num_bytes = static_cast(*alloc->size.get());
 if (log)
-log->Printf("RenderScriptRuntime::SaveAllocation - Writing 0x%" PRIx64 
" bytes from %s", (uint64_t) num_bytes, buffer.get());
+log->Printf("RenderScriptRuntime::SaveAllocation - Writing 0x%" PRIx64 
" bytes from %p", (uint64_t) num_bytes, (void*) buffer.get());
 
 err = file.Write(buffer.get(), num_bytes);
 if (!err.Success())

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp?rev=256833&r1=256832&r2=256833&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp Tue Jan  5 
07:18:46 2016
@@ -69,7 +69,7 @@ NameToDIE::Dump (Stream *s)
 {
 const char *cstr = m_map.GetCStringAtIndex(i);
 const DIERef& die_ref = m_map.GetValueAtIndexUnchecked(i);
-s->Printf("%s: {0x%8.8x/0x%8.8x} \"%s\"\n", cstr, die_ref.cu_offset, 
die_ref.die_offset, cstr);
+s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", (const void*) cstr, 
die_ref.cu_offset, die_ref.die_offset, cstr);
 }
 }
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r256927 - Add LogDump methods to lldb_private::StringList.

2016-01-06 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Jan  6 05:06:30 2016
New Revision: 256927

URL: http://llvm.org/viewvc/llvm-project?rev=256927&view=rev
Log:
Add LogDump methods to lldb_private::StringList.

This patch eases the printing of iterable string containers.

Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D15773

Modified:
lldb/trunk/include/lldb/Core/StringList.h
lldb/trunk/source/Core/StringList.cpp

Modified: lldb/trunk/include/lldb/Core/StringList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StringList.h?rev=256927&r1=256926&r2=256927&view=diff
==
--- lldb/trunk/include/lldb/Core/StringList.h (original)
+++ lldb/trunk/include/lldb/Core/StringList.h Wed Jan  6 05:06:30 2016
@@ -133,8 +133,15 @@ public:
 operator << (const char* str);
 
 StringList&
+operator << (const std::string &s);
+
+StringList&
 operator << (StringList strings);
 
+// Copy assignment for a vector of strings
+StringList&
+operator = (const std::vector &rhs);
+
 // This string list contains a list of valid auto completion
 // strings, and the "s" is passed in. "matches" is filled in
 // with zero or more string values that start with "s", and
@@ -147,6 +154,23 @@ public:
   StringList &matches,
   size_t &exact_matches_idx) const;
 
+// Dump the StringList to the given lldb_private::Log, `log`, one item per 
line.
+// If given, `name` will be used to identify the start and end of the list 
in the output.
+virtual void LogDump(Log *log, const char *name = nullptr);
+
+// Static helper to convert an iterable of strings to a StringList, and 
then
+// dump it with the semantics of the `LogDump` method.
+template static void LogDump(Log *log, T s_iterable, const 
char *name = nullptr)
+{
+if (!log)
+return;
+// Make a copy of the iterable as a StringList
+StringList l{};
+for (const auto &s : s_iterable)
+l << s;
+
+l.LogDump(log, name);
+}
 private:
 STLStringArray m_strings;
 };

Modified: lldb/trunk/source/Core/StringList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StringList.cpp?rev=256927&r1=256926&r2=256927&view=diff
==
--- lldb/trunk/source/Core/StringList.cpp (original)
+++ lldb/trunk/source/Core/StringList.cpp Wed Jan  6 05:06:30 2016
@@ -11,6 +11,8 @@
 
 #include "lldb/Core/StreamString.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamString.h"
 
 #include 
 
@@ -305,12 +307,29 @@ StringList::operator << (const char* str
 }
 
 StringList&
+StringList::operator << (const std::string& str)
+{
+AppendString(str);
+return *this;
+}
+
+StringList&
 StringList::operator << (StringList strings)
 {
 AppendList(strings);
 return *this;
 }
 
+StringList&
+StringList::operator = (const std::vector &rhs)
+{
+Clear();
+for (const auto &s : rhs)
+m_strings.push_back(s);
+
+return *this;
+}
+
 size_t
 StringList::AutoComplete (const char *s, StringList &matches, size_t 
&exact_idx) const
 {
@@ -339,3 +358,21 @@ StringList::AutoComplete (const char *s,
 return matches.GetSize();
 }
 
+void
+StringList::LogDump(Log *log, const char *name)
+{
+if (!log)
+return;
+
+StreamString strm;
+if (name)
+strm.Printf("Begin %s:\n", name);
+for (const auto &s : m_strings) {
+strm.Indent();
+strm.Printf("%s\n", s.c_str());
+}
+if (name)
+strm.Printf("End %s.\n", name);
+
+log->Debug("%s", strm.GetData());
+}


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15773: Add LogDump methods to lldb_private::StringList to ease printing of iterable string containers

2016-01-06 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256927: Add LogDump methods to lldb_private::StringList. 
(authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D15773?vs=44000&id=44104#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15773

Files:
  lldb/trunk/include/lldb/Core/StringList.h
  lldb/trunk/source/Core/StringList.cpp

Index: lldb/trunk/source/Core/StringList.cpp
===
--- lldb/trunk/source/Core/StringList.cpp
+++ lldb/trunk/source/Core/StringList.cpp
@@ -11,6 +11,8 @@
 
 #include "lldb/Core/StreamString.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamString.h"
 
 #include 
 
@@ -305,12 +307,29 @@
 }
 
 StringList&
+StringList::operator << (const std::string& str)
+{
+AppendString(str);
+return *this;
+}
+
+StringList&
 StringList::operator << (StringList strings)
 {
 AppendList(strings);
 return *this;
 }
 
+StringList&
+StringList::operator = (const std::vector &rhs)
+{
+Clear();
+for (const auto &s : rhs)
+m_strings.push_back(s);
+
+return *this;
+}
+
 size_t
 StringList::AutoComplete (const char *s, StringList &matches, size_t &exact_idx) const
 {
@@ -339,3 +358,21 @@
 return matches.GetSize();
 }
 
+void
+StringList::LogDump(Log *log, const char *name)
+{
+if (!log)
+return;
+
+StreamString strm;
+if (name)
+strm.Printf("Begin %s:\n", name);
+for (const auto &s : m_strings) {
+strm.Indent();
+strm.Printf("%s\n", s.c_str());
+}
+if (name)
+strm.Printf("End %s.\n", name);
+
+log->Debug("%s", strm.GetData());
+}
Index: lldb/trunk/include/lldb/Core/StringList.h
===
--- lldb/trunk/include/lldb/Core/StringList.h
+++ lldb/trunk/include/lldb/Core/StringList.h
@@ -133,8 +133,15 @@
 operator << (const char* str);
 
 StringList&
+operator << (const std::string &s);
+
+StringList&
 operator << (StringList strings);
 
+// Copy assignment for a vector of strings
+StringList&
+operator = (const std::vector &rhs);
+
 // This string list contains a list of valid auto completion
 // strings, and the "s" is passed in. "matches" is filled in
 // with zero or more string values that start with "s", and
@@ -147,6 +154,23 @@
   StringList &matches,
   size_t &exact_matches_idx) const;
 
+// Dump the StringList to the given lldb_private::Log, `log`, one item per line.
+// If given, `name` will be used to identify the start and end of the list in the output.
+virtual void LogDump(Log *log, const char *name = nullptr);
+
+// Static helper to convert an iterable of strings to a StringList, and then
+// dump it with the semantics of the `LogDump` method.
+template static void LogDump(Log *log, T s_iterable, const char *name = nullptr)
+{
+if (!log)
+return;
+// Make a copy of the iterable as a StringList
+StringList l{};
+for (const auto &s : s_iterable)
+l << s;
+
+l.LogDump(log, name);
+}
 private:
 STLStringArray m_strings;
 };
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15948: Remove duplicate header added in http://reviews.llvm.org/rL256927

2016-01-07 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257061: Remove duplicate header added in r256927 (authored 
by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D15948?vs=44205&id=44207#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15948

Files:
  lldb/trunk/source/Core/StringList.cpp

Index: lldb/trunk/source/Core/StringList.cpp
===
--- lldb/trunk/source/Core/StringList.cpp
+++ lldb/trunk/source/Core/StringList.cpp
@@ -12,7 +12,6 @@
 #include "lldb/Core/StreamString.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
 
 #include 
 


Index: lldb/trunk/source/Core/StringList.cpp
===
--- lldb/trunk/source/Core/StringList.cpp
+++ lldb/trunk/source/Core/StringList.cpp
@@ -12,7 +12,6 @@
 #include "lldb/Core/StreamString.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
 
 #include 
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r257759 - Fix ambiguous resolution of clang::ArrayType/llvm::ArrayType in ClangAstContext

2016-01-14 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Jan 14 06:18:09 2016
New Revision: 257759

URL: http://llvm.org/viewvc/llvm-project?rev=257759&view=rev
Log:
Fix ambiguous resolution of clang::ArrayType/llvm::ArrayType in ClangAstContext

Both llvm and clang have an ArrayType class, which can cause resolution to fail 
when llvm headers that are implicitly included name this type.
source/Symbol/ClangASTContext.cpp has 'using namespace llvm;' and 'using 
namespace clang;' 

Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D16155

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=257759&r1=257758&r2=257759&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Jan 14 06:18:09 2016
@@ -2105,14 +2105,14 @@ ClangASTContext::CreateArrayType (const
 if (element_count == 0)
 {
 return CompilerType (ast, ast->getIncompleteArrayType 
(GetQualType(element_type),
-   
ArrayType::Normal,
+   
clang::ArrayType::Normal,
0));
 }
 else
 {
 return CompilerType (ast, ast->getConstantArrayType 
(GetQualType(element_type),
  
ap_element_count,
- 
ArrayType::Normal,
+ 
clang::ArrayType::Normal,
  0));
 }
 }


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D16155: possible ambiguous resolution of clang::ArrayType/llvm::ArrayType in ClangAstContext

2016-01-14 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257759: Fix ambiguous resolution of 
clang::ArrayType/llvm::ArrayType in ClangAstContext (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D16155?vs=44788&id=44854#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16155

Files:
  lldb/trunk/source/Symbol/ClangASTContext.cpp

Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -2105,14 +2105,14 @@
 if (element_count == 0)
 {
 return CompilerType (ast, ast->getIncompleteArrayType 
(GetQualType(element_type),
-   
ArrayType::Normal,
+   
clang::ArrayType::Normal,
0));
 }
 else
 {
 return CompilerType (ast, ast->getConstantArrayType 
(GetQualType(element_type),
  
ap_element_count,
- 
ArrayType::Normal,
+ 
clang::ArrayType::Normal,
  0));
 }
 }


Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -2105,14 +2105,14 @@
 if (element_count == 0)
 {
 return CompilerType (ast, ast->getIncompleteArrayType (GetQualType(element_type),
-   ArrayType::Normal,
+   clang::ArrayType::Normal,
0));
 }
 else
 {
 return CompilerType (ast, ast->getConstantArrayType (GetQualType(element_type),
  ap_element_count,
- ArrayType::Normal,
+ clang::ArrayType::Normal,
  0));
 }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r258038 - [RenderScript] Remove mips specific expressions

2016-01-18 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Mon Jan 18 03:16:02 2016
New Revision: 258038

URL: http://llvm.org/viewvc/llvm-project?rev=258038&view=rev
Log:
[RenderScript] Remove mips specific expressions

Reverts earlier commit r254910, which used function pointers for jitted 
expressions
to avoid a Mips64 compiler bug. Bug has since been fixed, and compiler longer 
issues the problem instruction.

Author: Dean De Leo 

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=258038&r1=258037&r2=258038&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Mon Jan 18 03:16:02 2016
@@ -1374,136 +1374,61 @@ RenderScriptRuntime::EvalRSExpression(co
 return true;
 }
 
-namespace // anonymous
+// Used to index expression format strings
+enum ExpressionStrings
 {
-// max length of an expanded expression
-const int jit_max_expr_size = 768;
-
-// Format strings containing the expressions we may need to evaluate.
-const char runtimeExpressions[][256] =
-{
- // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
- 
"(int*)_Z12GetOffsetPtrPKN7android12renderscript10AllocationE23RsAllocationCubemapFace(0x%lx,
 %u, %u, %u, 0, 0)",
-
- // Type* rsaAllocationGetType(Context*, Allocation*)
- "(void*)rsaAllocationGetType(0x%lx, 0x%lx)",
-
- // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
- // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; 
mHal.state.dimZ;
- // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
- // Need to specify 32 or 64 bit for uint_t since this differs between 
devices
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[0]", // X dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[1]", // Y dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[2]", // Z dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[5]", // Element ptr
-
- // rsaElementGetNativeData(Context*, Element*, uint32_t* elemData,size)
- // Pack mType; mKind; mNormalized; mVectorSize; NumSubElements into 
elemData
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[0]", // Type
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[1]", // Kind
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[3]", // Vector Size
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[4]", // Field Count
-
-  // rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t 
*ids, const char **names,
-  // size_t *arraySizes, uint32_t dataSize)
-  // Needed for Allocations of structs to gather details about 
fields/Subelements
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
ids[%u]", // Element* of field
-
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
names[%u]",   // Name of field
-
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
arr_size[%u]" // Array size of field
-};
-
-
-// Temporary workaround for MIPS, until the compiler emits the JAL 
instruction when invoking directly the function.
-// At the moment, when evaluating an expression involving a function call, 
the LLVM codegen for Mips  emits a JAL
-// instruction, which is able to jump in the range +/- 128MB with respect 
to the current program counter ($pc). If
-// the requested function happens to reside outside the above region, the 
function address will be truncated and the
-// function invocation will fail. This is a problem in the RS plugin as we 
rely on the RS API to probe the number and
-// the nature of allocations. A proper solution in the MIPS compiler is 
currently being investigated. As temporary
-// work around for this context, we'll invoke the RS API through function 
pointers, which cause the compiler to emit a
-// register based JALR instruction.
-const char runtimeExpressions_mips[][512] =

[Lldb-commits] [lldb] r258303 - [RenderScript] New command for viewing coordinate of current kernel invocation

2016-01-20 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Jan 20 06:03:29 2016
New Revision: 258303

URL: http://llvm.org/viewvc/llvm-project?rev=258303&view=rev
Log:
[RenderScript] New command for viewing coordinate of current kernel invocation

Patch adds command 'language renderscript kernel coordinate' for printing the 
kernel index in (x,y,z) format.
This is done by walking the call stack and looking for a function with suffix 
'.expand', as well as the frame variables containing the coordinate data. 

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=258303&r1=258302&r2=258303&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Jan 20 06:03:29 2016
@@ -390,6 +390,8 @@ const unsigned int RenderScriptRuntime::
 {eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 4} // 
RS_TYPE_MATRIX_2X2
 };
 
+const std::string RenderScriptRuntime::s_runtimeExpandSuffix(".expand");
+const std::array 
RenderScriptRuntime::s_runtimeCoordVars{"rsIndex", "p->current.y", 
"p->current.z"};
 //--
 // Static Functions
 //--
@@ -3071,6 +3073,79 @@ RenderScriptRuntime::GetFrameVarAsUnsign
 return true;
 }
 
+// Function attempts to find the current coordinate of a kernel invocation by 
investigating the
+// values of frame variables in the .expand function. These coordinates are 
returned via the coord
+// array reference parameter. Returns true if the coordinates could be found, 
and false otherwise.
+bool
+RenderScriptRuntime::GetKernelCoordinate(RSCoordinate &coord, Thread 
*thread_ptr)
+{
+Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+if (!thread_ptr)
+{
+if (log)
+log->Printf("%s - Error, No thread pointer", __FUNCTION__);
+
+return false;
+}
+
+// Walk the call stack looking for a function whose name has the suffix 
'.expand'
+// and contains the variables we're looking for.
+for (uint32_t i = 0; i < thread_ptr->GetStackFrameCount(); ++i)
+{
+if (!thread_ptr->SetSelectedFrameByIndex(i))
+continue;
+
+StackFrameSP frame_sp = thread_ptr->GetSelectedFrame();
+if (!frame_sp)
+continue;
+
+// Find the function name
+const SymbolContext sym_ctx = frame_sp->GetSymbolContext(false);
+const char *func_name_cstr = sym_ctx.GetFunctionName().AsCString();
+if (!func_name_cstr)
+continue;
+
+if (log)
+log->Printf("%s - Inspecting function '%s'", __FUNCTION__, 
func_name_cstr);
+
+// Check if function name has .expand suffix
+std::string func_name(func_name_cstr);
+const int length_difference = func_name.length() - 
RenderScriptRuntime::s_runtimeExpandSuffix.length();
+if (length_difference <= 0)
+continue;
+
+const int32_t has_expand_suffix = func_name.compare(length_difference,
+
RenderScriptRuntime::s_runtimeExpandSuffix.length(),
+
RenderScriptRuntime::s_runtimeExpandSuffix);
+
+if (has_expand_suffix != 0)
+continue;
+
+if (log)
+log->Printf("%s - Found .expand function '%s'", __FUNCTION__, 
func_name_cstr);
+
+// Get values for variables in .expand frame that tell us the current 
kernel invocation
+bool found_coord_variables = true;
+assert(RenderScriptRuntime::s_runtimeCoordVars.size() == coord.size());
+
+for (uint32_t i = 0; i < coord.size(); ++i)
+{
+uint64_t value = 0;
+if (!GetFrameVarAsUnsigned(frame_sp, 
RenderScriptRuntime::s_runtimeCoordVars[i], value))
+{
+found_coord_variables = false;
+break;
+}
+coord[i] = value;
+}
+
+if (found_coord_variables)
+return true;
+}
+return false;
+}
+
 // Callback when a kernel breakpoint hits and we're looking for a specific 
coordinate.
 // Baton parameter contains a pointer to the target coordinate we want to 
break on.
 // Function then checks the .expand frame for the current coordinate and 
breaks to user if it matches.
@@ -3086,53 +31

[Lldb-commits] [lldb] r258800 - [RenderScript] Provide option to specify a single allocation to print

2016-01-26 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Jan 26 04:41:08 2016
New Revision: 258800

URL: http://llvm.org/viewvc/llvm-project?rev=258800&view=rev
Log:
[RenderScript] Provide option to specify a single allocation to print

Patch replaces the 'renderscript allocation list' command flag --refresh, with 
a new option --id .
This new option only prints the details of a single allocation with a given id, 
rather than printing all the allocations.
Functionality from the removed '--refresh' flag will be moved into its own 
command in a subsequent commit.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=258800&r1=258799&r2=258800&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Tue Jan 26 04:41:08 2016
@@ -2870,10 +2870,11 @@ RenderScriptRuntime::DumpAllocation(Stre
 return true;
 }
 
-// Prints infomation regarding all the currently loaded allocations.
+// Prints information regarding currently loaded allocations.
 // These details are gathered by jitting the runtime, which has as latency.
+// Index parameter specifies a single allocation ID to print, or a zero value 
to print them all
 void
-RenderScriptRuntime::ListAllocations(Stream &strm, StackFrame* frame_ptr, bool 
recompute)
+RenderScriptRuntime::ListAllocations(Stream &strm, StackFrame *frame_ptr, 
const uint32_t index)
 {
 strm.Printf("RenderScript Allocations:");
 strm.EOL();
@@ -2881,13 +2882,14 @@ RenderScriptRuntime::ListAllocations(Str
 
 for (auto &alloc : m_allocations)
 {
-// JIT the allocation info if we haven't done it, or the user forces 
us to.
-bool do_refresh = alloc->shouldRefresh() || recompute;
+// index will only be zero if we want to print all allocations
+if (index != 0 && index != alloc->id)
+continue;
 
 // JIT current allocation information
-if (do_refresh && !RefreshAllocation(alloc.get(), frame_ptr))
+if (alloc->shouldRefresh() && !RefreshAllocation(alloc.get(), 
frame_ptr))
 {
-strm.Printf("Error: Couldn't evaluate details for allocation 
%u\n", alloc->id);
+strm.Printf("Error: Couldn't evaluate details for allocation %" 
PRIu32 "\n", alloc->id);
 continue;
 }
 
@@ -3926,9 +3928,7 @@ public:
 class CommandOptions : public Options
 {
 public:
-CommandOptions(CommandInterpreter &interpreter) : 
Options(interpreter), m_refresh(false)
-{
-}
+CommandOptions(CommandInterpreter &interpreter) : 
Options(interpreter), m_id(0) {}
 
 ~CommandOptions() override = default;
 
@@ -3940,8 +3940,11 @@ public:
 
 switch (short_option)
 {
-case 'r':
-m_refresh = true;
+case 'i':
+bool success;
+m_id = StringConvert::ToUInt32(option_arg, 0, 0, &success);
+if (!success)
+error.SetErrorStringWithFormat("invalid integer value 
for option '%c'", short_option);
 break;
 default:
 error.SetErrorStringWithFormat("unrecognized option '%c'", 
short_option);
@@ -3953,7 +3956,7 @@ public:
 void
 OptionParsingStarting() override
 {
-m_refresh = false;
+m_id = 0;
 }
 
 const OptionDefinition*
@@ -3963,7 +3966,7 @@ public:
 }
 
 static OptionDefinition g_option_table[];
-bool m_refresh;
+uint32_t m_id;
 };
 
 bool
@@ -3971,7 +3974,7 @@ public:
 {
 RenderScriptRuntime *runtime =
   static_cast(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
-runtime->ListAllocations(result.GetOutputStream(), 
m_exe_ctx.GetFramePtr(), m_options.m_refresh);
+runtime->ListAllocations(result.GetOutputStream(), 
m_exe_ctx.GetFramePtr(), m_options.m_id);
 result.SetStatus(eReturnStatusSuccessFinishResult);
 return true;
 }
@@ -3980,13 +3983,10 @@ private:
 CommandOptions m_options;
 };
 
-OptionDefinition
-CommandObjectRenderScriptRuntimeAllocationList::CommandOptions::g_option_table[]
 =
-{
-{ LLDB_OPT_SET_1, false, "refresh", 'r', OptionParser::eNoArgument, NULL, 
NULL, 0, eArgTypeNone,
-  "Recompute allocation details."},
- 

[Lldb-commits] [lldb] r259181 - [RenderScript] Remove unused RS command

2016-01-29 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Fri Jan 29 04:11:03 2016
New Revision: 259181

URL: http://llvm.org/viewvc/llvm-project?rev=259181&view=rev
Log:
[RenderScript] Remove unused RS command

Patch deletes the 'language renderscript module probe' command.
This command was present in the initial commit to help debug the plugin.
However we haven't used it recently and it's functionality is unclear, so can 
be removed entirely. 

Also add back 'kernel coordinate' command, removed by accident in clang format 
patch r259056.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=259181&r1=259180&r2=259181&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Fri Jan 29 04:11:03 2016
@@ -2589,19 +2589,6 @@ RSModuleDescriptor::ParseRSInfo()
 return false;
 }
 
-bool
-RenderScriptRuntime::ProbeModules(const ModuleList module_list)
-{
-bool rs_found = false;
-size_t num_modules = module_list.GetSize();
-for (size_t i = 0; i < num_modules; i++)
-{
-auto module = module_list.GetModuleAtIndex(i);
-rs_found |= LoadModule(module);
-}
-return rs_found;
-}
-
 void
 RenderScriptRuntime::Status(Stream &strm) const
 {
@@ -3384,44 +3371,6 @@ RSKernelDescriptor::Dump(Stream &strm) c
 strm.EOL();
 }
 
-class CommandObjectRenderScriptRuntimeModuleProbe : public CommandObjectParsed
-{
-public:
-CommandObjectRenderScriptRuntimeModuleProbe(CommandInterpreter 
&interpreter)
-: CommandObjectParsed(interpreter, "renderscript module probe",
-  "Initiates a Probe of all loaded modules for 
kernels and other renderscript objects.",
-  "renderscript module probe",
-  eCommandRequiresTarget | eCommandRequiresProcess 
| eCommandProcessMustBeLaunched)
-{
-}
-
-~CommandObjectRenderScriptRuntimeModuleProbe() override = default;
-
-bool
-DoExecute(Args &command, CommandReturnObject &result) override
-{
-const size_t argc = command.GetArgumentCount();
-if (argc == 0)
-{
-Target *target = m_exe_ctx.GetTargetPtr();
-RenderScriptRuntime *runtime =
-(RenderScriptRuntime 
*)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
-auto module_list = target->GetImages();
-bool new_rs_details = runtime->ProbeModules(module_list);
-if (new_rs_details)
-{
-result.AppendMessage("New renderscript modules added to 
runtime model.");
-}
-result.SetStatus(eReturnStatusSuccessFinishResult);
-return true;
-}
-
-result.AppendErrorWithFormat("'%s' takes no arguments", 
m_cmd_name.c_str());
-result.SetStatus(eReturnStatusFailed);
-return false;
-}
-};
-
 class CommandObjectRenderScriptRuntimeModuleDump : public CommandObjectParsed
 {
 public:
@@ -3452,7 +3401,6 @@ public:
 : CommandObjectMultiword(interpreter, "renderscript module", "Commands 
that deal with renderscript modules.",
  nullptr)
 {
-LoadSubCommand("probe", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeModuleProbe(interpreter)));
 LoadSubCommand("dump", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeModuleDump(interpreter)));
 }
 
@@ -3730,6 +3678,8 @@ public:
  nullptr)
 {
 LoadSubCommand("list", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeKernelList(interpreter)));
+LoadSubCommand("coordinate",
+   CommandObjectSP(new 
CommandObjectRenderScriptRuntimeKernelCoordinate(interpreter)));
 LoadSubCommand("breakpoint",
CommandObjectSP(new 
CommandObjectRenderScriptRuntimeKernelBreakpoint(interpreter)));
 }

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=259181&r1=259180&r2=259181&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 (original)
+++ 
l

[Lldb-commits] [PATCH] D16766: [RenderScript] Use LLVM DWARF language enum

2016-02-01 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added a reviewer: clayborg.
EwanCrawford added a subscriber: lldb-commits.
EwanCrawford set the repository for this revision to rL LLVM.

A DWARF language vender extension for RenderScript was added to LLVM in 
r259348(http://reviews.llvm.org/D16409)
We should use this generated enum instead of the hardcoded value.

RenderScript is also C99 with some extensions, so when it's detected we should 
treat it as C. 

Repository:
  rL LLVM

http://reviews.llvm.org/D16766

Files:
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Target/Language.cpp

Index: source/Target/Language.cpp
===
--- source/Target/Language.cpp
+++ source/Target/Language.cpp
@@ -269,6 +269,7 @@
 case eLanguageTypeC89:
 case eLanguageTypeC99:
 case eLanguageTypeC11:
+case eLanguageTypeExtRenderScript:
 return true;
 default:
 return false;
Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1180,7 +1180,7 @@
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);


Index: source/Target/Language.cpp
===
--- source/Target/Language.cpp
+++ source/Target/Language.cpp
@@ -269,6 +269,7 @@
 case eLanguageTypeC89:
 case eLanguageTypeC99:
 case eLanguageTypeC11:
+case eLanguageTypeExtRenderScript:
 return true;
 default:
 return false;
Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1180,7 +1180,7 @@
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D16766: [RenderScript] Use LLVM DWARF language enum

2016-02-02 Thread Ewan Crawford via lldb-commits
EwanCrawford updated this revision to Diff 46656.
EwanCrawford added a comment.

Thanks for taking a look, yes I want to use ClangASTContext.
Although RenderScript is mostly just C99 checking for it in a function called 
`LanguageIsC` does seem off.

I've put the comparison directly in ClangASTContextSupportsLanguage(), but let 
me know if you'd prefer a more generic solution for allowing new languages to 
use ClangASTContext.


Repository:
  rL LLVM

http://reviews.llvm.org/D16766

Files:
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Symbol/ClangASTContext.cpp

Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -105,7 +105,8 @@
 return language == eLanguageTypeUnknown || // Clang is the default 
type system
Language::LanguageIsC (language) ||
Language::LanguageIsCPlusPlus (language) ||
-   Language::LanguageIsObjC (language);
+   Language::LanguageIsObjC (language) ||
+   language == eLanguageTypeExtRenderScript;
 }
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1180,7 +1180,7 @@
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);


Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -105,7 +105,8 @@
 return language == eLanguageTypeUnknown || // Clang is the default type system
Language::LanguageIsC (language) ||
Language::LanguageIsCPlusPlus (language) ||
-   Language::LanguageIsObjC (language);
+   Language::LanguageIsObjC (language) ||
+   language == eLanguageTypeExtRenderScript;
 }
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1180,7 +1180,7 @@
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D16766: [RenderScript] Use LLVM DWARF language enum

2016-02-03 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259634: [RenderScript] Use LLVM DWARF language enum 
(authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D16766?vs=46656&id=46755#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16766

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp

Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -105,7 +105,8 @@
 return language == eLanguageTypeUnknown || // Clang is the default 
type system
Language::LanguageIsC (language) ||
Language::LanguageIsCPlusPlus (language) ||
-   Language::LanguageIsObjC (language);
+   Language::LanguageIsObjC (language) ||
+   language == eLanguageTypeExtRenderScript;
 }
 }
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1180,7 +1180,7 @@
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);


Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -105,7 +105,8 @@
 return language == eLanguageTypeUnknown || // Clang is the default type system
Language::LanguageIsC (language) ||
Language::LanguageIsCPlusPlus (language) ||
-   Language::LanguageIsObjC (language);
+   Language::LanguageIsObjC (language) ||
+   language == eLanguageTypeExtRenderScript;
 }
 }
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1180,7 +1180,7 @@
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r259634 - [RenderScript] Use LLVM DWARF language enum

2016-02-03 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Feb  3 03:17:03 2016
New Revision: 259634

URL: http://llvm.org/viewvc/llvm-project?rev=259634&view=rev
Log:
[RenderScript] Use LLVM DWARF language enum

A DWARF language vender extension for RenderScript was added to LLVM in 
r259348(http://reviews.llvm.org/D16409)
We should use this generated enum instead of the hardcoded value.

RenderScript is also based on C99 with some extensions, so we want to use 
ClangASTContext when RS is detected.

Reviewers:  clayborg
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D16766

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=259634&r1=259633&r2=259634&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Feb  3 
03:17:03 2016
@@ -1180,7 +1180,7 @@ DWARFCompileUnit::LanguageTypeFromDWARF(
 {
 case DW_LANG_Mips_Assembler:
 return eLanguageTypeMipsAssembler;
-case 0x8e57: // FIXME: needs to be added to llvm
+case DW_LANG_GOOGLE_RenderScript:
 return eLanguageTypeExtRenderScript;
 default:
 return static_cast(val);

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=259634&r1=259633&r2=259634&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Feb  3 03:17:03 2016
@@ -105,7 +105,8 @@ namespace
 return language == eLanguageTypeUnknown || // Clang is the default 
type system
Language::LanguageIsC (language) ||
Language::LanguageIsCPlusPlus (language) ||
-   Language::LanguageIsObjC (language);
+   Language::LanguageIsObjC (language) ||
+   language == eLanguageTypeExtRenderScript;
 }
 }
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r259773 - [RenderScript] Add command for recalculating allocation details

2016-02-04 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Feb  4 03:44:23 2016
New Revision: 259773

URL: http://llvm.org/viewvc/llvm-project?rev=259773&view=rev
Log:
[RenderScript] Add command for recalculating allocation details

Patch replaces the --refresh flag removed in r258800 with it's own command, 
'language renderscript allocation refresh'.
Since there is no reason this functionality should be tied to another command 
as an option. 
The command itself simply re-JITs all our cached information about allocations.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=259773&r1=259772&r2=259773&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Thu Feb  4 03:44:23 2016
@@ -2861,6 +2861,30 @@ RenderScriptRuntime::DumpAllocation(Stre
 return true;
 }
 
+// Function recalculates all our cached information about allocations by 
jitting the
+// RS runtime regarding each allocation we know about.
+// Returns true if all allocations could be recomputed, false otherwise.
+bool
+RenderScriptRuntime::RecomputeAllAllocations(Stream &strm, StackFrame 
*frame_ptr)
+{
+bool success = true;
+for (auto &alloc : m_allocations)
+{
+// JIT current allocation information
+if (!RefreshAllocation(alloc.get(), frame_ptr))
+{
+strm.Printf("Error: Couldn't evaluate details for allocation %" 
PRIu32 "\n", alloc->id);
+success = false;
+}
+}
+
+if (success)
+strm.Printf("All allocations successfully recomputed");
+strm.EOL();
+
+return success;
+}
+
 // Prints information regarding currently loaded allocations.
 // These details are gathered by jitting the runtime, which has as latency.
 // Index parameter specifies a single allocation ID to print, or a zero value 
to print them all
@@ -4036,6 +4060,39 @@ public:
 }
 };
 
+class CommandObjectRenderScriptRuntimeAllocationRefresh : public 
CommandObjectParsed
+{
+public:
+CommandObjectRenderScriptRuntimeAllocationRefresh(CommandInterpreter 
&interpreter)
+: CommandObjectParsed(interpreter, "renderscript allocation refresh",
+  "Recomputes the details of all allocations.", 
"renderscript allocation refresh",
+  eCommandRequiresProcess | 
eCommandProcessMustBeLaunched)
+{
+}
+
+~CommandObjectRenderScriptRuntimeAllocationRefresh() override = default;
+
+bool
+DoExecute(Args &command, CommandReturnObject &result) override
+{
+RenderScriptRuntime *runtime = static_cast(
+
m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+
+bool success = 
runtime->RecomputeAllAllocations(result.GetOutputStream(), 
m_exe_ctx.GetFramePtr());
+
+if (success)
+{
+result.SetStatus(eReturnStatusSuccessFinishResult);
+return true;
+}
+else
+{
+result.SetStatus(eReturnStatusFailed);
+return false;
+}
+}
+};
+
 class CommandObjectRenderScriptRuntimeAllocation : public 
CommandObjectMultiword
 {
 public:
@@ -4047,6 +4104,7 @@ public:
 LoadSubCommand("dump", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationDump(interpreter)));
 LoadSubCommand("save", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationSave(interpreter)));
 LoadSubCommand("load", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationLoad(interpreter)));
+LoadSubCommand("refresh", CommandObjectSP(new 
CommandObjectRenderScriptRuntimeAllocationRefresh(interpreter)));
 }
 
 ~CommandObjectRenderScriptRuntimeAllocation() override = default;

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=259773&r1=259772&r2=259773&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 Thu Feb  4 03:44:23 2016
@@ -209,6 +209,9 @@ public:
 void
 ListAllocations(

[Lldb-commits] [lldb] r260372 - [RenderScript] Refactor allocation expressions

2016-02-10 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Feb 10 05:23:27 2016
New Revision: 260372

URL: http://llvm.org/viewvc/llvm-project?rev=260372&view=rev
Log:
[RenderScript] Refactor allocation expressions 

Patch refractors RS plugin code specifying how format strings are used to JIT 
the runtime.

Author: Dean De Leo 

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=260372&r1=260371&r2=260372&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Feb 10 05:23:27 2016
@@ -1373,6 +1373,8 @@ RenderScriptRuntime::EvalRSExpression(co
 return true;
 }
 
+namespace
+{
 // Used to index expression format strings
 enum ExpressionStrings
 {
@@ -1388,46 +1390,59 @@ enum ExpressionStrings
eExprElementFieldCount,
eExprSubelementsId,
eExprSubelementsName,
-   eExprSubelementsArrSize
-};
+   eExprSubelementsArrSize,
 
-// Format strings containing the expressions we may need to evaluate.
-const char runtimeExpressions[][256] =
-{
- // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
- 
"(int*)_Z12GetOffsetPtrPKN7android12renderscript10AllocationE23RsAllocationCubemapFace(0x%lx,
 %u, %u, %u, 0, 0)",
+   _eExprLast // keep at the end, implicit size of the array runtimeExpressions
+};
 
- // Type* rsaAllocationGetType(Context*, Allocation*)
- "(void*)rsaAllocationGetType(0x%lx, 0x%lx)",
+// max length of an expanded expression
+const int jit_max_expr_size = 512;
 
- // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
- // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; 
mHal.state.dimZ;
- // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
- // Need to specify 32 or 64 bit for uint_t since this differs between devices
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[0]", // X dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[1]", // Y dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[2]", // Z dim
- "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[5]", // Element ptr
-
- // rsaElementGetNativeData(Context*, Element*, uint32_t* elemData,size)
- // Pack mType; mKind; mNormalized; mVectorSize; NumSubElements into elemData
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[0]", // Type
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[1]", // Kind
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[3]", // Vector Size
- "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); 
data[4]", // Field Count
-
-  // rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t *ids, 
const char **names,
-  // size_t *arraySizes, uint32_t dataSize)
-  // Needed for Allocations of structs to gather details about 
fields/Subelements
- "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
- "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); 
ids[%u]", // Element* of field
+// Retrieve the string to JIT for the given expression
+const char*
+JITTemplate(ExpressionStrings e)
+{
+// Format strings containing the expressions we may need to evaluate.
+static std::array runtimeExpressions = {{
+ // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
+ 
"(int*)_Z12GetOffsetPtrPKN7android12renderscript10AllocationE23RsAllocationCubemapFace(0x%lx,
 %u, %u, %u, 0, 0)",
+
+ // Type* rsaAllocationGetType(Context*, Allocation*)
+ "(void*)rsaAllocationGetType(0x%lx, 0x%lx)",
+
+ // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
+ // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; 
mHal.state.dimZ;
+ // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
+ // Need to specify 32 or 64 bit for uint_t since this differs between 
devices
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[0]", // X dim
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[1]", // Y dim
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[2]", // Z dim
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); 
data[5]", // Element ptr
+
+ // rsaElementGetNativeData(Context*, Element*, uint32_t* elemData,size)
+ // Pack mType; mKind; mNormalized; mVec

Re: [Lldb-commits] [PATCH] D16853: Use BKPT instead of UDF for arm/thumb breakpoints

2016-02-16 Thread Ewan Crawford via lldb-commits
EwanCrawford added a subscriber: EwanCrawford.
EwanCrawford added a comment.

Hi Tamas,

This commit causes a SIGBUS for me on Nexus 6 ARMv7 devices, specifically the 
g_thumb_breakpoint_opcode change.
I can revert this locally but any advice on tracking the issue down further?


Repository:
  rL LLVM

http://reviews.llvm.org/D16853



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D17384: Fix OSX cmake build

2016-02-18 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: sivachandra, zturner, labath.
EwanCrawford added a subscriber: lldb-commits.
EwanCrawford set the repository for this revision to rL LLVM.

Commit r260721(http://reviews.llvm.org/D17182) introduced the following error 
when building for OSX using cmake:

Undefined symbols for architecture x86_64:
  "_PyInit__lldb", referenced from:
 -exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Adding '*' to the regex solves this problem but I'm building with Python 2.7 
instead of 3 so can't test thoroughly.


Repository:
  rL LLVM

http://reviews.llvm.org/D17384

Files:
  source/API/liblldb.exports

Index: source/API/liblldb.exports
===
--- source/API/liblldb.exports
+++ source/API/liblldb.exports
@@ -1,4 +1,4 @@
 _ZN4lldb*
 _ZNK4lldb*
 init_lld*
-PyInit__lldb
+PyInit__lldb*


Index: source/API/liblldb.exports
===
--- source/API/liblldb.exports
+++ source/API/liblldb.exports
@@ -1,4 +1,4 @@
 _ZN4lldb*
 _ZNK4lldb*
 init_lld*
-PyInit__lldb
+PyInit__lldb*
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r261227 - Fix OSX cmake build

2016-02-18 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Feb 18 11:01:40 2016
New Revision: 261227

URL: http://llvm.org/viewvc/llvm-project?rev=261227&view=rev
Log:
Fix OSX cmake build

Commit r260721(http://reviews.llvm.org/D17182) introduced the following error 
when building for OSX using cmake:

Undefined symbols for architecture x86_64:

"_PyInit__lldb", referenced from:
   -exported_symbol[s_list] command line option

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Adding '*' to the regex solves this problem, since it makes the symbol optional.

Reviewers: sivachandra, zturner, labath
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D17384

Modified:
lldb/trunk/source/API/liblldb.exports

Modified: lldb/trunk/source/API/liblldb.exports
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/liblldb.exports?rev=261227&r1=261226&r2=261227&view=diff
==
--- lldb/trunk/source/API/liblldb.exports (original)
+++ lldb/trunk/source/API/liblldb.exports Thu Feb 18 11:01:40 2016
@@ -1,4 +1,4 @@
 _ZN4lldb*
 _ZNK4lldb*
 init_lld*
-PyInit__lldb
+PyInit__lldb*


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17384: Fix OSX cmake build

2016-02-18 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261227: Fix OSX cmake build (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D17384?vs=48325&id=48336#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17384

Files:
  lldb/trunk/source/API/liblldb.exports

Index: lldb/trunk/source/API/liblldb.exports
===
--- lldb/trunk/source/API/liblldb.exports
+++ lldb/trunk/source/API/liblldb.exports
@@ -1,4 +1,4 @@
 _ZN4lldb*
 _ZNK4lldb*
 init_lld*
-PyInit__lldb
+PyInit__lldb*


Index: lldb/trunk/source/API/liblldb.exports
===
--- lldb/trunk/source/API/liblldb.exports
+++ lldb/trunk/source/API/liblldb.exports
@@ -1,4 +1,4 @@
 _ZN4lldb*
 _ZNK4lldb*
 init_lld*
-PyInit__lldb
+PyInit__lldb*
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17266: delete unused function in ClangExpressionParser`

2016-02-19 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261328: Delete unused function in ClangExpressionParser 
(authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D17266?vs=47980&id=48484#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17266

Files:
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -87,21 +87,6 @@
 // Utility Methods for Clang
 
//===--===//
 
-std::string GetBuiltinIncludePath(const char *Argv0) {
-SmallString<128> P(llvm::sys::fs::getMainExecutable(
-Argv0, (void *)(intptr_t) GetBuiltinIncludePath));
-
-if (!P.empty()) {
-llvm::sys::path::remove_filename(P); // Remove /clang from 
foo/bin/clang
-llvm::sys::path::remove_filename(P); // Remove /bin   from foo/bin
-
-// Get foo/lib/clang//include
-llvm::sys::path::append(P, "lib", "clang", CLANG_VERSION_STRING,
-"include");
-}
-
-return P.str();
-}
 
 class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks
 {


Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -87,21 +87,6 @@
 // Utility Methods for Clang
 //===--===//
 
-std::string GetBuiltinIncludePath(const char *Argv0) {
-SmallString<128> P(llvm::sys::fs::getMainExecutable(
-Argv0, (void *)(intptr_t) GetBuiltinIncludePath));
-
-if (!P.empty()) {
-llvm::sys::path::remove_filename(P); // Remove /clang from foo/bin/clang
-llvm::sys::path::remove_filename(P); // Remove /bin   from foo/bin
-
-// Get foo/lib/clang//include
-llvm::sys::path::append(P, "lib", "clang", CLANG_VERSION_STRING,
-"include");
-}
-
-return P.str();
-}
 
 class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks
 {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r261328 - Delete unused function in ClangExpressionParser

2016-02-19 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Fri Feb 19 08:31:41 2016
New Revision: 261328

URL: http://llvm.org/viewvc/llvm-project?rev=261328&view=rev
Log:
Delete unused function in ClangExpressionParser

[git 65dafa83] introduced the GetBuiltinIncludePath function copied from 
cfe/lib/Driver/CC1Options.cpp

This function is no longer used in lldb's expression parser and I believe it is 
safe to remove it.


Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D17266

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=261328&r1=261327&r2=261328&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Fri Feb 19 08:31:41 2016
@@ -87,21 +87,6 @@ using namespace lldb_private;
 // Utility Methods for Clang
 
//===--===//
 
-std::string GetBuiltinIncludePath(const char *Argv0) {
-SmallString<128> P(llvm::sys::fs::getMainExecutable(
-Argv0, (void *)(intptr_t) GetBuiltinIncludePath));
-
-if (!P.empty()) {
-llvm::sys::path::remove_filename(P); // Remove /clang from 
foo/bin/clang
-llvm::sys::path::remove_filename(P); // Remove /bin   from foo/bin
-
-// Get foo/lib/clang//include
-llvm::sys::path::append(P, "lib", "clang", CLANG_VERSION_STRING,
-"include");
-}
-
-return P.str();
-}
 
 class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks
 {


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r261345 - refactor/cleanup ClangExpressionParser::Parse

2016-02-19 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Fri Feb 19 11:55:10 2016
New Revision: 261345

URL: http://llvm.org/viewvc/llvm-project?rev=261345&view=rev
Log:
refactor/cleanup ClangExpressionParser::Parse

This patches does the following:

+ fix return type: ClangExpressionParser::Parse returns unsigned, but was 
actually returning a signed value, num_errors.
+ use helper clang::TextDiagnosticBuffer::getNumErrors() instead of counting 
the errors ourself.
+ limit scoping of block-level automatic variables as much as practical.
+ remove reused multipurpose TextDiagnosticBuffer::const_iterator in favour of 
loop-scoped err, warn, and note variables in the diagnostic printing code.
+ refactor diagnostic printing loops to use a proper loop invariant.

Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D17273

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=261345&r1=261344&r2=261345&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Fri Feb 19 11:55:10 2016
@@ -435,37 +435,34 @@ ClangExpressionParser::~ClangExpressionP
 }
 
 unsigned
-ClangExpressionParser::Parse (Stream &stream)
+ClangExpressionParser::Parse(Stream &stream)
 {
-TextDiagnosticBuffer *diag_buf = 
static_cast(m_compiler->getDiagnostics().getClient());
-
-diag_buf->FlushDiagnostics (m_compiler->getDiagnostics());
+TextDiagnosticBuffer *diag_buf = static_cast(m_compiler->getDiagnostics().getClient());
+diag_buf->FlushDiagnostics(m_compiler->getDiagnostics());
 
 const char *expr_text = m_expr.Text();
 
-clang::SourceManager &SourceMgr = m_compiler->getSourceManager();
+clang::SourceManager &source_mgr = m_compiler->getSourceManager();
 bool created_main_file = false;
 if (m_compiler->getCodeGenOpts().getDebugInfo() == 
codegenoptions::FullDebugInfo)
 {
-std::string temp_source_path;
-
 int temp_fd = -1;
 llvm::SmallString result_path;
 FileSpec tmpdir_file_spec;
 if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, 
tmpdir_file_spec))
 {
 tmpdir_file_spec.AppendPathComponent("lldb-%%.expr");
-temp_source_path = tmpdir_file_spec.GetPath();
+std::string temp_source_path = tmpdir_file_spec.GetPath();
 llvm::sys::fs::createUniqueFile(temp_source_path, temp_fd, 
result_path);
 }
 else
 {
 llvm::sys::fs::createTemporaryFile("lldb", "expr", temp_fd, 
result_path);
 }
-
+
 if (temp_fd != -1)
 {
-lldb_private::File file (temp_fd, true);
+lldb_private::File file(temp_fd, true);
 const size_t expr_text_len = strlen(expr_text);
 size_t bytes_written = expr_text_len;
 if (file.Write(expr_text, bytes_written).Success())
@@ -473,9 +470,8 @@ ClangExpressionParser::Parse (Stream &st
 if (bytes_written == expr_text_len)
 {
 file.Close();
-SourceMgr.setMainFileID(SourceMgr.createFileID(
-m_file_manager->getFile(result_path),
-SourceLocation(), SrcMgr::C_User));
+
source_mgr.setMainFileID(source_mgr.createFileID(m_file_manager->getFile(result_path),
+ 
SourceLocation(), SrcMgr::C_User));
 created_main_file = true;
 }
 }
@@ -485,7 +481,7 @@ ClangExpressionParser::Parse (Stream &st
 if (!created_main_file)
 {
 std::unique_ptr memory_buffer = 
MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
-
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(memory_buffer)));
+
source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer)));
 }
 
 diag_buf->BeginSourceFile(m_compiler->getLangOpts(), 
&m_compiler->getPreprocessor());
@@ -510,34 +506,25 @@ ClangExpressionParser::Parse (Stream &st
 
 diag_buf->EndSourceFile();
 
-TextDiagnosticBuffer::const_iterator diag_iterator;
+unsigned num_errors = diag_buf->getNumErrors();
 
-int num_errors = 0;
-
 if (m_pp_callbacks && m_pp_callbacks->hasErrors())
 {
 num_errors++;
-
 stream.PutCString(m_pp_callbacks->getErrorString().c_str());
 }
 
-for (diag_iterator = diag_buf->warn_begin();
- diag_iterator != diag_buf->warn_end();
- ++diag_iterator)
-stream.Printf("warning: %s\n", (*diag_iterator).second.c_str());
-
-for (

Re: [Lldb-commits] [PATCH] D17273: refactor/cleanup ClangExpressionParser::Parse

2016-02-19 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261345: refactor/cleanup ClangExpressionParser::Parse 
(authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D17273?vs=48002&id=48507#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17273

Files:
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -435,47 +435,43 @@
 }
 
 unsigned
-ClangExpressionParser::Parse (Stream &stream)
+ClangExpressionParser::Parse(Stream &stream)
 {
-TextDiagnosticBuffer *diag_buf = static_cast(m_compiler->getDiagnostics().getClient());
-
-diag_buf->FlushDiagnostics (m_compiler->getDiagnostics());
+TextDiagnosticBuffer *diag_buf = static_cast(m_compiler->getDiagnostics().getClient());
+diag_buf->FlushDiagnostics(m_compiler->getDiagnostics());
 
 const char *expr_text = m_expr.Text();
 
-clang::SourceManager &SourceMgr = m_compiler->getSourceManager();
+clang::SourceManager &source_mgr = m_compiler->getSourceManager();
 bool created_main_file = false;
 if (m_compiler->getCodeGenOpts().getDebugInfo() == codegenoptions::FullDebugInfo)
 {
-std::string temp_source_path;
-
 int temp_fd = -1;
 llvm::SmallString result_path;
 FileSpec tmpdir_file_spec;
 if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
 {
 tmpdir_file_spec.AppendPathComponent("lldb-%%.expr");
-temp_source_path = tmpdir_file_spec.GetPath();
+std::string temp_source_path = tmpdir_file_spec.GetPath();
 llvm::sys::fs::createUniqueFile(temp_source_path, temp_fd, result_path);
 }
 else
 {
 llvm::sys::fs::createTemporaryFile("lldb", "expr", temp_fd, result_path);
 }
-
+
 if (temp_fd != -1)
 {
-lldb_private::File file (temp_fd, true);
+lldb_private::File file(temp_fd, true);
 const size_t expr_text_len = strlen(expr_text);
 size_t bytes_written = expr_text_len;
 if (file.Write(expr_text, bytes_written).Success())
 {
 if (bytes_written == expr_text_len)
 {
 file.Close();
-SourceMgr.setMainFileID(SourceMgr.createFileID(
-m_file_manager->getFile(result_path),
-SourceLocation(), SrcMgr::C_User));
+source_mgr.setMainFileID(source_mgr.createFileID(m_file_manager->getFile(result_path),
+ SourceLocation(), SrcMgr::C_User));
 created_main_file = true;
 }
 }
@@ -485,7 +481,7 @@
 if (!created_main_file)
 {
 std::unique_ptr memory_buffer = MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
-SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(memory_buffer)));
+source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer)));
 }
 
 diag_buf->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
@@ -510,34 +506,25 @@
 
 diag_buf->EndSourceFile();
 
-TextDiagnosticBuffer::const_iterator diag_iterator;
+unsigned num_errors = diag_buf->getNumErrors();
 
-int num_errors = 0;
-
 if (m_pp_callbacks && m_pp_callbacks->hasErrors())
 {
 num_errors++;
-
 stream.PutCString(m_pp_callbacks->getErrorString().c_str());
 }
 
-for (diag_iterator = diag_buf->warn_begin();
- diag_iterator != diag_buf->warn_end();
- ++diag_iterator)
-stream.Printf("warning: %s\n", (*diag_iterator).second.c_str());
-
-for (diag_iterator = diag_buf->err_begin();
- diag_iterator != diag_buf->err_end();
- ++diag_iterator)
-{
-num_errors++;
-stream.Printf("error: %s\n", (*diag_iterator).second.c_str());
-}
-
-for (diag_iterator = diag_buf->note_begin();
- diag_iterator != diag_buf->note_end();
- ++diag_iterator)
-stream.Printf("note: %s\n", (*diag_iterator).second.c_str());
+for (TextDiagnosticBuffer::const_iterator warn = diag_buf->warn_begin(), warn_end = diag_buf->warn_end();
+ warn != warn_end; ++warn)
+stream.Printf("warning: %s\n", warn->second.c_str());
+
+for (TextDiagnosticBuffer::const_iterator err = diag_buf->err_begin(), err_end = diag_buf->err_end();
+ err != err_end; ++err)
+stream.Printf("error: %s\n", err->second.c_str());
+
+for (TextDiagnosticBuffer::const_iterator note = diag_buf->

[Lldb-commits] [lldb] r262920 - Use c_str() instead of GetCString() to fix build

2016-03-08 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Mar  8 04:03:23 2016
New Revision: 262920

URL: http://llvm.org/viewvc/llvm-project?rev=262920&view=rev
Log:
Use c_str() instead of GetCString() to fix build 


Modified:
lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=262920&r1=262919&r2=262920&view=diff
==
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Mar  8 04:03:23 
2016
@@ -461,7 +461,7 @@ CommandInterpreter::Initialize ()
 AddAlias ("run", cmd_obj_sp, "--shell-expand-args true --");
 #else
 StreamString defaultshell;
-defaultshell.Printf("--shell=%s --", 
HostInfo::GetDefaultShell().GetPath().GetCString());
+defaultshell.Printf("--shell=%s --", 
HostInfo::GetDefaultShell().GetPath().c_str());
 AddAlias ("r", cmd_obj_sp, defaultshell.GetData());
 AddAlias ("run", cmd_obj_sp, defaultshell.GetData());
 #endif


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D17957: Expression evaluation for overloaded C functions

2016-03-08 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: spyffe, clayborg.
EwanCrawford added a subscriber: lldb-commits.
EwanCrawford set the repository for this revision to rL LLVM.

Fixes bugzilla ticket https://llvm.org/bugs/show_bug.cgi?id=26694
Where we can currently pick the incorrect declaration when calling a C function 
with the overloadable attribute.

This is done by checking if we're using language C, but the function has a 
mangled name.
Patch also includes some additional fallback parameter manglings for when clang 
doesn't emit a matching symbol.

Repository:
  rL LLVM

http://reviews.llvm.org/D17957

Files:
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/Makefile
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/TestCallOverloadedCFunction.py
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/main.c
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -2028,9 +2028,9 @@
 Type *function_type = function->GetType();
 
 const lldb::LanguageType comp_unit_language = function->GetCompileUnit()->GetLanguage();
-const bool extern_c = Language::LanguageIsC(comp_unit_language) ||
-  (Language::LanguageIsObjC(comp_unit_language) &&
-   !Language::LanguageIsCPlusPlus(comp_unit_language));
+bool extern_c = Language::LanguageIsC(comp_unit_language) ||
+(Language::LanguageIsObjC(comp_unit_language) &&
+!Language::LanguageIsCPlusPlus(comp_unit_language));
 
 if (!extern_c)
 {
@@ -2075,6 +2075,10 @@
 }
 }
 
+// __attribute__((overloadable)) in C can mangle names
+if (extern_c && Language::LanguageIsC(comp_unit_language))
+extern_c = !CPlusPlusLanguage::IsCPPMangledName(function->GetMangled().GetMangledName().AsCString());
+
 if (!function_type)
 {
 if (log)
Index: source/Expression/IRExecutionUnit.cpp
===
--- source/Expression/IRExecutionUnit.cpp
+++ source/Expression/IRExecutionUnit.cpp
@@ -700,6 +700,42 @@
 return ConstString();
 }
 
+// Given a mangled function, replaces all the function parameters of mangled type
+// 'search', with parameters of type 'replace'.
+static ConstString
+SubstituteMangledParameters(const llvm::StringRef& mangled, const llvm::StringRef& search, const llvm::StringRef& replace)
+{
+// Find length of function name, already encoded in mangled symbol
+static const llvm::StringRef numeric_digits("0123456789");
+const size_t encoded_length_start = mangled.find_first_of(numeric_digits);
+if (encoded_length_start == llvm::StringRef::npos)
+return ConstString();
+
+const size_t encoded_length_end = mangled.find_first_not_of(numeric_digits, encoded_length_start);
+if (encoded_length_end == llvm::StringRef::npos || encoded_length_end <= encoded_length_start)
+return ConstString();
+
+// Parse encoded length into name_length
+int name_length;
+const llvm::StringRef encoded_length_str = mangled.substr(encoded_length_start, encoded_length_end - encoded_length_start);
+if (encoded_length_str.getAsInteger(10, name_length) || name_length == 0)
+return ConstString();
+
+// Position in 'mangled' string of first function parameter
+size_t param_pos = encoded_length_end + name_length;
+
+// Iterate over all matching parameters, replacing them with string 'replace'
+std::string modified_str = mangled.str();
+while ((param_pos = modified_str.find(search, param_pos)) != std::string::npos)
+{
+modified_str.replace(param_pos, search.size(), replace);
+param_pos += replace.size();
+}
+
+return ConstString(modified_str);
+}
+
+
 struct IRExecutionUnit::SearchSpec
 {
 ConstString name;
@@ -763,6 +799,20 @@
 CPP_specs.push_back(ConstString(fixed_scratch.c_str()));
 }
 
+// Char is implementation defined as either signed or unsigned.
+// As a result a char parameter has 3 possible manglings: 'c'-char, 'a'-signed char, 'h'-unsigned char.
+// If we're looking for symbols with a signed char parameter,
+// try finding matches which have the general case 'c'.
+ConstString char_fixup = SubstituteMangledParameters(name.GetStringRef(), llvm::StringRef("a"), llvm::StringRef("c"));
+CPP_specs.push_back(SearchSpec(char_fixup, lldb::eFunctionNameTypeFull));
+
+// long long parameter mangling 'x',

[Lldb-commits] [lldb] r263099 - Track expression language from one place in ClangExpressionParser

2016-03-10 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Mar 10 04:31:08 2016
New Revision: 263099

URL: http://llvm.org/viewvc/llvm-project?rev=263099&view=rev
Log:
Track expression language from one place in ClangExpressionParser

The current expression language is currently tracked in a few places within the 
ClangExpressionParser constructor. 
This patch adds a private lldb::LanguageType attribute to the 
ClangExpressionParser class and tracks the expression language from that one 
place.

Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D17719

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=263099&r1=263098&r2=263099&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Thu Mar 10 04:31:08 2016
@@ -157,7 +157,7 @@ ClangExpressionParser::ClangExpressionPa
 
 // 1. Create a new compiler instance.
 m_compiler.reset(new CompilerInstance());
-lldb::LanguageType frame_lang = expr.Language(); // defaults to 
lldb::eLanguageTypeUnknown
+m_language = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
 bool overridden_target_opts = false;
 lldb_private::LanguageRuntime *lang_rt = nullptr;
 lldb::TargetSP target_sp;
@@ -176,14 +176,14 @@ ClangExpressionParser::ClangExpressionPa
 
 // Make sure the user hasn't provided a preferred execution language
 // with `expression --language X -- ...`
-if (frame && frame_lang == lldb::eLanguageTypeUnknown)
-frame_lang = frame->GetLanguage();
+if (frame && m_language == lldb::eLanguageTypeUnknown)
+m_language = frame->GetLanguage();
 
-if (frame_lang != lldb::eLanguageTypeUnknown)
+if (m_language != lldb::eLanguageTypeUnknown)
 {
-lang_rt = 
exe_scope->CalculateProcess()->GetLanguageRuntime(frame_lang);
+lang_rt = 
exe_scope->CalculateProcess()->GetLanguageRuntime(m_language);
 if (log)
-log->Printf("Frame has language of type %s", 
Language::GetNameForLanguageType(frame_lang));
+log->Printf("Frame has language of type %s", 
Language::GetNameForLanguageType(m_language));
 }
 
 // 2. Configure the compiler with a set of default options that are 
appropriate
@@ -263,9 +263,7 @@ ClangExpressionParser::ClangExpressionPa
 assert (m_compiler->hasTarget());
 
 // 5. Set language options.
-lldb::LanguageType language = expr.Language();
-
-switch (language)
+switch (m_language)
 {
 case lldb::eLanguageTypeC:
 case lldb::eLanguageTypeC89:

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h?rev=263099&r1=263098&r2=263099&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h 
Thu Mar 10 04:31:08 2016
@@ -129,6 +129,8 @@ private:
 class LLDBPreprocessorCallbacks;
 LLDBPreprocessorCallbacks   *m_pp_callbacks; ///< 
Called when the preprocessor encounters module imports
 std::unique_ptr m_ast_context;
+lldb::LanguageType   m_language;///< The 
the source language of the expression
+/// which 
may be explicitly set or inferred.
 };
 
 }


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17719: Track expression language from one place in ClangExpressionParser

2016-03-10 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263099: Track expression language from one place in 
ClangExpressionParser (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D17719?vs=49531&id=50253#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17719

Files:
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h

Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -129,6 +129,8 @@
 class LLDBPreprocessorCallbacks;
 LLDBPreprocessorCallbacks   *m_pp_callbacks; ///< 
Called when the preprocessor encounters module imports
 std::unique_ptr m_ast_context;
+lldb::LanguageType   m_language;///< The 
the source language of the expression
+/// which 
may be explicitly set or inferred.
 };
 
 }
Index: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -157,7 +157,7 @@
 
 // 1. Create a new compiler instance.
 m_compiler.reset(new CompilerInstance());
-lldb::LanguageType frame_lang = expr.Language(); // defaults to 
lldb::eLanguageTypeUnknown
+m_language = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
 bool overridden_target_opts = false;
 lldb_private::LanguageRuntime *lang_rt = nullptr;
 lldb::TargetSP target_sp;
@@ -176,14 +176,14 @@
 
 // Make sure the user hasn't provided a preferred execution language
 // with `expression --language X -- ...`
-if (frame && frame_lang == lldb::eLanguageTypeUnknown)
-frame_lang = frame->GetLanguage();
+if (frame && m_language == lldb::eLanguageTypeUnknown)
+m_language = frame->GetLanguage();
 
-if (frame_lang != lldb::eLanguageTypeUnknown)
+if (m_language != lldb::eLanguageTypeUnknown)
 {
-lang_rt = 
exe_scope->CalculateProcess()->GetLanguageRuntime(frame_lang);
+lang_rt = 
exe_scope->CalculateProcess()->GetLanguageRuntime(m_language);
 if (log)
-log->Printf("Frame has language of type %s", 
Language::GetNameForLanguageType(frame_lang));
+log->Printf("Frame has language of type %s", 
Language::GetNameForLanguageType(m_language));
 }
 
 // 2. Configure the compiler with a set of default options that are 
appropriate
@@ -263,9 +263,7 @@
 assert (m_compiler->hasTarget());
 
 // 5. Set language options.
-lldb::LanguageType language = expr.Language();
-
-switch (language)
+switch (m_language)
 {
 case lldb::eLanguageTypeC:
 case lldb::eLanguageTypeC89:


Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -129,6 +129,8 @@
 class LLDBPreprocessorCallbacks;
 LLDBPreprocessorCallbacks   *m_pp_callbacks; ///< Called when the preprocessor encounters module imports
 std::unique_ptr m_ast_context;
+lldb::LanguageType   m_language;///< The the source language of the expression
+/// which may be explicitly set or inferred.
 };
 
 }
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -157,7 +157,7 @@
 
 // 1. Create a new compiler instance.
 m_compiler.reset(new CompilerInstance());
-lldb::LanguageType frame_lang = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
+m_language = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
 bool overridden_target_opts = false;
 lldb_private::LanguageRuntime *lang_rt = nullptr;
 lldb::TargetSP target_sp;
@@ -176,14 +176,14 @@
 
 // Make sure the user hasn't provided a preferred execution language
 // with `expression --language X -- ...`
-if (frame && frame_lang == lldb::eLanguageTypeUnknown)
-frame_lang = frame->GetLanguage();
+if (frame && m_language == 

[Lldb-commits] [lldb] r263107 - Revert "Track expression language from one place in ClangExpressionParser"

2016-03-10 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Mar 10 06:38:55 2016
New Revision: 263107

URL: http://llvm.org/viewvc/llvm-project?rev=263107&view=rev
Log:
Revert "Track expression language from one place in ClangExpressionParser"

r263099 seems to have broken some OSX tests

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=263107&r1=263106&r2=263107&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Thu Mar 10 06:38:55 2016
@@ -157,7 +157,7 @@ ClangExpressionParser::ClangExpressionPa
 
 // 1. Create a new compiler instance.
 m_compiler.reset(new CompilerInstance());
-m_language = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
+lldb::LanguageType frame_lang = expr.Language(); // defaults to 
lldb::eLanguageTypeUnknown
 bool overridden_target_opts = false;
 lldb_private::LanguageRuntime *lang_rt = nullptr;
 lldb::TargetSP target_sp;
@@ -176,14 +176,14 @@ ClangExpressionParser::ClangExpressionPa
 
 // Make sure the user hasn't provided a preferred execution language
 // with `expression --language X -- ...`
-if (frame && m_language == lldb::eLanguageTypeUnknown)
-m_language = frame->GetLanguage();
+if (frame && frame_lang == lldb::eLanguageTypeUnknown)
+frame_lang = frame->GetLanguage();
 
-if (m_language != lldb::eLanguageTypeUnknown)
+if (frame_lang != lldb::eLanguageTypeUnknown)
 {
-lang_rt = 
exe_scope->CalculateProcess()->GetLanguageRuntime(m_language);
+lang_rt = 
exe_scope->CalculateProcess()->GetLanguageRuntime(frame_lang);
 if (log)
-log->Printf("Frame has language of type %s", 
Language::GetNameForLanguageType(m_language));
+log->Printf("Frame has language of type %s", 
Language::GetNameForLanguageType(frame_lang));
 }
 
 // 2. Configure the compiler with a set of default options that are 
appropriate
@@ -263,7 +263,9 @@ ClangExpressionParser::ClangExpressionPa
 assert (m_compiler->hasTarget());
 
 // 5. Set language options.
-switch (m_language)
+lldb::LanguageType language = expr.Language();
+
+switch (language)
 {
 case lldb::eLanguageTypeC:
 case lldb::eLanguageTypeC89:

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h?rev=263107&r1=263106&r2=263107&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h 
Thu Mar 10 06:38:55 2016
@@ -129,8 +129,6 @@ private:
 class LLDBPreprocessorCallbacks;
 LLDBPreprocessorCallbacks   *m_pp_callbacks; ///< 
Called when the preprocessor encounters module imports
 std::unique_ptr m_ast_context;
-lldb::LanguageType   m_language;///< The 
the source language of the expression
-/// which 
may be explicitly set or inferred.
 };
 
 }


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17957: Expression evaluation for overloaded C functions

2016-03-11 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

friendly ping


Repository:
  rL LLVM

http://reviews.llvm.org/D17957



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17957: Expression evaluation for overloaded C functions

2016-03-14 Thread Ewan Crawford via lldb-commits
EwanCrawford updated this revision to Diff 50595.
EwanCrawford added a comment.

Thanks for taking a look Sean.

I moved the mangling logic into `LanguageCPlusPlus` and created a new method 
for it. 
There was an existing function `FindEquivalentNames` that used 
`CPPRuntimeEquivalents`, but looked like that was targeted at types. Let me 
know if you prefer I reuse that.


Repository:
  rL LLVM

http://reviews.llvm.org/D17957

Files:
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/Makefile
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/TestCallOverloadedCFunction.py
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/main.c
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -174,6 +174,11 @@
 static uint32_t
 FindEquivalentNames(ConstString type_name, std::vector& equivalents);
 
+// Given a mangled function name, calculates some alternative manglings
+// since the compiler mangling may not line up with the symbol we are expecting
+static uint32_t
+FindAlternateFunctionMangling(ConstString mangled_name, std::vector& alternates);
+
 //--
 // PluginInterface protocol
 //--
Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -482,6 +482,85 @@
 return count;
 }
 
+// Given a mangled function, replaces all the function parameters of mangled type
+// 'search', with parameters of type 'replace'.
+static ConstString
+SubstituteMangledParameters(const llvm::StringRef& mangled, const llvm::StringRef& search, const llvm::StringRef& replace)
+{
+// Find length of function name, already encoded in mangled symbol
+static const llvm::StringRef numeric_digits("0123456789");
+const size_t encoded_length_start = mangled.find_first_of(numeric_digits);
+if (encoded_length_start == llvm::StringRef::npos)
+return ConstString();
+
+const size_t encoded_length_end = mangled.find_first_not_of(numeric_digits, encoded_length_start);
+if (encoded_length_end == llvm::StringRef::npos || encoded_length_end <= encoded_length_start)
+   return ConstString();
+
+// Parse encoded length into name_length
+int name_length;
+const llvm::StringRef encoded_length_str = mangled.substr(encoded_length_start, encoded_length_end - encoded_length_start);
+if (encoded_length_str.getAsInteger(10, name_length) || name_length == 0)
+   return ConstString();
+
+// Position in 'mangled' string of first function parameter
+size_t param_pos = encoded_length_end + name_length;
+
+// Iterate over all matching parameters, replacing them with string 'replace'
+std::string modified_str = mangled.str();
+while ((param_pos = modified_str.find(search, param_pos)) != std::string::npos)
+{
+modified_str.replace(param_pos, search.size(), replace);
+param_pos += replace.size();
+}
+
+return ConstString(modified_str);
+}
+
+uint32_t
+CPlusPlusLanguage::FindAlternateFunctionMangling(ConstString mangled_name, std::vector& alternates)
+{
+const uint32_t start_size = alternates.size();
+
+// Maybe we're looking for a const symbol but the debug info told us it was const...
+if (!strncmp(mangled_name.GetCString(), "_ZN", 3) &&
+strncmp(mangled_name.GetCString(), "_ZNK", 4))
+{
+std::string fixed_scratch("_ZNK");
+fixed_scratch.append(mangled_name.GetCString() + 3);
+alternates.push_back(ConstString(fixed_scratch.c_str()));
+}
+
+// Maybe we're looking for a static symbol but we thought it was global...
+if (!strncmp(mangled_name.GetCString(), "_Z", 2) &&
+strncmp(mangled_name.GetCString(), "_ZL", 3))
+{
+std::string fixed_scratch("_ZL");
+fixed_scratch.append(mangled_name.GetCString() + 2);
+alternates.push_back(ConstString(fixed_scratch.c_str()));
+}
+
+// Char is implementation defined as either signed or unsigned.
+// As a result a char parameter has 3 possible manglings: 'c'-char, 'a'-signed char, 'h'-unsigned char.
+// If we're looking for symbols with a signed char parameter,
+// try finding matches which have the general case 'c'.
+ConstString char_fixup = SubstituteMangledParameters(mangl

Re: [Lldb-commits] [PATCH] D17957: Expression evaluation for overloaded C functions

2016-03-14 Thread Ewan Crawford via lldb-commits
EwanCrawford added inline comments.


Comment at: 
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/Makefile:8
@@ +7,2 @@
+clean::
+   rm -rf $(wildcard *.o *.d *.dSYM)

labath wrote:
> clayborg wrote:
> > Maybe we can have a standard clean rule in the main makefiles:
> > 
> > standard_clean:
> > rm -rf $(wildcard *.o *.d *.dSYM)
> > 
> > And maybe we can call this before calling the "clean" where each test case 
> > can override this. Not required for this patch though.
> The main Makefile.rules does the cleanup already, I'm pretty sure this rule 
> is not necessary.
Good to know, I'll remove this case


Repository:
  rL LLVM

http://reviews.llvm.org/D17957



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r263544 - Fix expression evaluation for resolving anonymous aggregrate types with a typedefed name

2016-03-15 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Mar 15 04:50:16 2016
New Revision: 263544

URL: http://llvm.org/viewvc/llvm-project?rev=263544&view=rev
Log:
Fix expression evaluation for resolving anonymous aggregrate types with a 
typedefed name

This fixes a recently reported a 
bug(https://llvm.org/bugs/show_bug.cgi?id=26790) relating to the clang 
expression evaluator no longer being able to resolve calls to
functions with arguments to typedefed anonymous structs, unions, or enums after 
a cleanup to the expression parsing code in r260768

This fixes the issue by attaching the tagged name to the original 
clang::TagDecl object when generating the typedef in 
lldb::ClangAstContext::CreateTypeDef.

This also fixes the issue for anonymous typedefs for non-struct types (unions 
and enums) where we have a tag name.


Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D18099

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=263544&r1=263543&r2=263544&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Mar 15 04:50:16 2016
@@ -4640,6 +4640,20 @@ ClangASTContext::CreateTypedef (lldb::op

&clang_ast->Idents.get(typedef_name),

clang_ast->getTrivialTypeSourceInfo(qual_type));
 
+clang::TagDecl *tdecl = nullptr;
+if (!qual_type.isNull())
+{
+if (const clang::RecordType *rt = 
qual_type->getAs())
+tdecl = rt->getDecl();
+if (const clang::EnumType *et = 
qual_type->getAs())
+tdecl = et->getDecl();
+}
+
+// Check whether this declaration is an anonymous struct, union, or 
enum, hidden behind a typedef. If so, we
+// try to check whether we have a typedef tag to attach to the 
original record declaration
+if (tdecl && !tdecl->getIdentifier() && 
!tdecl->getTypedefNameForAnonDecl())
+tdecl->setTypedefNameForAnonDecl(decl);
+
 decl->setAccess(clang::AS_public); // TODO respect proper access 
specifier
 
 // Get a uniqued clang::QualType for the typedef decl type


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17777: Add regression test for expressions calling functions taking anonymous struct typedef arguments

2016-03-15 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263547: Add regression test for expressions calling 
functions taking anonymous struct… (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D1?vs=49524&id=50719#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D1

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp

Index: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
@@ -0,0 +1,40 @@
+"""
+Test calling user defined functions using expression evaluation.
+This test checks that typesystem lookup works correctly for typedefs of
+untagged structures.
+
+Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790
+"""
+
+from __future__ import print_function
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestExprLookupAnonStructTypedef(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+# Find the breakpoint
+self.line = line_number('main.cpp', '// lldb testsuite break')
+
+def test(self):
+"""Test typedeffed untagged struct arguments for function call 
expressions"""
+self.build()
+
+self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+lldbutil.run_break_set_by_file_and_line(
+self,
+"main.cpp",
+self.line,
+num_expected_locations=-1,
+loc_exact=True
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("expr multiply(&s)", substrs=['$0 = 1'])
Index: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets.  Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+  CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
Index: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp
@@ -0,0 +1,26 @@
+#include 
+
+typedef struct {
+float f;
+int i;
+} my_untagged_struct;
+
+double multiply(my_untagged_struct *s)
+{
+return s->f * s->i;
+}
+
+double multiply(my_untagged_struct *s, int x)
+{
+return multiply(s) * x;
+}
+
+int main(int argc, char **argv)
+{
+my_untagged_struct s = {
+.f = (float)argc,
+.i = argc,
+};
+// lldb testsuite break
+return !(multiply(&s, argc) == pow(argc, 3));
+}


Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
@@ -0,0 +1,40 @@
+"""
+Test calling user defined functions using expression evaluation.
+This test checks that typesystem lookup works correctly for typedefs of
+untagged structures.
+
+Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790
+"""
+
+from __future__ import print_function
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestExprLookupAnonStructTypedef(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+# Find the breakpoint
+self.line = line_number('main.cpp', '// lldb testsuite break')
+
+def test(self):
+"""Test typedeffed untagged struct arguments for function call expressions"""
+self.build()
+
+self.runCmd("file a.out", CURRENT_EXECUT

[Lldb-commits] [lldb] r263547 - Add regression test for expressions calling functions taking anonymous struct typedef arguments

2016-03-15 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Mar 15 08:02:11 2016
New Revision: 263547

URL: http://llvm.org/viewvc/llvm-project?rev=263547&view=rev
Log:
Add regression test for expressions calling functions taking anonymous struct 
typedef arguments

This CL adds a regression test for the bug listed at 
https://llvm.org/bugs/show_bug.cgi?id=26790
Functionality was implemented in commit r263544

Author: Luke Drummond 
Differential Revision: http://reviews.llvm.org/D1

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile?rev=263547&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile
 Tue Mar 15 08:02:11 2016
@@ -0,0 +1,12 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets.  Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+  CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py?rev=263547&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py
 Tue Mar 15 08:02:11 2016
@@ -0,0 +1,40 @@
+"""
+Test calling user defined functions using expression evaluation.
+This test checks that typesystem lookup works correctly for typedefs of
+untagged structures.
+
+Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790
+"""
+
+from __future__ import print_function
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestExprLookupAnonStructTypedef(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+# Find the breakpoint
+self.line = line_number('main.cpp', '// lldb testsuite break')
+
+def test(self):
+"""Test typedeffed untagged struct arguments for function call 
expressions"""
+self.build()
+
+self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+lldbutil.run_break_set_by_file_and_line(
+self,
+"main.cpp",
+self.line,
+num_expected_locations=-1,
+loc_exact=True
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("expr multiply(&s)", substrs=['$0 = 1'])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp?rev=263547&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp
 Tue Mar 15 08:02:11 2016
@@ -0,0 +1,26 @@
+#include 
+
+typedef struct {
+float f;
+int i;
+} my_untagged_struct;
+
+double multiply(my_untagged_struct *s)
+{
+return s->f * s->i;
+}
+
+double multiply(my_untagged_struct *s, int x)
+{
+return multiply(s) * x;
+}
+
+int main(int argc, char **argv)
+{
+my_untagged_struct s = {
+.f = (float)argc,
+.i = argc,
+};
+// lldb testsuite break
+return !(multiply(&s, argc) == pow(argc, 3));
+}


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D17957: Expression evaluation for overloaded C functions

2016-03-21 Thread Ewan Crawford via lldb-commits
EwanCrawford updated this revision to Diff 51182.
EwanCrawford added a comment.

Rebased on tip


Repository:
  rL LLVM

http://reviews.llvm.org/D17957

Files:
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/Makefile
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/TestCallOverloadedCFunction.py
  
packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/main.c
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -174,6 +174,11 @@
 static uint32_t
 FindEquivalentNames(ConstString type_name, std::vector& equivalents);
 
+// Given a mangled function name, calculates some alternative manglings
+// since the compiler mangling may not line up with the symbol we are expecting
+static uint32_t
+FindAlternateFunctionMangling(ConstString mangled_name, std::vector& alternates);
+
 //--
 // PluginInterface protocol
 //--
Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -482,6 +482,85 @@
 return count;
 }
 
+// Given a mangled function, replaces all the function parameters of mangled type
+// 'search', with parameters of type 'replace'.
+static ConstString
+SubstituteMangledParameters(const llvm::StringRef& mangled, const llvm::StringRef& search, const llvm::StringRef& replace)
+{
+// Find length of function name, already encoded in mangled symbol
+static const llvm::StringRef numeric_digits("0123456789");
+const size_t encoded_length_start = mangled.find_first_of(numeric_digits);
+if (encoded_length_start == llvm::StringRef::npos)
+return ConstString();
+
+const size_t encoded_length_end = mangled.find_first_not_of(numeric_digits, encoded_length_start);
+if (encoded_length_end == llvm::StringRef::npos || encoded_length_end <= encoded_length_start)
+   return ConstString();
+
+// Parse encoded length into name_length
+int name_length;
+const llvm::StringRef encoded_length_str = mangled.substr(encoded_length_start, encoded_length_end - encoded_length_start);
+if (encoded_length_str.getAsInteger(10, name_length) || name_length == 0)
+   return ConstString();
+
+// Position in 'mangled' string of first function parameter
+size_t param_pos = encoded_length_end + name_length;
+
+// Iterate over all matching parameters, replacing them with string 'replace'
+std::string modified_str = mangled.str();
+while ((param_pos = modified_str.find(search, param_pos)) != std::string::npos)
+{
+modified_str.replace(param_pos, search.size(), replace);
+param_pos += replace.size();
+}
+
+return ConstString(modified_str);
+}
+
+uint32_t
+CPlusPlusLanguage::FindAlternateFunctionMangling(ConstString mangled_name, std::vector& alternates)
+{
+const uint32_t start_size = alternates.size();
+
+// Maybe we're looking for a const symbol but the debug info told us it was const...
+if (!strncmp(mangled_name.GetCString(), "_ZN", 3) &&
+strncmp(mangled_name.GetCString(), "_ZNK", 4))
+{
+std::string fixed_scratch("_ZNK");
+fixed_scratch.append(mangled_name.GetCString() + 3);
+alternates.push_back(ConstString(fixed_scratch.c_str()));
+}
+
+// Maybe we're looking for a static symbol but we thought it was global...
+if (!strncmp(mangled_name.GetCString(), "_Z", 2) &&
+strncmp(mangled_name.GetCString(), "_ZL", 3))
+{
+std::string fixed_scratch("_ZL");
+fixed_scratch.append(mangled_name.GetCString() + 2);
+alternates.push_back(ConstString(fixed_scratch.c_str()));
+}
+
+// Char is implementation defined as either signed or unsigned.
+// As a result a char parameter has 3 possible manglings: 'c'-char, 'a'-signed char, 'h'-unsigned char.
+// If we're looking for symbols with a signed char parameter,
+// try finding matches which have the general case 'c'.
+ConstString char_fixup = SubstituteMangledParameters(mangled_name.GetStringRef(), llvm::StringRef("a"), llvm::StringRef("c"));
+if (!char_fixup.IsEmpty())
+alternates.push_back(char_fixup);
+
+// long long parameter mangling 'x', may actually just be a long 'l' argument
+ConstString long_fixup = SubstituteMangledPa

[Lldb-commits] [PATCH] D12360: RenderScript pending kernel breakpoints.

2015-08-26 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: clayborg, jingham.
EwanCrawford added subscribers: lldb-commits, domipheus, ADodds.
EwanCrawford set the repository for this revision to rL LLVM.

Currently the RS breakpoint command can only find a kernel if it's in an 
already loaded RS module.
This patch allows users to set pending breakpoints on RenderScript kernels 
which will be loaded in the future.

To maintain these breakpoints the command 'renderscript kernel breakpoint' is 
split into 3 separate sub-commands.
'renderscript kernel breakpoint set', 'renderscript kernel breakpoint list', 
and 'renderscript kernel breakpoint delete'.

Repository:
  rL LLVM

http://reviews.llvm.org/D12360

Files:
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -147,8 +147,12 @@
 
 void DumpKernels(Stream &strm) const;
 
+void DumpBreakpoints(Stream &strm) const;
+
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error);
 
+void DeleteBreakpoint(Stream &strm, const char* name);
+
 void Status(Stream &strm) const;
 
 virtual size_t GetAlternateManglings(const ConstString &mangled, std::vector &alternates) {
@@ -206,6 +210,8 @@
 std::map m_scriptMappings;
 std::map m_runtimeHooks;
 
+std::map m_kernel_breakpoints; // BreakpointSP is null if breakpoint is pending
+
 bool m_initiated;
 bool m_debuggerPresentFlagged;
 static const HookDefn s_runtimeHookDefns[];
@@ -225,6 +231,9 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+void CheckModuleForPendingBreakpoints(const RSModuleDescriptorSP& module_desc);
+bool ResolveKernelBreakpoint(ConstString kernel_name, const RSModuleDescriptorSP& module,
+ Error& error, lldb::BreakpointSP& bp, Stream* strm = nullptr);
 };
 
 } // namespace lldb_private
Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -28,6 +28,8 @@
 
 #include "lldb/Symbol/VariableList.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -496,7 +498,12 @@
 for (const auto &rs_module : m_rsmodules)
 {
 if (rs_module->m_module == module_sp)
+{
+// The dynamic loader can update the loaded sections
+// after we have already seen the module.
+CheckModuleForPendingBreakpoints(rs_module);
 return false;
+}
 }
 bool module_loaded = false;
 switch (GetModuleKind(module_sp))
@@ -507,6 +514,7 @@
 module_desc.reset(new RSModuleDescriptor(module_sp));
 if (module_desc->ParseRSInfo())
 {
+CheckModuleForPendingBreakpoints(module_desc);
 m_rsmodules.push_back(module_desc);
 module_loaded = true;
 }
@@ -767,72 +775,189 @@
 strm.IndentLess();
 }
 
-void 
-RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* name, Error& error)
+void
+RenderScriptRuntime::DumpBreakpoints(Stream &strm) const
 {
-if (!name) 
+strm.Printf("RenderScript Kernel Breakpoints:");
+strm.EOL();
+strm.IndentMore();
+for (const auto &bp_pair : m_kernel_breakpoints)
 {
-error.SetErrorString("invalid kernel name");
-return;
+   strm.Printf("\t%s  - ", bp_pair.first.AsCString());
+   if (bp_pair.second == nullptr)
+   strm.Printf("Pending on RS module load");
+   else
+   bp_pair.second->GetDescription(&strm, lldb::eDescriptionLevelBrief, false);
+
+   strm.EOL();
 }
+strm.IndentLess();
+}
 
-bool kernels_found = false;
+void
+RenderScriptRuntime::DeleteBreakpoint(Stream &strm, const char* name)
+{
 ConstString kernel_name(name);
-for (const auto &module : m_rsmodules)
+auto match = m_kernel_breakpoints.find(kernel_name);
+
+if (match != m_kernel_breakpoints.end())
 {
-for (const auto &kernel : module->m_kernels)
+BreakpointSP bp = match->second;
+if (bp != nullptr)
+GetProcess()->GetTarget().RemoveBreak

Re: [Lldb-commits] [PATCH] D12360: RenderScript pending kernel breakpoints.

2015-08-28 Thread Ewan Crawford via lldb-commits
EwanCrawford updated this revision to Diff 33425.
EwanCrawford added a comment.

Thanks for taking a look.

Previously we just tried to find a way to leverage the existing 
BreakpointResovlerName, and SearchFilter. 
However your suggestion to create a new BreakpointResolver works a lot better, 
and indeed removes the need for the extra commands.

This updated patch impements the RS breakpoint resolver, allowing us to set 
pending breakpoints on future kernels.


Repository:
  rL LLVM

http://reviews.llvm.org/D12360

Files:
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -22,6 +22,9 @@
 namespace lldb_private
 {
 
+namespace lldb_renderscript
+{
+
 typedef uint32_t RSSlot;
 class RSModuleDescriptor;
 struct RSGlobalDescriptor;
@@ -31,8 +34,54 @@
 typedef std::shared_ptr RSGlobalDescriptorSP;
 typedef std::shared_ptr RSKernelDescriptorSP;
 
+// Breakpoint Resolvers decide where a breakpoint is placed,
+// so having our own allows us to limit the search scope to RS kernel modules.
+// As well as check for .expand kernels as a fallback.
+class RSBreakpointResolver : public BreakpointResolver
+{
+  public:
 
+RSBreakpointResolver(Breakpoint *bkpt, ConstString name):
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+ m_kernel_name(name)
+{
+}
 
+void
+GetDescription(Stream *strm) override
+{
+if (strm)
+strm->Printf("RenderScript kernel breakpoint for '%s'", m_kernel_name.AsCString());
+}
+
+void
+Dump(Stream *s) const override
+{
+}
+
+Searcher::CallbackReturn
+SearchCallback(SearchFilter &filter,
+   SymbolContext &context,
+   Address *addr,
+   bool containing) override;
+
+Searcher::Depth
+GetDepth() override
+{
+return Searcher::eDepthModule;
+}
+
+lldb::BreakpointResolverSP
+CopyForBreakpoint(Breakpoint &breakpoint) override
+{
+lldb::BreakpointResolverSP ret_sp(new RSBreakpointResolver(&breakpoint, m_kernel_name));
+return ret_sp;
+}
+
+  protected:
+ConstString m_kernel_name;
+};
+
 struct RSKernelDescriptor
 {
   public:
@@ -86,6 +135,8 @@
 std::string m_resname;
 };
 
+} // end lldb_renderscript namespace
+
 class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
 {
   public:
@@ -147,7 +198,7 @@
 
 void DumpKernels(Stream &strm) const;
 
-void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error);
+void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
 
 void Status(Stream &strm) const;
 
@@ -163,7 +214,7 @@
 
   protected:
 
-void FixupScriptDetails(RSModuleDescriptorSP rsmodule_sp);
+void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
 
 void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
 
@@ -200,10 +251,10 @@
 lldb::ModuleSP m_libRS;
 lldb::ModuleSP m_libRSDriver;
 lldb::ModuleSP m_libRSCpuRef;
-std::vector m_rsmodules;
+std::vector m_rsmodules;
 std::vector m_scripts;
 
-std::map m_scriptMappings;
+std::map m_scriptMappings;
 std::map m_runtimeHooks;
 
 bool m_initiated;
Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -30,6 +30,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_renderscript;
 
 //--
 // Static Functions
@@ -44,6 +45,47 @@
 return NULL;
 }
 
+// Callback with a module to search for matching symbols.
+// We first check that the module contains RS kernels.
+// Then look for a symbol which matches our kernel name.
+// The breakpoint address is finally set using the address of this symbol.
+Searcher::CallbackReturn
+RSBreakpointResolver::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address*,
+ bool)
+{
+ModuleSP module = context.module_sp;
+
+if (!module)
+return Searcher::eCallbackReturnContinue;
+
+// Is this a module containing r

Re: [Lldb-commits] [PATCH] D12360: RenderScript pending kernel breakpoints.

2015-09-02 Thread Ewan Crawford via lldb-commits
EwanCrawford added a comment.

Does this address your concerns Jim?


Repository:
  rL LLVM

http://reviews.llvm.org/D12360



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r246842 - RenderScript pending kernel breakpoints.

2015-09-04 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Fri Sep  4 03:56:52 2015
New Revision: 246842

URL: http://llvm.org/viewvc/llvm-project?rev=246842&view=rev
Log:
RenderScript pending kernel breakpoints.

Currently the RS breakpoint command can only find a kernel if it's in an 
already loaded RS module.
This patch allows users to set pending breakpoints on RenderScript kernels 
which will be loaded in the future.
Implemented by creating a RS breakpoint resolver, to limit search scope to only 
RS modules.

Reviewed by: clayborg, jingham
Subscribers: lldb-commits, ADodds, domipheus
Differential Revision: http://reviews.llvm.org/D12360

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=246842&r1=246841&r2=246842&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Fri Sep  4 03:56:52 2015
@@ -30,6 +30,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_renderscript;
 
 //--
 // Static Functions
@@ -44,6 +45,47 @@ RenderScriptRuntime::CreateInstance(Proc
 return NULL;
 }
 
+// Callback with a module to search for matching symbols.
+// We first check that the module contains RS kernels.
+// Then look for a symbol which matches our kernel name.
+// The breakpoint address is finally set using the address of this symbol.
+Searcher::CallbackReturn
+RSBreakpointResolver::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address*,
+ bool)
+{
+ModuleSP module = context.module_sp;
+
+if (!module)
+return Searcher::eCallbackReturnContinue;
+
+// Is this a module containing renderscript kernels?
+if (nullptr == 
module->FindFirstSymbolWithNameAndType(ConstString(".rs.info"), 
eSymbolTypeData))
+return Searcher::eCallbackReturnContinue;
+
+// Attempt to set a breakpoint on the kernel name symbol within the module 
library.
+// If it's not found, it's likely debug info is unavailable - try to set a
+// breakpoint on .expand.
+
+const Symbol* kernel_sym = 
module->FindFirstSymbolWithNameAndType(m_kernel_name, eSymbolTypeCode);
+if (!kernel_sym)
+{
+std::string kernel_name_expanded(m_kernel_name.AsCString());
+kernel_name_expanded.append(".expand");
+kernel_sym = 
module->FindFirstSymbolWithNameAndType(ConstString(kernel_name_expanded.c_str()),
 eSymbolTypeCode);
+}
+
+if (kernel_sym)
+{
+Address bp_addr = kernel_sym->GetAddress();
+if (filter.AddressPasses(bp_addr))
+m_breakpoint->AddLocation(bp_addr);
+}
+
+return Searcher::eCallbackReturnContinue;
+}
+
 void
 RenderScriptRuntime::Initialize()
 {
@@ -767,68 +809,24 @@ RenderScriptRuntime::DumpKernels(Stream
 strm.IndentLess();
 }
 
-void 
-RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* 
name, Error& error)
+void
+RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* 
name, Error& error, TargetSP target)
 {
-if (!name) 
+if (!name)
 {
 error.SetErrorString("invalid kernel name");
 return;
 }
 
-bool kernels_found = false;
-ConstString kernel_name(name);
-for (const auto &module : m_rsmodules)
-{
-for (const auto &kernel : module->m_kernels)
-{
-if (kernel.m_name == kernel_name)
-{
-//Attempt to set a breakpoint on this symbol, within the 
module library
-//If it's not found, it's likely debug info is unavailable - 
set a
-//breakpoint on .expand and emit a warning.
-
-const Symbol* kernel_sym = 
module->m_module->FindFirstSymbolWithNameAndType(kernel_name, eSymbolTypeCode);
-
-if (!kernel_sym)
-{
-std::string kernel_name_expanded(name);
-kernel_name_expanded.append(".expand");
-kernel_sym = 
module->m_module->FindFirstSymbolWithNameAndType(ConstString(kernel_name_expanded.c_str()),
 eSymbolTypeCode);
-
-if (kernel_sym)
-{
-strm.Printf("Kernel '%s' could not be found, but 
expansion exists. ", name); 
-

Re: [Lldb-commits] [PATCH] D12360: RenderScript pending kernel breakpoints.

2015-09-04 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246842: RenderScript pending kernel breakpoints. (authored 
by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D12360?vs=33425&id=34018#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12360

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -30,6 +30,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_renderscript;
 
 //--
 // Static Functions
@@ -44,6 +45,47 @@
 return NULL;
 }
 
+// Callback with a module to search for matching symbols.
+// We first check that the module contains RS kernels.
+// Then look for a symbol which matches our kernel name.
+// The breakpoint address is finally set using the address of this symbol.
+Searcher::CallbackReturn
+RSBreakpointResolver::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address*,
+ bool)
+{
+ModuleSP module = context.module_sp;
+
+if (!module)
+return Searcher::eCallbackReturnContinue;
+
+// Is this a module containing renderscript kernels?
+if (nullptr == module->FindFirstSymbolWithNameAndType(ConstString(".rs.info"), eSymbolTypeData))
+return Searcher::eCallbackReturnContinue;
+
+// Attempt to set a breakpoint on the kernel name symbol within the module library.
+// If it's not found, it's likely debug info is unavailable - try to set a
+// breakpoint on .expand.
+
+const Symbol* kernel_sym = module->FindFirstSymbolWithNameAndType(m_kernel_name, eSymbolTypeCode);
+if (!kernel_sym)
+{
+std::string kernel_name_expanded(m_kernel_name.AsCString());
+kernel_name_expanded.append(".expand");
+kernel_sym = module->FindFirstSymbolWithNameAndType(ConstString(kernel_name_expanded.c_str()), eSymbolTypeCode);
+}
+
+if (kernel_sym)
+{
+Address bp_addr = kernel_sym->GetAddress();
+if (filter.AddressPasses(bp_addr))
+m_breakpoint->AddLocation(bp_addr);
+}
+
+return Searcher::eCallbackReturnContinue;
+}
+
 void
 RenderScriptRuntime::Initialize()
 {
@@ -767,68 +809,24 @@
 strm.IndentLess();
 }
 
-void 
-RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* name, Error& error)
+void
+RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* name, Error& error, TargetSP target)
 {
-if (!name) 
+if (!name)
 {
 error.SetErrorString("invalid kernel name");
 return;
 }
 
-bool kernels_found = false;
-ConstString kernel_name(name);
-for (const auto &module : m_rsmodules)
-{
-for (const auto &kernel : module->m_kernels)
-{
-if (kernel.m_name == kernel_name)
-{
-//Attempt to set a breakpoint on this symbol, within the module library
-//If it's not found, it's likely debug info is unavailable - set a
-//breakpoint on .expand and emit a warning.
-
-const Symbol* kernel_sym = module->m_module->FindFirstSymbolWithNameAndType(kernel_name, eSymbolTypeCode);
-
-if (!kernel_sym)
-{
-std::string kernel_name_expanded(name);
-kernel_name_expanded.append(".expand");
-kernel_sym = module->m_module->FindFirstSymbolWithNameAndType(ConstString(kernel_name_expanded.c_str()), eSymbolTypeCode);
-
-if (kernel_sym)
-{
-strm.Printf("Kernel '%s' could not be found, but expansion exists. ", name); 
-strm.Printf("Breakpoint placed on expanded kernel. Have you compiled in debug mode?");
-strm.EOL();
-}
-else
-{
-error.SetErrorStringWithFormat("Could not locate symbols for loaded kernel '%s'.", name);
-return;
-}
-}
-
-addr_t bp_addr = kernel_sym->GetLoadAddress(&GetProcess()->GetTarget());
-if (bp_addr == LLDB_INVALID_ADDRESS)
-{
-error.SetErrorStringWithFormat("Could not locate load address for symbols of k

[Lldb-commits] [PATCH] D12728: New RenderScript command to break on all kernels

2015-09-09 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: clayborg, jingham.
EwanCrawford added subscribers: lldb-commits, domipheus, ADodds.
EwanCrawford set the repository for this revision to rL LLVM.

Patch adds a command to RenderScript plugin allowing users to automatically set 
breakpoints on every RS kernel.

Command syntax is 'language renderscript kernel breakpoint all 
.'  
Enable sets breakpoints on all currently loaded kernels, and any kernels which 
will be loaded in future. 
Disable results in breakpoints no longer being set on loaded kernels, but 
doesn't affect existing breakpoints.

Current command 'language renderscript kernel breakpoint' is changed to 
'language renderscript kernel breakpoint set'

Repository:
  rL LLVM

http://reviews.llvm.org/D12728

Files:
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -200,6 +200,8 @@
 
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
 
+void SetBreakAllKernels(bool do_break, lldb::TargetSP target);
+
 void Status(Stream &strm) const;
 
 virtual size_t GetAlternateManglings(const ConstString &mangled, std::vector &alternates) {
@@ -213,10 +215,20 @@
 void Initiate();
 
   protected:
+
+void InitSearchFilter(lldb::TargetSP target)
+{
+if (!m_filtersp)
+m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target));
+}
 
 void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
 
 void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
+
+lldb::BreakpointSP CreateKernelBreakpoint(const ConstString& name);
+
+void BreakOnModuleKernels(const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
 
 struct RuntimeHook;
 typedef void (RenderScriptRuntime::*CaptureStateFn)(RuntimeHook* hook_info, ExecutionContext &context);  // Please do this!
@@ -257,8 +269,11 @@
 std::map m_scriptMappings;
 std::map m_runtimeHooks;
 
+lldb::SearchFilterSP m_filtersp; // Needed to create breakpoints through Target API
+
 bool m_initiated;
 bool m_debuggerPresentFlagged;
+bool m_breakAllKernels;
 static const HookDefn s_runtimeHookDefns[];
 static const size_t s_runtimeHookCount;
 
Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -538,7 +538,14 @@
 for (const auto &rs_module : m_rsmodules)
 {
 if (rs_module->m_module == module_sp)
+{
+// Check if the user has enabled automatically breaking on
+// all RS kernels.
+if (m_breakAllKernels)
+BreakOnModuleKernels(rs_module);
+
 return false;
+}
 }
 bool module_loaded = false;
 switch (GetModuleKind(module_sp))
@@ -809,7 +816,74 @@
 strm.IndentLess();
 }
 
+// Set breakpoints on every kernel found in RS module
 void
+RenderScriptRuntime::BreakOnModuleKernels(const RSModuleDescriptorSP rsmodule_sp)
+{
+for (const auto &kernel : rsmodule_sp->m_kernels)
+{
+// Don't set breakpoint on 'root' kernel
+if (strcmp(kernel.m_name.AsCString(), "root") == 0)
+continue;
+
+CreateKernelBreakpoint(kernel.m_name);
+}
+}
+
+// Method is internally called by the 'kernel breakpoint all' command to
+// enable or disable breaking on all kernels.
+//
+// When do_break is true we want to enable this functionality.
+// When do_break is false we want to disable it.
+void
+RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+InitSearchFilter(target);
+
+// Set breakpoints on all the kernels
+if (do_break && !m_breakAllKernels)
+{
+m_breakAllKernels = true;
+
+for (const auto &module : m_rsmodules)
+BreakOnModuleKernels(module);
+
+if (log)
+log->Printf("RenderScriptRuntime::SetBreakAllKernels(True)"
+"- breakpoints set on all currently loaded kernels");
+}
+else if (!do_break && m_breakAllKernels) // Breakpoints won't be set on any new kernels.
+{
+m_breakAllKernels = false;
+
+ 

[Lldb-commits] [lldb] r247262 - New RenderScript command to break on all kernels

2015-09-10 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Thu Sep 10 05:08:48 2015
New Revision: 247262

URL: http://llvm.org/viewvc/llvm-project?rev=247262&view=rev
Log:
New RenderScript command to break on all kernels

Patch adds a command to RenderScript plugin allowing users to automatically set 
breakpoints on every RS kernel.

Command syntax is 'language renderscript kernel breakpoint all 
.'
Enable sets breakpoints on all currently loaded kernels, and any kernels which 
will be loaded in future.
Disable results in breakpoints no longer being set on loaded kernels, but 
doesn't affect existing breakpoints.

Current command 'language renderscript kernel breakpoint' is changed to 
'language renderscript kernel breakpoint set'

Reviewed by: clayborg, jingham
Subscribers: lldb-commits, ADodds, domipheus
Differential Revision: http://reviews.llvm.org/D12728

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=247262&r1=247261&r2=247262&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Thu Sep 10 05:08:48 2015
@@ -538,7 +538,14 @@ RenderScriptRuntime::LoadModule(const ll
 for (const auto &rs_module : m_rsmodules)
 {
 if (rs_module->m_module == module_sp)
+{
+// Check if the user has enabled automatically breaking on
+// all RS kernels.
+if (m_breakAllKernels)
+BreakOnModuleKernels(rs_module);
+
 return false;
+}
 }
 bool module_loaded = false;
 switch (GetModuleKind(module_sp))
@@ -809,6 +816,73 @@ RenderScriptRuntime::DumpKernels(Stream
 strm.IndentLess();
 }
 
+// Set breakpoints on every kernel found in RS module
+void
+RenderScriptRuntime::BreakOnModuleKernels(const RSModuleDescriptorSP 
rsmodule_sp)
+{
+for (const auto &kernel : rsmodule_sp->m_kernels)
+{
+// Don't set breakpoint on 'root' kernel
+if (strcmp(kernel.m_name.AsCString(), "root") == 0)
+continue;
+
+CreateKernelBreakpoint(kernel.m_name);
+}
+}
+
+// Method is internally called by the 'kernel breakpoint all' command to
+// enable or disable breaking on all kernels.
+//
+// When do_break is true we want to enable this functionality.
+// When do_break is false we want to disable it.
+void
+RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+InitSearchFilter(target);
+
+// Set breakpoints on all the kernels
+if (do_break && !m_breakAllKernels)
+{
+m_breakAllKernels = true;
+
+for (const auto &module : m_rsmodules)
+BreakOnModuleKernels(module);
+
+if (log)
+log->Printf("RenderScriptRuntime::SetBreakAllKernels(True)"
+"- breakpoints set on all currently loaded kernels");
+}
+else if (!do_break && m_breakAllKernels) // Breakpoints won't be set on 
any new kernels.
+{
+m_breakAllKernels = false;
+
+if (log)
+log->Printf("RenderScriptRuntime::SetBreakAllKernels(False) - 
breakpoints no longer automatically set");
+}
+}
+
+// Given the name of a kernel this function creates a breakpoint using our
+// own breakpoint resolver, and returns the Breakpoint shared pointer.
+BreakpointSP
+RenderScriptRuntime::CreateKernelBreakpoint(const ConstString& name)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+if (!m_filtersp)
+{
+if (log)
+log->Printf("RenderScriptRuntime::CreateKernelBreakpoint - Error: 
No breakpoint search filter set");
+return nullptr;
+}
+
+BreakpointResolverSP resolver_sp(new RSBreakpointResolver(nullptr, name));
+BreakpointSP bp = GetProcess()->GetTarget().CreateBreakpoint(m_filtersp, 
resolver_sp, false, false, false);
+
+return bp;
+}
+
 void
 RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* 
name, Error& error, TargetSP target)
 {
@@ -818,12 +892,10 @@ RenderScriptRuntime::AttemptBreakpointAt
 return;
 }
 
-SearchFilterSP filter_sp(new SearchFilterForUnconstrainedSearches(target));
+InitSearchFilter(target);
 
 ConstString kernel_name(name);
-BreakpointResolverSP resolver_sp(new RSBreakpointResolver(nullptr, 
kernel_name));
-
-BreakpointSP bp

Re: [Lldb-commits] [PATCH] D12728: New RenderScript command to break on all kernels

2015-09-10 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247262: New RenderScript command to break on all kernels 
(authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D12728?vs=34327&id=34424#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12728

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -200,6 +200,8 @@
 
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
 
+void SetBreakAllKernels(bool do_break, lldb::TargetSP target);
+
 void Status(Stream &strm) const;
 
 virtual size_t GetAlternateManglings(const ConstString &mangled, std::vector &alternates) {
@@ -213,10 +215,20 @@
 void Initiate();
 
   protected:
+
+void InitSearchFilter(lldb::TargetSP target)
+{
+if (!m_filtersp)
+m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target));
+}
 
 void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
 
 void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
+
+lldb::BreakpointSP CreateKernelBreakpoint(const ConstString& name);
+
+void BreakOnModuleKernels(const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
 
 struct RuntimeHook;
 typedef void (RenderScriptRuntime::*CaptureStateFn)(RuntimeHook* hook_info, ExecutionContext &context);  // Please do this!
@@ -257,8 +269,11 @@
 std::map m_scriptMappings;
 std::map m_runtimeHooks;
 
+lldb::SearchFilterSP m_filtersp; // Needed to create breakpoints through Target API
+
 bool m_initiated;
 bool m_debuggerPresentFlagged;
+bool m_breakAllKernels;
 static const HookDefn s_runtimeHookDefns[];
 static const size_t s_runtimeHookCount;
 
Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -538,7 +538,14 @@
 for (const auto &rs_module : m_rsmodules)
 {
 if (rs_module->m_module == module_sp)
+{
+// Check if the user has enabled automatically breaking on
+// all RS kernels.
+if (m_breakAllKernels)
+BreakOnModuleKernels(rs_module);
+
 return false;
+}
 }
 bool module_loaded = false;
 switch (GetModuleKind(module_sp))
@@ -809,6 +816,73 @@
 strm.IndentLess();
 }
 
+// Set breakpoints on every kernel found in RS module
+void
+RenderScriptRuntime::BreakOnModuleKernels(const RSModuleDescriptorSP rsmodule_sp)
+{
+for (const auto &kernel : rsmodule_sp->m_kernels)
+{
+// Don't set breakpoint on 'root' kernel
+if (strcmp(kernel.m_name.AsCString(), "root") == 0)
+continue;
+
+CreateKernelBreakpoint(kernel.m_name);
+}
+}
+
+// Method is internally called by the 'kernel breakpoint all' command to
+// enable or disable breaking on all kernels.
+//
+// When do_break is true we want to enable this functionality.
+// When do_break is false we want to disable it.
+void
+RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target)
+{
+Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+InitSearchFilter(target);
+
+// Set breakpoints on all the kernels
+if (do_break && !m_breakAllKernels)
+{
+m_breakAllKernels = true;
+
+for (const auto &module : m_rsmodules)
+BreakOnModuleKernels(module);
+
+if (log)
+log->Printf("RenderScriptRuntime::SetBreakAllKernels(True)"
+"- breakpoints set on all currently loaded kernels");
+}
+else if (!do_break && m_breakAllKernels) // Breakpoints won't be set on any new kernels.
+{
+m_breakAllKernels = false;
+
+if (log)
+log->Printf("RenderScriptRuntime::SetBreakAllKernels(False) - breakpoints no longer automatically set");
+}
+}
+
+// Given the name of a kernel this function creates a breakpoint using our
+// own breakpoint resolver, and returns the Breakpoint shared pointer.
+BreakpointSP
+RenderScriptRuntime::CreateKernelBreakpoint(const ConstString& name)
+{
+L

[Lldb-commits] [lldb] r247782 - Add names to RenderScript kernel breakpoints.

2015-09-16 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Wed Sep 16 05:02:57 2015
New Revision: 247782

URL: http://llvm.org/viewvc/llvm-project?rev=247782&view=rev
Log:
Add names to RenderScript kernel breakpoints.

Use Breakpoint::AddName to mark all RenderScript kernel breakpoints with the 
name 'RenderScriptKernel'.
Also update logging channels to include LIBLLDB_LOG_BREAKPOINT where 
appropriate. 

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=247782&r1=247781&r2=247782&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Wed Sep 16 05:02:57 2015
@@ -838,7 +838,7 @@ RenderScriptRuntime::BreakOnModuleKernel
 void
 RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target)
 {
-Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | 
LIBLLDB_LOG_BREAKPOINTS));
 
 InitSearchFilter(target);
 
@@ -868,7 +868,7 @@ RenderScriptRuntime::SetBreakAllKernels(
 BreakpointSP
 RenderScriptRuntime::CreateKernelBreakpoint(const ConstString& name)
 {
-Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | 
LIBLLDB_LOG_BREAKPOINTS));
 
 if (!m_filtersp)
 {
@@ -880,6 +880,11 @@ RenderScriptRuntime::CreateKernelBreakpo
 BreakpointResolverSP resolver_sp(new RSBreakpointResolver(nullptr, name));
 BreakpointSP bp = GetProcess()->GetTarget().CreateBreakpoint(m_filtersp, 
resolver_sp, false, false, false);
 
+// Give RS breakpoints a specific name, so the user can manipulate them as 
a group.
+Error err;
+if (!bp->AddName("RenderScriptKernel", err) && log)
+log->Printf("RenderScriptRuntime::CreateKernelBreakpoint: Error 
setting break name, %s", err.AsCString());
+
 return bp;
 }
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12936: Groundwork for better tracking of renderscript allocations and scripts.

2015-09-21 Thread Ewan Crawford via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248149: Groundwork for better tracking of renderscript 
allocations and scripts (authored by EwanCrawford).

Changed prior to commit:
  http://reviews.llvm.org/D12936?vs=34996&id=35224#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12936

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -32,6 +32,126 @@
 using namespace lldb_private;
 using namespace lldb_renderscript;
 
+namespace {
+
+// The empirical_type adds a basic level of validation to arbitrary data
+// allowing us to track if data has been discovered and stored or not.
+// An empirical_type will be marked as valid only if it has been explicitly assigned to.
+template 
+class empirical_type
+{
+  public:
+// Ctor. Contents is invalid when constructed.
+empirical_type()
+: valid(false)
+{}
+
+// Return true and copy contents to out if valid, else return false.
+bool get(type_t& out) const
+{
+if (valid)
+out = data;
+return valid;
+}
+
+// Return a pointer to the contents or nullptr if it was not valid.
+const type_t* get() const
+{
+return valid ? &data : nullptr;
+}
+
+// Assign data explicitly.
+void set(const type_t in)
+{
+data = in;
+valid = true;
+}
+
+// Mark contents as invalid.
+void invalidate()
+{
+valid = false;
+}
+
+// Returns true if this type contains valid data.
+bool isValid() const
+{
+return valid;
+}
+
+// Assignment operator.
+empirical_type& operator = (const type_t in)
+{
+set(in);
+return *this;
+}
+
+// Dereference operator returns contents.
+// Warning: Will assert if not valid so use only when you know data is valid.
+const type_t& operator * () const
+{
+assert(valid);
+return data;
+}
+
+  protected:
+bool valid;
+type_t data;
+};
+
+} // namespace {}
+
+// The ScriptDetails class collects data associated with a single script instance.
+struct RenderScriptRuntime::ScriptDetails
+{
+~ScriptDetails() {};
+
+enum ScriptType
+{
+eScript,
+eScriptC
+};
+
+// The derived type of the script.
+empirical_type type;
+// The name of the original source file.
+empirical_type resName;
+// Path to script .so file on the device.
+empirical_type scriptDyLib;
+// Directory where kernel objects are cached on device.
+empirical_type cacheDir;
+// Pointer to the context which owns this script.
+empirical_type context;
+// Pointer to the script object itself.
+empirical_type script;
+};
+
+// This AllocationDetails class collects data associated with a single
+// allocation instance.
+struct RenderScriptRuntime::AllocationDetails
+{
+~AllocationDetails () {};
+
+enum DataType
+{
+eInt,
+};
+
+enum Dimension
+{
+e1d,
+e2d,
+e3d,
+eCubeMap,
+};
+
+empirical_type type;
+empirical_type dimension;
+empirical_type address;
+empirical_type dataPtr;
+empirical_type context;
+};
+
 //--
 // Static Functions
 //--
@@ -484,6 +604,10 @@
 if (log)
 log->Printf ("RenderScriptRuntime::CaptureAllocationInit1 - 0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 " .",
 rs_context_u64, rs_alloc_u64, rs_forceZero_u64);
+
+AllocationDetails* alloc = LookUpAllocation(rs_alloc_u64, true);
+if (alloc)
+alloc->context = rs_context_u64;
 }
 
 void 
@@ -541,14 +665,15 @@
 StreamString strm;
 strm.Printf("librs.%s.so", resname.c_str());
 
-ScriptDetails script;
-script.cachedir = cachedir;
-script.resname = resname;
-script.scriptDyLib.assign(strm.GetData());
-script.script = (addr_t) rs_script_u64;
-script.context = (addr_t) rs_context_u64;
-
-m_scripts.push_back(script);
+ScriptDetails* script = LookUpScript(rs_script_u64, true);
+if (script)
+{
+script->type = ScriptDetails::eScriptC;
+script->cacheDir = cachedir;
+script->resName = resname;
+script->scriptDyLib = strm.GetData();
+script->context = addr_t(rs_c

[Lldb-commits] [lldb] r248149 - Groundwork for better tracking of renderscript allocations and scripts

2015-09-21 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Mon Sep 21 05:53:18 2015
New Revision: 248149

URL: http://llvm.org/viewvc/llvm-project?rev=248149&view=rev
Log:
Groundwork for better tracking of renderscript allocations and scripts

This patch adds some of the groundwork required for tracking the lifetime of 
scripts and allocations and collecting data associated with them during 
execution.
Committed on behalf of Aidan Dodds.

Authored by: ADodds
Reviewed by: clayborg, jingham
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D12936

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=248149&r1=248148&r2=248149&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Mon Sep 21 05:53:18 2015
@@ -32,6 +32,126 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_renderscript;
 
+namespace {
+
+// The empirical_type adds a basic level of validation to arbitrary data
+// allowing us to track if data has been discovered and stored or not.
+// An empirical_type will be marked as valid only if it has been explicitly 
assigned to.
+template 
+class empirical_type
+{
+  public:
+// Ctor. Contents is invalid when constructed.
+empirical_type()
+: valid(false)
+{}
+
+// Return true and copy contents to out if valid, else return false.
+bool get(type_t& out) const
+{
+if (valid)
+out = data;
+return valid;
+}
+
+// Return a pointer to the contents or nullptr if it was not valid.
+const type_t* get() const
+{
+return valid ? &data : nullptr;
+}
+
+// Assign data explicitly.
+void set(const type_t in)
+{
+data = in;
+valid = true;
+}
+
+// Mark contents as invalid.
+void invalidate()
+{
+valid = false;
+}
+
+// Returns true if this type contains valid data.
+bool isValid() const
+{
+return valid;
+}
+
+// Assignment operator.
+empirical_type& operator = (const type_t in)
+{
+set(in);
+return *this;
+}
+
+// Dereference operator returns contents.
+// Warning: Will assert if not valid so use only when you know data is 
valid.
+const type_t& operator * () const
+{
+assert(valid);
+return data;
+}
+
+  protected:
+bool valid;
+type_t data;
+};
+
+} // namespace {}
+
+// The ScriptDetails class collects data associated with a single script 
instance.
+struct RenderScriptRuntime::ScriptDetails
+{
+~ScriptDetails() {};
+
+enum ScriptType
+{
+eScript,
+eScriptC
+};
+
+// The derived type of the script.
+empirical_type type;
+// The name of the original source file.
+empirical_type resName;
+// Path to script .so file on the device.
+empirical_type scriptDyLib;
+// Directory where kernel objects are cached on device.
+empirical_type cacheDir;
+// Pointer to the context which owns this script.
+empirical_type context;
+// Pointer to the script object itself.
+empirical_type script;
+};
+
+// This AllocationDetails class collects data associated with a single
+// allocation instance.
+struct RenderScriptRuntime::AllocationDetails
+{
+~AllocationDetails () {};
+
+enum DataType
+{
+eInt,
+};
+
+enum Dimension
+{
+e1d,
+e2d,
+e3d,
+eCubeMap,
+};
+
+empirical_type type;
+empirical_type dimension;
+empirical_type address;
+empirical_type dataPtr;
+empirical_type context;
+};
+
 //--
 // Static Functions
 //--
@@ -484,6 +604,10 @@ RenderScriptRuntime::CaptureAllocationIn
 if (log)
 log->Printf ("RenderScriptRuntime::CaptureAllocationInit1 - 0x%" 
PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 " .",
 rs_context_u64, rs_alloc_u64, rs_forceZero_u64);
+
+AllocationDetails* alloc = LookUpAllocation(rs_alloc_u64, true);
+if (alloc)
+alloc->context = rs_context_u64;
 }
 
 void 
@@ -541,14 +665,15 @@ RenderScriptRuntime::CaptureScriptInit1(
 StreamString strm;
 strm.Printf("librs.%s.so", resname.c_str());
 
-ScriptDetails script;
-script.cachedir = cachedir

[Lldb-commits] [lldb] r248274 - RenderScript lookup bug fix

2015-09-22 Thread Ewan Crawford via lldb-commits
Author: ewancrawford
Date: Tue Sep 22 08:36:35 2015
New Revision: 248274

URL: http://llvm.org/viewvc/llvm-project?rev=248274&view=rev
Log:
RenderScript lookup bug fix

After the std::move operation the unique pointer is null. 
So this statement always returns a null pointer. 

Also remove unnecessary call to Module::ParseAllDebugSymbols(), 
which spews errors due to how it incorrectly tries to parse DWARF DIE types.

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=248274&r1=248273&r2=248274&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Tue Sep 22 08:36:35 2015
@@ -1225,7 +1225,7 @@ RenderScriptRuntime::LookUpScript(addr_t
 std::unique_ptr s(new ScriptDetails);
 s->script = address;
 m_scripts.push_back(std::move(s));
-return s.get();
+return m_scripts.back().get();
 }
 return nullptr;
 }
@@ -1244,7 +1244,7 @@ RenderScriptRuntime::LookUpAllocation(ad
 std::unique_ptr a(new AllocationDetails);
 a->address = address;
 m_allocations.push_back(std::move(a));
-return a.get();
+return m_allocations.back().get();
 }
 return nullptr;
 }
@@ -1254,7 +1254,6 @@ RSModuleDescriptor::Dump(Stream &strm) c
 {
 strm.Indent();
 m_module->GetFileSpec().Dump(&strm);
-m_module->ParseAllDebugSymbols();
 if(m_module->GetNumCompileUnits())
 {
 strm.Indent("Debug info loaded.");


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D13247: RenderScript command for printing allocation information

2015-09-29 Thread Ewan Crawford via lldb-commits
EwanCrawford created this revision.
EwanCrawford added reviewers: jingham, clayborg.
EwanCrawford added subscribers: lldb-commits, domipheus, ADodds, dean.
EwanCrawford set the repository for this revision to rL LLVM.
Herald added subscribers: srhines, danalbert, tberghammer.

This patch adds a new command 'language renderscript allocation list' for 
printing the details of all loaded RS allocations.

In order to work out this information lldb JITs the runtime for the data it 
wants. 
This has a penalty of a couple seconds latency, so is only done once for each 
allocation and the results cached. 

If the user later wants to recalculate this information however, they can force 
lldb to do so with the --refresh flag.

Repository:
  rL LLVM

http://reviews.llvm.org/D13247

Files:
  RenderScriptRuntime.cpp
  RenderScriptRuntime.h

Index: RenderScriptRuntime.h
===
--- RenderScriptRuntime.h
+++ RenderScriptRuntime.h
@@ -202,6 +202,8 @@
 
 void DumpKernels(Stream &strm) const;
 
+void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
+
 void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error, lldb::TargetSP target);
 
 void SetBreakAllKernels(bool do_break, lldb::TargetSP target);
@@ -220,6 +222,9 @@
 
   protected:
 
+struct ScriptDetails;
+struct AllocationDetails;
+
 void InitSearchFilter(lldb::TargetSP target)
 {
 if (!m_filtersp)
@@ -230,6 +235,10 @@
 
 void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
 
+bool RefreshAllocation(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+bool EvalRSExpression(const char* expression, StackFrame* frame_ptr, uint64_t* result);
+
 lldb::BreakpointSP CreateKernelBreakpoint(const ConstString& name);
 
 void BreakOnModuleKernels(const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
@@ -256,9 +265,6 @@
 
 typedef std::shared_ptr RuntimeHookSP;
 
-struct ScriptDetails;
-struct AllocationDetails;
-
 lldb::ModuleSP m_libRS;
 lldb::ModuleSP m_libRSDriver;
 lldb::ModuleSP m_libRSCpuRef;
@@ -292,6 +298,18 @@
 void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
 void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
 
+//
+// Helper functions for jitting the runtime
+//
+bool JITDataPointer(AllocationDetails* allocation, StackFrame* frame_ptr,
+unsigned int x = 0, unsigned int y = 0, unsigned int z = 0);
+
+bool JITTypePointer(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+bool JITTypePacked(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+bool JITElementPacked(AllocationDetails* allocation, StackFrame* frame_ptr);
+
 // Search for a script detail object using a target address.
 // If a script does not currently exist this function will return nullptr.
 // If 'create' is true and there is no previous script with this address,
Index: RenderScriptRuntime.cpp
===
--- RenderScriptRuntime.cpp
+++ RenderScriptRuntime.cpp
@@ -25,7 +25,7 @@
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Target/RegisterContext.h"
-
+#include "lldb/Expression/UserExpression.h"
 #include "lldb/Symbol/VariableList.h"
 
 using namespace lldb;
@@ -130,28 +130,118 @@
 // allocation instance.
 struct RenderScriptRuntime::AllocationDetails
 {
-~AllocationDetails () {};
+   // Taken from rsDefines.h
+   enum DataKind
+   {
+   RS_KIND_USER,
+   RS_KIND_PIXEL_L = 7,
+   RS_KIND_PIXEL_A,
+   RS_KIND_PIXEL_LA,
+   RS_KIND_PIXEL_RGB,
+   RS_KIND_PIXEL_RGBA,
+   RS_KIND_PIXEL_DEPTH,
+   RS_KIND_PIXEL_YUV,
+   RS_KIND_INVALID = 100
+   };
 
-enum DataType
-{
-eInt,
+   // Taken from rsDefines.h
+   enum DataType
+   {
+   RS_TYPE_NONE = 0,
+   RS_TYPE_FLOAT_16,
+   RS_TYPE_FLOAT_32,
+   RS_TYPE_FLOAT_64,
+   RS_TYPE_SIGNED_8,
+   RS_TYPE_SIGNED_16,
+   RS_TYPE_SIGNED_32,
+   RS_TYPE_SIGNED_64,
+   RS_TYPE_UNSIGNED_8,
+   RS_TYPE_UNSIGNED_16,
+   RS_TYPE_UNSIGNED_32,
+   RS_TYPE_UNSIGNED_64,
+   RS_TYPE_BOOLEAN
 };
 
-enum Dimension
+struct Dimension
 {
-e1d,
-e2d,
-e3d,
-eCubeMap,
+uint32_t dim_1;
+uint32_t dim_2;
+uint32_t dim_3;
+uint32_t cubeMap;
+
+Dimension()
+{
+ dim_1 = 0;
+ dim_2 = 0;
+ dim_3 = 0;
+ cubeMap = 0;
+}
 };
 
-empirical_type type;
-empirical_type dimension;
-empirical_type address;
-empirical_type dataPtr;
-empirical_type context;
+// Monotonically increasing from 1
+static unsigned int ID;
+
+// Maps Allocatio