2011-07-19 07:11:07 +08:00
//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
n a m e s p a c e l l d b {
% 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 ( )
and r i c h c o m p a r i 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 ,
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);
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);
2011-07-19 07:11:07 +08:00
2012-02-05 10:38:54 +08:00
S B M o d u l e ( l l d b : : S B P r o c e s s &process,
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 ;
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" , "
//------------------------------------------------------------------
/// Get const accessor for the module file specification.
///
/// This function returns the file for the module on the host system
/// that is running LLDB. This can differ from the path on the
/// platform since we might be doing remote debugging.
///
/// @return
/// A const reference to the file specification object.
//------------------------------------------------------------------
" ) G e t F i l e S p e c ;
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" , "
//------------------------------------------------------------------
/// Get accessor for the module platform file specification.
///
/// Platform file refers to the path of the module as it is known on
/// the remote system on which it is being debugged. For local
/// debugging this is always the same as Module::GetFileSpec(). But
/// remote debugging might mention a file '/usr/lib/liba.dylib'
/// which might be locally downloaded and cached. In this case the
/// platform file could be something like:
/// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
/// The file could also be cached in a local developer kit directory.
///
/// @return
/// A const reference to the file specification object.
//------------------------------------------------------------------
" ) G e t P l a t f o r m F i l e S p e c ;
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);
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 ;
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
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,
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 ) ;
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 ( ) ;
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 ) ;
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" , "
//------------------------------------------------------------------
/// Find functions by name.
///
/// @param[in] name
/// The name of the function we are looking for.
///
/// @param[in] name_type_mask
/// A logical OR of one or more FunctionNameType enum bits that
/// indicate what kind of names should be used when doing the
/// lookup. Bits include fully qualified names, base names,
/// C++ methods, or ObjC selectors.
/// See FunctionNameType for more details.
///
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
/// @return
2011-07-19 07:11:07 +08:00
/// A symbol context list that gets filled in with all of the
/// 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
2011-07-19 07:11:07 +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 ) ;
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" , "
//------------------------------------------------------------------
/// Get all types matching \a type_mask from debug info in this
/// module.
///
/// @param[in] type_mask
/// A bitfield that consists of one or more bits logically OR'ed
/// together from the lldb::TypeClass enumeration. This allows
/// you to request only structure types, or only class, struct
/// and union types. Passing in lldb::eTypeClassAny will return
/// all types found in the debug information for this module.
///
/// @return
/// A list of types in this module that match \a type_mask
//------------------------------------------------------------------
" ) G e t T y p e s ;
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" , "
//------------------------------------------------------------------
/// Find global and static variables by name.
///
/// @param[in] target
/// A valid SBTarget instance representing the debuggee.
///
/// @param[in] name
/// The name of the global or static variable we are looking
/// for.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
/// @return
/// A list of matched variables in an SBValueList.
//------------------------------------------------------------------
" ) 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 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 ( l l d b : : S B T a r g e t &target,
c o n s t char * name ,
u i n t 32 _ t m a x _ m a t c h e s ) ;
2012-01-29 14:07:39 +08:00
2013-01-17 02:53:52 +08:00
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Find the first global (or static) variable by name.
///
/// @param[in] target
/// A valid SBTarget instance representing the debuggee.
///
/// @param[in] name
/// The name of the global or static variable we are looking
/// for.
///
/// @return
/// An SBValue that gets filled in with the found 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 ;
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);
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 ( ) ;
u i n t 32 _ t
G e t A d d r e s s B y t e S i z e ( ) ;
c o n s t char *
G e t T r i p l e ( ) ;
2012-02-23 03:41:02 +08:00
u i n t 32 _ t
G e t V e r s i o n ( u i n t 32 _ t * v e r s i o n s ,
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 ;
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;
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;
2012-01-29 14:07:39 +08:00
% p y t h o n c o d e % {
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
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
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
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 )
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 )
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
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
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
2012-02-03 11:22:53 +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
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 )
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
2012-02-01 16:09:32 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "symbols" ] = g e t _ s y m b o l s _ a r r a y
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-02-01 16:09:32 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "symbol" ] = g e t _ s y m b o l s _ a c c e s s _ o b j e c t
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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 ''' )
2012-02-03 11:22:53 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "sections" ] = g e t _ s e c t i o n s _ a r r a y
2012-06-30 06:00:42 +08:00
if _ n e w c l a 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.''' )
2013-03-07 11:25:11 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "compile_units" ] = g e t _ c o m p i l e _ u n i t s _ a r r a y
if _ n e w c l a s s : 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.''' )
2012-02-03 11:22:53 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "section" ] = g e t _ s e c t i o n s _ a c c e s s _ o b j e c t
2012-06-30 06:00:42 +08:00
if _ n e w c l a 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 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 ''' )
2012-02-03 11:22:53 +08:00
2013-03-07 11:25:11 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "compile_unit" ] = 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
if _ n e w c l a 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 . ''' )
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 ( ) )
_ _ s w i g _ g e t m e t h o d s _ _ [ "uuid" ] = g e t _ u u i d
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-02-01 16:09:32 +08:00
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "file" ] = G e t F i l e S p e c
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "platform_file" ] = G e t P l a t f o r m F i l e S p e c
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "byte_order" ] = G e t B y t e O r d e r
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "addr_size" ] = G e t A d d r e s s B y t e S i z e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "triple" ] = G e t T r i p l e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "num_symbols" ] = G e t N u m S y m b o l s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "num_sections" ] = G e t N u m S e c t i o n s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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.''' )
2012-01-29 14:07:39 +08:00
% }
2011-07-19 07:11:07 +08:00
} ;
} // namespace lldb