[Lldb-commits] [lldb] r301389 - Initial implementation of SB APIs for Tracing support.

2017-04-26 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Apr 26 03:48:50 2017
New Revision: 301389

URL: http://llvm.org/viewvc/llvm-project?rev=301389&view=rev
Log:
Initial implementation of SB APIs for Tracing support.

Summary:
This patch introduces new SB APIs for tracing support
inside LLDB. The idea is to gather trace data from
LLDB and provide it through this APIs to external
tools integrating with LLDB. These tools will be
responsible for interpreting and presenting the
trace data to their users.

The patch implements the following new SB APIs ->
-> StartTrace - starts tracing with given parameters
-> StopTrace - stops tracing.
-> GetTraceData - read the trace data .
-> GetMetaData - read the meta data assosciated with the trace.
-> GetTraceConfig - read the trace configuration

Tracing is associated with a user_id that is returned
by the StartTrace API and this id needs to be used
for accessing the trace data and also Stopping
the trace. The user_id itself may map to tracing
the complete process or just an individual thread.
The APIs require an additional thread parameter
when the user of these APIs wishes to perform
thread specific manipulations on the tracing instances.
The patch also includes the corresponding
python wrappers for the C++ based APIs.

Reviewers: k8stone, lldb-commits, clayborg

Reviewed By: clayborg

Subscribers: jingham, mgorny

Differential Revision: https://reviews.llvm.org/D29581

Added:
lldb/trunk/include/lldb/API/SBTrace.h
lldb/trunk/include/lldb/API/SBTraceOptions.h
lldb/trunk/include/lldb/Core/StructuredDataImpl.h
lldb/trunk/include/lldb/Core/TraceOptions.h
lldb/trunk/scripts/interface/SBTrace.i
lldb/trunk/scripts/interface/SBTraceOptions.i
lldb/trunk/source/API/SBTrace.cpp
lldb/trunk/source/API/SBTraceOptions.cpp
Modified:
lldb/trunk/include/lldb/API/LLDB.h
lldb/trunk/include/lldb/API/SBDefines.h
lldb/trunk/include/lldb/API/SBError.h
lldb/trunk/include/lldb/API/SBProcess.h
lldb/trunk/include/lldb/API/SBStructuredData.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/scripts/interface/SBProcess.i
lldb/trunk/scripts/interface/SBStructuredData.i
lldb/trunk/scripts/lldb.swig
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/API/SBStructuredData.cpp

Modified: lldb/trunk/include/lldb/API/LLDB.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/LLDB.h?rev=301389&r1=301388&r2=301389&view=diff
==
--- lldb/trunk/include/lldb/API/LLDB.h (original)
+++ lldb/trunk/include/lldb/API/LLDB.h Wed Apr 26 03:48:50 2017
@@ -63,6 +63,8 @@
 #include "lldb/API/SBThread.h"
 #include "lldb/API/SBThreadCollection.h"
 #include "lldb/API/SBThreadPlan.h"
+#include "lldb/API/SBTrace.h"
+#include "lldb/API/SBTraceOptions.h"
 #include "lldb/API/SBType.h"
 #include "lldb/API/SBTypeCategory.h"
 #include "lldb/API/SBTypeEnumMember.h"

Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=301389&r1=301388&r2=301389&view=diff
==
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Wed Apr 26 03:48:50 2017
@@ -79,6 +79,8 @@ class LLDB_API SBTarget;
 class LLDB_API SBThread;
 class LLDB_API SBThreadCollection;
 class LLDB_API SBThreadPlan;
+class LLDB_API SBTrace;
+class LLDB_API SBTraceOptions;
 class LLDB_API SBType;
 class LLDB_API SBTypeCategory;
 class LLDB_API SBTypeEnumMember;

Modified: lldb/trunk/include/lldb/API/SBError.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=301389&r1=301388&r2=301389&view=diff
==
--- lldb/trunk/include/lldb/API/SBError.h (original)
+++ lldb/trunk/include/lldb/API/SBError.h Wed Apr 26 03:48:50 2017
@@ -61,6 +61,7 @@ protected:
   friend class SBProcess;
   friend class SBStructuredData;
   friend class SBThread;
+  friend class SBTrace;
   friend class SBTarget;
   friend class SBValue;
   friend class SBWatchpoint;

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=301389&r1=301388&r2=301389&view=diff
==
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Wed Apr 26 03:48:50 2017
@@ -234,6 +234,33 @@ public:
 
   bool GetDescription(lldb::SBStream &description);
 
+  //--
+  /// Start Tracing with the given SBTraceOptions.
+  ///
+  /// @param[in] options
+  /// Class containing trace options like trace buffer 

[Lldb-commits] [lldb] r303972 - Implementation of remote packets for Trace data.

2017-05-26 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Fri May 26 06:46:27 2017
New Revision: 303972

URL: http://llvm.org/viewvc/llvm-project?rev=303972&view=rev
Log:
Implementation of remote packets for Trace data.

Summary:
The changes consist of new packets for trace manipulation and
trace collection. The new packets are also documented. The packets
are capable of providing custom trace specific parameters to start
tracing and also retrieve such configuration from the server.

Reviewers: clayborg, lldb-commits, tberghammer, labath, zturner

Reviewed By: clayborg, labath

Subscribers: krytarowski, lldb-commits

Differential Revision: https://reviews.llvm.org/D32585

Modified:
lldb/trunk/docs/lldb-gdb-remote.txt
lldb/trunk/include/lldb/API/SBTrace.h
lldb/trunk/include/lldb/Core/TraceOptions.h
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/Utility/StringExtractor.h
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/API/SBTrace.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/source/Utility/StringExtractor.cpp
lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
lldb/trunk/source/Utility/StringExtractorGDBRemote.h
lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Modified: lldb/trunk/docs/lldb-gdb-remote.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=303972&r1=303971&r2=303972&view=diff
==
--- lldb/trunk/docs/lldb-gdb-remote.txt (original)
+++ lldb/trunk/docs/lldb-gdb-remote.txt Fri May 26 06:46:27 2017
@@ -209,6 +209,163 @@ send packet: QListThreadsInStopReply
 read packet: OK
 
 //--
+// jTraceStart:
+//
+// BRIEF
+//  Packet for starting trace of type lldb::TraceType. The following
+//  parameters should be appended to the packet formatted as a JSON
+//  dictionary, where the schematic for the JSON dictionary in terms of
+//  the recognized Keys is given below in the table.
+//  Different tracing types could require different custom parameters.
+//  Such custom tracing parameters if needed should be collectively
+//  specified in a JSON dictionary and the dictionary can be appended
+//  to this packet (as Value corresponding to "params"). Since sending
+//  JSON data over gdb-remote protocol has certain limitations, binary
+//  escaping convention should be used.
+//
+//  Following is the list of parameters -
+//
+//  Key Value (Integer) (O)Optional/
+//  (except params which should be a(M)Mandatory
+//  JSON dictionary)
+//  ==  
+//
+//  typeThe type of trace to start (see  M
+//  lldb-enumerations for TraceType)
+//
+//  buffersize  The size of the buffer to allocate   M
+//  for trace gathering.
+//
+//  threadidThe id of the thread to start tracingO
+//  on.
+//
+//  metabuffersize  The size of buffer to hold meta data O
+//  used for decoding the trace data.
+//
+//  params  Any parameters that are specific to  O
+//  certain trace technologies should be
+//  collectively specified as a JSON
+//  dictionary
+//  ==  
+//
+//  Each tracing instance is identified by a trace id which is returned
+//  as the reply to this packet. In case the tracing failed to begin an
+//  error code is returned instead.
+//--
+
+send packet: jTraceStart:{"type":,"buffersize":}]
+read packet: /E
+
+//--
+// jTraceStop:
+//
+// BRIEF
+//  Stop tracing instance with trace id , of course trace
+//  needs to be started before. The following parameters should be
+//  formatted as a JSON dictionary to the packet. Since sending
+//  JSON data over gdb-remote protocol has certain limitations, binary
+//  escaping convention should be used.
+//
+//  Following is the list of parameters -
+//
+//  Key Value (Integer) (O)Optional/
+//  (M)Mandatory
+//  ==  =

[Lldb-commits] [lldb] r303991 - Fixing Memory Leak

2017-05-26 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Fri May 26 09:26:14 2017
New Revision: 303991

URL: http://llvm.org/viewvc/llvm-project?rev=303991&view=rev
Log:
Fixing Memory Leak

Modified:

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp?rev=303991&r1=303990&r2=303991&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
 Fri May 26 09:26:14 2017
@@ -1300,13 +1300,13 @@ GDBRemoteCommunicationServerLLGS::Handle
   json_dict->GetValueForKeyAsInteger("threadid", tid);
 
   // Allocate the response buffer.
-  uint8_t *buffer = new (std::nothrow) uint8_t[byte_count];
-  if (buffer == nullptr)
+  std::unique_ptr buffer (new (std::nothrow) uint8_t[byte_count]);
+  if (!buffer)
 return SendErrorResponse(0x78);
 
   StreamGDBRemote response;
   Status error;
-  llvm::MutableArrayRef buf(buffer, byte_count);
+  llvm::MutableArrayRef buf(buffer.get(), byte_count);
 
   if (tracetype == BufferData)
 error = m_debugged_process_sp->GetData(uid, tid, buf, offset);


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


[Lldb-commits] [lldb] r306516 - Implementation of Intel(R) Processor Trace support for Linux

2017-06-28 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Jun 28 00:58:31 2017
New Revision: 306516

URL: http://llvm.org/viewvc/llvm-project?rev=306516&view=rev
Log:
Implementation of Intel(R) Processor Trace support for Linux

Summary:
This patch implements support for Intel(R) Processor Trace
in lldb server. The changes have support for
starting/stopping and reading the trace data. The code
is only available on Linux versions where the perf
attributes for aux buffers are available.

The patch also consists of Unit tests for testing the
core buffer reading function.

Reviewers: lldb-commits, labath, clayborg, zturner, tberghammer

Reviewed By: labath, clayborg

Subscribers: mgorny

Differential Revision: https://reviews.llvm.org/D33674

Added:
lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.cpp
lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.h
lldb/trunk/unittests/Process/Linux/
lldb/trunk/unittests/Process/Linux/CMakeLists.txt
lldb/trunk/unittests/Process/Linux/ProcessorTraceTest.cpp
Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/include/lldb/Host/linux/Support.h
lldb/trunk/source/Host/linux/Support.cpp
lldb/trunk/source/Plugins/Process/Linux/CMakeLists.txt
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/trunk/unittests/Process/CMakeLists.txt

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=306516&r1=306515&r2=306516&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Wed Jun 28 
00:58:31 2017
@@ -333,7 +333,7 @@ public:
   //--
   /// StopTracing API as the name suggests stops a tracing instance.
   ///
-  /// @param[in] uid
+  /// @param[in] traceid
   /// The user id of the trace intended to be stopped. Now a
   /// user_id may map to multiple threads in which case this API
   /// could be used to stop the tracing for a specific thread by
@@ -346,7 +346,7 @@ public:
   /// @return
   /// Status indicating what went wrong.
   //--
