2010-06-09 00:52:24 +08:00
|
|
|
//===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Core/AddressResolverFileLine.h"
|
|
|
|
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/Core/Log.h"
|
|
|
|
#include "lldb/Core/StreamString.h"
|
|
|
|
#include "lldb/lldb-private-log.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// AddressResolverFileLine:
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
AddressResolverFileLine::AddressResolverFileLine
|
|
|
|
(
|
|
|
|
const FileSpec &file_spec,
|
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
2011-04-19 12:19:37 +08:00
|
|
|
uint32_t line_no,
|
2010-06-09 00:52:24 +08:00
|
|
|
bool check_inlines
|
|
|
|
) :
|
|
|
|
AddressResolver (),
|
|
|
|
m_file_spec (file_spec),
|
|
|
|
m_line_number (line_no),
|
|
|
|
m_inlines (check_inlines)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AddressResolverFileLine::~AddressResolverFileLine ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Searcher::CallbackReturn
|
|
|
|
AddressResolverFileLine::SearchCallback
|
|
|
|
(
|
|
|
|
SearchFilter &filter,
|
|
|
|
SymbolContext &context,
|
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
2011-04-19 12:19:37 +08:00
|
|
|
Address *addr,
|
2010-06-09 00:52:24 +08:00
|
|
|
bool containing
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SymbolContextList sc_list;
|
|
|
|
uint32_t sc_list_size;
|
|
|
|
CompileUnit *cu = context.comp_unit;
|
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything,
|
|
|
|
sc_list);
|
2010-07-10 04:39:50 +08:00
|
|
|
for (uint32_t i = 0; i < sc_list_size; i++)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
if (sc_list.GetContextAtIndex(i, sc))
|
|
|
|
{
|
|
|
|
Address line_start = sc.line_entry.range.GetBaseAddress();
|
|
|
|
addr_t byte_size = sc.line_entry.range.GetByteSize();
|
|
|
|
if (line_start.IsValid())
|
|
|
|
{
|
|
|
|
AddressRange new_range (line_start, byte_size);
|
|
|
|
m_address_ranges.push_back (new_range);
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString s;
|
|
|
|
//new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
|
|
|
|
//log->Printf ("Added address: %s\n", s.GetData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf ("error: Unable to resolve address at file address 0x%llx for %s:%d\n",
|
|
|
|
line_start.GetFileAddress(),
|
|
|
|
m_file_spec.GetFilename().AsCString("<Unknown>"),
|
|
|
|
m_line_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Searcher::eCallbackReturnContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Searcher::Depth
|
|
|
|
AddressResolverFileLine::GetDepth()
|
|
|
|
{
|
|
|
|
return Searcher::eDepthCompUnit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AddressResolverFileLine::GetDescription (Stream *s)
|
|
|
|
{
|
|
|
|
s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(), m_line_number);
|
|
|
|
}
|
|
|
|
|
|
|
|
|