Beispiel #1
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')

# Run gnatdbg.setup twice, check that the pretty-printers still work
gdb = GDBSession('foo', log_file='gdb-double-setup.log', load_gnatdbg=True)
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))
gdb.test('python gnatdbg.setup()', '')
gdb.print_expr('empty_string', 'Unbounded_String ("")')
gdb.stop()

# Run gnatdbg.setup without registering pretty-printers globally
gdb = GDBSession('foo', log_file='gdb-local.log', load_gnatdbg=False)
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))
gdb.test('python import gnatdbg; gnatdbg.setup(globally=False)', '')
gdb.print_expr('empty_string', 'Unbounded_String ("")')

# Re-load and re-run foo, just to make sure the new_objfile event is run.
gdb.kill()
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))
gdb.print_expr('empty_string', 'Unbounded_String ("")')
Beispiel #2
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('set corrupted_string.reference := 0x1')

gdb.print_expr('empty_string', '""')
gdb.print_expr('some_string', '"Hello, world!"')
gdb.print_expr('binary_string', '"b["00"]""["ff"]"')
gdb.print_expr(
    'corrupted_string',
    '<error reading variable: Cannot access memory at address 0x1>')
Beispiel #3
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

# Corrupt the linked list and the cursor
gdb.test('set variable l.length := 2', '')
gdb.test('set variable cur.container := 1', '')
gdb.test('set variable cur.node := 2', '')

gdb.print_expr(
    'l', 'foo.str_lists.list of length 2 ='
    ' {"one",'
    ' "two"'
    '<error reading variable: The linked list seems invalid>...}')
gdb.print_expr('cur', 'Cursor ([Invalid])')
Beispiel #4
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.test('set lang c',
         'Warning: the current language does not match this frame.')
gdb.test('set corrupted_string.P_ARRAY = 0x1', '')
gdb.test('set lang auto', '')

gdb.print_expr('null_string', '0x0 <null string access>')
gdb.print_expr('empty_string', '""')
gdb.print_expr('some_string', '"Hello, world!"')
gdb.print_expr('binary_string', '"b["00"]""["ff"]"')
gdb.print_expr('wstring', '"wide string"')
gdb.print_expr('wwstring', '"wide wide string"')
gdb.print_expr('corrupted_string',
               '<error: Cannot access memory at address 0x1>')

gdb.test(
    'python'
    ' i = gdb.parse_and_eval("i");'
    ' v = gnatdbg.strings.StringAccess(i)',
    '@...TypeError: Input is not an access to string@...')
Beispiel #5
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.print_expr('us1', '"Hello world!"')
gdb.print_expr('us2', '""')

gdb.print_expr(
    'v1', 'foo.str_vectors.vector of length 3 ='
    ' {"one",'
    '  "two",'
    '  "three"}')
gdb.print_expr('v2', 'foo.str_vectors.vector of length 0')
gdb.print_expr('cur_v', 'Cursor (2 => "two")')
gdb.print_expr('no_cur_v', 'Cursor (No_Element)')

gdb.print_expr(
    'l1', 'foo.str_lists.list of length 3 ='
    ' {"one",'
    '  "two",'
    '  "three"}')
gdb.print_expr('l2', 'foo.str_lists.list of length 0')
gdb.print_expr('cur_l', 'Cursor ("one")')
gdb.print_expr('no_cur_l', 'Cursor (No_Element)')

gdb.print_expr(
    'om1', 'foo.int_to_str.map of length 3 ='
    ' {[1] = "one",'
Beispiel #6
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.test('set lang c',
         'Warning: the current language does not match this frame.')
gdb.test('set corrupted_string.P_ARRAY = 0x1', '')
gdb.test('set lang auto', '')

gdb.print_expr('null_string', '(foo__string_access) 0x0 [Invalid]')
gdb.print_expr('empty_string', '(foo__string_access) @ADDRESS ""')
gdb.print_expr('some_string', '(foo__string_access) @ADDRESS "Hello, world!"')
gdb.print_expr('binary_string',
               '(foo__string_access) @ADDRESS "b["00"]""["ff"]"')
gdb.print_expr('wstring', '(foo__wstring_access) @ADDRESS "wide string"')
gdb.print_expr('wwstring',
               '(foo__wwstring_access) @ADDRESS "wide wide string"')
gdb.print_expr('corrupted_string', '(foo__string_access) 0x1 [Invalid]')

gdb.test(
    'python'
    ' i = gdb.parse_and_eval("i");'
    ' v = gnatdbg.strings.StringAccess(i)',
    '@...TypeError: Input is not an access to string@...')
Beispiel #7
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')

# Run gnatdbg.setup twice, check that the pretty-printers still work
gdb = GDBSession('foo', log_file='gdb-double-setup.log', load_gnatdbg=True)
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))
gdb.test('python gnatdbg.setup()', '')
gdb.print_expr('empty_string', '""')
gdb.stop()

