jaydeep updated this revision to Diff 31213.
jaydeep added a comment.

Address review comments


Repository:
  rL LLVM

http://reviews.llvm.org/D11519

Files:
  source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -758,7 +758,8 @@
         return error;
     StartAsyncThread ();
 
-    lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID ();
+    const ArchSpec &target_arch = GetTarget().GetArchitecture();
+    lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID (true, target_arch.GetTriple().getOS());
     if (pid == LLDB_INVALID_PROCESS_ID)
     {
         // We don't have a valid process ID, so note that we are connected
@@ -1012,7 +1013,8 @@
                     std::string error_str;
                     if (m_gdb_comm.GetLaunchSuccess (error_str))
                     {
-                        SetID (m_gdb_comm.GetCurrentProcessID ());
+                        const ArchSpec &target_arch = GetTarget().GetArchitecture();
+                        SetID (m_gdb_comm.GetCurrentProcessID (true, target_arch.GetTriple().getOS()));
                     }
                     else
                     {
@@ -2318,7 +2320,8 @@
                 // sure we know about our registers
                 if (GetID() == LLDB_INVALID_PROCESS_ID)
                 {
-                    lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID ();
+                    const ArchSpec &target_arch = GetTarget().GetArchitecture();
+                    lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID (true, target_arch.GetTriple().getOS());
                     if (pid != LLDB_INVALID_PROCESS_ID)
                         SetID (pid);
                 }
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -109,7 +109,7 @@
                    bool &timed_out);
 
     lldb::pid_t
-    GetCurrentProcessID (bool allow_lazy = true);
+    GetCurrentProcessID (bool allow_lazy = true, llvm::Triple::OSType ostype = llvm::Triple::OSType::UnknownOS);
 
     bool
     GetLaunchSuccess (std::string &error_str);
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1098,7 +1098,7 @@
                         {
                             if (process->GetID() == LLDB_INVALID_PROCESS_ID)
                             {
-                                lldb::pid_t pid = GetCurrentProcessID ();
+                                lldb::pid_t pid = GetCurrentProcessID (true, process->GetTarget().GetArchitecture().GetTriple().getOS());
                                 if (pid != LLDB_INVALID_PROCESS_ID)
                                     process->SetID (pid);
                             }
@@ -1425,7 +1425,7 @@
 }
 
 lldb::pid_t
-GDBRemoteCommunicationClient::GetCurrentProcessID (bool allow_lazy)
+GDBRemoteCommunicationClient::GetCurrentProcessID (bool allow_lazy, llvm::Triple::OSType ostype)
 {
     if (allow_lazy && m_curr_pid_is_valid == eLazyBoolYes)
         return m_curr_pid;
@@ -1459,6 +1459,21 @@
                 }
             }
         }
+
+        // If we don't get a response for $qC, check if $qfThreadID gives us a result.
+        if (m_curr_pid == LLDB_INVALID_PROCESS_ID && ostype == llvm::Triple::UnknownOS)
+        {
+            std::vector<lldb::tid_t> thread_ids;
+            bool sequence_mutex_unavailable;
+            size_t size;
+            size = GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable);
+            if (size && sequence_mutex_unavailable == false)
+            {
+                m_curr_pid = thread_ids.front();
+                m_curr_pid_is_valid = eLazyBoolYes;
+                return m_curr_pid;
+            }
+        }
     }
     
     return LLDB_INVALID_PROCESS_ID;
Index: source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
===================================================================
--- source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -542,7 +542,7 @@
         std::string error_str;
         if (m_gdb_client.GetLaunchSuccess (error_str))
         {
-            const auto pid = m_gdb_client.GetCurrentProcessID (false);
+            const lldb::pid_t pid = m_gdb_client.GetCurrentProcessID (false, arch_spec.GetTriple().getOS());
             if (pid != LLDB_INVALID_PROCESS_ID)
             {
                 launch_info.SetProcessID (pid);
_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to