diff options
author | Greg Clayton <gclayton@apple.com> | 2011-04-19 04:19:37 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-04-19 04:19:37 +0000 |
commit | 176761e530a96289fb5fed331272bc08ad4acf5b (patch) | |
tree | eabe10abbbacbef5722f61d5687b6d7cd2652286 /lldb/source/Core/SourceManager.cpp | |
parent | 7d6cd4902e9a26b61b65eada1fe8685fbb9e6bac (diff) | |
download | bcm5719-llvm-176761e530a96289fb5fed331272bc08ad4acf5b.tar.gz bcm5719-llvm-176761e530a96289fb5fed331272bc08ad4acf5b.zip |
Added a new option to the "source list" command that allows us to see where
line tables specify breakpoints can be set in the source. When dumping the
source, the number of breakpoints that can be set on a source line are shown
as a prefix:
(lldb) source list -f test.c -l1 -c222 -b
1 #include <stdio.h>
2 #include <sys/fcntl.h>
3 #include <unistd.h>
4 int
5 sleep_loop (const int num_secs)
[2] 6 {
7 int i;
[1] 8 for (i=0; i<num_secs; ++i)
9 {
[1] 10 printf("%d of %i - sleep(1);\n", i, num_secs);
[1] 11 sleep(1);
12 }
13 return 0;
[1] 14 }
15
16 int
17 main (int argc, char const* argv[])
[1] 18 {
[1] 19 printf("Process: %i\n\n", getpid());
[1] 20 puts("Press any key to continue..."); getchar();
[1] 21 sleep_loop (20);
22 return 12;
[1] 23 }
Above we can see there are two breakpoints for line 6 and one breakpoint for
lines 8, 10, 11, 14, 18, 19, 20, 21 and 23. All other lines have no line table
entries for them. This helps visualize the data provided in the debug
information without having to manually dump all line tables. It also includes
all inline breakpoint that may result for a given file which can also be very
handy to see.
llvm-svn: 129747
Diffstat (limited to 'lldb/source/Core/SourceManager.cpp')
-rw-r--r-- | lldb/source/Core/SourceManager.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index a43b592c231..04a0d766c0f 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -15,6 +15,7 @@ // Project includes #include "lldb/Core/DataBuffer.h" #include "lldb/Core/Stream.h" +#include "lldb/Symbol/SymbolContext.h" using namespace lldb_private; @@ -85,7 +86,8 @@ SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile uint32_t context_before, uint32_t context_after, const char* current_line_cstr, - Stream *s + Stream *s, + const SymbolContextList *bp_locs ) { if (line == 0) @@ -119,7 +121,21 @@ SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile break; } - s->Printf("%2.2s %-4u\t", curr_line == line ? current_line_cstr : "", curr_line); + char prefix[32] = ""; + if (bp_locs) + { + uint32_t bp_count = bp_locs->NumLineEntriesWithLine (curr_line); + + if (bp_count > 0) + ::snprintf (prefix, sizeof (prefix), "[%u] ", bp_count); + else + ::snprintf (prefix, sizeof (prefix), " "); + } + + s->Printf("%s%2.2s %-4u\t", + prefix, + curr_line == line ? current_line_cstr : "", + curr_line); if (m_last_file_sp->DisplaySourceLines (curr_line, 0, 0, s) == 0) { m_last_file_line = UINT32_MAX; @@ -138,7 +154,8 @@ SourceManager::DisplaySourceLinesWithLineNumbers uint32_t context_before, uint32_t context_after, const char* current_line_cstr, - Stream *s + Stream *s, + const SymbolContextList *bp_locs ) { bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec); @@ -152,17 +169,17 @@ SourceManager::DisplaySourceLinesWithLineNumbers m_last_file_line = 0; } - return DisplaySourceLinesWithLineNumbersUsingLastFile (line, context_before, context_after, current_line_cstr, s); + return DisplaySourceLinesWithLineNumbersUsingLastFile (line, context_before, context_after, current_line_cstr, s, bp_locs); } size_t -SourceManager::DisplayMoreWithLineNumbers (Stream *s) +SourceManager::DisplayMoreWithLineNumbers (Stream *s, const SymbolContextList *bp_locs) { if (m_last_file_sp) { if (m_last_file_line == UINT32_MAX) return 0; - DisplaySourceLinesWithLineNumbersUsingLastFile (0, m_last_file_context_before, m_last_file_context_after, "", s); + DisplaySourceLinesWithLineNumbersUsingLastFile (0, m_last_file_context_before, m_last_file_context_after, "", s, bp_locs); } return 0; } |