# Run gnatdbg.setup without registering pretty-printers globally
gdb = GDBSession('foo', log_file='gdb-local.log', load_gnatdbg=False)
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))
gdb.test('python import gnatdbg; gnatdbg.setup(globally=False)', '')
gdb.print_expr('empty_string', '""')

# Re-load and re-run foo, just to make sure the new_objfile event is run.
gdb.kill()
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))
gdb.print_expr('empty_string', '""')
Beispiel #8
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('set corrupted.value.c := 0x1')

gdb.print_expr('uninit', 'Big_Integer ([Uninitialized])')
gdb.print_expr('zero', 'Big_Integer (0)')
gdb.print_expr('neg_one', 'Big_Integer (-1)')
gdb.print_expr('neg_small', 'Big_Integer (-1000)')
gdb.print_expr('neg_big',
               'Big_Integer (-1234567890098765432112345678900987654321)')
gdb.print_expr('pos_one', 'Big_Integer (1)')
gdb.print_expr('pos_small', 'Big_Integer (1000)')
gdb.print_expr('pos_big',
               'Big_Integer (1234567890098765432112345678900987654321)')
gdb.print_expr('corrupted', 'Big_Integer ([Invalid])')
Beispiel #9
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

# Corrupt the linked list and the cursor
gdb.test('set variable l.length := 2', '')
gdb.test('set variable cur.container := 1', '')
gdb.test('set variable cur.node := 2', '')

gdb.print_expr(
    'l', 'foo.str_lists.list of length 2 ='
    ' {Unbounded_String ("one"),'
    ' Unbounded_String ("two")'
    '<error reading variable: The linked list seems invalid>...}')
gdb.print_expr('cur', 'Cursor ([Invalid])')
Beispiel #10
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('set corrupted_string.reference := 0x1')

gdb.print_expr('empty_string', 'Unbounded_String ("")')
gdb.print_expr('some_string', 'Unbounded_String ("Hello, world!")')
gdb.print_expr('binary_string', 'Unbounded_String ("b["00"]""["ff"]")')
gdb.print_expr('corrupted_string', 'Unbounded_String ([Invalid])')

gdb.test(
    'python'
    ' s = gdb.parse_and_eval("binary_string");'
    ' v = gnatdbg.strings.UnboundedString(s);'
    ' string = v.get_string("ascii", errors="ignore");'
    ' print(gnatdbg.utils.ada_string_repr(string))', '"b["00"]"""')
Beispiel #11
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('main')
gdb = GDBSession('main')
gdb.run_to(gdb.find_loc('main.adb', 'break here'))
gdb.test('source custom.py', '')
gdb.print_expr(
    'v', '(t => time, vec => main.time_vectors.vector of length 1 = {time})')
Beispiel #12
0
from support.build import gnatmake
from support.gdb import GDBSession


gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.print_expr('us1', 'Unbounded_String ("Hello world!")')
gdb.print_expr('us2', 'Unbounded_String ("")')

gdb.print_expr('v1', 'foo.str_vectors.vector of length 3 ='
                     ' {Unbounded_String ("one"),'
                     '  Unbounded_String ("two"),'
                     '  Unbounded_String ("three")}')
gdb.print_expr('v2', 'foo.str_vectors.vector of length 0')
gdb.print_expr('cur_v', 'Cursor (2 => Unbounded_String ("two"))')
gdb.print_expr('no_cur_v', 'Cursor (No_Element)')

gdb.print_expr('l1', 'foo.str_lists.list of length 3 ='
                     ' {Unbounded_String ("one"),'
                     '  Unbounded_String ("two"),'
                     '  Unbounded_String ("three")}')
gdb.print_expr('l2', 'foo.str_lists.list of length 0')
gdb.print_expr('cur_l', 'Cursor (Unbounded_String ("one"))')
gdb.print_expr('no_cur_l', 'Cursor (No_Element)')

gdb.print_expr('om1', 'foo.int_to_str.map of length 3 ='
                      ' {[1] = Unbounded_String ("one"),'
                      '  [2] = Unbounded_String ("two"),'
                      '  [3] = Unbounded_String ("three")}')
Beispiel #13
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('set corrupted.num.value.c := 0x1')

gdb.print_expr('uninit', 'Big_Real ([Uninitialized])')
gdb.print_expr('zero', 'Big_Real (0 / 1)')
gdb.print_expr('neg_one', 'Big_Real (-1 / 1)')
gdb.print_expr('neg_small', 'Big_Real (-10 / 9)')
gdb.print_expr('pos_one', 'Big_Real (1 / 1)')
gdb.print_expr('pos_small', 'Big_Real (1000 / 3)')
gdb.print_expr('corrupted', 'Big_Real ([Invalid])')
Beispiel #14
0
from support.build import gnatmake
from support.gdb import GDBSession


gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.test('source pp.py', '')
gdb.print_expr('i1', 'My_Int (10)')
gdb.print_expr('i2', 'My_Int (20)')
gdb.print_expr('n', 'My_Nat (30)')
gdb.print_expr('i', '0')