-  virtual Status StopTrace(lldb::user_id_t uid,
+  virtual Status StopTrace(lldb::user_id_t traceid,
lldb::tid_t thread = LLDB_INVALID_THREAD_ID) {
 return Status("Not implemented");
   }
@@ -355,8 +355,8 @@ public:
   /// This API provides the trace data collected in the form of raw
   /// data.
   ///
-  /// @param[in] uid thread
-  /// The uid and thread provide the context for the trace
+  /// @param[in] traceid thread
+  /// The traceid and thread provide the context for the trace
   /// instance.
   ///
   /// @param[in] buffer
@@ -372,7 +372,7 @@ public:
   /// @return
   /// The size of the data actually read.
   //--
-  virtual Status GetData(lldb::user_id_t uid, lldb::tid_t thread,
+  virtual Status GetData(lldb::user_id_t traceid, lldb::tid_t thread,
  llvm::MutableArrayRef &buffer,
  size_t offset = 0) {
 return Status("Not implemented");
@@ -382,7 +382,7 @@ public:
   /// Similar API as above except it aims to provide any extra data
   /// useful for decoding the actual trace data.
   //--
-  virtual Status GetMetaData(lldb::user_id_t uid, lldb::tid_t thread,
+  virtual Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread,
  llvm::MutableArrayRef &buffer,
  size_t offset = 0) {
 return Status("Not implemented");
@@ -391,7 +391,7 @@ public:
   //--
   /// API to query the TraceOptions for a given user id
   ///
-  /// @param[in] uid
+  /// @param[in] traceid
   /// The user id of the tracing instance.
   ///
   /// @param[in] config
@@ -405,7 +405,7 @@ public:
   /// @param[out] config
   /// The actual configuration being used for tracing.
   //--
-  virtual Status GetTraceConfig(lldb::user_id_t uid, TraceOptions &config) {
+  virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) 
{
 return Status("Not implemented");
   }
 

Modified: lldb/trunk/include/lldb/Host/linux/Support.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/linux/Support.h?rev=306516&r1=306515&r2=306516&view=diff

[Lldb-commits] [lldb] r306520 - Linux unit tests should only run on

2017-06-28 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Jun 28 02:01:17 2017
New Revision: 306520

URL: http://llvm.org/viewvc/llvm-project?rev=306520&view=rev
Log:
Linux unit tests should only run on
Linux based systems.

Modified:
lldb/trunk/unittests/Process/CMakeLists.txt

Modified: lldb/trunk/unittests/Process/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/CMakeLists.txt?rev=306520&r1=306519&r2=306520&view=diff
==
--- lldb/trunk/unittests/Process/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Process/CMakeLists.txt Wed Jun 28 02:01:17 2017
@@ -1,3 +1,5 @@
 add_subdirectory(gdb-remote)
-add_subdirectory(Linux)
+if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
+  add_subdirectory(Linux)
+endif()
 add_subdirectory(minidump)


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


[Lldb-commits] [lldb] r307030 - Fixing warnings for unused variables and copy ellision

2017-07-03 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Mon Jul  3 08:07:36 2017
New Revision: 307030

URL: http://llvm.org/viewvc/llvm-project?rev=307030&view=rev
Log:
Fixing warnings for unused variables and copy ellision

Summary:
The std::move was preventing copy ellision when compiled with
clang, the patch fixes the warning along with rearranging code
to remove unused variables warnings on Linux machines with
older perf_event interface.

Reviewers: labath, ted

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D34946

Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.cpp?rev=307030&r1=307029&r2=307030&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessorTrace.cpp Mon Jul  3 
08:07:36 2017
@@ -46,13 +46,11 @@ Status ProcessorTraceMonitor::GetTraceCo
 
 Status ProcessorTraceMonitor::StartTrace(lldb::pid_t pid, lldb::tid_t tid,
  const TraceOptions &config) {
-  Status error;
-  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
-  LLDB_LOG(log, "{0}", config.getThreadID());
-
 #ifndef PERF_ATTR_SIZE_VER5
   llvm_unreachable("perf event not supported");
 #else
+  Status error;
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
 
   LLDB_LOG(log, "called thread id {0}", tid);
   uint64_t page_size = getpagesize();
@@ -66,7 +64,6 @@ Status ProcessorTraceMonitor::StartTrace
 
   numpages = static_cast(
   llvm::PowerOf2Floor((metabufsize + page_size - 1) / page_size));
-  numpages = std::max(0ul, numpages);
   metabufsize = page_size * numpages;
 
   perf_event_attr attr;
@@ -117,7 +114,7 @@ Status ProcessorTraceMonitor::StartTrace
 return error;
   }
 
-  m_fd = std::move(std::unique_ptr(new int(fd), 
file_close()));
+  m_fd = std::unique_ptr(new int(fd), file_close());
 
   errno = 0;
   auto base =
@@ -129,9 +126,9 @@ Status ProcessorTraceMonitor::StartTrace
 return error;
   }
 
-  m_mmap_meta = std::move(std::unique_ptr(
+  m_mmap_meta = std::unique_ptr(
   reinterpret_cast(base),
-  munmap_delete(metabufsize + page_size)));
+  munmap_delete(metabufsize + page_size));
 
   m_mmap_meta->aux_offset = m_mmap_meta->data_offset + m_mmap_meta->data_size;
   m_mmap_meta->aux_size = bufsize;
@@ -145,10 +142,10 @@ Status ProcessorTraceMonitor::StartTrace
 error.SetErrorString("Trace buffer allocation failed");
 return error;
   }
-  m_mmap_aux = std::move(std::unique_ptr(
-  reinterpret_cast(mmap_aux), munmap_delete(bufsize)));
-#endif
+  m_mmap_aux = std::unique_ptr(
+  reinterpret_cast(mmap_aux), munmap_delete(bufsize));
   return error;
+#endif
 }
 
 llvm::MutableArrayRef ProcessorTraceMonitor::GetDataBuffer() {
@@ -251,14 +248,14 @@ ProcessorTraceMonitor::Create(lldb::pid_
   Status error;
   if (tid == LLDB_INVALID_THREAD_ID) {
 error.SetErrorString("thread not specified");
-return std::move(error.ToError());
+return error.ToError();
   }
 
   ProcessorTraceMonitorUP pt_monitor_up(new ProcessorTraceMonitor);
 
   error = pt_monitor_up->StartTrace(pid, tid, config);
   if (error.Fail())
-return std::move(error.ToError());
+return error.ToError();
 
   pt_monitor_up->SetThreadID(tid);
 
@@ -274,13 +271,11 @@ ProcessorTraceMonitor::Create(lldb::pid_
 Status
 ProcessorTraceMonitor::ReadPerfTraceAux(llvm::MutableArrayRef &buffer,
 size_t offset) {
-
-  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
-  Status error;
-
 #ifndef PERF_ATTR_SIZE_VER5
   llvm_unreachable("perf event not supported");
 #else
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
+  Status error;
   uint64_t head = m_mmap_meta->aux_head;
 
   LLDB_LOG(log, "Aux size -{0} , Head - {1}", m_mmap_meta->aux_size, head);
@@ -306,12 +301,12 @@ ProcessorTraceMonitor::ReadPerfTraceAux(
 Status
 ProcessorTraceMonitor::ReadPerfTraceData(llvm::MutableArrayRef 
&buffer,
  size_t offset) {
-  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
-  uint64_t bytes_remaining = buffer.size();
-  Status error;
 #ifndef PERF_ATTR_SIZE_VER5
   llvm_unreachable("perf event not supported");
 #else
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
+  uint64_t bytes_remaining = buffer.size();
+  Status error;
 
   uint64_t head = m_mmap_meta->data_head;
 


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


[Lldb-commits] [lldb] r307768 - Adding Support for Error Strings in Remote Packets

2017-07-12 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Jul 12 04:15:34 2017
New Revision: 307768

URL: http://llvm.org/viewvc/llvm-project?rev=307768&view=rev
Log:
Adding Support for Error Strings in Remote Packets

Summary:
This patch adds support for sending strings along with
error codes in the reply packets. The implementation is
based on the feedback recieved in the lldb-dev mailing
list. The patch also adds an extra packet for the client
to query if the server has the capability to provide
strings along with error replys.

Reviewers: labath, jingham, sas, lldb-commits, clayborg

Reviewed By: labath, clayborg

Differential Revision: https://reviews.llvm.org/D34945

Modified:
lldb/trunk/docs/lldb-gdb-remote.txt

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
lldb/trunk/source/Utility/StringExtractorGDBRemote.h

Modified: lldb/trunk/docs/lldb-gdb-remote.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=307768&r1=307767&r2=307768&view=diff
==
--- lldb/trunk/docs/lldb-gdb-remote.txt (original)
+++ lldb/trunk/docs/lldb-gdb-remote.txt Wed Jul 12 04:15:34 2017
@@ -126,6 +126,32 @@ read packet: $OK#00
 This packet can be sent one or more times _prior_ to sending a "A" packet.
 
 //--
+// "QEnableErrorStrings"
+//
+// BRIEF
+//  This packet enables reporting of Error strings in remote packet
+//  replies from the server to client. If the server supports this
+//  feature, it should send an OK response. The client can expect the
+//  following error replies if this feature is enabled in the server ->
+//
+//  EXX;A
+//
+//  where A will be a hex encoded ASCII string.
+//  XX is hex encoded byte number.
+//
+//  It must be noted that even if the client has enabled reporting
+//  strings in error replies, it must not expect error strings to all
+//  error replies.
+// 
+// PRIORITY TO IMPLEMENT
+//  Low. Only needed if the remote target wants to provide strings that
+//  are human readable along with an error code.
+//--
+
+send packet: $QErrorStringInPacketSupported
+read packet: $OK#00
+
+//--
 // "QSetSTDIN:"
 // "QSetSTDOUT:"
 // "QSetSTDERR:"
@@ -250,11 +276,12 @@ read packet: OK
 //
 //  Each tracing instance is identified by a trace id which is returned
 //  as the reply to this packet. In case the tracing failed to begin an
-//  error code is returned instead.
+//  error code along with a hex encoded ASCII message is returned
+//  instead.
 //--
 
 send packet: jTraceStart:{"type":,"buffersize":}]
-read packet: /E
+read packet: /E;A
 
 //--
 // jTraceStop:
@@ -283,12 +310,12 @@ read packet: /E
 //  to stop tracing on that thread.
 //  ==  
 //
-//  An OK response is sent in case of success else an error code is
-//  returned.
+//  An OK response is sent in case of success else an error code along
+//  with a hex encoded ASCII message is returned.
 //--
 
 send packet: jTraceStop:{"traceid":}]
-read packet: /E
+read packet: /E;A
 
 //--
 // jTraceBufferRead:
@@ -317,11 +344,11 @@ read packet: /E
 //  ==  
 //
 //  The trace data is sent as raw binary data if the read was successful
-//  else an error code is sent.
+//  else an error code along with a hex encoded ASCII message is sent.
 //--
 
 send packet: jTraceBufferRead:{"traceid":,"offset":,"buffersize":}]
-read packet: /E
+read packet: /E;A
 
 //--
 // jTraceMetaRead:
@@ -359,11 +386,11 @@ read packet: /E was not found, an
-//  error code is returned.
+//  error code along with a hex encoded ASCII message is returned.
 //--
 
 send packet: jTraceConfigRead:{"traceid":}
-read packet: 
{"conf1":,"conf2":,"params":{"paramName":para

[Lldb-commits] [lldb] r307773 - Fixing Android builder

2017-07-12 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Jul 12 04:54:17 2017
New Revision: 307773

URL: http://llvm.org/viewvc/llvm-project?rev=307773&view=rev
Log:
Fixing Android builder

Modified:
lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp

Modified: lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp?rev=307773&r1=307772&r2=307773&view=diff
==
--- lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp (original)
+++ lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp Wed Jul 12 04:54:17 
2017
@@ -469,12 +469,12 @@ lldb_private::Status StringExtractorGDBR
 uint8_t errc = GetHexU8(255);
 error.SetError(errc, lldb::eErrorTypeGeneric);
 
-std::string error_messg("Error ");
-error_messg += std::to_string(errc);
-if (GetChar() == ';')
+error.SetErrorStringWithFormat("Error %u", errc);
+std::string error_messg;
+if (GetChar() == ';') {
   GetHexByteString(error_messg);
-
-error.SetErrorString(error_messg);
+  error.SetErrorString(error_messg);
+}
   }
   return error;
 }


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


[Lldb-commits] [lldb] r285885 - Test for YMMRegisters.

2016-11-03 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Thu Nov  3 03:35:55 2016
New Revision: 285885

URL: http://llvm.org/viewvc/llvm-project?rev=285885&view=rev
Log:
Test for YMMRegisters.

Summary:
This patch contains test for reading YMM Registers. The test basically
contains an inferior that loads the ymm registers with a bit pattern
and the python test executes register read to check if the bit pattern
is correctly written in the registers. This test is repeated twice for
each register with a different pattern for better sanity.

Reviewers: tberghammer, zturner, clayborg

Subscribers: tberghammer, danalbert, srhines

Differential Revision: https://reviews.llvm.org/D26242

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/Makefile?rev=285885&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/Makefile
 Thu Nov  3 03:35:55 2016
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+CFLAGS_EXTRAS ?= -g -O1
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py?rev=285885&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
 Thu Nov  3 03:35:55 2016
@@ -0,0 +1,75 @@
+"""
+Test that we correctly read the YMM registers.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestYMMRegister(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfFreeBSD
+@skipIfiOSSimulator
+@skipIfTargetAndroid()
+@skipIf(archs=no_match(['i386', 'x86_64']))
+def test(self):
+self.build()
+self.setTearDownCleanup()
+
+exe = os.path.join(os.getcwd(), "a.out")
+target = self.dbg.CreateTarget(exe)
+
+self.assertTrue(target, VALID_TARGET)
+
+byte_pattern1 = 0x80
+byte_pattern2 = 0xFF
+
+# Launch the process and stop.
+self.expect("run", PROCESS_STOPPED, substrs=['stopped'])
+
+# Check stop reason; Should be either signal SIGTRAP or EXC_BREAKPOINT
+output = self.res.GetOutput()
+matched = False
+substrs = [
+'stop reason = EXC_BREAKPOINT',
+'stop reason = signal SIGTRAP']
+for str1 in substrs:
+matched = output.find(str1) != -1
+with recording(self, False) as sbuf:
+print("%s sub string: %s" % ('Expecting', str1), file=sbuf)
+print("Matched" if matched else "Not Matched", file=sbuf)
+if matched:
+break
+self.assertTrue(matched, STOPPED_DUE_TO_SIGNAL)
+
+if self.getArchitecture() == 'x86_64':
+register_range = 16
+else:
+register_range = 8
+for i in range(register_range):
+self.runCmd("thread step-inst")
+
+register_byte = (byte_pattern1 | i)
+pattern = "ymm" + str(i) + " = " + str('{') + (
+str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) 
+ str('}')
+
+self.expect(
+"register read ymm" + str(i),
+substrs=[pattern])
+
+register_byte = (byte_pattern2 | i)
+pattern = "ymm" + str(i) + " = " + str('{') + (
+str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) 
+ str('}')
+
+self.runCmd("thread step-inst")
+self.expect(
+"register read ymm" + str(i),
+substrs=[pattern])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c?rev=285885&view=auto
==
---

[Lldb-commits] [lldb] r249673 - Testcase and fix for bug 24074

2015-10-08 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Thu Oct  8 04:45:41 2015
New Revision: 249673

URL: http://llvm.org/viewvc/llvm-project?rev=249673&view=rev
Log:
Testcase and fix for bug 24074

Summary:
In bug 24074, the type information is not shown
correctly. This commit includes the following -
-> Changes for displaying correct type based on
current lexical scope for the command "image
lookup -t"

-> The corresponding testcase.

-> This patch was reverted due to segfaults in
FreeBSD and Mac, I fixed the problems for both now.

Reviewers: emaste, granata.enrico, jingham, clayborg

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

Added:
lldb/trunk/include/lldb/Symbol/TypeMap.h
lldb/trunk/source/Symbol/TypeMap.cpp
lldb/trunk/test/lang/c/typedef/
lldb/trunk/test/lang/c/typedef/Makefile
lldb/trunk/test/lang/c/typedef/Testtypedef.py
lldb/trunk/test/lang/c/typedef/main.c
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Symbol/SymbolContext.h
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/include/lldb/Symbol/SymbolVendor.h
lldb/trunk/include/lldb/Symbol/TypeList.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/trunk/source/Symbol/CMakeLists.txt
lldb/trunk/source/Symbol/SymbolContext.cpp
lldb/trunk/source/Symbol/SymbolFile.cpp
lldb/trunk/source/Symbol/SymbolVendor.cpp
lldb/trunk/source/Symbol/TypeList.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=249673&r1=249672&r2=249673&view=diff
==
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Oct  8 04:45:41 2015
@@ -1193,7 +1193,7 @@ private:
 const CompilerDeclContext *parent_decl_ctx,
 bool append, 
 size_t max_matches,
-TypeList& types);
+TypeMap& types);
 
 
 DISALLOW_COPY_AND_ASSIGN (Module);

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=249673&r1=249672&r2=249673&view=diff
==
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Thu Oct  8 04:45:41 2015
@@ -299,6 +299,13 @@ public:
ConstString &language_object_name);
 
 //--
+/// Sorts the types in TypeMap according to SymbolContext
+/// to TypeList
+///
+//--
+void
+   SortTypeList(TypeMap &type_map, TypeList &type_list) const;
+//--
 /// Find a name of the innermost function for the symbol context.
 ///
 /// For instance, if the symbol context contains an inlined block,

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=249673&r1=249672&r2=249673&view=diff
==
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Thu Oct  8 04:45:41 2015
@@ -141,7 +141,7 @@ public:
 virtual uint32_tFindGlobalVariables (const RegularExpression& 
regex, bool append, uint32_t max_matches, VariableList& variables);
 virtual uint32_tFindFunctions (const ConstString &name, const 
CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool 
include_inlines, bool append, SymbolContextList& sc_list);
 virtual uint32_tFindFunctions (const RegularExpression& regex, 
bool include_inlines, bool append, SymbolContextList& sc_list);
-virtual uint32_tFindTypes (const SymbolContext& sc, const 
ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, 
uint32_t max_matches, TypeList& types);
+virtual uint32_tFindTypes (const SymbolContext& sc, const 
ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, 
uint32_t max_matches, TypeMap& types);
 //  virtual uint32_tFindTypes (const SymbolContext& sc, const 
RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 
0;
 virtual TypeList *  GetTypeList ();
 virtual size_t  GetTypes 

[Lldb-commits] [lldb] r251505 - Changes for Bug 17384

2015-10-28 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Oct 28 04:47:29 2015
New Revision: 251505

URL: http://llvm.org/viewvc/llvm-project?rev=251505&view=rev
Log:
Changes for Bug 17384

Summary:
Virtual dynamic shared objects, or vdso files were 
not loaded for Linux OS.In Bug 17384 the call 
stack could not be unwinded from functions
residing in the vdso object.

This commit adds support for loading such files by
reading the Aux vectors since a vdso is invisibily 
mapped to the inferiors address space and the
 actual file is not present in the filesystem. The 
presence of the vdso is detected by inspecting 
the Aux vector for AT_SYSINFO_EHDR tag.

Reviewers: lldb-commits, ovyalov, tberghammer

Subscribers: lldb-commits

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

Modified:

lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py
lldb/trunk/test/python_api/hello_world/TestHelloWorld.py

Modified: 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=251505&r1=251504&r2=251505&view=diff
==
--- 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
Wed Oct 28 04:47:29 2015
@@ -91,7 +91,8 @@ DynamicLoaderPOSIXDYLD::DynamicLoaderPOS
   m_load_offset(LLDB_INVALID_ADDRESS),
   m_entry_point(LLDB_INVALID_ADDRESS),
   m_auxv(),
-  m_dyld_bid(LLDB_INVALID_BREAK_ID)
+  m_dyld_bid(LLDB_INVALID_BREAK_ID),
+  m_vdso_base(LLDB_INVALID_ADDRESS)
 {
 }
 
@@ -126,6 +127,8 @@ DynamicLoaderPOSIXDYLD::DidAttach()
 if (log)
 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " executable 
'%s', load_offset 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : 
LLDB_INVALID_PROCESS_ID, executable_sp ? 
executable_sp->GetFileSpec().GetPath().c_str () : "", 
load_offset);
 
+EvalVdsoStatus();
+
 // if we dont have a load address we cant re-base
 bool rebase_exec = (load_offset == LLDB_INVALID_ADDRESS) ? false : true;
 
@@ -213,6 +216,7 @@ DynamicLoaderPOSIXDYLD::DidLaunch()
 
 executable = GetTargetExecutable();
 load_offset = ComputeLoadOffset();
+EvalVdsoStatus();
 
 if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
 {
@@ -503,7 +507,15 @@ DynamicLoaderPOSIXDYLD::LoadAllCurrentMo
 // that ourselves here.
 ModuleSP executable = GetTargetExecutable();
 m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress();
-
+if (m_vdso_base != LLDB_INVALID_ADDRESS)
+{
+FileSpec file_spec("[vdso]", false);
+ModuleSP module_sp = LoadModuleAtAddress(file_spec, 
LLDB_INVALID_ADDRESS, m_vdso_base, false);
+if (module_sp.get())
+{
+module_list.Append(module_sp);
+}
+}
 for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
 {
 ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, 
I->base_addr, true);
@@ -551,6 +563,16 @@ DynamicLoaderPOSIXDYLD::ComputeLoadOffse
 return m_load_offset;
 }
 
+void
+DynamicLoaderPOSIXDYLD::EvalVdsoStatus()
+{
+AuxVector::iterator I = m_auxv->FindEntry(AuxVector::AT_SYSINFO_EHDR);
+
+if (I != m_auxv->end())
+m_vdso_base = I->value;
+
+}
+
 addr_t
 DynamicLoaderPOSIXDYLD::GetEntryPoint()
 {

Modified: 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h?rev=251505&r1=251504&r2=251505&view=diff
==
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h 
(original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h 
Wed Oct 28 04:47:29 2015
@@ -88,6 +88,10 @@ protected:
 /// Rendezvous breakpoint.
 lldb::break_id_t m_dyld_bid;
 
+/// Contains AT_SYSINFO_EHDR, which means a vDSO has been
+/// mapped to the address space
+lldb::addr_t m_vdso_base;
+
 /// Loaded module list. (link map for each module)
 std::map> 
m_loaded_modules;
 
@@ -159,6 +163,11 @@ protected:
 lldb::addr_t
 GetEntryPoint();
 
+/// Evaluate if Aux vectors contain vDSO information
+/// in case they do, read and assign the address to m_vdso_base
+void
+EvalVdsoStatus();
+
 /// Loads Module from inferior process.
 void
 ResolveExecutableModule(lldb::ModuleSP &module_sp);

Modified: lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py
URL: 
http://llvm.org/viewvc/llvm-project/l

Re: [Lldb-commits] [PATCH] D14118: Changes for Bug 17384

2015-10-28 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 38637.
ravitheja added a comment.

Updates for previous comments.


http://reviews.llvm.org/D14118

Files:
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  test/functionalities/inferior-assert/TestInferiorAssert.py
  test/python_api/hello_world/TestHelloWorld.py

Index: test/python_api/hello_world/TestHelloWorld.py
===
--- test/python_api/hello_world/TestHelloWorld.py
+++ test/python_api/hello_world/TestHelloWorld.py
@@ -73,7 +73,6 @@
 self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
 
 @add_test_categories(['pyapi'])
-@expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly
 @expectedFailureWindows("llvm.org/pr24600")
 def test_with_attach_to_process_with_id_api(self):
 """Create target, spawn a process, and attach to it with process id."""
@@ -102,7 +101,6 @@
'(int)argc=3'])
 
 @add_test_categories(['pyapi'])
-@expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly
 @expectedFailureWindows("llvm.org/pr24600")
 def test_with_attach_to_process_with_name_api(self):
 """Create target, spawn a process, and attach to it with process name."""
Index: test/functionalities/inferior-assert/TestInferiorAssert.py
===
--- test/functionalities/inferior-assert/TestInferiorAssert.py
+++ test/functionalities/inferior-assert/TestInferiorAssert.py
@@ -12,7 +12,6 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailurei386("llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly")
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
 def test_inferior_asserting(self):
 """Test that lldb reliably catches the inferior asserting (command)."""
@@ -26,7 +25,6 @@
 self.build()
 self.inferior_asserting_registers()
 
-@expectedFailurei386("llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly")
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
 def test_inferior_asserting_disassemble(self):
 """Test that lldb reliably disassembles frames after asserting (command)."""
@@ -40,14 +38,12 @@
 self.build()
 self.inferior_asserting_python()
 
-@expectedFailurei386('llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly')
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
 def test_inferior_asserting_expr(self):
 """Test that the lldb expression interpreter can read from the inferior after asserting (command)."""
 self.build()
 self.inferior_asserting_expr()
 
-@expectedFailurei386("llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly")
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
 def test_inferior_asserting_step(self):
 """Test that lldb functions correctly after stepping through a call to assert()."""
@@ -146,6 +142,12 @@
 thread = process.GetThreadAtIndex(0)
 self.assertTrue(thread.IsValid(), "current thread is valid")
 
+lastframeID = thread.GetFrameAtIndex(thread.GetNumFrames() - 1).GetFrameID()
+
+isi386Arch = False
+if "i386" in self.getArchitecture():
+isi386Arch = True
+
 # lldb should be able to disassemble frames from the inferior after asserting.
 for frame in thread:
 self.assertTrue(frame.IsValid(), "current frame is valid")
@@ -160,6 +162,9 @@
 pc_backup_offset = 1
 if frame.GetFrameID() == 0:
 pc_backup_offset = 0
+if isi386Arch == True:
+if lastframeID == frame.GetFrameID():
+pc_backup_offset = 0
 self.expect("disassemble -a %s" % (frame.GetPC() - pc_backup_offset),
 substrs = ['<+0>: '])
 
Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
===
--- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -88,6 +88,10 @@
 /// Rendezvous breakpoint.
 lldb::break_id_t m_dyld_bid;
 
+/// Contains AT_SYSINFO_EHDR, which means a vDSO has been
+/// mapped to the address space
+lldb::addr_t m_vdso_base;
+
 /// Loaded module list. (link map for each module)
 std::map> m_loaded_modules;
 

Re: [Lldb-commits] [PATCH] D14118: Changes for Bug 17384

2015-10-29 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hi,
This link for the traces needs a password, could u maybe provide me the 
login details or upload these somewhere else ? Also could u provide me the 
value of the AuxVectors during this test ?

BR,
A Ravi Theja


http://reviews.llvm.org/D14118



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


[Lldb-commits] [lldb] r251917 - Changes for Bug 25251

2015-11-03 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Tue Nov  3 08:24:24 2015
New Revision: 251917

URL: http://llvm.org/viewvc/llvm-project?rev=251917&view=rev
Log:
Changes for Bug 25251

Summary:
The solution to bug 24074,rL249673 needed
to parse the function information from the Dwarf in order
to set the SymbolContext. For that, GetFunction was called
for the parent in GetTypeForDIE, which parses the
ChildParameters and in the flow, GetTypeForDIE was called
for one of the sibling die and so an infinite
loop was triggered by calling GetFunction repeatedly for the
same function.

The changes in this revision modify the GetTypeForDIE to only
resolve the function context in the Type Lookup flow and so
prevent the infinite loop.

A testcase has also been added to check for regression in the
future and a test vector had been added to the testcase of
24074.

Reviewers: jingham, tberghammer, clayborg

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
   (with props)

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py
Modified:
lldb/trunk/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py
lldb/trunk/packages/Python/lldbsuite/test/lang/c/typedef/main.c
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/Makefile?rev=251917&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/Makefile
 Tue Nov  3 08:24:24 2015
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+CXXFLAGS += -std=c++11
+CXX_SOURCES := ParallelTask.cpp
+ENABLE_STD_THREADS := YES
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp?rev=251917&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
 Tue Nov  3 08:24:24 2015
@@ -0,0 +1,151 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+class TaskPoolImpl
+{
+public:
+TaskPoolImpl(uint32_t num_threads) :
+m_stop(false)
+{
+for (uint32_t i = 0; i < num_threads; ++i)
+m_threads.emplace_back(Worker, this);
+}
+
+~TaskPoolImpl()
+{
+Stop();
+}
+
+template
+std::future::type>
+AddTask(F&& f, Args&&... args)
+{
+auto task = std::make_shared::type()>>(
+std::bind(std::forward(f), std::forward(args)...));
+
+std::unique_lock lock(m_tasks_mutex);
+assert(!m_stop && "Can't add task to TaskPool after it is stopped");
+m_tasks.emplace([task](){ (*task)(); });
+lock.unlock();
+m_tasks_cv.notify_one();
+
+return task->get_future();
+}
+
+void
+Stop()
+{
+std::unique_lock lock(m_tasks_mutex);
+m_stop = true;
+m_tasks_mutex.unlock();
+m_tasks_cv.notify_all();
+for (auto& t : m_threads)
+t.join();
+}
+
+private:
+static void
+Worker(TaskPoolImpl* pool)
+{
+while (true)
+{
+std::unique_lock lock(pool->m_tasks_mutex);
+if (pool->m_tasks.empty())
+pool->m_tasks_cv.wait(lock, [pool](){ return 
!pool->m_tasks.empty() || pool->m_stop; });
+if (pool->m_tasks.empty())
+break;
+
+std::function f = pool->m_tasks.front();
+pool->m_tasks.pop();
+lock.unlock();
+
+f();
+}
+}
+
+std::queue> m_tasks;
+std::mutexm_tasks_mutex;
+std::condition_variable   m_tasks_cv;
+bool  m_stop;
+std::vector  m_threads;
+};
+
+class TaskPool
+{
+public:
+// Add a new task to the thread pool and return a std::future belongs for 
the newly created task.
+// The caller of this function have to wait on the future for this task to 
complete.
+template
+static std::future:

Re: [Lldb-commits] [PATCH] D14118: Changes for Bug 17384

2015-11-03 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hello,
I tried making an instance on GCE but it asks for a credit card 
information which I unfortunately don’t have. Can you provide me maybe access 
through some other way ? btw I checked the logs u sent me and the vdso is being 
loaded but the unwinding till main is diferent from what I see on the Ubuntu 
machine I have.

BR,
A Ravi Theja


http://reviews.llvm.org/D14118



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


Re: [Lldb-commits] [PATCH] D15046: Fix for TestNoreturnUnwind.py on i386

2015-12-01 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hi Jason,

  Ok let me explain the scenario here, the application i.e the test function 
tries to abort which eventually ends up in a function present in the vdso, on 
the way the call flow goes through some functions in libc. Now the backtrace is 
done from inside of the function in the vdso, which was successful in the case 
of gcc and unsuccessful for clang. Before I tell you my findings, I would 
mention that the vdso is mapped by the kernel in to the inferiors memory and 
would be the same for clang or gcc. Now I found that the ebp register was not 
touched by the functions in the libc and the assembly unwind plan was used for 
the vdso for the first frame. This was successful for gcc because gcc emitted 
the prologue for the main function whereas clang does not. 

Here is the log without my patch -

(lldb) log enable lldb unwind
(lldb) run
Process 99000 launched: 
'/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out'
 (i386)
th1/fr0 with pc value of 0x8048350, symbol name is ''
(i386) 
/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out:
 Reading EH frame info
th1/fr0 0x08048350: CFA=esp +4 => esp=CFA+0 eip=[CFA-4]

th1/fr0 CFA is 0xd4d4: Register esp (7) contents are 0xd4d0, offset is 4
th1/fr0 initialized frame current pc is 0x8048350 cfa is 0xd4d4 using 
assembly insn profiling UnwindPlan
th1/fr0 supplying caller's saved eip (8)'s location using assembly insn 
profiling UnwindPlan
th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus 
offset -4 [saved at 0xd4d0]
 th1/fr1 pc = 0x1
th1/fr0 supplying caller's register ebp (6) from the live RegisterContext at 
frame 0
 th1/fr1 fp = 0x0
th1/fr0 supplying caller's saved esp (7)'s location using assembly insn 
profiling UnwindPlan
th1/fr0 supplying caller's register esp (7), value is CFA plus offset 0 [value 
is 0xd4d4]
 th1/fr1 sp = 0xd4d4
 th1/fr1 this frame has a pc of 0x0
th1/fr0 supplying caller's saved eip (8)'s location, cached
th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0
th1/fr0 failed to get cfa with fallback unwindplan
 Frame 1 invalid RegisterContext for this frame, stopping stack walk
th1 Unwind of this thread is complete.
th1/fr0 with pc value of 0xf7fd9d80, symbol name is '__kernel_vsyscall'
(i386) [vdso](0xf7fd9000): Reading EH frame info
th1/fr0 0xf7fd9d75: CFA=ebp+16 => ebp=[CFA-16] esp=CFA+0 eip=[CFA-4]

th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0
th1/fr0 could not read CFA register for this frame.
th1 Unwind of this thread is complete.
Process 99000 stopped

- thread #1: tid = 99000, 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16, name = 
'a.out', stop reason = signal SIGABRT frame #0: 0xf7fd9d80 
[vdso]`__kernel_vsyscall + 16

[vdso]`__kernel_vsyscall:
->  0xf7fd9d80 <+16>: popl   %ebp

  0xf7fd9d81 <+17>: popl   %edx
  0xf7fd9d82 <+18>: popl   %ecx
  0xf7fd9d83 <+19>: retl   

(lldb) disassemble
[vdso]`__kernel_vsyscall:

  0xf7fd9d70 <+0>:  pushl  %ecx
  0xf7fd9d71 <+1>:  pushl  %edx
  0xf7fd9d72 <+2>:  pushl  %ebp
  0xf7fd9d73 <+3>:  movl   %esp, %ebp
  0xf7fd9d75 <+5>:  sysenter 
  0xf7fd9d77 <+7>:  nop
  0xf7fd9d78 <+8>:  nop
  0xf7fd9d79 <+9>:  nop
  0xf7fd9d7a <+10>: nop
  0xf7fd9d7b <+11>: nop
  0xf7fd9d7c <+12>: nop
  0xf7fd9d7d <+13>: nop
  0xf7fd9d7e <+14>: int$0x80

->  0xf7fd9d80 <+16>: popl   %ebp

  0xf7fd9d81 <+17>: popl   %edx
  0xf7fd9d82 <+18>: popl   %ecx
  0xf7fd9d83 <+19>: retl   

After the patch ->

(lldb) log enable lldb unwind
(lldb) run
Process 99000 launched: 
'/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out'
 (i386)
th1/fr0 with pc value of 0x8048350, symbol name is ''
(i386) 
/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out:
 Reading EH frame info
th1/fr0 0x08048350: CFA=esp +4 => esp=CFA+0 eip=[CFA-4]

th1/fr0 CFA is 0xd4d4: Register esp (7) contents are 0xd4d0, offset is 4
th1/fr0 initialized frame current pc is 0x8048350 cfa is 0xd4d4 using 
assembly insn profiling UnwindPlan
th1/fr0 supplying caller's saved eip (8)'s location using assembly insn 
profiling UnwindPlan
th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus 
offset -4 [saved at 0xd4d0]
 th1/fr1 pc = 0x1
th1/fr0 supplying caller's register ebp (6) from the live RegisterContext at 
frame 0
 th1/fr1 fp = 0x0
th1/fr0 supplying caller's saved esp (7)'s location using assembly insn 
profiling UnwindPlan
th1/fr0 supplying caller's register esp (7), value is CFA plus offset 0 [value 
is 0xd4d4]
 th1/fr1 sp = 0xd4d4
 th1/fr1 this frame has a pc of 0x0
th1/fr0 supplying caller's saved eip (8)'s location, cached
th1/f

Re: [Lldb-commits] [PATCH] D15046: Fix for TestNoreturnUnwind.py on i386

2015-12-02 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

The reason assembly unwind did not work is because if the ebp register is set 
to 0 at that time, so the CFA is not available. In the case of clang the frame 
pointer is not set by any function, which is why the formula does not work.

(lldb) image show-unwind -n __kernel_vsyscall
UNWIND PLANS for [vdso]`__kernel_vsyscall (start addr 0xf7fd9d70)

Asynchronous (not restricted to call-sites) UnwindPlan is 'assembly insn 
profiling'
Synchronous (restricted to call-sites) UnwindPlan is 'eh_frame CFI'

Assembly language inspection UnwindPlan:
This UnwindPlan originally sourced from assembly insn profiling
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: yes.
Address range of this UnwindPlan: [[vdso]..text + 1600-0x0654)
row[0]:0: CFA=esp +4 => esp=CFA+0 eip=[CFA-4] 
row[1]:1: CFA=esp +8 => esp=CFA+0 eip=[CFA-4] 
row[2]:2: CFA=esp+12 => esp=CFA+0 eip=[CFA-4] 
row[3]:3: CFA=esp+16 => ebp=[CFA-16] esp=CFA+0 eip=[CFA-4] 
row[4]:5: CFA=ebp+16 => ebp=[CFA-16] esp=CFA+0 eip=[CFA-4] 
row[5]:   17: CFA=esp+12 => esp=CFA+0 eip=[CFA-4] 
row[6]:   18: CFA=esp +8 => esp=CFA+0 eip=[CFA-4] 
row[7]:   19: CFA=esp +4 => esp=CFA+0 eip=[CFA-4]

eh_frame UnwindPlan:
This UnwindPlan originally sourced from eh_frame CFI
This UnwindPlan is sourced from the compiler: yes.
This UnwindPlan is valid at all instruction locations: no.
Address range of this UnwindPlan: [[vdso]..text + 1600-0x0654)
row[0]:0: CFA=esp +4 => eip=[CFA-4] 
row[1]:1: CFA=esp +8 => eip=[CFA-4] 
row[2]:2: CFA=esp+12 => eip=[CFA-4] 
row[3]:3: CFA=esp+16 => ebp=[CFA-16] eip=[CFA-4] 
row[4]:   17: CFA=esp+12 => ebp=[CFA-16] eip=[CFA-4] 
row[5]:   18: CFA=esp +8 => ebp=[CFA-16] eip=[CFA-4] 
row[6]:   19: CFA=esp +4 => ebp=[CFA-16] eip=[CFA-4]

Arch default UnwindPlan:
This UnwindPlan originally sourced from i386 default unwind plan
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: no.
row[0]:0: CFA=ebp +8 => esp=CFA+0 ebp=[CFA-8] eip=[CFA-4]

Arch default at entry point UnwindPlan:
This UnwindPlan originally sourced from i386 at-func-entry default
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: not specified.
row[0]:0: CFA=esp +4 => esp=CFA+0 eip=[CFA-4]


http://reviews.llvm.org/D15046



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


Re: [Lldb-commits] [PATCH] D20091: Rewriting TestMultithreaded.py to solve flakyness on Linux

2016-05-11 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

@labath, Well the other tests in TestMultithreaded.py are not flaky and I see 
the only difference as an extra push operation, so I thought the push operation 
could be potential bottleneck.


http://reviews.llvm.org/D20091



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


[Lldb-commits] [lldb] r269168 - Rewriting TestMultithreaded.py to solve flakyness on Linux

2016-05-11 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed May 11 04:54:41 2016
New Revision: 269168

URL: http://llvm.org/viewvc/llvm-project?rev=269168&view=rev
Log:
Rewriting TestMultithreaded.py to solve flakyness on Linux

Summary:
test_listener_event_process_state checks for Threads
and Frames in the multithreaded_queue. The listener_func has
more computational load, which may be latter executed than the
pop leading to the failure. This patch tries to only check for
frames in listener_func as presence of frames also confirms 
prescence of threads and avoids the second push into the 
multithreaded_queue.

Reviewers: lldb-commits, clayborg, labath

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py

lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py?rev=269168&r1=269167&r2=269168&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
 Wed May 11 04:54:41 2016
@@ -37,7 +37,6 @@ class SBBreakpointCallbackCase(TestBase)
 @skipIfNoSBHeaders
 @skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
-@expectedFlakeyLinux # Driver occasionally returns '1' as exit status
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
 def test_sb_api_listener_event_process_state(self):
 """ Test that a registered SBListener receives events when a process

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp?rev=269168&r1=269167&r2=269168&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
 Wed May 11 04:54:41 2016
@@ -18,7 +18,6 @@ using namespace std;
 // listener thread control
 extern atomic g_done;
 
-multithreaded_queue g_thread_descriptions;
 multithreaded_queue g_frame_functions;
 
 extern SBListener g_listener;
@@ -30,26 +29,21 @@ void listener_func() {
 if (got_event) {
   if (!event.IsValid())
 throw Exception("event is not valid in listener thread");
-
-  // send process description
-  SBProcess process = SBProcess::GetProcessFromEvent(event);
-  SBStream description;
-
-  for (int i = 0; i < process.GetNumThreads(); ++i) {
-// send each thread description
-description.Clear();
-SBThread thread = process.GetThreadAtIndex(i);
-thread.GetDescription(description);
-g_thread_descriptions.push(description.GetData());
-
-// send each frame function name
-uint32_t num_frames = thread.GetNumFrames();
-for(int j = 0; j < num_frames; ++j) {
-  const char* function_name = 
thread.GetFrameAtIndex(j).GetSymbol().GetName();
-  if (function_name)
-g_frame_functions.push(function_name);
+// send process description
+SBProcess process = SBProcess::GetProcessFromEvent(event);
+SBStream description;
+
+for (int i = 0; i < process.GetNumThreads(); ++i) {
+// send each thread description
+SBThread thread = process.GetThreadAtIndex(i);
+// send each frame function name
+uint32_t num_frames = thread.GetNumFrames();
+for(int j = 0; j < num_frames; ++j) {
+const char* function_name = 
thread.GetFrameAtIndex(j).GetSymbol().GetName();
+if (function_name)
+g_frame_functions.push(string(function_name));
+}
 }
-  }
 }
   }
 }
@@ -57,12 +51,8 @@ void listener_func() {
 void check_listener(SBDebugger &dbg) {
   // check thread description
   bool got_description = false;
-  string desc = g_thread_descriptions.pop(5, got_description);
-  if (!got_description)
-throw Exception("Expected at least one thread description string");
-
-  // check at least one frame has a function name
-  desc = g_frame_functions.pop(5, got_description);
-  if (!got_description)
-throw Exception("Expected at least one frame function name string");
+  string func_name = g_frame_functions.pop(5, got_description);
+  
+  if(got_description

Re: [Lldb-commits] [PATCH] D20091: Rewriting TestMultithreaded.py to solve flakyness on Linux

2016-05-11 Thread Ravitheja Addepally via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269168: Rewriting TestMultithreaded.py to solve flakyness on 
Linux (authored by ravitheja).

Changed prior to commit:
  http://reviews.llvm.org/D20091?vs=56671&id=56870#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20091

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
  
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp

Index: 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
@@ -18,7 +18,6 @@
 // listener thread control
 extern atomic g_done;
 
-multithreaded_queue g_thread_descriptions;
 multithreaded_queue g_frame_functions;
 
 extern SBListener g_listener;
@@ -30,39 +29,30 @@
 if (got_event) {
   if (!event.IsValid())
 throw Exception("event is not valid in listener thread");
-
-  // send process description
-  SBProcess process = SBProcess::GetProcessFromEvent(event);
-  SBStream description;
-
-  for (int i = 0; i < process.GetNumThreads(); ++i) {
-// send each thread description
-description.Clear();
-SBThread thread = process.GetThreadAtIndex(i);
-thread.GetDescription(description);
-g_thread_descriptions.push(description.GetData());
-
-// send each frame function name
-uint32_t num_frames = thread.GetNumFrames();
-for(int j = 0; j < num_frames; ++j) {
-  const char* function_name = 
thread.GetFrameAtIndex(j).GetSymbol().GetName();
-  if (function_name)
-g_frame_functions.push(function_name);
+// send process description
+SBProcess process = SBProcess::GetProcessFromEvent(event);
+SBStream description;
+
+for (int i = 0; i < process.GetNumThreads(); ++i) {
+// send each thread description
+SBThread thread = process.GetThreadAtIndex(i);
+// send each frame function name
+uint32_t num_frames = thread.GetNumFrames();
+for(int j = 0; j < num_frames; ++j) {
+const char* function_name = 
thread.GetFrameAtIndex(j).GetSymbol().GetName();
+if (function_name)
+g_frame_functions.push(string(function_name));
+}
 }
-  }
 }
   }
 }
 
 void check_listener(SBDebugger &dbg) {
   // check thread description
   bool got_description = false;
-  string desc = g_thread_descriptions.pop(5, got_description);
-  if (!got_description)
-throw Exception("Expected at least one thread description string");
-
-  // check at least one frame has a function name
-  desc = g_frame_functions.pop(5, got_description);
-  if (!got_description)
-throw Exception("Expected at least one frame function name string");
+  string func_name = g_frame_functions.pop(5, got_description);
+  
+  if(got_description == false)
+throw Exception("Expected at least one frame function");
 }
Index: 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
@@ -37,7 +37,6 @@
 @skipIfNoSBHeaders
 @skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
-@expectedFlakeyLinux # Driver occasionally returns '1' as exit status
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
 def test_sb_api_listener_event_process_state(self):
 """ Test that a registered SBListener receives events when a process


Index: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
@@ -18,7 +18,6 @@
 // listener thread control
 extern atomic g_done;
 
-multithreaded_queue g_thread_descriptions;
 multithreaded_queue g_frame_functions;
 
 extern SBListener g_listener;
@@ -30,39 +29,30 @@
 if (got_event) {
   if (!event.IsValid())
 throw Exception("event is not valid in listener thread");
-
-  // send process description
-  SBProcess process = SBProcess::GetProcessFromEvent(event);
-  SBStream description;
-
-  for (int i = 0; i < pr

Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-13 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Well its not possible for the assembly unwinder to do the correct thing in this 
situation , as the function is entered through a stub function (which has push 
instruction) and then a jump. The point of this patch is to catch when to use 
the CFI or the assembly unwinder.


http://reviews.llvm.org/D21221



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


Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-13 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 60533.
ravitheja added a comment.

Making EH Frame CFI the full unwinder
when artificial symbols are found.


http://reviews.llvm.org/D21221

Files:
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -210,12 +210,28 @@
 m_frame_type = eNormalFrame;
 }
 
+// We've set m_frame_type and m_sym_ctx before these calls.
+
+m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
+m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
+
 // If we were able to find a symbol/function, set addr_range to the bounds of that symbol/function.
 // else treat the current pc value as the start_pc and record no offset.
 if (addr_range.GetBaseAddress().IsValid())
 {
 m_start_pc = addr_range.GetBaseAddress();
-if (m_current_pc.GetSection() == m_start_pc.GetSection())
+if (m_sym_ctx.symbol->IsSynthetic())
+{
+// The current offset should be recalculated here. The m_current_offset is
+// calculated from the base address of the symbol. The symbol can lie in the PLT
+// (Procedure Linkage Table) i.e its a symbol stub for external call. In this case
+// the base address for the unwindplan and the base address of the symbol maybe different, hence
+// the m_current_offset will be wrong.
+AddressRange unwind_address_range = m_full_unwind_plan_sp->GetAddressRange();
+if (unwind_address_range.ContainsFileAddress(m_current_pc))
+m_current_offset = m_current_pc.GetOffset() - unwind_address_range.GetBaseAddress().GetOffset();
+}
+else if (m_current_pc.GetSection() == m_start_pc.GetSection())
 {
 m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset();
 }
@@ -236,11 +252,6 @@
 m_current_offset_backed_up_one = -1;
 }
 
-// We've set m_frame_type and m_sym_ctx before these calls.
-
-m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
-m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
-
 UnwindPlan::RowSP active_row;
 lldb::RegisterKind row_register_kind = eRegisterKindGeneric;
 if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc))
@@ -255,36 +266,14 @@
 }
 }
 
-if (!active_row.get())
-{
-UnwindLogMsg ("could not find an unwindplan row for this frame's pc");
-m_frame_type = eNotAValidFrame;
-return;
-}
-
-
 if (!ReadCFAValueForRow (row_register_kind, active_row, m_cfa))
 {
 // Try the fall back unwind plan since the
 // full unwind plan failed.
-FuncUnwindersSP func_unwinders_sp;
-UnwindPlanSP call_site_unwind_plan;
 bool cfa_status = false;
+if (TryFallbackUnwindPlan())
+cfa_status = true;
 
-if (m_sym_ctx_valid)
-{
-func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
-}
-
-if(func_unwinders_sp.get() != nullptr)
-call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
-
-if (call_site_unwind_plan.get() != nullptr)
-{
-m_fallback_unwind_plan_sp = call_site_unwind_plan;
-if(TryFallbackUnwindPlan())
-cfa_status = true;
-}
 if (!cfa_status)
 {
 UnwindLogMsg ("could not read CFA value for first frame.");
@@ -881,6 +870,8 @@
 // call GetUnwindPlanAtCallSite() -- because CallSite may return an unwind plan sourced from
 // either eh_frame (that's what we intend) or compact unwind (this won't work)
 unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
+m_fallback_unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+
 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
 {
 UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan because the DynamicLoader suggested we prefer it",
@@ -1608,8 +1599,8 @@
 
 // If a compiler generated unwind plan failed, trying the arch default unwindplan
 // isn't going to do any better.
-if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
-return false;
+//if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
+//return false;
 

Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-13 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 60539.
ravitheja added a comment.

Checks for nullptr


http://reviews.llvm.org/D21221

Files:
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -210,12 +210,28 @@
 m_frame_type = eNormalFrame;
 }
 
+// We've set m_frame_type and m_sym_ctx before these calls.
+
+m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
+m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
+
 // If we were able to find a symbol/function, set addr_range to the bounds of that symbol/function.
 // else treat the current pc value as the start_pc and record no offset.
 if (addr_range.GetBaseAddress().IsValid())
 {
 m_start_pc = addr_range.GetBaseAddress();
-if (m_current_pc.GetSection() == m_start_pc.GetSection())
+if (m_sym_ctx.symbol != nullptr && m_sym_ctx.symbol->IsSynthetic())
+{
+// The current offset should be recalculated here. The m_current_offset is
+// calculated from the base address of the symbol. The symbol can lie in the PLT
+// (Procedure Linkage Table) i.e its a symbol stub for external call. In this case
+// the base address for the unwindplan and the base address of the symbol maybe different, hence
+// the m_current_offset will be wrong.
+AddressRange unwind_address_range = m_full_unwind_plan_sp->GetAddressRange();
+if (unwind_address_range.ContainsFileAddress(m_current_pc))
+m_current_offset = m_current_pc.GetOffset() - unwind_address_range.GetBaseAddress().GetOffset();
+}
+else if (m_current_pc.GetSection() == m_start_pc.GetSection())
 {
 m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset();
 }
@@ -236,11 +252,6 @@
 m_current_offset_backed_up_one = -1;
 }
 
-// We've set m_frame_type and m_sym_ctx before these calls.
-
-m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
-m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
-
 UnwindPlan::RowSP active_row;
 lldb::RegisterKind row_register_kind = eRegisterKindGeneric;
 if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc))
@@ -255,36 +266,14 @@
 }
 }
 
-if (!active_row.get())
-{
-UnwindLogMsg ("could not find an unwindplan row for this frame's pc");
-m_frame_type = eNotAValidFrame;
-return;
-}
-
-
 if (!ReadCFAValueForRow (row_register_kind, active_row, m_cfa))
 {
 // Try the fall back unwind plan since the
 // full unwind plan failed.
-FuncUnwindersSP func_unwinders_sp;
-UnwindPlanSP call_site_unwind_plan;
 bool cfa_status = false;
+if (TryFallbackUnwindPlan())
+cfa_status = true;
 
-if (m_sym_ctx_valid)
-{
-func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
-}
-
-if(func_unwinders_sp.get() != nullptr)
-call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
-
-if (call_site_unwind_plan.get() != nullptr)
-{
-m_fallback_unwind_plan_sp = call_site_unwind_plan;
-if(TryFallbackUnwindPlan())
-cfa_status = true;
-}
 if (!cfa_status)
 {
 UnwindLogMsg ("could not read CFA value for first frame.");
@@ -881,6 +870,8 @@
 // call GetUnwindPlanAtCallSite() -- because CallSite may return an unwind plan sourced from
 // either eh_frame (that's what we intend) or compact unwind (this won't work)
 unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
+m_fallback_unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+
 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
 {
 UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan because the DynamicLoader suggested we prefer it",
@@ -1608,8 +1599,8 @@
 
 // If a compiler generated unwind plan failed, trying the arch default unwindplan
 // isn't going to do any better.
-if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
-return false;
+//if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
+//return false;
 
 
 // Get the call

Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-14 Thread Ravitheja Addepally via lldb-commits
ravitheja added inline comments.


Comment at: source/Plugins/Process/Utility/RegisterContextLLDB.cpp:1602
@@ -1610,3 +1601,3 @@
 // isn't going to do any better.
-if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
-return false;
+//if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
+//return false;

labath wrote:
> What is this supposed to do?
It stops the the TryFallbackUnwindplan to use the assembly unwinder.


http://reviews.llvm.org/D21221



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


Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-14 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

so regarding this particular situation I want to give little more insight ->
It starts out from here

  0x40143a <+346>: movabsq $0x403e32, %rdi   ; imm = 0x403E32 
  0x401444 <+356>: movb   $0x0, %al
  0x401446 <+358>: callq  0x400d30  ; symbol stub for: printf
  0x40144b <+363>: movq   0x6071c0, %rdi
  0x401453 <+371>: movl   %eax, -0xdc(%rbp)

->0x401459 <+377>: callq  0x400ed0  ; symbol stub for: fflush

  0x40145e <+382>: movl   $0x40, %esi
  0x401463 <+387>: leaq   -0xb0(%rbp), %rdi
  0x40146a <+394>: movq   0x607158, %rdx
  0x401472 <+402>: movl   %eax, -0xe0(%rbp)

(lldb) disassemble
a.out`fflush:
->  0x400ed0 <+0>:  jmpq   *0x206212(%rip)   ; _GLOBAL_OFFSET_TABLE_ + 
232

  0x400ed6 <+6>:  pushq  $0x1a
  0x400edb <+11>: jmp0x400d20

(lldb) disassemble 
->  0x400d20:   pushq  0x2062e2(%rip); _GLOBAL_OFFSET_TABLE_ + 8

  0x400d26:   jmpq   *0x2062e4(%rip)   ; _GLOBAL_OFFSET_TABLE_ + 16 
  I think this jump goes to fflush.

ld-linux-x86-64.so.2`___lldb_unnamed_symbol95$$ld-linux-x86-64.so.2:

  0x77df04a0 <+0>:  subq   $0x38, %rsp-> The testcase tries to unwind 
out of here and fails.
  0x77df04a4 <+4>:  movq   %rax, (%rsp)
  0x77df04a8 <+8>:  movq   %rcx, 0x8(%rsp)
  0x77df04ad <+13>: movq   %rdx, 0x10(%rsp)
  0x77df04b2 <+18>: movq   %rsi, 0x18(%rsp)
  0x77df04b7 <+23>: movq   %rdi, 0x20(%rsp)
  0x77df04bc <+28>: movq   %r8, 0x28(%rsp)
  0x77df04c1 <+33>: movq   %r9, 0x30(%rsp)
  0x77df04c6 <+38>: movq   0x40(%rsp), %rsi

Now as you can see, from inside fflush its not possible for the assembly unwind 
to figure out the situation. 
@jasonmolenda The functions I posted in the lldb-dev are the same, here i am 
just posting how it got there.
There is eh_frame information for these functions, that is able to correctly 
point out the CFA.

lldb) image show-unwind --address 0x77df04a0
UNWIND PLANS for 
ld-linux-x86-64.so.2`___lldb_unnamed_symbol95$$ld-linux-x86-64.so.2 (start addr 
0x77df04a0)

Asynchronous (not restricted to call-sites) UnwindPlan is 'assembly insn 
profiling'
Synchronous (restricted to call-sites) UnwindPlan is 'eh_frame CFI'

Assembly language inspection UnwindPlan:
This UnwindPlan originally sourced from assembly insn profiling
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: yes.
Address range of this UnwindPlan: [ld-linux-x86-64.so.2..text + 
88512-0x00015a30)
row[0]:0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8] 
row[1]:4: CFA=rsp+64 => rsp=CFA+0 rip=[CFA-8] 
row[2]:   94: CFA=rsp -8 => rsp=CFA+0 rip=[CFA-8]

eh_frame UnwindPlan:
This UnwindPlan originally sourced from eh_frame CFI
This UnwindPlan is sourced from the compiler: yes.
This UnwindPlan is valid at all instruction locations: no.
Address range of this UnwindPlan: [ld-linux-x86-64.so.2..text + 
88512-0x00015a21)
row[0]:0: CFA=rsp+24 => rip=[CFA-8] 
row[1]:4: CFA=rsp+80 => rip=[CFA-8] 
row[2]:   94: CFA=rsp +8 => rip=[CFA-8]

Arch default UnwindPlan:
This UnwindPlan originally sourced from x86_64 default unwind plan
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: no.
row[0]:0: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]

Arch default at entry point UnwindPlan:
This UnwindPlan originally sourced from x86_64 at-func-entry default
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: not specified.
row[0]:0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]

As you can see the eh_frame UnwindPlan is correct here.


http://reviews.llvm.org/D21221



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


Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-14 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

@labath In order to reproduce this situation without the help of standard 
library, I would have to write handwritten assembly and the CFI directives for 
that, is that fine ?


http://reviews.llvm.org/D21221



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


Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-15 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

@jasonmolenda The approach suggested seems promising, I look forward to it, if 
u want I can test it at my end ? once I see it.


http://reviews.llvm.org/D21221



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


Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-23 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 61668.
ravitheja added a comment.

Adding testcase


http://reviews.llvm.org/D21221

Files:
  packages/Python/lldbsuite/test/functionalities/unwind/nonabi/
  packages/Python/lldbsuite/test/functionalities/unwind/nonabi/Makefile
  
packages/Python/lldbsuite/test/functionalities/unwind/nonabi/TestNonABIFuncUnwind.py
  packages/Python/lldbsuite/test/functionalities/unwind/nonabi/main.c
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -210,12 +210,28 @@
 m_frame_type = eNormalFrame;
 }
 
+// We've set m_frame_type and m_sym_ctx before these calls.
+
+m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
+m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
+
 // If we were able to find a symbol/function, set addr_range to the bounds of that symbol/function.
 // else treat the current pc value as the start_pc and record no offset.
 if (addr_range.GetBaseAddress().IsValid())
 {
 m_start_pc = addr_range.GetBaseAddress();
-if (m_current_pc.GetSection() == m_start_pc.GetSection())
+if (m_sym_ctx.symbol != nullptr && m_sym_ctx.symbol->IsSynthetic())
+{
+// The current offset should be recalculated here. The m_current_offset is
+// calculated from the base address of the symbol. The symbol can lie in the PLT
+// (Procedure Linkage Table) i.e its a symbol stub for external call. In this case
+// the base address for the unwindplan and the base address of the symbol maybe different, hence
+// the m_current_offset will be wrong.
+AddressRange unwind_address_range = m_full_unwind_plan_sp->GetAddressRange();
+if (unwind_address_range.ContainsFileAddress(m_current_pc))
+m_current_offset = m_current_pc.GetOffset() - unwind_address_range.GetBaseAddress().GetOffset();
+}
+else if (m_current_pc.GetSection() == m_start_pc.GetSection())
 {
 m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset();
 }
@@ -236,11 +252,6 @@
 m_current_offset_backed_up_one = -1;
 }
 
-// We've set m_frame_type and m_sym_ctx before these calls.
-
-m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
-m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
-
 UnwindPlan::RowSP active_row;
 lldb::RegisterKind row_register_kind = eRegisterKindGeneric;
 if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc))
@@ -255,36 +266,14 @@
 }
 }
 
-if (!active_row.get())
-{
-UnwindLogMsg ("could not find an unwindplan row for this frame's pc");
-m_frame_type = eNotAValidFrame;
-return;
-}
-
-
 if (!ReadCFAValueForRow (row_register_kind, active_row, m_cfa))
 {
 // Try the fall back unwind plan since the
 // full unwind plan failed.
-FuncUnwindersSP func_unwinders_sp;
-UnwindPlanSP call_site_unwind_plan;
 bool cfa_status = false;
+if (TryFallbackUnwindPlan())
+cfa_status = true;
 
-if (m_sym_ctx_valid)
-{
-func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
-}
-
-if(func_unwinders_sp.get() != nullptr)
-call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
-
-if (call_site_unwind_plan.get() != nullptr)
-{
-m_fallback_unwind_plan_sp = call_site_unwind_plan;
-if(TryFallbackUnwindPlan())
-cfa_status = true;
-}
 if (!cfa_status)
 {
 UnwindLogMsg ("could not read CFA value for first frame.");
@@ -881,6 +870,8 @@
 // call GetUnwindPlanAtCallSite() -- because CallSite may return an unwind plan sourced from
 // either eh_frame (that's what we intend) or compact unwind (this won't work)
 unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
+m_fallback_unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+
 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
 {
 UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan because the DynamicLoader suggested we prefer it",
@@ -1608,8 +1599,8 @@
 
 // If a compiler generated unwind plan failed, tryi

Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-27 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 61936.
ravitheja added a comment.

Renaming testcase


http://reviews.llvm.org/D21221

Files:
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
  
packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -210,12 +210,28 @@
 m_frame_type = eNormalFrame;
 }
 
+// We've set m_frame_type and m_sym_ctx before these calls.
+
+m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
+m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
+
 // If we were able to find a symbol/function, set addr_range to the bounds of that symbol/function.
 // else treat the current pc value as the start_pc and record no offset.
 if (addr_range.GetBaseAddress().IsValid())
 {
 m_start_pc = addr_range.GetBaseAddress();
-if (m_current_pc.GetSection() == m_start_pc.GetSection())
+if (m_sym_ctx.symbol != nullptr && m_sym_ctx.symbol->IsSynthetic())
+{
+// The current offset should be recalculated here. The m_current_offset is
+// calculated from the base address of the symbol. The symbol can lie in the PLT
+// (Procedure Linkage Table) i.e its a symbol stub for external call. In this case
+// the base address for the unwindplan and the base address of the symbol maybe different, hence
+// the m_current_offset will be wrong.
+AddressRange unwind_address_range = m_full_unwind_plan_sp->GetAddressRange();
+if (unwind_address_range.ContainsFileAddress(m_current_pc))
+m_current_offset = m_current_pc.GetOffset() - unwind_address_range.GetBaseAddress().GetOffset();
+}
+else if (m_current_pc.GetSection() == m_start_pc.GetSection())
 {
 m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset();
 }
@@ -236,11 +252,6 @@
 m_current_offset_backed_up_one = -1;
 }
 
-// We've set m_frame_type and m_sym_ctx before these calls.
-
-m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
-m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
-
 UnwindPlan::RowSP active_row;
 lldb::RegisterKind row_register_kind = eRegisterKindGeneric;
 if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc))
@@ -255,36 +266,14 @@
 }
 }
 
-if (!active_row.get())
-{
-UnwindLogMsg ("could not find an unwindplan row for this frame's pc");
-m_frame_type = eNotAValidFrame;
-return;
-}
-
-
 if (!ReadCFAValueForRow (row_register_kind, active_row, m_cfa))
 {
 // Try the fall back unwind plan since the
 // full unwind plan failed.
-FuncUnwindersSP func_unwinders_sp;
-UnwindPlanSP call_site_unwind_plan;
 bool cfa_status = false;
+if (TryFallbackUnwindPlan())
+cfa_status = true;
 
-if (m_sym_ctx_valid)
-{
-func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
-}
-
-if(func_unwinders_sp.get() != nullptr)
-call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
-
-if (call_site_unwind_plan.get() != nullptr)
-{
-m_fallback_unwind_plan_sp = call_site_unwind_plan;
-if(TryFallbackUnwindPlan())
-cfa_status = true;
-}
 if (!cfa_status)
 {
 UnwindLogMsg ("could not read CFA value for first frame.");
@@ -881,6 +870,8 @@
 // call GetUnwindPlanAtCallSite() -- because CallSite may return an unwind plan sourced from
 // either eh_frame (that's what we intend) or compact unwind (this won't work)
 unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
+m_fallback_unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+
 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
 {
 UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan because the DynamicLoader suggested we prefer it",
@@ -1608,8 +1599,8 @@
 
 // If a compiler generated unwind plan failed, t

Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-07-06 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 62831.
ravitheja added a comment.

Removing other files.


http://reviews.llvm.org/D21221

Files:
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
  
packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c

Index: packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
===
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
@@ -0,0 +1,20 @@
+void func() {
+   __asm__ (
+   "pushq $0x10;"
+   ".cfi_def_cfa_offset 16;"
+   "jmp label;"
+   "movq $0x48, %rax;"
+"label: subq $0x38, %rax;"
+   "movq $0x48, %rcx;"
+   "movq $0x48, %rdx;"
+   "movq $0x48, %rax;"
+   "popq %rax;"
+   );
+
+}
+
+
+int main(int argc, char const *argv[])
+{
+   func();
+}
\ No newline at end of file
Index: 
packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
@@ -0,0 +1,51 @@
+"""
+Test that we can backtrace correctly from Non ABI functions on the stack
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class EHFrameBasedUnwind(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+   
+@skipUnlessPlatform(['linux'])
+@skipIf(archs=["aarch64", "arm", "i386", "i686"])
+def test (self):
+"""Test that we can backtrace correctly from Non ABI  functions on the 
stack"""
+self.build()
+self.setTearDownCleanup()
+
+exe = os.path.join(os.getcwd(), "a.out")
+target = self.dbg.CreateTarget(exe)
+
+self.assertTrue(target, VALID_TARGET)
+
+lldbutil.run_break_set_by_symbol (self, "func")
+
+process = target.LaunchSimple (["abc", "xyz"], None, 
self.get_process_working_directory())
+
+if not process:
+self.fail("SBTarget.Launch() failed")
+
+if process.GetState() != lldb.eStateStopped:
+self.fail("Process should be in the 'stopped' state, "
+  "instead the actual state is: '%s'" %
+  lldbutil.state_type_to_str(process.GetState()))
+
+stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+self.expect(stacktraces, exe=False,
+substrs = ['(int)argc=3'])
+
+self.runCmd("thread step-inst")
+
+stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+self.expect(stacktraces, exe=False,
+substrs = ['(int)argc=3'])
Index: packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+CFLAGS ?= -g -fomit-frame-pointer
+
+include $(LEVEL)/Makefile.rules


Index: packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
===
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
@@ -0,0 +1,20 @@
+void func() {
+	__asm__ (
+		"pushq $0x10;"
+		".cfi_def_cfa_offset 16;"
+		"jmp label;"
+		"movq $0x48, %rax;"
+"label: subq $0x38, %rax;"
+		"movq $0x48, %rcx;"
+		"movq $0x48, %rdx;"
+		"movq $0x48, %rax;"
+		"popq %rax;"
+	);
+
+}
+
+
+int main(int argc, char const *argv[])
+{
+	func();
+}
\ No newline at end of file
Index: packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
@@ -0,0 +1,51 @@
+"""
+Test that we can backtrace correctly from Non ABI functions on the stack
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class EHFrameBasedUnwind(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+	
+@skipUnlessPlatform(['linux'])
+@skipIf(archs=["aarch64", "arm", "i386", "i686"])
+def test (self):
+"""Test that we can backtrace correctly from Non ABI  functions on the stack"""
+self.build()
+self.setTearDownCleanup()
+
+exe = os.path.join(os.getcwd(), "a.out")
+target = self.dbg.CreateTarget(exe)

[Lldb-commits] [lldb] r274750 - Fix for PrintStackTraces

2016-07-07 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Thu Jul  7 08:00:29 2016
New Revision: 274750

URL: http://llvm.org/viewvc/llvm-project?rev=274750&view=rev
Log:
Fix for PrintStackTraces

Summary:
The issue arises due to the wrong unwinder used for the first
stack frame, where the default unwinder returns erroneous frame
whereas the fallback would have given the correct frame had it
been used.
The following fix consists of two parts ->
 1) The first part changes the unwinding strategy, earlier the
default unwinder was used to get 2 more stack frames and if it
failed a fallback unwinder was used. Now we try to obtain as many
frames (max 10) as we can get from default unwinder and also
fallback unwinder and use the one that gives more number of frames.

 2) Normally unwindplans are assosciated with functions and the
row to be used is obtained from the offset (obtained from the low_pc
of the function symbol). Sometimes it may occur that the unwindplan
is assosciated to the complete Elf section in which case the offset
calculation would be wrong as the debugger uses the same offset originally
obtained from the function symbol. Hence this offset is recalculated.

Reviewers: tberghammer, lldb-commits, labath, jasonmolenda

Subscribers: jingham

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile?rev=274750&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
 Thu Jul  7 08:00:29 2016
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+CFLAGS ?= -g -fomit-frame-pointer
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py?rev=274750&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
 Thu Jul  7 08:00:29 2016
@@ -0,0 +1,51 @@
+"""
+Test that we can backtrace correctly from Non ABI functions on the stack
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class EHFrameBasedUnwind(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+   
+@skipUnlessPlatform(['linux'])
+@skipIf(archs=["aarch64", "arm", "i386", "i686"])
+def test (self):
+"""Test that we can backtrace correctly from Non ABI  functions on the 
stack"""
+self.build()
+self.setTearDownCleanup()
+
+exe = os.path.join(os.getcwd(), "a.out")
+target = self.dbg.CreateTarget(exe)
+
+self.assertTrue(target, VALID_TARGET)
+
+lldbutil.run_break_set_by_symbol (self, "func")
+
+process = target.LaunchSimple (["abc", "xyz"], None, 
self.get_process_working_directory())
+
+if not process:
+self.fail("SBTarget.Launch() failed")
+
+if process.GetState() != lldb.eStateStopped:
+self.fail("Process should be in the 'stopped' state, "
+  "instead the actual state is: '%s'" %
+  lldbutil.state_type_to_str(process.GetState()))
+
+stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+self.expect(stacktraces, exe=False,
+substrs = ['(int)argc=3'])
+
+self.runCmd("thread step-inst")
+
+stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+self.expect(stacktraces, exe=False,
+substrs = ['(int)argc=3'])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c?rev=274750&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c 
(added)
+++ 
lldb/t

Re: [Lldb-commits] [PATCH] D15046: Fix for TestNoreturnUnwind.py on i386

2016-01-11 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hello, Any updates on this differential ?


http://reviews.llvm.org/D15046



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


[Lldb-commits] [lldb] r257465 - Fix for TestNoreturnUnwind.py on i386

2016-01-12 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Tue Jan 12 04:08:41 2016
New Revision: 257465

URL: http://llvm.org/viewvc/llvm-project?rev=257465&view=rev
Log:
Fix for TestNoreturnUnwind.py on i386

Summary:
The testcase TestNoreturnUnwind.py was failing
because the unwind from the vdso library was not
successful for clang compiler while it was passing
for gcc. It was passing for gcc since the unwind plan
used was the assembly plan and the ebp register was
set by the main function in case of gcc and was not
used by the functions in the call flow to the vdso, whereas
clang did not emit assembly prologue for main and so
 the assembly unwind was failing. Normally in case of
failure of assembly unwind, lldb switches to EH CFI frame
based unwinding, but this was not happening for
the first frame. This patch tries to fix this behaviour by
falling to EH CFI frame based unwinding in case of assembly
unwind failure even for the first frame.
The test is still marked as XFAIL since it relys on the fix
of another bug.

Reviewers: lldb-commits, jingham, zturner, tberghammer, jasonmolenda

Subscribers: jasonmolenda

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py?rev=257465&r1=257464&r2=257465&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
 Tue Jan 12 04:08:41 2016
@@ -14,7 +14,7 @@ import lldbsuite.test.lldbutil as lldbut
 class NoreturnUnwind(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailurei386 #xfail to get buildbot green, failing config: i386 
binary running on ubuntu 14.04 x86_64
+@expectedFailurei386("llvm.org/pr25338")
 @skipIfWindows # clang-cl does not support gcc style attributes.
 def test (self):
 """Test that we can backtrace correctly with 'noreturn' functions on 
the stack"""

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=257465&r1=257464&r2=257465&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Jan 
12 04:08:41 2016
@@ -265,9 +265,32 @@ RegisterContextLLDB::InitializeZerothFra
 
 if (!ReadCFAValueForRow (row_register_kind, active_row, m_cfa))
 {
-UnwindLogMsg ("could not read CFA register for this frame.");
-m_frame_type = eNotAValidFrame;
-return;
+// Try the fall back unwind plan since the
+// full unwind plan failed.
+FuncUnwindersSP func_unwinders_sp;
+UnwindPlanSP call_site_unwind_plan;
+bool cfa_status = false;
+
+if (m_sym_ctx_valid)
+{
+func_unwinders_sp = 
pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress
 (m_current_pc, m_sym_ctx);
+}
+
+if(func_unwinders_sp.get() != nullptr)
+call_site_unwind_plan = 
func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), 
m_current_offset_backed_up_one);
+
+if (call_site_unwind_plan.get() != nullptr)
+{
+m_fallback_unwind_plan_sp = call_site_unwind_plan;
+if(TryFallbackUnwindPlan())
+cfa_status = true;
+}
+if (!cfa_status)
+{
+UnwindLogMsg ("could not read CFA value for first frame.");
+m_frame_type = eNotAValidFrame;
+return;
+}
 }
 
 UnwindLogMsg ("initialized frame current pc is 0x%" PRIx64 " cfa is 0x%" 
PRIx64 " using %s UnwindPlan",


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


Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-13 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hi Tamas, a modified algorithm may work in this case for now, but this issue 
may still reoccur for some other Elf Format .


http://reviews.llvm.org/D16107



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


Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-13 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hi Oleyksiy, actually the problem is not with the Elf Format but its a problem 
with the ObjectFileElf itself which cannot handle reading from arbitrary 
offsets in the Elf. Now the ideal solution would be to fix that but as we had 
discussed last year we agreed to allocate more memory for the vdso. I could try 
to contain the complete fix in the ObjectFileElf but that may be 
counterproductive since it already buggy ?


http://reviews.llvm.org/D16107



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


Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-13 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Yes the vdso is fine, last year I did discuss this and we here decided that at 
the moment we can only offer this solution.


http://reviews.llvm.org/D16107



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


Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-18 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 45185.
ravitheja added a comment.

Changes according to http://reviews.llvm.org/D16151


http://reviews.llvm.org/D16107

Files:
  
packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
  
packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
  packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -10,6 +10,7 @@
 #ifndef liblldb_ObjectFileELF_h_
 #define liblldb_ObjectFileELF_h_
 
+#include 
 // C Includes
 #include 
 
@@ -231,6 +232,7 @@
 typedef DynamicSymbolColl::const_iterator   DynamicSymbolCollConstIter;
 
 typedef std::map FileAddressToAddressClassMap;
+typedef std::function SetDataFunction;
 
 /// Version of this reader common to all plugins based on this class.
 static const uint32_t m_plugin_version = 1;
@@ -279,7 +281,7 @@
 // Parses the ELF program headers.
 static size_t
 GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
- lldb_private::DataExtractor &data,
+ const SetDataFunction set_data,
  const elf::ELFHeader &header);
 
 // Finds PT_NOTE segments and calculates their crc sum.
@@ -302,7 +304,7 @@
 /// Parses the elf section headers and returns the uuid, debug link name, crc, archspec.
 static size_t
 GetSectionHeaderInfo(SectionHeaderColl §ion_headers,
- lldb_private::DataExtractor &data,
+ const SetDataFunction set_data,
  const elf::ELFHeader &header,
  lldb_private::UUID &uuid,
  std::string &gnu_debuglink_file,
@@ -437,6 +439,13 @@
 
 static lldb_private::Error
 RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid);
+
+
+static lldb::offset_t
+SetData(const lldb_private::DataExtractor &src, lldb_private::DataExtractor &dst, lldb::offset_t offset, lldb::offset_t length);
+
+lldb::offset_t
+SetDataWithReadMemoryFallback(lldb_private::DataExtractor &dst, lldb::offset_t offset, lldb::offset_t length);
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -729,7 +729,10 @@
 SectionHeaderColl section_headers;
 lldb_private::UUID &uuid = spec.GetUUID();
 
-GetSectionHeaderInfo(section_headers, data, header, uuid, gnu_debuglink_file, gnu_debuglink_crc, spec.GetArchitecture ());
+using namespace std::placeholders;
+const SetDataFunction set_data = std::bind(&ObjectFileELF::SetData, std::cref(data), _1, _2, _3);
+GetSectionHeaderInfo(section_headers, set_data, header, uuid, gnu_debuglink_file, gnu_debuglink_crc, spec.GetArchitecture ());
+
 
 llvm::Triple &spec_triple = spec.GetArchitecture ().GetTriple ();
 
@@ -759,7 +762,7 @@
 data.SetData(data_sp);
 }
 ProgramHeaderColl program_headers;
-GetProgramHeaderInfo(program_headers, data, header);
+GetProgramHeaderInfo(program_headers, set_data, header);
 
 size_t segment_data_end = 0;
 for (ProgramHeaderCollConstIter I = program_headers.begin();
@@ -1256,7 +1259,7 @@
 //--
 size_t
 ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
-DataExtractor &object_data,
+const SetDataFunction set_data,
 const ELFHeader &header)
 {
 // We have already parsed the program headers
@@ -1274,7 +1277,7 @@
 const size_t ph_size = header.e_phnum * header.e_phentsize;
 const elf_off ph_offset = header.e_phoff;
 DataExtractor data;
-if (data.SetData(object_data, ph_offset, ph_size) != ph_size)
+if (set_data(data, ph_offset, ph_size) != ph_size)
 return 0;
 
 uint32_t idx;
@@ -1298,7 +1301,10 @@
 size_t
 ObjectFileELF::ParseProgramHeaders()
 {
-return GetProgramHeaderInfo(m_program_headers, m_data, m_header);
+using namespace std::placeholders;
+return GetProgramHeaderInfo(m_program_hea

Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-19 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 45238.
ravitheja added a comment.

correcting previous revision.


http://reviews.llvm.org/D16107

Files:
  
packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
  
packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
  packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -14,6 +14,7 @@
 #include 
 
 // C++ Includes
+#include 
 #include 
 
 // Other libraries and framework includes
@@ -231,6 +232,7 @@
 typedef DynamicSymbolColl::const_iterator   DynamicSymbolCollConstIter;
 
 typedef std::map FileAddressToAddressClassMap;
+typedef std::function SetDataFunction;
 
 /// Version of this reader common to all plugins based on this class.
 static const uint32_t m_plugin_version = 1;
@@ -279,7 +281,7 @@
 // Parses the ELF program headers.
 static size_t
 GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
- lldb_private::DataExtractor &data,
+ const SetDataFunction &set_data,
  const elf::ELFHeader &header);
 
 // Finds PT_NOTE segments and calculates their crc sum.
@@ -302,7 +304,7 @@
 /// Parses the elf section headers and returns the uuid, debug link name, crc, archspec.
 static size_t
 GetSectionHeaderInfo(SectionHeaderColl §ion_headers,
- lldb_private::DataExtractor &data,
+ const SetDataFunction &set_data,
  const elf::ELFHeader &header,
  lldb_private::UUID &uuid,
  std::string &gnu_debuglink_file,
@@ -437,6 +439,13 @@
 
 static lldb_private::Error
 RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid);
+
+
+static lldb::offset_t
+SetData(const lldb_private::DataExtractor &src, lldb_private::DataExtractor &dst, lldb::offset_t offset, lldb::offset_t length);
+
+lldb::offset_t
+SetDataWithReadMemoryFallback(lldb_private::DataExtractor &dst, lldb::offset_t offset, lldb::offset_t length);
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -729,7 +729,10 @@
 SectionHeaderColl section_headers;
 lldb_private::UUID &uuid = spec.GetUUID();
 
-GetSectionHeaderInfo(section_headers, data, header, uuid, gnu_debuglink_file, gnu_debuglink_crc, spec.GetArchitecture ());
+using namespace std::placeholders;
+const SetDataFunction set_data = std::bind(&ObjectFileELF::SetData, std::cref(data), _1, _2, _3);
+GetSectionHeaderInfo(section_headers, set_data, header, uuid, gnu_debuglink_file, gnu_debuglink_crc, spec.GetArchitecture ());
+
 
 llvm::Triple &spec_triple = spec.GetArchitecture ().GetTriple ();
 
@@ -759,7 +762,7 @@
 data.SetData(data_sp);
 }
 ProgramHeaderColl program_headers;
-GetProgramHeaderInfo(program_headers, data, header);
+GetProgramHeaderInfo(program_headers, set_data, header);
 
 size_t segment_data_end = 0;
 for (ProgramHeaderCollConstIter I = program_headers.begin();
@@ -1256,7 +1259,7 @@
 //--
 size_t
 ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
-DataExtractor &object_data,
+const SetDataFunction &set_data,
 const ELFHeader &header)
 {
 // We have already parsed the program headers
@@ -1274,7 +1277,7 @@
 const size_t ph_size = header.e_phnum * header.e_phentsize;
 const elf_off ph_offset = header.e_phoff;
 DataExtractor data;
-if (data.SetData(object_data, ph_offset, ph_size) != ph_size)
+if (set_data(data, ph_offset, ph_size) != ph_size)
 return 0;
 
 uint32_t idx;
@@ -1298,7 +1301,10 @@
 size_t
 ObjectFileELF::ParseProgramHeaders()
 {
-return GetProgramHeaderInfo(m_program_headers, m_data, m_header);
+using namespace std::placeholders;
+return GetProgramHeaderInfo(m_program_headers,
+

[Lldb-commits] [lldb] r258122 - Fix for Bug 25338

2016-01-19 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Tue Jan 19 06:55:21 2016
New Revision: 258122

URL: http://llvm.org/viewvc/llvm-project?rev=258122&view=rev
Log:
Fix for Bug 25338

Summary:
The issue arises because LLDB is not
able to read the vdso library correctly.
The fix adds memory allocation callbacks
to allocate sufficient memory in case the
requested offsets don't fit in the memory
buffer allocated for the ELF.

Reviewers: lldb-commits, clayborg, deepak2427, ovyalov, labath, tberghammer

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py?rev=258122&r1=258121&r2=258122&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
 Tue Jan 19 06:55:21 2016
@@ -15,8 +15,7 @@ class AssertingInferiorTestCase(TestBase
 mydir = TestBase.compute_mydir(__file__)
 
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for 
detecting assertion / abort on Windows")
-@expectedFailurei386("llvm.org/pr25338")
-@expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
+@expectedFailureLinux("llvm.org/pr25338", archs=['arm'])
 def test_inferior_asserting(self):
 """Test that lldb reliably catches the inferior asserting (command)."""
 self.build()
@@ -30,8 +29,7 @@ class AssertingInferiorTestCase(TestBase
 self.inferior_asserting_registers()
 
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for 
detecting assertion / abort on Windows")
-@expectedFailurei386("llvm.org/pr25338")
-@expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
+@expectedFailureLinux("llvm.org/pr25338", archs=['arm'])
 def test_inferior_asserting_disassemble(self):
 """Test that lldb reliably disassembles frames after asserting 
(command)."""
 self.build()
@@ -45,16 +43,14 @@ class AssertingInferiorTestCase(TestBase
 self.inferior_asserting_python()
 
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for 
detecting assertion / abort on Windows")
-@expectedFailurei386("llvm.org/pr25338")
-@expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
+@expectedFailureLinux("llvm.org/pr25338", archs=['arm'])
 def test_inferior_asserting_expr(self):
 """Test that the lldb expression interpreter can read from the 
inferior after asserting (command)."""
 self.build()
 self.inferior_asserting_expr()
 
 @expectedFailureWindows("llvm.org/pr21793: need to implement support for 
detecting assertion / abort on Windows")
-@expectedFailurei386("llvm.org/pr25338")
-@expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
+@expectedFailureLinux("llvm.org/pr25338", archs=['arm'])
 def test_inferior_asserting_step(self):
 """Test that lldb functions correctly after stepping through a call to 
assert()."""
 self.build()

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py?rev=258122&r1=258121&r2=258122&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
 Tue Jan 19 06:55:21 2016
@@ -14,7 +14,6 @@ import lldbsuite.test.lldbutil as lldbut
 class NoreturnUnwind(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailurei386("llvm.org/pr25338")
 @skipIfWindows # clang-cl does not support gcc style attributes.
 def test (self):
 """Test that we can backtrace correctly with 'noreturn' functions on 
the stack"""

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=258122&r1=258121&r2=258122&view=diff
=

Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-25 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hello, Ok I will take a look.


http://reviews.llvm.org/D16107



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


Re: [Lldb-commits] [PATCH] D16107: Fix for Bug 25338

2016-01-28 Thread Ravitheja Addepally via lldb-commits
ravitheja added a comment.

Hello @ldrumm,

  I did investigate the issue and my finding is that incorrect values are being 
passed to the SetDataWithReadMemoryFallback function. Now I suspect the 
ElfSectionHeader is wrongly parsed in your case and the size and offsets 
obtained are wrong. To talk briefly about r258122, it just tries to allocate 
enough memory for Elf files being loaded by lldb and earlier it would not have 
read the Elf file so you wouldnt have seen this issue because it would have 
just returned. Could you maybe check the ElfSectionHeader::Parse function, and 
see the values it obtains for this elf (mainly the sh_offset and sh_size 
fields), maybe print them in logs ? I currently don't have an Android x86_64 
environment.


http://reviews.llvm.org/D16107



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


[Lldb-commits] [lldb] r244875 - Set orig_eax to -1 for Linux x86 platforms

2015-08-13 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Thu Aug 13 04:05:11 2015
New Revision: 244875

URL: http://llvm.org/viewvc/llvm-project?rev=244875&view=rev
Log:
Set orig_eax to -1 for Linux x86 platforms

Summary:
For Linux x86 based environments the orig_eax/orig_rax
register should be set to -1 to prevent the instruction pointer
to be decremented, which was the cause for the SIGILL exception.

Fix for Bug 23659

Reviewers: zturner, ashok.thirumurthi, mikesart, jingham, clayborg

Subscribers: clayborg, labath

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

Modified:

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h

lldb/trunk/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=244875&r1=244874&r2=244875&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
Thu Aug 13 04:05:11 2015
@@ -706,6 +706,34 @@ NativeRegisterContextLinux_x86_64::ReadA
 assert (false && "how do we save the floating point registers?");
 error.SetErrorString ("unsure how to save the floating point 
registers");
 }
+/** The following code is specific to Linux x86 based architectures,
+ *  where the register orig_eax (32 bit)/orig_rax (64 bit) is set to
+ *  -1 to solve the bug 23659, such a setting prevents the automatic
+ *  decrement of the instruction pointer which was causing the SIGILL
+ *  exception.
+ * **/
+llvm::Triple t_triple = 
GetRegisterInfoInterface().GetTargetArchitecture().GetTriple();
+
+if (t_triple.getOS() == llvm::Triple::Linux &&
+   (t_triple.getArch() == llvm::Triple::x86 ||
+t_triple.getArch() == llvm::Triple::x86_64))
+{
+RegisterValue value((uint64_t) -1);
+const RegisterInfo *reg_info = 
GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax");
+if (reg_info == nullptr)
+reg_info = 
GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax");
+
+if (reg_info != nullptr) {
+NativeProcessProtocolSP process_sp(m_thread.GetProcess());
+if (!process_sp)
+return Error("NativeProcessProtocol is NULL");
+
+NativeProcessLinux* process_p = 
static_cast(process_sp.get());
+return process_p->DoOperation([&] {
+return 
DoWriteRegisterValue(reg_info->byte_offset,reg_info->name,value);
+});
+}
+}
 
 return error;
 }

Modified: 
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp?rev=244875&r1=244874&r2=244875&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp Thu 
Aug 13 04:05:11 2015
@@ -26,7 +26,7 @@ struct GPR
 uint32_t es;
 uint32_t fs;
 uint32_t gs;
-uint32_t orig_ax;
+uint32_t orig_eax;
 uint32_t eip;
 uint32_t cs;
 uint32_t eflags;
@@ -98,6 +98,9 @@ struct UserArea
 RegisterContextLinux_i386::RegisterContextLinux_i386(const ArchSpec 
&target_arch) :
 RegisterInfoInterface(target_arch)
 {
+RegisterInfo orig_ax = { "orig_eax", NULL, sizeof(((GPR*)NULL)->orig_eax), 
(LLVM_EXTENSION offsetof(GPR, orig_eax)), eEncodingUint, \
+  eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 
LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL };
+d_register_infos.push_back(orig_ax);
 }
 
 size_t
@@ -131,3 +134,9 @@ RegisterContextLinux_i386::GetUserRegist
 {
 return static_cast (k_num_user_registers_i386);
 }
+
+const std::vector *
+RegisterContextLinux_i386::GetDynamicRegisterInfoP() const
+{
+return &d_register_infos;
+}

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h?rev=244875&r1=244874&r2=244875&view=diff

[Lldb-commits] [lldb] r244886 - Removing redundant check from r244875

2015-08-13 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Thu Aug 13 06:53:23 2015
New Revision: 244886

URL: http://llvm.org/viewvc/llvm-project?rev=244886&view=rev
Log:
Removing redundant check from r244875

Modified:

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=244886&r1=244885&r2=244886&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
Thu Aug 13 06:53:23 2015
@@ -712,20 +712,14 @@ NativeRegisterContextLinux_x86_64::ReadA
  *  decrement of the instruction pointer which was causing the SIGILL
  *  exception.
  * **/
-llvm::Triple t_triple = 
GetRegisterInfoInterface().GetTargetArchitecture().GetTriple();
 
-if (t_triple.getOS() == llvm::Triple::Linux &&
-   (t_triple.getArch() == llvm::Triple::x86 ||
-t_triple.getArch() == llvm::Triple::x86_64))
-{
-RegisterValue value((uint64_t) -1);
-const RegisterInfo *reg_info = 
GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax");
-if (reg_info == nullptr)
-reg_info = 
GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax");
+RegisterValue value((uint64_t) -1);
+const RegisterInfo *reg_info = 
GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax");
+if (reg_info == nullptr)
+reg_info = 
GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax");
 
-if (reg_info != nullptr)
-return 
DoWriteRegisterValue(reg_info->byte_offset,reg_info->name,value);
-}
+if (reg_info != nullptr)
+return 
DoWriteRegisterValue(reg_info->byte_offset,reg_info->name,value);
 
 return error;
 }


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


[Lldb-commits] [lldb] r248366 - Testcase and fix for bug 24074

2015-09-23 Thread Ravitheja Addepally via lldb-commits
Author: ravitheja
Date: Wed Sep 23 02:19:02 2015
New Revision: 248366

URL: http://llvm.org/viewvc/llvm-project?rev=248366&view=rev
Log:
Testcase and fix for bug 24074

Summary:
In bug 24074, the type information is not shown
correctly. This commit  includes the following -
-> Changes for displaying correct type based on
   current lexical scope for the command "image
   lookup -t"
-> The corresponding testcase.

Reviewers: jingham, ovyalov, spyffe, richard.mitton, clayborg

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

Added:
lldb/trunk/include/lldb/Symbol/TypeMap.h
lldb/trunk/source/Symbol/TypeMap.cpp
lldb/trunk/test/lang/c/typedef/
lldb/trunk/test/lang/c/typedef/Makefile
lldb/trunk/test/lang/c/typedef/Testtypedef.py
lldb/trunk/test/lang/c/typedef/main.c
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Symbol/SymbolContext.h
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/include/lldb/Symbol/SymbolVendor.h
lldb/trunk/include/lldb/Symbol/TypeList.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/trunk/source/Symbol/CMakeLists.txt
lldb/trunk/source/Symbol/SymbolContext.cpp
lldb/trunk/source/Symbol/SymbolFile.cpp
lldb/trunk/source/Symbol/SymbolVendor.cpp
lldb/trunk/source/Symbol/TypeList.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=248366&r1=248365&r2=248366&view=diff
==
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Wed Sep 23 02:19:02 2015
@@ -1193,7 +1193,7 @@ private:
 const CompilerDeclContext *parent_decl_ctx,
 bool append, 
 size_t max_matches,
-TypeList& types);
+TypeMap& types);
 
 
 DISALLOW_COPY_AND_ASSIGN (Module);

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=248366&r1=248365&r2=248366&view=diff
==
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Wed Sep 23 02:19:02 2015
@@ -299,6 +299,27 @@ public:
ConstString &language_object_name);
 
 //--
+/// If this symbol context represents a function that is a method,
+/// return true and provide information about the method.
+///
+/// @param[out] language
+/// If \b true is returned, the language for the method.
+///
+/// @param[out] is_instance_method
+/// If \b true is returned, \b true if this is a instance method,
+/// \b false if this is a static/class function.
+///
+/// @param[out] language_object_name
+/// If \b true is returned, the name of the artificial variable
+/// for the language ("this" for C++, "self" for ObjC).
+///
+/// @return
+/// \b True if this symbol context represents a function that
+/// is a method of a class, \b false otherwise.
+//--
+void
+   SortTypeList(TypeMap &type_map, TypeList &type_list) const;
+//--
 /// Find a name of the innermost function for the symbol context.
 ///
 /// For instance, if the symbol context contains an inlined block,

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=248366&r1=248365&r2=248366&view=diff
==
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Wed Sep 23 02:19:02 2015
@@ -141,7 +141,7 @@ public:
 virtual uint32_tFindGlobalVariables (const RegularExpression& 
regex, bool append, uint32_t max_matches, VariableList& variables);
 virtual uint32_tFindFunctions (const ConstString &name, const 
CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool 
include_inlines, bool append, SymbolContextList& sc_list);
 virtual uint32_tFindFunctions (const RegularExpression& regex, 
bool include_inlines, bool append, SymbolContextList& sc_list);
-virtual uint32_