Skip to content

Commit cc39f34

Browse files
committed
[lldb] print a notice when source list paging reaches the end of the file
1 parent 46e7347 commit cc39f34

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

lldb/include/lldb/Core/SourceManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class SourceManager {
155155
~SourceManager();
156156

157157
FileSP GetLastFile() { return GetFile(m_last_support_file_sp); }
158+
uint32_t GetLastLine() { return m_last_line; }
158159

159160
size_t DisplaySourceLinesWithLineNumbers(
160161
lldb::SupportFileSP support_file_sp, uint32_t line, uint32_t column,

lldb/source/Commands/CommandObjectSource.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,16 @@ class CommandObjectSourceList : public CommandObjectParsed {
10671067
&result.GetOutputStream(), m_options.num_lines,
10681068
m_options.reverse, GetBreakpointLocations())) {
10691069
result.SetStatus(eReturnStatusSuccessFinishResult);
1070+
} else {
1071+
uint32_t last_line = target.GetSourceManager().GetLastLine();
1072+
if (last_line == UINT32_MAX ||
1073+
(last_line == 1 && m_options.reverse)) {
1074+
result.AppendNote("Reached end of the file, no more to page");
1075+
} else {
1076+
result.AppendNote("No source available");
1077+
}
10701078
}
1079+
10711080
} else {
10721081
if (m_options.num_lines == 0)
10731082
m_options.num_lines = 10;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
2+
# RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
3+
4+
list
5+
# CHECK: note: No source available
6+
7+
b main
8+
# CHECK: Breakpoint 1:
9+
10+
r
11+
# CHECK: int main()
12+
13+
list
14+
# CHECK: if (child_pid == 0)
15+
16+
list
17+
# CHECK: printf("signo = %d\n", SIGCHLD);
18+
19+
list
20+
# CHECK: return 0;
21+
22+
list
23+
# CHECK: note: Reached end of the file, no more to page

0 commit comments

Comments
 (0)