Skip to content

[lldb] Add missing return statements in ThreadMemory #126128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

felipepiovezan
Copy link
Contributor

These prevented ThreadMemory from correctly returning the Name/Queue/Info of the backing thread.

Note about testing: this test only finds regressions if the system sets a name or queue for the backing thread. While this may not be true everywhere, it still provides coverage in some systems, e.g. in Apple platforms.

These prevented ThreadMemory from correctly returning the
Name/Queue/Info of the backing thread.

Note about testing: this test only finds regressions if the system sets
a name or queue for the backing thread. While this may not be true
everywhere, it still provides coverage in some systems, e.g. in Apple
platforms.
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

Changes

These prevented ThreadMemory from correctly returning the Name/Queue/Info of the backing thread.

Note about testing: this test only finds regressions if the system sets a name or queue for the backing thread. While this may not be true everywhere, it still provides coverage in some systems, e.g. in Apple platforms.


Full diff: https://github.com/llvm/llvm-project/pull/126128.diff

2 Files Affected:

  • (modified) lldb/source/Plugins/Process/Utility/ThreadMemory.h (+3-3)
  • (modified) lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py (+6)
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.h b/lldb/source/Plugins/Process/Utility/ThreadMemory.h
index 1e309671e85c653..cebb31538eaf20c 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.h
@@ -33,7 +33,7 @@ class ThreadMemory : public lldb_private::Thread {
 
   const char *GetInfo() override {
     if (m_backing_thread_sp)
-      m_backing_thread_sp->GetInfo();
+      return m_backing_thread_sp->GetInfo();
     return nullptr;
   }
 
@@ -41,7 +41,7 @@ class ThreadMemory : public lldb_private::Thread {
     if (!m_name.empty())
       return m_name.c_str();
     if (m_backing_thread_sp)
-      m_backing_thread_sp->GetName();
+      return m_backing_thread_sp->GetName();
     return nullptr;
   }
 
@@ -49,7 +49,7 @@ class ThreadMemory : public lldb_private::Thread {
     if (!m_queue.empty())
       return m_queue.c_str();
     if (m_backing_thread_sp)
-      m_backing_thread_sp->GetQueueName();
+      return m_backing_thread_sp->GetQueueName();
     return nullptr;
   }
 
diff --git a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
index 3ad7539018d5d83..fe78edd98f4d4be 100644
--- a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
+++ b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -160,6 +160,8 @@ def run_python_os_step(self):
         )
         self.assertTrue(process, PROCESS_IS_VALID)
 
+        core_thread_zero = process.GetThreadAtIndex(0)
+
         # Make sure there are no OS plug-in created thread when we first stop
         # at our breakpoint in main
         thread = process.GetThreadByID(0x111111111)
@@ -183,6 +185,10 @@ def run_python_os_step(self):
             thread.IsValid(),
             "Make sure there is a thread 0x111111111 after we load the python OS plug-in",
         )
+        # This OS plugin does not set thread names / queue names, so it should
+        # inherit the core thread's name.
+        self.assertEqual(core_thread_zero.GetName(), thread.GetName())
+        self.assertEqual(core_thread_zero.GetQueueName(), thread.GetQueueName())
 
         frame = thread.GetFrameAtIndex(0)
         self.assertTrue(

Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was clearly wrong. Thanks for adding the test.

@felipepiovezan felipepiovezan merged commit b800293 into llvm:main Feb 6, 2025
7 of 8 checks passed
@felipepiovezan felipepiovezan deleted the felipe/fix_thread_missing_return branch February 6, 2025 23:59
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request Feb 7, 2025
These prevented ThreadMemory from correctly returning the
Name/Queue/Info of the backing thread.

Note about testing: this test only finds regressions if the system sets
a name or queue for the backing thread. While this may not be true
everywhere, it still provides coverage in some systems, e.g. in Apple
platforms.

(cherry picked from commit b800293)
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
These prevented ThreadMemory from correctly returning the
Name/Queue/Info of the backing thread.

Note about testing: this test only finds regressions if the system sets
a name or queue for the backing thread. While this may not be true
everywhere, it still provides coverage in some systems, e.g. in Apple
platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants