2010-06-09 00:52:24 +08:00
//===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
# include "CommandObjectSource.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
2010-06-16 03:49:27 +08:00
# include "lldb/Interpreter/Args.h"
2010-06-23 09:19:29 +08:00
# include "lldb/Core/Debugger.h"
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
# include "lldb/Core/FileLineResolver.h"
# include "lldb/Core/SourceManager.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Interpreter/CommandInterpreter.h"
# include "lldb/Interpreter/CommandReturnObject.h"
2011-02-08 13:05:52 +08:00
# include "lldb/Host/FileSpec.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Target/Process.h"
# include "lldb/Target/TargetList.h"
2010-07-07 11:36:20 +08:00
# include "lldb/Interpreter/CommandCompletions.h"
# include "lldb/Interpreter/Options.h"
2010-06-09 00:52:24 +08:00
using namespace lldb ;
using namespace lldb_private ;
//-------------------------------------------------------------------------
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
// CommandObjectSourceInfo
2010-06-09 00:52:24 +08:00
//-------------------------------------------------------------------------
2010-07-07 11:36:20 +08:00
class CommandObjectSourceInfo : public CommandObject
2010-06-09 00:52:24 +08:00
{
2010-07-07 11:36:20 +08:00
class CommandOptions : public Options
{
public :
2011-04-08 06:46:35 +08:00
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
2010-07-07 11:36:20 +08:00
{
}
~ CommandOptions ( )
{
}
Error
2011-04-13 08:18:08 +08:00
SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-07-07 11:36:20 +08:00
{
Error error ;
const char short_option = g_option_table [ option_idx ] . short_option ;
switch ( short_option )
{
case ' l ' :
start_line = Args : : StringToUInt32 ( option_arg , 0 ) ;
if ( start_line = = 0 )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid line number: '%s' " , option_arg ) ;
2010-07-07 11:36:20 +08:00
break ;
case ' f ' :
file_name = option_arg ;
break ;
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " unrecognized short option '%c' " , short_option ) ;
2010-07-07 11:36:20 +08:00
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
OptionParsingStarting ( )
2010-07-07 11:36:20 +08:00
{
file_spec . Clear ( ) ;
file_name . clear ( ) ;
start_line = 0 ;
}
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-07-07 11:36:20 +08:00
GetDefinitions ( )
{
return g_option_table ;
}
2011-03-25 05:19:54 +08:00
static OptionDefinition g_option_table [ ] ;
2010-07-07 11:36:20 +08:00
// Instance variables to hold the values for command options.
FileSpec file_spec ;
std : : string file_name ;
uint32_t start_line ;
} ;
public :
2010-09-18 09:14:36 +08:00
CommandObjectSourceInfo ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" source info " ,
" Display information about the source lines from the current executable's debug info. " ,
2011-04-08 06:46:35 +08:00
" source info [<cmd-options>] " ) ,
m_options ( interpreter )
2010-07-07 11:36:20 +08:00
{
}
~ CommandObjectSourceInfo ( )
{
}
Options *
GetOptions ( )
{
return & m_options ;
}
bool
Execute
(
Args & args ,
CommandReturnObject & result
)
{
result . AppendError ( " Not yet implemented " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
protected :
CommandOptions m_options ;
} ;
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-07-07 11:36:20 +08:00
CommandObjectSourceInfo : : CommandOptions : : g_option_table [ ] =
2010-06-09 00:52:24 +08:00
{
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_1 , false , " line " , ' l ' , required_argument , NULL , 0 , eArgTypeLineNum , " The line number at which to start the display source. " } ,
{ LLDB_OPT_SET_1 , false , " file " , ' f ' , required_argument , NULL , CommandCompletions : : eSourceFileCompletion , eArgTypeFilename , " The file from which to display source. " } ,
{ 0 , false , NULL , 0 , 0 , NULL , 0 , eArgTypeNone , NULL }
2010-07-07 11:36:20 +08:00
} ;
# pragma mark CommandObjectSourceList
//-------------------------------------------------------------------------
// CommandObjectSourceList
//-------------------------------------------------------------------------
2010-06-09 00:52:24 +08:00
2010-07-07 11:36:20 +08:00
class CommandObjectSourceList : public CommandObject
2010-06-09 00:52:24 +08:00
{
2010-07-07 11:36:20 +08:00
class CommandOptions : public Options
2010-06-09 00:52:24 +08:00
{
2010-07-07 11:36:20 +08:00
public :
2011-04-08 06:46:35 +08:00
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
2010-07-07 11:36:20 +08:00
{
}
2010-06-09 00:52:24 +08:00
2010-07-07 11:36:20 +08:00
~ CommandOptions ( )
{
}
2010-06-09 00:52:24 +08:00
2010-07-07 11:36:20 +08:00
Error
2011-04-13 08:18:08 +08:00
SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-06-09 00:52:24 +08:00
{
2010-07-07 11:36:20 +08:00
Error error ;
const char short_option = g_option_table [ option_idx ] . short_option ;
switch ( short_option )
{
case ' l ' :
start_line = Args : : StringToUInt32 ( option_arg , 0 ) ;
if ( start_line = = 0 )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid line number: '%s' " , option_arg ) ;
2010-07-07 11:36:20 +08:00
break ;
2010-06-09 00:52:24 +08:00
2010-08-20 09:17:07 +08:00
case ' c ' :
2010-07-07 11:36:20 +08:00
num_lines = Args : : StringToUInt32 ( option_arg , 0 ) ;
if ( num_lines = = 0 )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid line count: '%s' " , option_arg ) ;
2010-07-07 11:36:20 +08:00
break ;
2010-06-09 00:52:24 +08:00
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
case ' f ' :
2010-07-07 11:36:20 +08:00
file_name = option_arg ;
break ;
2010-08-20 09:17:07 +08:00
case ' n ' :
symbol_name = option_arg ;
break ;
2010-07-07 11:36:20 +08:00
2010-08-20 09:17:07 +08:00
case ' s ' :
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
modules . push_back ( std : : string ( option_arg ) ) ;
break ;
case ' b ' :
show_bp_locs = true ;
2010-08-20 09:17:07 +08:00
break ;
2010-07-07 11:36:20 +08:00
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " unrecognized short option '%c' " , short_option ) ;
2010-07-07 11:36:20 +08:00
break ;
2010-06-09 00:52:24 +08:00
}
2010-07-07 11:36:20 +08:00
return error ;
}
2010-06-09 00:52:24 +08:00
2010-07-07 11:36:20 +08:00
void
2011-04-13 08:18:08 +08:00
OptionParsingStarting ( )
2010-07-07 11:36:20 +08:00
{
file_spec . Clear ( ) ;
file_name . clear ( ) ;
2010-08-20 09:17:07 +08:00
symbol_name . clear ( ) ;
2010-07-07 11:36:20 +08:00
start_line = 0 ;
num_lines = 10 ;
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
show_bp_locs = false ;
modules . clear ( ) ;
2010-07-07 11:36:20 +08:00
}
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-07-07 11:36:20 +08:00
GetDefinitions ( )
{
return g_option_table ;
}
2011-03-25 05:19:54 +08:00
static OptionDefinition g_option_table [ ] ;
2010-07-07 11:36:20 +08:00
// Instance variables to hold the values for command options.
FileSpec file_spec ;
std : : string file_name ;
2010-08-20 09:17:07 +08:00
std : : string symbol_name ;
2010-07-07 11:36:20 +08:00
uint32_t start_line ;
uint32_t num_lines ;
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
STLStringArray modules ;
bool show_bp_locs ;
2010-07-07 11:36:20 +08:00
} ;
public :
2010-09-18 09:14:36 +08:00
CommandObjectSourceList ( CommandInterpreter & interpreter ) :
CommandObject ( interpreter ,
" source list " ,
" Display source code (as specified) based on the current executable's debug info. " ,
2011-04-08 06:46:35 +08:00
NULL ) ,
m_options ( interpreter )
2010-07-07 11:36:20 +08:00
{
2010-10-05 06:28:36 +08:00
CommandArgumentEntry arg ;
CommandArgumentData file_arg ;
// Define the first (and only) variant of this arg.
file_arg . arg_type = eArgTypeFilename ;
file_arg . arg_repetition = eArgRepeatOptional ;
// There is only one variant this argument could be; put it into the argument entry.
arg . push_back ( file_arg ) ;
// Push the data for the first argument into the m_arguments vector.
m_arguments . push_back ( arg ) ;
2010-07-07 11:36:20 +08:00
}
~ CommandObjectSourceList ( )
{
}
Options *
GetOptions ( )
{
return & m_options ;
}
bool
Execute
(
Args & args ,
CommandReturnObject & result
)
{
const int argc = args . GetArgumentCount ( ) ;
if ( argc ! = 0 )
{
result . AppendErrorWithFormat ( " '%s' takes no arguments, only flags. \n " , GetCommandName ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
2011-11-30 05:21:26 +08:00
return false ;
2010-07-07 11:36:20 +08:00
}
2011-04-12 13:54:46 +08:00
ExecutionContext exe_ctx ( m_interpreter . GetExecutionContext ( ) ) ;
2011-09-22 12:58:26 +08:00
Target * target = exe_ctx . GetTargetPtr ( ) ;
2011-09-09 06:13:49 +08:00
2011-09-22 12:58:26 +08:00
if ( target = = NULL )
2011-09-09 06:13:49 +08:00
target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
if ( target = = NULL )
{
result . AppendError ( " invalid target, create a debug target using the 'target create' command " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-08-20 09:17:07 +08:00
if ( ! m_options . symbol_name . empty ( ) )
{
// Displaying the source for a symbol:
SymbolContextList sc_list ;
ConstString name ( m_options . symbol_name . c_str ( ) ) ;
2011-01-27 14:44:37 +08:00
bool include_symbols = false ;
2012-02-11 06:52:19 +08:00
bool include_inlines = true ;
2010-08-20 09:17:07 +08:00
bool append = true ;
size_t num_matches = 0 ;
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
if ( m_options . modules . size ( ) > 0 )
2010-08-20 09:17:07 +08:00
{
ModuleList matching_modules ;
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
for ( unsigned i = 0 , e = m_options . modules . size ( ) ; i ! = e ; i + + )
2010-08-20 09:17:07 +08:00
{
2012-02-26 13:51:37 +08:00
FileSpec module_file_spec ( m_options . modules [ i ] . c_str ( ) , false ) ;
if ( module_file_spec )
2010-08-20 09:17:07 +08:00
{
2012-02-26 13:51:37 +08:00
ModuleSpec module_spec ( module_file_spec ) ;
2010-08-20 09:17:07 +08:00
matching_modules . Clear ( ) ;
2012-02-26 13:51:37 +08:00
target - > GetImages ( ) . FindModules ( module_spec , matching_modules ) ;
2012-02-11 06:52:19 +08:00
num_matches + = matching_modules . FindFunctions ( name , eFunctionNameTypeAuto , include_symbols , include_inlines , append , sc_list ) ;
2010-08-20 09:17:07 +08:00
}
}
}
else
{
2012-02-11 06:52:19 +08:00
num_matches = target - > GetImages ( ) . FindFunctions ( name , eFunctionNameTypeAuto , include_symbols , include_inlines , append , sc_list ) ;
2010-08-20 09:17:07 +08:00
}
SymbolContext sc ;
if ( num_matches = = 0 )
{
result . AppendErrorWithFormat ( " Could not find function named: \" %s \" . \n " , m_options . symbol_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
sc_list . GetContextAtIndex ( 0 , sc ) ;
FileSpec start_file ;
uint32_t start_line ;
uint32_t end_line ;
FileSpec end_file ;
if ( sc . function ! = NULL )
{
sc . function - > GetStartLineSourceInfo ( start_file , start_line ) ;
if ( start_line = = 0 )
{
result . AppendErrorWithFormat ( " Could not find line information for start of function: \" %s \" . \n " , m_options . symbol_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
sc . function - > GetEndLineSourceInfo ( end_file , end_line ) ;
}
else
{
result . AppendErrorWithFormat ( " Could not find function info for: \" %s \" . \n " , m_options . symbol_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( num_matches > 1 )
{
// This could either be because there are multiple functions of this name, in which case
// we'll have to specify this further... Or it could be because there are multiple inlined instances
// of one function. So run through the matches and if they all have the same file & line then we can just
// list one.
bool found_multiple = false ;
for ( size_t i = 1 ; i < num_matches ; i + + )
{
SymbolContext scratch_sc ;
sc_list . GetContextAtIndex ( i , scratch_sc ) ;
if ( scratch_sc . function ! = NULL )
{
FileSpec scratch_file ;
uint32_t scratch_line ;
scratch_sc . function - > GetStartLineSourceInfo ( scratch_file , scratch_line ) ;
if ( scratch_file ! = start_file
| | scratch_line ! = start_line )
{
found_multiple = true ;
break ;
}
}
}
if ( found_multiple )
{
StreamString s ;
for ( size_t i = 0 ; i < num_matches ; i + + )
{
SymbolContext scratch_sc ;
sc_list . GetContextAtIndex ( i , scratch_sc ) ;
if ( scratch_sc . function ! = NULL )
{
2011-09-21 05:44:10 +08:00
s . Printf ( " \n %lu: " , i ) ;
2010-08-20 09:17:07 +08:00
scratch_sc . function - > Dump ( & s , true ) ;
}
}
result . AppendErrorWithFormat ( " Multiple functions found matching: %s: \n %s \n " ,
m_options . symbol_name . c_str ( ) ,
s . GetData ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
// This is a little hacky, but the first line table entry for a function points to the "{" that
// starts the function block. It would be nice to actually get the function
// declaration in there too. So back up a bit, but not further than what you're going to display.
size_t lines_to_back_up = m_options . num_lines > = 10 ? 5 : m_options . num_lines / 2 ;
uint32_t line_no ;
if ( start_line < = lines_to_back_up )
line_no = 1 ;
else
line_no = start_line - lines_to_back_up ;
// For fun, if the function is shorter than the number of lines we're supposed to display,
// only display the function...
if ( end_line ! = 0 )
{
if ( m_options . num_lines > end_line - line_no )
m_options . num_lines = end_line - line_no ;
}
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
char path_buf [ PATH_MAX ] ;
start_file . GetPath ( path_buf , sizeof ( path_buf ) ) ;
2011-04-21 02:52:45 +08:00
2011-09-09 06:13:49 +08:00
if ( m_options . show_bp_locs )
2011-04-21 02:52:45 +08:00
{
const bool show_inlines = true ;
m_breakpoint_locations . Reset ( start_file , 0 , show_inlines ) ;
2011-09-22 12:58:26 +08:00
SearchFilter target_search_filter ( exe_ctx . GetTargetSP ( ) ) ;
2011-04-21 02:52:45 +08:00
target_search_filter . Search ( m_breakpoint_locations ) ;
}
else
m_breakpoint_locations . Clear ( ) ;
2010-08-20 09:17:07 +08:00
result . AppendMessageWithFormat ( " File: %s. \n " , path_buf ) ;
2011-09-09 06:13:49 +08:00
target - > GetSourceManager ( ) . DisplaySourceLinesWithLineNumbers ( start_file ,
line_no ,
0 ,
m_options . num_lines ,
" " ,
& result . GetOutputStream ( ) ,
GetBreakpointLocations ( ) ) ;
2010-08-20 09:17:07 +08:00
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
return true ;
}
else if ( m_options . file_name . empty ( ) )
2010-07-07 11:36:20 +08:00
{
// Last valid source manager context, or the current frame if no
// valid last context in source manager.
// One little trick here, if you type the exact same list command twice in a row, it is
// more likely because you typed it once, then typed it again
if ( m_options . start_line = = 0 )
{
2011-09-30 04:22:33 +08:00
if ( target - > GetSourceManager ( ) . DisplayMoreWithLineNumbers ( & result . GetOutputStream ( ) ,
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
GetBreakpointLocations ( ) ) )
2010-06-09 00:52:24 +08:00
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
2010-07-07 11:36:20 +08:00
}
else
{
2011-09-09 06:13:49 +08:00
if ( m_options . show_bp_locs )
2011-04-21 02:52:45 +08:00
{
2011-09-09 06:13:49 +08:00
SourceManager : : FileSP last_file_sp ( target - > GetSourceManager ( ) . GetLastFile ( ) ) ;
2011-04-21 02:52:45 +08:00
if ( last_file_sp )
{
const bool show_inlines = true ;
m_breakpoint_locations . Reset ( last_file_sp - > GetFileSpec ( ) , 0 , show_inlines ) ;
2012-01-30 04:56:30 +08:00
SearchFilter target_search_filter ( target - > shared_from_this ( ) ) ;
2011-04-21 02:52:45 +08:00
target_search_filter . Search ( m_breakpoint_locations ) ;
}
}
else
m_breakpoint_locations . Clear ( ) ;
2011-09-09 06:13:49 +08:00
if ( target - > GetSourceManager ( ) . DisplaySourceLinesWithLineNumbersUsingLastFile (
2010-07-07 11:36:20 +08:00
m_options . start_line , // Line to display
0 , // Lines before line to display
m_options . num_lines , // Lines after line to display
" " , // Don't mark "line"
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
& result . GetOutputStream ( ) ,
GetBreakpointLocations ( ) ) )
2010-06-09 00:52:24 +08:00
{
2010-07-07 11:36:20 +08:00
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
2010-06-09 00:52:24 +08:00
}
2010-07-07 11:36:20 +08:00
2010-06-09 00:52:24 +08:00
}
}
else
{
2010-07-07 11:36:20 +08:00
const char * filename = m_options . file_name . c_str ( ) ;
bool check_inlines = false ;
SymbolContextList sc_list ;
2010-08-20 09:17:07 +08:00
size_t num_matches = 0 ;
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
if ( m_options . modules . size ( ) > 0 )
2010-08-20 09:17:07 +08:00
{
ModuleList matching_modules ;
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
for ( unsigned i = 0 , e = m_options . modules . size ( ) ; i ! = e ; i + + )
2010-08-20 09:17:07 +08:00
{
2012-02-26 13:51:37 +08:00
FileSpec module_file_spec ( m_options . modules [ i ] . c_str ( ) , false ) ;
if ( module_file_spec )
2010-08-20 09:17:07 +08:00
{
2012-02-26 13:51:37 +08:00
ModuleSpec module_spec ( module_file_spec ) ;
2010-08-20 09:17:07 +08:00
matching_modules . Clear ( ) ;
2012-02-26 13:51:37 +08:00
target - > GetImages ( ) . FindModules ( module_spec , matching_modules ) ;
2010-08-20 09:17:07 +08:00
num_matches + = matching_modules . ResolveSymbolContextForFilePath ( filename ,
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
0 ,
check_inlines ,
eSymbolContextModule | eSymbolContextCompUnit ,
sc_list ) ;
2010-08-20 09:17:07 +08:00
}
}
}
else
{
num_matches = target - > GetImages ( ) . ResolveSymbolContextForFilePath ( filename ,
0 ,
check_inlines ,
eSymbolContextModule | eSymbolContextCompUnit ,
sc_list ) ;
}
if ( num_matches = = 0 )
{
result . AppendErrorWithFormat ( " Could not find source file \" %s \" . \n " ,
m_options . file_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( num_matches > 1 )
2010-07-07 11:36:20 +08:00
{
SymbolContext sc ;
2010-08-20 09:17:07 +08:00
bool got_multiple = false ;
FileSpec * test_cu_spec = NULL ;
2010-09-09 06:55:31 +08:00
for ( unsigned i = 0 ; i < num_matches ; i + + )
2010-07-07 11:36:20 +08:00
{
2010-08-20 09:17:07 +08:00
sc_list . GetContextAtIndex ( i , sc ) ;
2010-07-07 11:36:20 +08:00
if ( sc . comp_unit )
{
2010-08-20 09:17:07 +08:00
if ( test_cu_spec )
{
if ( test_cu_spec ! = static_cast < FileSpec * > ( sc . comp_unit ) )
got_multiple = true ;
break ;
}
else
test_cu_spec = sc . comp_unit ;
2010-07-07 11:36:20 +08:00
}
}
2010-08-20 09:17:07 +08:00
if ( got_multiple )
{
result . AppendErrorWithFormat ( " Multiple source files found matching: \" %s. \" \n " ,
m_options . file_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
SymbolContext sc ;
if ( sc_list . GetContextAtIndex ( 0 , sc ) )
{
if ( sc . comp_unit )
{
2011-09-09 06:13:49 +08:00
if ( m_options . show_bp_locs )
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
{
const bool show_inlines = true ;
m_breakpoint_locations . Reset ( * sc . comp_unit , 0 , show_inlines ) ;
2012-01-30 04:56:30 +08:00
SearchFilter target_search_filter ( target - > shared_from_this ( ) ) ;
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
target_search_filter . Search ( m_breakpoint_locations ) ;
}
else
m_breakpoint_locations . Clear ( ) ;
2011-09-09 06:13:49 +08:00
target - > GetSourceManager ( ) . DisplaySourceLinesWithLineNumbers ( sc . comp_unit ,
m_options . start_line ,
0 ,
m_options . num_lines ,
" " ,
& result . GetOutputStream ( ) ,
GetBreakpointLocations ( ) ) ;
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
2010-08-20 09:17:07 +08:00
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " No comp unit found for: \" %s. \" \n " ,
m_options . file_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2010-07-07 11:36:20 +08:00
}
2010-06-09 00:52:24 +08:00
}
2010-07-07 11:36:20 +08:00
return result . Succeeded ( ) ;
2010-06-09 00:52:24 +08:00
}
2010-07-07 11:36:20 +08:00
virtual const char * GetRepeatCommand ( Args & current_command_args , uint32_t index )
2010-06-09 00:52:24 +08:00
{
2010-07-07 11:36:20 +08:00
return m_cmd_name . c_str ( ) ;
2010-06-09 00:52:24 +08:00
}
2010-07-07 11:36:20 +08:00
protected :
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
const SymbolContextList *
GetBreakpointLocations ( )
{
if ( m_breakpoint_locations . GetFileLineMatches ( ) . GetSize ( ) > 0 )
return & m_breakpoint_locations . GetFileLineMatches ( ) ;
return NULL ;
}
2010-07-07 11:36:20 +08:00
CommandOptions m_options ;
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
FileLineResolver m_breakpoint_locations ;
2010-07-07 11:36:20 +08:00
} ;
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-07-07 11:36:20 +08:00
CommandObjectSourceList : : CommandOptions : : g_option_table [ ] =
{
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_ALL , false , " count " , ' c ' , required_argument , NULL , 0 , eArgTypeCount , " The number of source lines to display. " } ,
{ LLDB_OPT_SET_ALL , false , " shlib " , ' s ' , required_argument , NULL , CommandCompletions : : eModuleCompletion , eArgTypeShlibName , " Look up the source file in the given shared library. " } ,
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
{ LLDB_OPT_SET_ALL , false , " show-breakpoints " , ' b ' , no_argument , NULL , 0 , eArgTypeNone , " Show the line table locations from the debug information that indicate valid places to set source level breakpoints. " } ,
2010-10-02 03:59:14 +08:00
{ LLDB_OPT_SET_1 , false , " file " , ' f ' , required_argument , NULL , CommandCompletions : : eSourceFileCompletion , eArgTypeFilename , " The file from which to display source. " } ,
{ LLDB_OPT_SET_1 , false , " line " , ' l ' , required_argument , NULL , 0 , eArgTypeLineNum , " The line number at which to start the display source. " } ,
{ LLDB_OPT_SET_2 , false , " name " , ' n ' , required_argument , NULL , CommandCompletions : : eSymbolCompletion , eArgTypeSymbol , " The name of a function whose source to display. " } ,
{ 0 , false , NULL , 0 , 0 , NULL , 0 , eArgTypeNone , NULL }
2010-07-07 11:36:20 +08:00
} ;
# pragma mark CommandObjectMultiwordSource
//-------------------------------------------------------------------------
// CommandObjectMultiwordSource
//-------------------------------------------------------------------------
CommandObjectMultiwordSource : : CommandObjectMultiwordSource ( CommandInterpreter & interpreter ) :
2010-09-18 09:14:36 +08:00
CommandObjectMultiword ( interpreter ,
" source " ,
2010-09-08 06:38:08 +08:00
" A set of commands for accessing source file information " ,
2010-07-07 11:36:20 +08:00
" source <subcommand> [<subcommand-options>] " )
{
2010-09-18 09:14:36 +08:00
LoadSubCommand ( " info " , CommandObjectSP ( new CommandObjectSourceInfo ( interpreter ) ) ) ;
LoadSubCommand ( " list " , CommandObjectSP ( new CommandObjectSourceList ( interpreter ) ) ) ;
2010-07-07 11:36:20 +08:00
}
CommandObjectMultiwordSource : : ~ CommandObjectMultiwordSource ( )
{
2010-06-09 00:52:24 +08:00
}
2010-07-07 11:36:20 +08:00