[Lldb-commits] [PATCH] lldb: deal with non-portable PTRACE-related constants

Paul Osmialowski pawelo at king.net.pl
Tue Jun 10 12:45:39 PDT 2014


These PTRACE-related enum values are not present everywhere; their presence is denoted by certain preprocessor definitions in sys/ptrace.h that we can check.

http://reviews.llvm.org/D4091

Files:
  source/Plugins/Process/Linux/ProcessMonitor.cpp

Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -122,18 +122,22 @@
                 verbose_log->Printf("PTRACE_POKEUSER %s", buf.GetData());
                 break;
             }
+#ifdef PT_SETREGS
         case PTRACE_SETREGS:
             {
                 DisplayBytes(buf, data, data_size);
                 verbose_log->Printf("PTRACE_SETREGS %s", buf.GetData());
                 break;
             }
+#endif
+#ifdef PT_SETFPREGS
         case PTRACE_SETFPREGS:
             {
                 DisplayBytes(buf, data, data_size);
                 verbose_log->Printf("PTRACE_SETFPREGS %s", buf.GetData());
                 break;
             }
+#endif
         case PTRACE_SETSIGINFO:
             {
                 DisplayBytes(buf, data, sizeof(siginfo_t));
@@ -564,10 +568,14 @@
 void
 ReadGPROperation::Execute(ProcessMonitor *monitor)
 {
+#ifdef PT_GETREGS
     if (PTRACE(PTRACE_GETREGS, m_tid, NULL, m_buf, m_buf_size) < 0)
         m_result = false;
     else
         m_result = true;
+#else
+    m_result = false;
+#endif
 }
 
 //------------------------------------------------------------------------------
@@ -592,10 +600,14 @@
 void
 ReadFPROperation::Execute(ProcessMonitor *monitor)
 {
+#ifdef PT_GETFPREGS
     if (PTRACE(PTRACE_GETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0)
         m_result = false;
     else
         m_result = true;
+#else
+    m_result = false;
+#endif
 }
 
 //------------------------------------------------------------------------------
@@ -649,10 +661,14 @@
 void
 WriteGPROperation::Execute(ProcessMonitor *monitor)
 {
+#ifdef PT_SETREGS
     if (PTRACE(PTRACE_SETREGS, m_tid, NULL, m_buf, m_buf_size) < 0)
         m_result = false;
     else
         m_result = true;
+#else
+    m_result = false;
+#endif
 }
 
 //------------------------------------------------------------------------------
@@ -677,10 +693,14 @@
 void
 WriteFPROperation::Execute(ProcessMonitor *monitor)
 {
+#ifdef PT_SETFPREGS
     if (PTRACE(PTRACE_SETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0)
         m_result = false;
     else
         m_result = true;
+#else
+    m_result = false;
+#endif
 }
 
 //------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4091.10295.patch
Type: text/x-patch
Size: 2400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140610/61a4712c/attachment.bin>


More information about the lldb-commits mailing list