[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)

via lldb-commits lldb-commits at lists.llvm.org
Sun Apr 27 06:46:29 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (hapeeeeee)

<details>
<summary>Changes</summary>

This PR fixes the issue where the `list` command does not output a prompt when reaching the end of the file.  
Closes #<!-- -->128507.

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


2 Files Affected:

- (modified) lldb/source/Core/SourceManager.cpp (+5-2) 
- (added) lldb/test/Shell/Commands/command-list-reach-end-of-file.test (+16) 


``````````diff
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index d63d42de14e80..b57d8b3e20316 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -360,8 +360,11 @@ size_t SourceManager::DisplayMoreWithLineNumbers(
     GetDefaultFileAndLine();
 
   if (last_file_sp) {
-    if (m_last_line == UINT32_MAX)
-      return 0;
+    if (m_last_line == UINT32_MAX) {
+      Stream::ByteDelta delta(*s);
+      s->Printf("note: reached the end of current file, no more to page\n");
+      return *delta;
+    }
 
     if (reverse && m_last_line == 1)
       return 0;
diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
new file mode 100644
index 0000000000000..61237ce4af542
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
@@ -0,0 +1,16 @@
+# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %lldb %t.out -b -s %s | FileCheck %s
+
+b main
+r
+list
+# CHECK: assert (child_pid != -1);
+
+list
+# CHECK: printf("signo = %d\n", SIGCHLD);
+
+list 
+# CHECK: return 0;
+
+list 
+# CHECK: note: reached the end of current file, no more to page

``````````

</details>


https://github.com/llvm/llvm-project/pull/137515


More information about the lldb-commits mailing list