2011-07-19 07:11:07 +08:00
//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
//
2019-01-19 16:50:56 +08:00
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2011-07-19 07:11:07 +08:00
//
//===----------------------------------------------------------------------===//
n a m e s p a c e l l d b {
2019-02-27 22:16:48 +08:00
% p y t h o n c o d e % {
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# H e l p e r function for S B M o d u l e class
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
def i n _ r a n g e ( s y m b o l , section ) :
"" "Test whether a symbol is within the range of a section." ""
s y m S A = s y m b o l . G e t S t a r t A d d r e s s ( ) . G e t F i l e A d d r e s s ( )
s y m E A = s y m b o l . G e t E n d A d d r e s s ( ) . G e t F i l e A d d r e s s ( )
s e c S A = section . G e t F i l e A d d r e s s ( )
s e c E A = s e c S A + section . G e t B y t e S i z e ( )
if s y m E A ! = L L D B _ I N V A L I D _ A D D R E S S :
if s e c S A < = s y m S A and s y m E A < = s e c E A :
return True
else :
return False
else :
if s e c S A < = s y m S A and s y m S A < s e c E A :
return True
else :
return False
% }
2011-07-19 07:11:07 +08:00
% f e a t u r e ( "docstring" ,
" R e p r e s e n t s a n e x e c u t a b l e image and i t s a s s o c i a t e d o b j e c t and s y m b o l f i l e s .
T h e m o d u l e is d e s i g n e d to b e a b l e to select a single s l i c e of a n
e x e c u t a b l e image as i t w o u l d a p p e a r on d i s k and d u r i n g p r o g r a m
e x e c u t i o n .
Y o u c a n r e t r i e v e S B M o d u l e from S B S y m b o l C o n t e x t , w h i c h in t u r n is available
from S B F r a m e .
S B M o d u l e s u p p o r t s s y m b o l i t e r a t i o n , for e x a m p l e ,
for s y m b o l in m o d u l e :
name = s y m b o l . G e t N a m e ( )
s a d d r = s y m b o l . G e t S t a r t A d d r e s s ( )
e a d d r = s y m b o l . G e t E n d A d d r e s s ( )
2017-07-19 17:35:58 +08:00
and r i c h c o m p a r i s o n m e t h o d s w h i c h a l l o w t h e A P I p r o g r a m to use ,
2011-07-19 07:11:07 +08:00
if t h i s M o d u l e = = t h a t M o d u l e :
2015-10-17 01:52:32 +08:00
p r i n t ( 'This module is the same as that module' )
2011-07-19 07:11:07 +08:00
2011-09-24 12:51:43 +08:00
to t e s t m o d u l e e q u a l i t y . A m o d u l e a l s o contains o b j e c t file s e c t i o n s , n a m e l y
Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in
the lldb module. And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter(). Example:
# Iterates the text section and prints each symbols within each sub-section.
for subsec in text_sec:
print INDENT + repr(subsec)
for sym in exe_module.symbol_in_section_iter(subsec):
print INDENT2 + repr(sym)
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
might produce this following output:
[0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
symbol type: code
id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
symbol type: code
id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
symbol type: code
id = {0x00000023}, name = 'start', address = 0x0000000100001780
symbol type: code
[0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
symbol type: trampoline
id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
symbol type: trampoline
id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
symbol type: trampoline
id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
symbol type: trampoline
id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
symbol type: trampoline
id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
symbol type: trampoline
id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
symbol type: trampoline
id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
symbol type: trampoline
id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
symbol type: trampoline
id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
symbol type: trampoline
id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
symbol type: trampoline
id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
symbol type: trampoline
[0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
[0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
[0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
[0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
llvm-svn: 140830
2011-09-30 08:42:49 +08:00
S B S e c t i o n . S B M o d u l e s u p p o r t s section i t e r a t i o n through s e c t i o n _ i t e r ( ) , for
e x a m p l e ,
2015-10-17 01:52:32 +08:00
p r i n t ( 'Number of sections: %d' % m o d u l e . G e t N u m S e c t i o n s ( ) )
Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in
the lldb module. And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter(). Example:
# Iterates the text section and prints each symbols within each sub-section.
for subsec in text_sec:
print INDENT + repr(subsec)
for sym in exe_module.symbol_in_section_iter(subsec):
print INDENT2 + repr(sym)
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
might produce this following output:
[0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
symbol type: code
id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
symbol type: code
id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
symbol type: code
id = {0x00000023}, name = 'start', address = 0x0000000100001780
symbol type: code
[0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
symbol type: trampoline
id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
symbol type: trampoline
id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
symbol type: trampoline
id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
symbol type: trampoline
id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
symbol type: trampoline
id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
symbol type: trampoline
id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
symbol type: trampoline
id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
symbol type: trampoline
id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
symbol type: trampoline
id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
symbol type: trampoline
id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
symbol type: trampoline
id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
symbol type: trampoline
[0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
[0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
[0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
[0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
llvm-svn: 140830
2011-09-30 08:42:49 +08:00
for s e c in m o d u l e . s e c t i o n _ i t e r ( ) :
2015-10-17 01:52:32 +08:00
p r i n t ( s e c )
Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in
the lldb module. And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter(). Example:
# Iterates the text section and prints each symbols within each sub-section.
for subsec in text_sec:
print INDENT + repr(subsec)
for sym in exe_module.symbol_in_section_iter(subsec):
print INDENT2 + repr(sym)
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
might produce this following output:
[0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
symbol type: code
id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
symbol type: code
id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
symbol type: code
id = {0x00000023}, name = 'start', address = 0x0000000100001780
symbol type: code
[0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
symbol type: trampoline
id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
symbol type: trampoline
id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
symbol type: trampoline
id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
symbol type: trampoline
id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
symbol type: trampoline
id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
symbol type: trampoline
id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
symbol type: trampoline
id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
symbol type: trampoline
id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
symbol type: trampoline
id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
symbol type: trampoline
id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
symbol type: trampoline
id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
symbol type: trampoline
[0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
[0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
[0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
[0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
llvm-svn: 140830
2011-09-30 08:42:49 +08:00
And to i t e r a t e t h e s y m b o l s w i t h i n a S B S e c t i o n , use s y m b o l _ i n _ s e c t i o n _ i t e r ( ) ,
# I t e r a t e s t h e text section and p r i n t s each s y m b o l s w i t h i n each s u b - s e c t i o n .
for s u b s e c in t e x t _ s e c :
2015-10-17 01:52:32 +08:00
p r i n t ( I N D E N T + r e p r ( s u b s e c ) )
Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in
the lldb module. And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter(). Example:
# Iterates the text section and prints each symbols within each sub-section.
for subsec in text_sec:
print INDENT + repr(subsec)
for sym in exe_module.symbol_in_section_iter(subsec):
print INDENT2 + repr(sym)
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
might produce this following output:
[0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
symbol type: code
id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
symbol type: code
id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
symbol type: code
id = {0x00000023}, name = 'start', address = 0x0000000100001780
symbol type: code
[0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
symbol type: trampoline
id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
symbol type: trampoline
id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
symbol type: trampoline
id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
symbol type: trampoline
id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
symbol type: trampoline
id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
symbol type: trampoline
id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
symbol type: trampoline
id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
symbol type: trampoline
id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
symbol type: trampoline
id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
symbol type: trampoline
id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
symbol type: trampoline
id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
symbol type: trampoline
[0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
[0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
[0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
[0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
llvm-svn: 140830
2011-09-30 08:42:49 +08:00
for s y m in e x e _ m o d u l e . s y m b o l _ i n _ s e c t i o n _ i t e r ( s u b s e c ) :
2015-10-17 01:52:32 +08:00
p r i n t ( I N D E N T 2 + r e p r ( s y m ) )
p r i n t ( I N D E N T 2 + 'symbol type: %s' % s y m b o l _ t y p e _ t o _ s t r ( s y m . G e t T y p e ( ) ) )
Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in
the lldb module. And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter(). Example:
# Iterates the text section and prints each symbols within each sub-section.
for subsec in text_sec:
print INDENT + repr(subsec)
for sym in exe_module.symbol_in_section_iter(subsec):
print INDENT2 + repr(sym)
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
might produce this following output:
[0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
symbol type: code
id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
symbol type: code
id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
symbol type: code
id = {0x00000023}, name = 'start', address = 0x0000000100001780
symbol type: code
[0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
symbol type: trampoline
id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
symbol type: trampoline
id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
symbol type: trampoline
id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
symbol type: trampoline
id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
symbol type: trampoline
id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
symbol type: trampoline
id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
symbol type: trampoline
id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
symbol type: trampoline
id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
symbol type: trampoline
id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
symbol type: trampoline
id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
symbol type: trampoline
id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
symbol type: trampoline
[0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
[0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
[0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
[0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
llvm-svn: 140830
2011-09-30 08:42:49 +08:00
2011-10-01 09:19:45 +08:00
p r o d u c e s t h i s f o l l o w i n g output :
Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in
the lldb module. And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter(). Example:
# Iterates the text section and prints each symbols within each sub-section.
for subsec in text_sec:
print INDENT + repr(subsec)
for sym in exe_module.symbol_in_section_iter(subsec):
print INDENT2 + repr(sym)
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
might produce this following output:
[0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
symbol type: code
id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
symbol type: code
id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
symbol type: code
id = {0x00000023}, name = 'start', address = 0x0000000100001780
symbol type: code
[0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
symbol type: trampoline
id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
symbol type: trampoline
id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
symbol type: trampoline
id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
symbol type: trampoline
id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
symbol type: trampoline
id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
symbol type: trampoline
id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
symbol type: trampoline
id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
symbol type: trampoline
id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
symbol type: trampoline
id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
symbol type: trampoline
id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
symbol type: trampoline
id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
symbol type: trampoline
[0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
[0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
[0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
[0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
llvm-svn: 140830
2011-09-30 08:42:49 +08:00
[ 0x0000000100001780 - 0x0000000100001d5c ) a . o u t . _ _ T E X T . _ _ t e x t
i d = { 0 x 0 0 0 0 0 0 0 4 } , name = 'mask_access(MaskAction, unsigned int)' , r a n g e = [ 0x00000001000017c0 - 0x0000000100001870 )
s y m b o l type : code
i d = { 0 x 0 0 0 0 0 0 0 8 } , name = 'thread_func(void*)' , r a n g e = [ 0x0000000100001870 - 0x00000001000019b0 )
s y m b o l type : code
i d = { 0 x 0 0 0 0 0 0 0 c } , name = 'main' , r a n g e = [ 0x00000001000019b0 - 0x0000000100001d5c )
s y m b o l type : code
i d = { 0 x 0 0 0 0 0 0 2 3 } , name = 'start' , a d d r e s s = 0x0000000100001780
s y m b o l type : code
[ 0x0000000100001d5c - 0x0000000100001da4 ) a . o u t . _ _ T E X T . _ _ s t u b s
i d = { 0 x 0 0 0 0 0 0 2 4 } , name = '__stack_chk_fail' , r a n g e = [ 0x0000000100001d5c - 0x0000000100001d62 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 8 } , name = 'exit' , r a n g e = [ 0x0000000100001d62 - 0x0000000100001d68 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 9 } , name = 'fflush' , r a n g e = [ 0x0000000100001d68 - 0x0000000100001d6e )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 a } , name = 'fgets' , r a n g e = [ 0x0000000100001d6e - 0x0000000100001d74 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 b } , name = 'printf' , r a n g e = [ 0x0000000100001d74 - 0x0000000100001d7a )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 c } , name = 'pthread_create' , r a n g e = [ 0x0000000100001d7a - 0x0000000100001d80 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 d } , name = 'pthread_join' , r a n g e = [ 0x0000000100001d80 - 0x0000000100001d86 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 e } , name = 'pthread_mutex_lock' , r a n g e = [ 0x0000000100001d86 - 0x0000000100001d8c )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 2 f } , name = 'pthread_mutex_unlock' , r a n g e = [ 0x0000000100001d8c - 0x0000000100001d92 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 3 0 } , name = 'rand' , r a n g e = [ 0x0000000100001d92 - 0x0000000100001d98 )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 3 1 } , name = 'strtoul' , r a n g e = [ 0x0000000100001d98 - 0x0000000100001d9e )
s y m b o l type : t r a m p o l i n e
i d = { 0 x 0 0 0 0 0 0 3 2 } , name = 'usleep' , r a n g e = [ 0x0000000100001d9e - 0x0000000100001da4 )
s y m b o l type : t r a m p o l i n e
[ 0x0000000100001da4 - 0x0000000100001e2c ) a . o u t . _ _ T E X T . _ _ s t u b _ h e l p e r
[ 0x0000000100001e2c - 0x0000000100001f10 ) a . o u t . _ _ T E X T . _ _ c s t r i n g
[ 0x0000000100001f10 - 0x0000000100001f68 ) a . o u t . _ _ T E X T . _ _ u n w i n d _ i n f o
[ 0x0000000100001f68 - 0x0000000100001ff8 ) a . o u t . _ _ T E X T . _ _ e h _ f r a m e
"
2011-07-19 07:11:07 +08:00
) S B M o d u l e ;
class S B M o d u l e
{
public :
S B M o d u l e ( ) ;
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
S B M o d u l e ( c o n s t l l d b : : S B M o d u l e &rhs);
2019-04-19 00:23:33 +08:00
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
S B M o d u l e ( c o n s t l l d b : : S B M o d u l e S p e c &module_spec);
2019-04-19 00:23:33 +08:00
S B M o d u l e ( l l d b : : S B P r o c e s s &process,
2012-02-05 10:38:54 +08:00
l l d b : : a d d r _ t h e a d e r _ a d d r ) ;
2011-07-19 07:11:07 +08:00
~ S B M o d u l e ( ) ;
b o o l
I s V a l i d ( ) c o n s t ;
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
explicit o p e r a t o r b o o l ( ) c o n s t ;
2011-12-20 04:39:44 +08:00
void
Clear ( ) ;
2011-07-19 07:11:07 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Get c o n s t a c c e s s o r for t h e m o d u l e file s p e c i f i c a t i o n .
T h i s function returns t h e file for t h e m o d u l e on t h e h o s t s y s t e m
t h a t is r u n n i n g L L D B . T h i s c a n d i f f e r from t h e p a t h on t h e
p l a t f o r m s i n c e w e m i g h t b e d o i n g remote d e b u g g i n g .
@ return
A c o n s t r e f e r e n c e to t h e file s p e c i f i c a t i o n o b j e c t . " ) G e t F i l e S p e c ;
2011-07-19 07:11:07 +08:00
l l d b : : S B F i l e S p e c
G e t F i l e S p e c ( ) c o n s t ;
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Get a c c e s s o r for t h e m o d u l e p l a t f o r m file s p e c i f i c a t i o n .
P l a t f o r m file r e f e r s to t h e p a t h of t h e m o d u l e as i t is k n o w n on
t h e remote s y s t e m on w h i c h i t is b e i n g d e b u g g e d . For l o c a l
d e b u g g i n g t h i s is a l w a y s t h e s a m e as M o d u l e : : G e t F i l e S p e c ( ) . B u t
remote d e b u g g i n g m i g h t m e n t i o n a file '/usr/lib/liba.dylib'
w h i c h m i g h t b e l o c a l l y d o w n l o a d e d and c a c h e d . In t h i s case t h e
p l a t f o r m file c o u l d b e s o m e t h i n g like :
'/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
T h e file c o u l d a l s o b e c a c h e d in a l o c a l d e v e l o p e r k i t d i r e c t o r y .
@ return
A c o n s t r e f e r e n c e to t h e file s p e c i f i c a t i o n o b j e c t . " ) G e t P l a t f o r m F i l e S p e c ;
2011-07-19 07:11:07 +08:00
l l d b : : S B F i l e S p e c
G e t P l a t f o r m F i l e S p e c ( ) c o n s t ;
b o o l
S e t P l a t f o r m F i l e S p e c ( c o n s t l l d b : : S B F i l e S p e c &platform_file);
2019-04-19 00:23:33 +08:00
2013-11-21 05:07:01 +08:00
l l d b : : S B F i l e S p e c
G e t R e m o t e I n s t a l l F i l e S p e c ( ) ;
b o o l
S e t R e m o t e I n s t a l l F i l e S p e c ( l l d b : : S B F i l e S p e c &file);
2011-07-19 07:11:07 +08:00
% f e a t u r e ( "docstring" , "Returns the UUID of the module as a Python string."
) G e t U U I D S t r i n g ;
c o n s t char *
G e t U U I D S t r i n g ( ) c o n s t ;
Make operator==s consistent between c++ and python APIs
Summary:
modify-python-lldb.py had code to insert python equality operators to
some classes. Some of those classes already had c++ equality operators,
and some didn't.
This makes the situation more consistent, by removing all equality
handilng from modify-python-lldb. Instead, I add c++ operators to
classes where they were missing, and expose them in the swig interface
files so that they are available to python too.
The only tricky case was the SBAddress class, which had an operator==
defined as a free function, which is not handled by swig. This function
cannot be removed without breaking ABI, and we cannot add an extra
operator== member, as that would make equality comparisons ambiguous.
For this class, I define a python __eq__ function by hand and have it
delegate to the operator!=, which I have defined as a member function.
This isn't fully NFC, as the semantics of some equality functions in
python changes slightly, but I believe it changes for the better (e.g.,
previously SBBreakpoint.__eq__ would consider two breakpoints with the
same ID as equal, even if they belonged to different targets; now they
are only equal if they belong to the same target).
Reviewers: jingham, clayborg, zturner
Subscribers: jdoerfert, JDevlieghere, lldb-commits
Differential Revision: https://reviews.llvm.org/D59819
llvm-svn: 357463
2019-04-02 18:18:46 +08:00
b o o l o p e r a t o r = = ( c o n s t l l d b : : S B M o d u l e &rhs) const;
b o o l o p e r a t o r ! = ( c o n s t l l d b : : S B M o d u l e &rhs) const;
2011-09-24 08:52:29 +08:00
l l d b : : S B S e c t i o n
F i n d S e c t i o n ( c o n s t char * s e c t _ n a m e ) ;
l l d b : : S B A d d r e s s
R e s o l v e F i l e A d d r e s s ( l l d b : : a d d r _ t v m _ a d d r ) ;
2011-07-19 07:11:07 +08:00
l l d b : : S B S y m b o l C o n t e x t
2019-04-19 00:23:33 +08:00
R e s o l v e S y m b o l C o n t e x t F o r A d d r e s s ( c o n s t l l d b : : S B A d d r e s s & addr,
2011-07-19 07:11:07 +08:00
u i n t 32 _ t r e s o l v e _ s c o p e ) ;
b o o l
G e t D e s c r i p t i o n ( l l d b : : S B S t r e a m &description);
2012-03-17 05:55:42 +08:00
u i n t 32 _ t
G e t N u m C o m p i l e U n i t s ( ) ;
l l d b : : S B C o m p i l e U n i t
G e t C o m p i l e U n i t A t I n d e x ( u i n t 32 _ t ) ;
2018-07-03 22:22:44 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Find compile u n i t s r e l a t e d to * t h i s m o d u l e and p a s s e d source
file .
@ param [ in ] s b _ f i l e _ s p e c
A l l d b : : S B F i l e S p e c o b j e c t t h a t contains source file
s p e c i f i c a t i o n .
@ return
A l l d b : : S B S y m b o l C o n t e x t L i s t t h a t g e t s filled in with all of
t h e s y m b o l c o n t e x t s for all t h e matches . " ) F i n d C o m p i l e U n i t s ;
2018-07-03 22:22:44 +08:00
l l d b : : S B S y m b o l C o n t e x t L i s t
F i n d C o m p i l e U n i t s ( c o n s t l l d b : : S B F i l e S p e c &sb_file_spec);
2011-07-19 07:11:07 +08:00
s i z e _ t
G e t N u m S y m b o l s ( ) ;
2019-04-19 00:23:33 +08:00
2011-07-19 07:11:07 +08:00
l l d b : : S B S y m b o l
G e t S y m b o l A t I n d e x ( s i z e _ t i d x ) ;
2012-12-04 10:22:16 +08:00
l l d b : : S B S y m b o l
F i n d S y m b o l ( c o n s t char * name ,
l l d b : : S y m b o l T y p e type = e S y m b o l T y p e A n y ) ;
l l d b : : S B S y m b o l C o n t e x t L i s t
F i n d S y m b o l s ( c o n s t char * name ,
l l d b : : S y m b o l T y p e type = e S y m b o l T y p e A n y ) ;
2019-04-19 00:23:33 +08:00
2012-12-04 10:22:16 +08:00
2011-09-24 08:52:29 +08:00
s i z e _ t
G e t N u m S e c t i o n s ( ) ;
l l d b : : S B S e c t i o n
G e t S e c t i o n A t I n d e x ( s i z e _ t i d x ) ;
2011-07-19 07:11:07 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Find f u n c t i o n s by name .
@ param [ in ] name
T h e name of t h e function w e a r e l o o k i n g for .
@ param [ in ] n a m e _ t y p e _ m a s k
A logical OR of o n e or m o r e F u n c t i o n N a m e T y p e enum b i t s t h a t
i n d i c a t e w h a t k i n d of n a m e s s h o u l d b e u s e d when d o i n g t h e
lookup . B i t s i n c l u d e f u l l y q u a l i f i e d n a m e s , b a s e n a m e s ,
C + + m e t h o d s , or O b j C s e l e c t o r s .
S e e F u n c t i o n N a m e T y p e for m o r e d e t a i l s .
@ return
A s y m b o l context l i s t t h a t g e t s filled in with all of t h e
matches . " ) F i n d F u n c t i o n s ;
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
l l d b : : S B S y m b o l C o n t e x t L i s t
2019-04-19 00:23:33 +08:00
F i n d F u n c t i o n s ( c o n s t char * name ,
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
u i n t 32 _ t n a m e _ t y p e _ m a s k = l l d b : : e F u n c t i o n N a m e T y p e A n y ) ;
2019-04-19 00:23:33 +08:00
2011-07-30 03:53:35 +08:00
l l d b : : S B T y p e
F i n d F i r s t T y p e ( c o n s t char * name ) ;
l l d b : : S B T y p e L i s t
F i n d T y p e s ( c o n s t char * type ) ;
2014-01-24 05:38:34 +08:00
l l d b : : S B T y p e
G e t T y p e B y I D ( l l d b : : u s e r _ i d _ t u i d ) ;
2012-12-06 05:24:42 +08:00
l l d b : : S B T y p e
G e t B a s i c T y p e ( l l d b : : B a s i c T y p e type ) ;
2011-07-19 07:11:07 +08:00
2013-06-19 06:51:05 +08:00
% f e a t u r e ( "docstring" , "
2019-04-23 18:04:22 +08:00
Get all t y p e s m a t c h i n g t y p e _ m a s k from debug info in t h i s
2019-04-19 00:23:33 +08:00
m o d u l e .
@ param [ in ] t y p e _ m a s k
A b i t f i e l d t h a t c o n s i s t s of o n e or m o r e b i t s l o g i c a l l y OR ' e d
t o g e t h e r from t h e l l d b : : T y p e C l a s s e n u m e r a t i o n . T h i s a l l o w s
y o u to request o n l y s t r u c t u r e t y p e s , or o n l y class , s t r u c t
and union t y p e s . P a s s i n g in l l d b : : e T y p e C l a s s A n y w i l l return
all t y p e s f o u n d in t h e debug information for t h i s m o d u l e .
@ return
2019-04-23 18:04:22 +08:00
A l i s t of t y p e s in t h i s m o d u l e t h a t m a t c h t y p e _ m a s k " ) G e t T y p e s ;
2013-06-19 06:51:05 +08:00
l l d b : : S B T y p e L i s t
G e t T y p e s ( u i n t 32 _ t t y p e _ m a s k = l l d b : : e T y p e C l a s s A n y ) ;
2011-07-19 07:11:07 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Find global and static v a r i a b l e s by name .
@ param [ in ] target
A v a l i d S B T a r g e t i n s t a n c e r e p r e s e n t i n g t h e d e b u g g e e .
@ param [ in ] name
T h e name of t h e global or static variable w e a r e l o o k i n g
for .
@ param [ in ] m a x _ m a t c h e s
2019-04-23 18:04:22 +08:00
A l l o w t h e n u m b e r of matches to b e l i m i t e d to m a x _ m a t c h e s .
2019-04-19 00:23:33 +08:00
@ return
A l i s t of m a t c h e d v a r i a b l e s in a n S B V a l u e L i s t . " ) F i n d G l o b a l V a r i a b l e s ;
2011-07-19 07:11:07 +08:00
l l d b : : S B V a l u e L i s t
2019-04-19 00:23:33 +08:00
F i n d G l o b a l V a r i a b l e s ( l l d b : : S B T a r g e t &target,
c o n s t char * name ,
2011-07-19 07:11:07 +08:00
u i n t 32 _ t m a x _ m a t c h e s ) ;
2019-04-19 00:23:33 +08:00
2013-01-17 02:53:52 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Find t h e first global ( or static ) variable by name .
@ param [ in ] target
A v a l i d S B T a r g e t i n s t a n c e r e p r e s e n t i n g t h e d e b u g g e e .
@ param [ in ] name
T h e name of t h e global or static variable w e a r e l o o k i n g
for .
@ return
A n S B V a l u e t h a t g e t s filled in with t h e f o u n d variable ( if any ) . " ) F i n d F i r s t G l o b a l V a r i a b l e ;
2013-01-17 02:53:52 +08:00
l l d b : : S B V a l u e
F i n d F i r s t G l o b a l V a r i a b l e ( l l d b : : S B T a r g e t &target, const char *name);
2019-04-19 00:23:33 +08:00
2012-01-29 14:07:39 +08:00
l l d b : : B y t e O r d e r
G e t B y t e O r d e r ( ) ;
2019-04-19 00:23:33 +08:00
2012-01-29 14:07:39 +08:00
u i n t 32 _ t
G e t A d d r e s s B y t e S i z e ( ) ;
2019-04-19 00:23:33 +08:00
2012-01-29 14:07:39 +08:00
c o n s t char *
G e t T r i p l e ( ) ;
2019-04-19 00:23:33 +08:00
2012-02-23 03:41:02 +08:00
u i n t 32 _ t
2019-04-19 00:23:33 +08:00
G e t V e r s i o n ( u i n t 32 _ t * v e r s i o n s ,
2012-02-23 03:41:02 +08:00
u i n t 32 _ t n u m _ v e r s i o n s ) ;
2012-01-29 14:07:39 +08:00
2015-03-24 05:50:21 +08:00
l l d b : : S B F i l e S p e c
G e t S y m b o l F i l e S p e c ( ) c o n s t ;
l l d b : : S B A d d r e s s
G e t O b j e c t F i l e H e a d e r A d d r e s s ( ) c o n s t ;
2018-11-30 17:45:52 +08:00
l l d b : : S B A d d r e s s
G e t O b j e c t F i l e E n t r y P o i n t A d d r e s s ( ) c o n s t ;
2013-05-03 09:29:27 +08:00
b o o l
o p e r a t o r = = ( c o n s t l l d b : : S B M o d u l e &rhs) const;
2019-04-19 00:23:33 +08:00
2013-05-03 09:29:27 +08:00
b o o l
o p e r a t o r ! = ( c o n s t l l d b : : S B M o d u l e &rhs) const;
2019-04-19 00:23:33 +08:00
2012-01-29 14:07:39 +08:00
% p y t h o n c o d e % {
2019-04-04 18:13:59 +08:00
def _ _ l e n _ _ ( self ) :
'''Return the number of symbols in a lldb.SBModule object.'''
return self . G e t N u m S y m b o l s ( )
def _ _ i t e r _ _ ( self ) :
'''Iterate over all symbols in a lldb.SBModule object.'''
return l l d b _ i t e r ( self , 'GetNumSymbols', 'GetSymbolAtIndex' )
def s e c t i o n _ i t e r ( self ) :
'''Iterate over all sections in a lldb.SBModule object.'''
return l l d b _ i t e r ( self , 'GetNumSections', 'GetSectionAtIndex' )
def c o m p i l e _ u n i t _ i t e r ( self ) :
'''Iterate over all compile units in a lldb.SBModule object.'''
return l l d b _ i t e r ( self , 'GetNumCompileUnits', 'GetCompileUnitAtIndex' )
def s y m b o l _ i n _ s e c t i o n _ i t e r ( self , section ) :
''' G i v e n a m o d u l e and i t s c o n t a i n e d section , returns a n i t e r a t o r on t h e
s y m b o l s w i t h i n t h e section . '''
for s y m in self :
if i n _ r a n g e ( s y m , section ) :
y i e l d s y m
2012-02-01 16:09:32 +08:00
class s y m b o l s _ a c c e s s ( o b j e c t ) :
2012-02-03 11:22:53 +08:00
r e _ c o m p i l e _ t y p e = type ( r e . compile ( '.' ) )
2013-03-07 11:25:11 +08:00
'''A helper object that will lazily hand out lldb.SBSymbol objects for a module when supplied an index, name, or regular expression.'''
2012-02-01 16:09:32 +08:00
def _ _ i n i t _ _ ( self , s b m o d u l e ) :
self . s b m o d u l e = s b m o d u l e
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def _ _ l e n _ _ ( self ) :
if self . s b m o d u l e :
2012-05-12 04:39:42 +08:00
return int ( self . s b m o d u l e . G e t N u m S y m b o l s ( ) )
2012-02-01 16:09:32 +08:00
return 0
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def _ _ g e t i t e m _ _ ( self , key ) :
2012-02-03 11:22:53 +08:00
count = l e n ( self )
2012-02-01 16:09:32 +08:00
if type ( key ) is int :
if key < count :
return self . s b m o d u l e . G e t S y m b o l A t I n d e x ( key )
e l i f type ( key ) is s t r :
matches = [ ]
2012-12-04 10:22:16 +08:00
s c _ l i s t = self . s b m o d u l e . F i n d S y m b o l s ( key )
for s c in s c _ l i s t :
s y m b o l = s c . s y m b o l
if s y m b o l :
2012-02-01 16:09:32 +08:00
matches . append ( s y m b o l )
2012-02-03 11:22:53 +08:00
return matches
e l i f i s i n s t a n c e ( key , self . r e _ c o m p i l e _ t y p e ) :
2012-02-01 16:09:32 +08:00
matches = [ ]
for i d x in r a n g e ( count ) :
s y m b o l = self . s b m o d u l e . G e t S y m b o l A t I n d e x ( i d x )
a d d e d = False
name = s y m b o l . name
if name :
r e _ m a t c h = key . search ( name )
if r e _ m a t c h :
matches . append ( s y m b o l )
a d d e d = True
if not a d d e d :
m a n g l e d = s y m b o l . m a n g l e d
if m a n g l e d :
r e _ m a t c h = key . search ( m a n g l e d )
if r e _ m a t c h :
matches . append ( s y m b o l )
2012-02-03 11:22:53 +08:00
return matches
2012-02-01 16:09:32 +08:00
else :
2015-10-17 01:52:32 +08:00
p r i n t ( "error: unsupported item type: %s" % type ( key ) )
2012-02-01 16:09:32 +08:00
return None
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def g e t _ s y m b o l s _ a c c e s s _ o b j e c t ( self ) :
2012-02-03 11:22:53 +08:00
'''An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.'''
2012-02-01 16:09:32 +08:00
return self . s y m b o l s _ a c c e s s ( self )
2019-04-19 00:23:33 +08:00
2013-03-07 11:25:11 +08:00
def g e t _ c o m p i l e _ u n i t s _ a c c e s s _ o b j e c t ( self ) :
'''An accessor function that returns a compile_units_access() object which allows lazy compile unit access from a lldb.SBModule object.'''
return self . c o m p i l e _ u n i t s _ a c c e s s ( self )
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def g e t _ s y m b o l s _ a r r a y ( self ) :
2012-02-03 11:22:53 +08:00
'''An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.'''
2012-02-01 16:09:32 +08:00
s y m b o l s = [ ]
2012-02-03 11:22:53 +08:00
for i d x in r a n g e ( self . n u m _ s y m b o l s ) :
2012-02-01 16:09:32 +08:00
s y m b o l s . append ( self . G e t S y m b o l A t I n d e x ( i d x ) )
return s y m b o l s
2012-02-03 11:22:53 +08:00
class s e c t i o n s _ a c c e s s ( o b j e c t ) :
r e _ c o m p i l e _ t y p e = type ( r e . compile ( '.' ) )
2013-03-07 11:25:11 +08:00
'''A helper object that will lazily hand out lldb.SBSection objects for a module when supplied an index, name, or regular expression.'''
2012-02-03 11:22:53 +08:00
def _ _ i n i t _ _ ( self , s b m o d u l e ) :
self . s b m o d u l e = s b m o d u l e
2019-04-19 00:23:33 +08:00
2012-02-03 11:22:53 +08:00
def _ _ l e n _ _ ( self ) :
if self . s b m o d u l e :
2012-05-12 04:39:42 +08:00
return int ( self . s b m o d u l e . G e t N u m S e c t i o n s ( ) )
2012-02-03 11:22:53 +08:00
return 0
2019-04-19 00:23:33 +08:00
2012-02-03 11:22:53 +08:00
def _ _ g e t i t e m _ _ ( self , key ) :
count = l e n ( self )
if type ( key ) is int :
if key < count :
return self . s b m o d u l e . G e t S e c t i o n A t I n d e x ( key )
e l i f type ( key ) is s t r :
for i d x in r a n g e ( count ) :
section = self . s b m o d u l e . G e t S e c t i o n A t I n d e x ( i d x )
if section . name = = key :
2012-02-04 10:58:17 +08:00
return section
2012-02-03 11:22:53 +08:00
e l i f i s i n s t a n c e ( key , self . r e _ c o m p i l e _ t y p e ) :
matches = [ ]
for i d x in r a n g e ( count ) :
section = self . s b m o d u l e . G e t S e c t i o n A t I n d e x ( i d x )
name = section . name
if name :
r e _ m a t c h = key . search ( name )
if r e _ m a t c h :
matches . append ( section )
return matches
else :
2015-10-17 01:52:32 +08:00
p r i n t ( "error: unsupported item type: %s" % type ( key ) )
2012-02-03 11:22:53 +08:00
return None
2013-03-07 11:25:11 +08:00
class c o m p i l e _ u n i t s _ a c c e s s ( o b j e c t ) :
r e _ c o m p i l e _ t y p e = type ( r e . compile ( '.' ) )
'''A helper object that will lazily hand out lldb.SBCompileUnit objects for a module when supplied an index, full or partial path, or regular expression.'''
def _ _ i n i t _ _ ( self , s b m o d u l e ) :
self . s b m o d u l e = s b m o d u l e
2019-04-19 00:23:33 +08:00
2013-03-07 11:25:11 +08:00
def _ _ l e n _ _ ( self ) :
if self . s b m o d u l e :
return int ( self . s b m o d u l e . G e t N u m C o m p i l e U n i t s ( ) )
return 0
2019-04-19 00:23:33 +08:00
2013-03-07 11:25:11 +08:00
def _ _ g e t i t e m _ _ ( self , key ) :
count = l e n ( self )
if type ( key ) is int :
if key < count :
return self . s b m o d u l e . G e t C o m p i l e U n i t A t I n d e x ( key )
e l i f type ( key ) is s t r :
i s _ f u l l _ p a t h = key [ 0 ] = = '/'
for i d x in r a n g e ( count ) :
c o m p _ u n i t = self . s b m o d u l e . G e t C o m p i l e U n i t A t I n d e x ( i d x )
if i s _ f u l l _ p a t h :
if c o m p _ u n i t . file . f u l l p a t h = = key :
return c o m p _ u n i t
else :
if c o m p _ u n i t . file . b a s e n a m e = = key :
return c o m p _ u n i t
e l i f i s i n s t a n c e ( key , self . r e _ c o m p i l e _ t y p e ) :
matches = [ ]
for i d x in r a n g e ( count ) :
c o m p _ u n i t = self . s b m o d u l e . G e t C o m p i l e U n i t A t I n d e x ( i d x )
f u l l p a t h = c o m p _ u n i t . file . f u l l p a t h
if f u l l p a t h :
r e _ m a t c h = key . search ( f u l l p a t h )
if r e _ m a t c h :
matches . append ( c o m p _ u n i t )
return matches
else :
2015-10-17 01:52:32 +08:00
p r i n t ( "error: unsupported item type: %s" % type ( key ) )
2013-03-07 11:25:11 +08:00
return None
2012-02-03 11:22:53 +08:00
def g e t _ s e c t i o n s _ a c c e s s _ o b j e c t ( self ) :
'''An accessor function that returns a sections_access() object which allows lazy section array access.'''
return self . s e c t i o n s _ a c c e s s ( self )
2019-04-19 00:23:33 +08:00
2012-02-03 11:22:53 +08:00
def g e t _ s e c t i o n s _ a r r a y ( self ) :
'''An accessor function that returns an array object that contains all sections in this module object.'''
2013-02-26 05:53:07 +08:00
if not h a s a t t r ( self , 'sections_array' ) :
self . s e c t i o n s _ a r r a y = [ ]
2012-02-03 11:22:53 +08:00
for i d x in r a n g e ( self . n u m _ s e c t i o n s ) :
2013-02-26 05:53:07 +08:00
self . s e c t i o n s _ a r r a y . append ( self . G e t S e c t i o n A t I n d e x ( i d x ) )
return self . s e c t i o n s _ a r r a y
2012-02-03 11:22:53 +08:00
2013-03-07 11:25:11 +08:00
def g e t _ c o m p i l e _ u n i t s _ a r r a y ( self ) :
'''An accessor function that returns an array object that contains all compile_units in this module object.'''
if not h a s a t t r ( self , 'compile_units_array' ) :
self . c o m p i l e _ u n i t s _ a r r a y = [ ]
for i d x in r a n g e ( self . G e t N u m C o m p i l e U n i t s ( ) ) :
self . c o m p i l e _ u n i t s _ a r r a y . append ( self . G e t C o m p i l e U n i t A t I n d e x ( i d x ) )
return self . c o m p i l e _ u n i t s _ a r r a y
2019-07-03 06:18:35 +08:00
s y m b o l s = property ( g e t _ s y m b o l s _ a r r a y , None , d o c = '''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''' )
s y m b o l = property ( g e t _ s y m b o l s _ a c c e s s _ o b j e c t , None , d o c = ''' A r e a d o n l y property t h a t c a n b e u s e d to a c c e s s s y m b o l s by index ( "symbol = module.symbol[0]" ) , name ( "symbols = module.symbol['main']" ) , or using a r e g u l a r e x p r e s s i o n ( "symbols = module.symbol[re.compile(...)]" ) . T h e return value is a single l l d b . S B S y m b o l o b j e c t for a r r a y a c c e s s , and a l i s t ( ) of l l d b . S B S y m b o l o b j e c t s for name and r e g u l a r e x p r e s s i o n a c c e s s ''' )
s e c t i o n s = property ( g e t _ s e c t i o n s _ a r r a y , None , d o c = '''A read only property that returns a list() of lldb.SBSection objects contained in this module.''' )
c o m p i l e _ u n i t s = property ( g e t _ c o m p i l e _ u n i t s _ a r r a y , None , d o c = '''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''' )
section = property ( g e t _ s e c t i o n s _ a c c e s s _ o b j e c t , None , d o c = ''' A r e a d o n l y property t h a t c a n b e u s e d to a c c e s s s y m b o l s by index ( "section = module.section[0]" ) , name ( "sections = module.section[\'main\']" ) , or using a r e g u l a r e x p r e s s i o n ( "sections = module.section[re.compile(...)]" ) . T h e return value is a single l l d b . S B S e c t i o n o b j e c t for a r r a y a c c e s s , and a l i s t ( ) of l l d b . S B S e c t i o n o b j e c t s for name and r e g u l a r e x p r e s s i o n a c c e s s ''' )
section = property ( g e t _ s e c t i o n s _ a c c e s s _ o b j e c t , None , d o c = ''' A r e a d o n l y property t h a t c a n b e u s e d to a c c e s s compile u n i t s by index ( "compile_unit = module.compile_unit[0]" ) , name ( "compile_unit = module.compile_unit[\'main.cpp\']" ) , or using a r e g u l a r e x p r e s s i o n ( "compile_unit = module.compile_unit[re.compile(...)]" ) . T h e return value is a single l l d b . S B C o m p i l e U n i t o b j e c t for a r r a y a c c e s s or by f u l l or p a r t i a l p a t h , and a l i s t ( ) of l l d b . S B C o m p i l e U n i t o b j e c t s r e g u l a r e x p r e s s i o n s . ''' )
2013-03-07 11:25:11 +08:00
2012-02-01 16:09:32 +08:00
def g e t _ u u i d ( self ) :
return u u i d . U U I D ( self . G e t U U I D S t r i n g ( ) )
2019-04-19 00:23:33 +08:00
2019-07-03 06:18:35 +08:00
u u i d = property ( g e t _ u u i d , None , d o c = '''A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.''' )
file = property ( G e t F i l e S p e c , None , d o c = '''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.''' )
p l a t f o r m _ f i l e = property ( G e t P l a t f o r m F i l e S p e c , None , d o c = '''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.''' )
b y t e _ o r d e r = property ( G e t B y t e O r d e r , None , d o c = '''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.''' )
a d d r _ s i z e = property ( G e t A d d r e s s B y t e S i z e , None , d o c = '''A read only property that returns the size in bytes of an address for this module.''' )
t r i p l e = property ( G e t T r i p l e , None , d o c = '''A read only property that returns the target triple (arch-vendor-os) for this module.''' )
n u m _ s y m b o l s = property ( G e t N u m S y m b o l s , None , d o c = '''A read only property that returns number of symbols in the module symbol table as an integer.''' )
n u m _ s e c t i o n s = property ( G e t N u m S e c t i o n s , None , d o c = '''A read only property that returns number of sections in the module as an integer.''' )
2019-04-19 00:23:33 +08:00
2012-01-29 14:07:39 +08:00
% }
2011-07-19 07:11:07 +08:00
} ;
} // namespace lldb