From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4620 invoked by alias); 12 Nov 2012 16:11:19 -0000 Received: (qmail 4609 invoked by uid 22791); 12 Nov 2012 16:11:16 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_50,KAM_STOCKGEN,KHOP_JS_OBFUSCATION,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,TW_BJ,TW_GJ,TW_RG X-Spam-Check-By: sourceware.org Received: from ausxippc101.us.dell.com (HELO ausxippc101.us.dell.com) (143.166.85.207) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Nov 2012 16:10:55 +0000 X-Loopcount0: from 10.175.216.249 From: To: Subject: [PATCH] Python 3 support, part 2 (testsuite part) Date: Mon, 12 Nov 2012 16:11:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" Content-ID: <03C4201F13F4ED408FEB7769290F28F0@dell.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00287.txt.bz2 This is the testsuite part of Python 3 support for GDB. Most of the changes are for turning "print" from a statement into a functio= n call. There are also some changes to handle the fact that "str" is now U= nicode and the separate "unicode" type is gone, similarly "int" is now long= integer and "long" is gone.=20 In the process of running the tests on a range of Python versions, I notice= d that the py-finish-breakpoint.exp test script does not work on Python 2.4= -- it uses syntax that was introduced in 2.6. And since the old syntax do= esn't work in Python 3, I left in the newer syntax but added code to skip t= hat script in Python 2.4. Tested on Linux with Python version 2.4, 2.6, 2.7, 3.2, and 3.3. No regres= sions on any of the tests. Ok to commit? paul 2012-11-12 Paul Koning * gdb.base/charset.exp: Change print syntax for Python 3 compatibility.=20 * gdb.python/py-block.exp: Ditto. * gdb.python/py-breakpoint.exp: Ditto. * gdb.python/py-cmd.exp: Ditto. * gdb.python/py-events.py: Ditto. * gdb.python/py-finish-breakpoint.py: Ditto. * gdb.python/py-finish-breakpoint2.exp: Ditto. * gdb.python/py-finish-breakpoint2.py: Ditto. * gdb.python/py-frame-inline.exp: Ditto. * gdb.python/py-frame.exp: Ditto. * gdb.python/py-infthread.exp: Ditto. * gdb.python/py-objfile.exp: Ditto. * gdb.python/py-parameter.exp: Ditto. * gdb.python/py-progspace.exp: Ditto. * gdb.python/py-prompt.exp: Ditto. * gdb.python/py-symbol.exp: Ditto. * gdb.python/py-symtab.exp: Ditto. * gdb.python/py-template.exp: Ditto. * gdb.python/py-value-cc.exp: Ditto. * gdb.python/python.exp: Ditto. * gdb.python/source2.py: Ditto. * gdb.python/lib-types.exp: Change print syntax for Python 3 compatibility.=20 Use sorted() function rather than sort() method. Accept either int or long values for enum values. * gdb.python/py-events.exp: Use exec(open(...).read()) instead of execfile for Python 3 compatibility. * gdb.python/py-evsignal.exp: Ditto. * gdb.python/py-evthreads.exp: Ditto. * gdb.python/py-mi.exp: Ditto. * gdb.python/py-pp-maint.exp: Ditto. * gdb.python/py-prettyprint.exp: Ditto. * gdb.python/py-finish-breakpoint.exp: Change print syntax for Python 3 compatibility.=20 Skip tests for Python 2.4. * gdb.python/py-inferior.exp: Change print syntax for Python 3 compatibility.=20 Use byte string rather than character string in memory write test if Python 3. * gdb.python/py-pp-maint.py: Change class declarations to "new class" syntax. * gdb.python/py-prettyprint.py: Change iterator class to generator function for Python 3 compatibility. Make all classes "new style". Fix indentation issue and stray semicolon. * gdb.python/py-shared.expChange print syntax for Python 3 compatibility. Define "long" if Python 3. * gdb.python/py-type.exp: Change print syntax for Python 3 compatibility.=20 Accept either int or long values for enum values. * gdb.python/py-value.exp: Change print syntax for Python 3 compatibility.=20 Skip "long" and "unicode" tests if Python 3. Accept either "type" or "class" in type checks. * lib/gdb.exp (gdb_py_is_py3k): New flag set if Python 3. (gdb_py_is_py24): New flag set if Python 2.4 or 2.5. Index: gdb/testsuite/gdb.base/charset.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.base/charset.exp,v retrieving revision 1.32 diff -u -r1.32 charset.exp --- gdb/testsuite/gdb.base/charset.exp 18 May 2012 15:29:13 -0000 1.32 +++ gdb/testsuite/gdb.base/charset.exp 9 Nov 2012 22:26:56 -0000 @@ -578,7 +578,7 @@ =20 if {$ucs2_ok} { set go 1 - gdb_test_multiple "python print 'hello, world!'" \ + gdb_test_multiple "python print ('hello, world!')" \ "verify python support for charset tests" { -re "not supported.*$gdb_prompt $" { unsupported "python support is disabled" @@ -591,7 +591,7 @@ gdb_test "print u\"abcdef\"" " =3D u\"abcdef\"" \ "set up for python printing of utf-16 string" =20 - gdb_test "python print gdb.history(0).string()" "abcdef" \ + gdb_test "python print (gdb.history(0).string())" "abcdef" \ "extract utf-16 string using python" } } Index: gdb/testsuite/gdb.python/lib-types.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/lib-types.exp,v retrieving revision 1.9 diff -u -r1.9 lib-types.exp --- gdb/testsuite/gdb.python/lib-types.exp 24 Jun 2012 06:36:27 -0000 1.9 +++ gdb/testsuite/gdb.python/lib-types.exp 9 Nov 2012 22:26:56 -0000 @@ -37,9 +37,9 @@ # test get_basic_type const stripping gdb_test_no_output "python const_class1_obj =3D gdb.parse_and_eval ('const= _class1_obj')" gdb_test_no_output "python basic_type_const_class1_obj =3D gdb.types.get_b= asic_type (const_class1_obj.type)" -gdb_test "python print str (const_class1_obj.type)" "const class1" +gdb_test "python print (str (const_class1_obj.type))" "const class1" set test "const stripping" -gdb_test_multiple "python print str (basic_type_const_class1_obj)" $test { +gdb_test_multiple "python print (str (basic_type_const_class1_obj))" $test= { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -48,9 +48,9 @@ # test get_basic_type volatile stripping gdb_test_no_output "python volatile_class1_obj =3D gdb.parse_and_eval ('vo= latile_class1_obj')" gdb_test_no_output "python basic_type_volatile_class1_obj =3D gdb.types.ge= t_basic_type (volatile_class1_obj.type)" -gdb_test "python print str (volatile_class1_obj.type)" "volatile class1" +gdb_test "python print (str (volatile_class1_obj.type))" "volatile class1" set test "volatile stripping" -gdb_test_multiple "python print str (basic_type_volatile_class1_obj)" $tes= t { +gdb_test_multiple "python print (str (basic_type_volatile_class1_obj))" $t= est { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -59,9 +59,9 @@ # test get_basic_type volatile+const stripping gdb_test_no_output "python const_volatile_class1_obj =3D gdb.parse_and_eva= l ('const_volatile_class1_obj')" gdb_test_no_output "python basic_type_const_volatile_class1_obj =3D gdb.ty= pes.get_basic_type (const_volatile_class1_obj.type)" -gdb_test "python print str (const_volatile_class1_obj.type)" "const volati= le class1" +gdb_test "python print (str (const_volatile_class1_obj.type))" "const vola= tile class1" set test "volatile+const stripping" -gdb_test_multiple "python print str (basic_type_const_volatile_class1_obj)= " $test { +gdb_test_multiple "python print (str (basic_type_const_volatile_class1_obj= ))" $test { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -70,9 +70,9 @@ # test get_basic_type typedef stripping gdb_test_no_output "python typedef_class1_obj =3D gdb.parse_and_eval ('typ= edef_class1_obj')" gdb_test_no_output "python basic_type_typedef_class1_obj =3D gdb.types.get= _basic_type (typedef_class1_obj.type)" -gdb_test "python print str (typedef_class1_obj.type)" "typedef_class1" +gdb_test "python print (str (typedef_class1_obj.type))" "typedef_class1" set test "typedef stripping" -gdb_test_multiple "python print str (basic_type_typedef_class1_obj)" $test= { +gdb_test_multiple "python print (str (basic_type_typedef_class1_obj))" $te= st { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -81,9 +81,9 @@ # test get_basic_type reference stripping gdb_test_no_output "python class1_ref_obj =3D gdb.parse_and_eval ('class1_= ref_obj')" gdb_test_no_output "python basic_type_class1_ref_obj =3D gdb.types.get_bas= ic_type (class1_ref_obj.type)" -gdb_test "python print str (class1_ref_obj.type)" "class1 &" +gdb_test "python print (str (class1_ref_obj.type))" "class1 &" set test "reference stripping" -gdb_test_multiple "python print str (basic_type_class1_ref_obj)" $test { +gdb_test_multiple "python print (str (basic_type_class1_ref_obj))" $test { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -92,9 +92,9 @@ # test nested typedef stripping gdb_test_no_output "python typedef_const_typedef_class1_obj =3D gdb.parse_= and_eval ('typedef_const_typedef_class1_obj')" gdb_test_no_output "python basic_type_typedef_const_typedef_class1_obj =3D= gdb.types.get_basic_type (typedef_const_typedef_class1_obj.type)" -gdb_test "python print str (typedef_class1_obj.type)" "typedef_class1" +gdb_test "python print (str (typedef_class1_obj.type))" "typedef_class1" set test "nested typedef stripping" -gdb_test_multiple "python print str (basic_type_typedef_const_typedef_clas= s1_obj)" $test { +gdb_test_multiple "python print (str (basic_type_typedef_const_typedef_cla= ss1_obj))" $test { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -103,9 +103,9 @@ # test nested typedef/reference stripping gdb_test_no_output "python typedef_const_typedef_class1_ref_obj =3D gdb.pa= rse_and_eval ('typedef_const_typedef_class1_ref_obj')" gdb_test_no_output "python basic_type_typedef_const_typedef_class1_ref_obj= =3D gdb.types.get_basic_type (typedef_const_typedef_class1_ref_obj.type)" -gdb_test "python print str (typedef_const_typedef_class1_ref_obj.type)" "c= onst typedef_const_typedef_class1_ref" +gdb_test "python print (str (typedef_const_typedef_class1_ref_obj.type))" = "const typedef_const_typedef_class1_ref" set test "nested typedef/ref stripping" -gdb_test_multiple "python print str (basic_type_typedef_const_typedef_clas= s1_ref_obj)" $test { +gdb_test_multiple "python print (str (basic_type_typedef_const_typedef_cla= ss1_ref_obj))" $test { -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" { pass $test } @@ -113,21 +113,20 @@ =20 # test has_field on simple class gdb_test_no_output "python class1_obj =3D gdb.parse_and_eval ('class1_obj'= )" -gdb_test "python print gdb.types.has_field (class1_obj.type, 'x')" "True" -gdb_test "python print gdb.types.has_field (class1_obj.type, 'nope')" "Fal= se" +gdb_test "python print (gdb.types.has_field (class1_obj.type, 'x'))" "True" +gdb_test "python print (gdb.types.has_field (class1_obj.type, 'nope'))" "F= alse" =20 # test has_field in base class gdb_test_no_output "python subclass1_obj =3D gdb.parse_and_eval ('subclass= 1_obj')" -gdb_test "python print gdb.types.has_field (subclass1_obj.type, 'x')" "Tru= e" +gdb_test "python print (gdb.types.has_field (subclass1_obj.type, 'x'))" "T= rue" =20 # test make_enum_dict gdb_test_no_output "python enum1_obj =3D gdb.parse_and_eval ('enum1_obj')" gdb_test_no_output "python enum1_dict =3D gdb.types.make_enum_dict (enum1_= obj.type)" -gdb_test_no_output "python enum1_list =3D enum1_dict.items ()" -gdb_test_no_output "python enum1_list.sort ()" -gdb_test "python print enum1_list" {\[\('A', 0L\), \('B', 1L\), \('C', 2L\= )\]} +gdb_test_no_output "python enum1_list =3D sorted (enum1_dict.items ())" +gdb_test "python print (enum1_list)" {\[\('A', 0L?\), \('B', 1L?\), \('C',= 2L?\)\]} =20 # test deep_items gdb_test_no_output "python struct_a =3D gdb.lookup_type ('struct A')" -gdb_test "python print struct_a.keys ()" {\['a', '', 'c', ''\]} -gdb_test "python print \[k for k,v in gdb.types.deep_items(struct_a)\]" {\= ['a', 'b0', 'b1', 'bb0', 'bb1', 'bbb0', 'bbb1', 'c', 'dd0', 'dd1', 'd2', 'd= 3'\]} +gdb_test "python print (struct_a.keys ())" {\['a', '', 'c', ''\]} +gdb_test "python print (\[k for k,v in gdb.types.deep_items(struct_a)\])" = {\['a', 'b0', 'b1', 'bb0', 'bb1', 'bbb0', 'bbb1', 'c', 'dd0', 'dd1', 'd2', = 'd3'\]} Index: gdb/testsuite/gdb.python/py-block.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-block.exp,v retrieving revision 1.11 diff -u -r1.11 py-block.exp --- gdb/testsuite/gdb.python/py-block.exp 22 Jun 2012 17:59:33 -0000 1.11 +++ gdb/testsuite/gdb.python/py-block.exp 9 Nov 2012 22:26:56 -0000 @@ -39,35 +39,35 @@ # Test initial innermost block. gdb_py_test_silent_cmd "python frame =3D gdb.selected_frame()" "Get Frame"= 0 gdb_py_test_silent_cmd "python block =3D frame.block()" "Get block" 0 -gdb_test "python print block" "" "Check block no= t None" -gdb_test "python print block.function" "None" "First anonymous block" -gdb_test "python print block.start" "${decimal}" "Check start not None" -gdb_test "python print block.end" "${decimal}" "Check end not None" +gdb_test "python print (block)" "" "Check block = not None" +gdb_test "python print (block.function)" "None" "First anonymous block" +gdb_test "python print (block.start)" "${decimal}" "Check start not None" +gdb_test "python print (block.end)" "${decimal}" "Check end not None" =20 # Test global/static blocks gdb_py_test_silent_cmd "python frame =3D gdb.selected_frame()" "Get Frame"= 0 gdb_py_test_silent_cmd "python block =3D frame.block()" "Get block" 0 -gdb_test "python print block.is_global" "False" "Not a global block" -gdb_test "python print block.is_static" "False" "Not a static block" +gdb_test "python print (block.is_global)" "False" "Not a global block" +gdb_test "python print (block.is_static)" "False" "Not a static block" gdb_py_test_silent_cmd "python gblock =3D block.global_block" "Get block" 1 gdb_py_test_silent_cmd "python sblock =3D block.static_block" "Get block" 1 -gdb_test "python print gblock.is_global" "True" "Is the global block" -gdb_test "python print sblock.is_static" "True" "Is the static block" +gdb_test "python print (gblock.is_global)" "True" "Is the global block" +gdb_test "python print (sblock.is_static)" "True" "Is the static block" =20 # Move up superblock(s) until we reach function block_func. gdb_test_no_output "python block =3D block.superblock" "Get superblock" -gdb_test "python print block.function" "None" "Second anonymous block" +gdb_test "python print (block.function)" "None" "Second anonymous block" gdb_test_no_output "python block =3D block.superblock" "Get superblock 2" -gdb_test "python print block.function" "block_func" \ +gdb_test "python print (block.function)" "block_func" \ "Print superblock 2 function" =20 # Switch frames, then test for main block. gdb_test "up" ".*" gdb_py_test_silent_cmd "python frame =3D gdb.selected_frame()" "Get Frame = 2" 0 gdb_py_test_silent_cmd "python block =3D frame.block()" "Get Frame 2's blo= ck" 0 -gdb_test "python print block" "" \ +gdb_test "python print (block)" "" \ "Check Frame 2's block not None" -gdb_test "python print block.function" "main" "main block" +gdb_test "python print (block.function)" "main" "main block" =20 =20 # Test Block is_valid. This must always be the last test in this @@ -76,12 +76,12 @@ gdb_py_test_silent_cmd "python frame =3D gdb.selected_frame()" "Get Frame"= 0 gdb_py_test_silent_cmd "python block =3D frame.block()" "Get Frame block" 0 gdb_py_test_silent_cmd "python block_iter =3D iter (block)" "Get Frame blo= ck" 0 -gdb_test "python print block.is_valid()" "True" \ +gdb_test "python print (block.is_valid())" "True" \ "Check block validity" -gdb_test "python print block_iter.is_valid()" "True" \ +gdb_test "python print (block_iter.is_valid())" "True" \ "Check block validity" gdb_unload -gdb_test "python print block.is_valid()" "False" \ +gdb_test "python print (block.is_valid())" "False" \ "Check block validity" -gdb_test "python print block_iter.is_valid()" "False" \ +gdb_test "python print (block_iter.is_valid())" "False" \ "Check block validity" Index: gdb/testsuite/gdb.python/py-breakpoint.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-breakpoint.exp,v retrieving revision 1.15 diff -u -r1.15 py-breakpoint.exp --- gdb/testsuite/gdb.python/py-breakpoint.exp 22 Jun 2012 17:59:33 -0000 1= .15 +++ gdb/testsuite/gdb.python/py-breakpoint.exp 9 Nov 2012 22:26:56 -0000 @@ -37,8 +37,8 @@ # Initially there should be one breakpoint: main. =20 gdb_py_test_silent_cmd "python blist =3D gdb.breakpoints()" "Get Breakpoin= t List" 0 -gdb_test "python print blist\[0\]" "" "Chec= k obj exists" -gdb_test "python print blist\[0\].location" "main." "Check breakpoint loca= tion" +gdb_test "python print (blist\[0\])" "" "Ch= eck obj exists" +gdb_test "python print (blist\[0\].location)" "main." "Check breakpoint lo= cation" =20 set mult_line [gdb_get_line_number "Break at multiply."] gdb_breakpoint ${mult_line} @@ -47,25 +47,25 @@ # Check that the Python breakpoint code noted the addition of a # breakpoint "behind the scenes".=20 gdb_py_test_silent_cmd "python blist =3D gdb.breakpoints()" "Get Breakpoin= t List" 0 -gdb_test "python print len(blist)" "2" "Check for two breakpoints" -gdb_test "python print blist\[0\]" "" "Chec= k obj exists" -gdb_test "python print blist\[0\].location" "main." "Check breakpoint loca= tion" -gdb_test "python print blist\[1\]" "" "Chec= k obj exists" +gdb_test "python print (len(blist))" "2" "Check for two breakpoints" +gdb_test "python print (blist\[0\])" "" "Ch= eck obj exists" +gdb_test "python print (blist\[0\].location)" "main." "Check breakpoint lo= cation" +gdb_test "python print (blist\[1\])" "" "Ch= eck obj exists" =20 -gdb_test "python print blist\[1\].location" "py-breakpoint\.c:${mult_line}= *" \ +gdb_test "python print (blist\[1\].location)" "py-breakpoint\.c:${mult_lin= e}*" \ "Check breakpoint location" =20 # Check hit and ignore counts.=20 -gdb_test "python print blist\[1\].hit_count" "1" "Check breakpoint hit cou= nt" +gdb_test "python print (blist\[1\].hit_count)" "1" "Check breakpoint hit c= ount" gdb_py_test_silent_cmd "python blist\[1\].ignore_count =3D 4" "Set breakpo= int hit count" 0 gdb_continue_to_breakpoint "Break at multiply." -gdb_test "python print blist\[1\].hit_count" "6" "Check breakpoint hit cou= nt" +gdb_test "python print (blist\[1\].hit_count)" "6" "Check breakpoint hit c= ount" gdb_test "print result" " =3D 545" "Check expected variable result after 6= iterations" =20 # Test breakpoint is enabled and disabled correctly.. gdb_breakpoint [gdb_get_line_number "Break at add."] gdb_continue_to_breakpoint "Break at add." -gdb_test "python print blist\[1\].enabled" "True" "Check breakpoint enable= d." +gdb_test "python print (blist\[1\].enabled)" "True" "Check breakpoint enab= led." gdb_py_test_silent_cmd "python blist\[1\].enabled =3D False" "Set breakpo= int disabled." 0 gdb_continue_to_breakpoint "Break at add." gdb_py_test_silent_cmd "python blist\[1\].enabled =3D True" "Set breakpoi= nt enabled." 0 @@ -73,11 +73,11 @@ =20 # Test other getters and setters. gdb_py_test_silent_cmd "python blist =3D gdb.breakpoints()" "Get Breakpoin= t List" 0 -gdb_test "python print blist\[1\].thread" "None" "Check breakpoint thread" -gdb_test "python print blist\[1\].type =3D=3D gdb.BP_BREAKPOINT" "True" "C= heck breakpoint type" -gdb_test "python print blist\[0\].number" "1" "Check breakpoint number" -gdb_test "python print blist\[1\].number" "2" "Check breakpoint number" -gdb_test "python print blist\[2\].number" "3" "Check breakpoint number" +gdb_test "python print (blist\[1\].thread)" "None" "Check breakpoint threa= d" +gdb_test "python print (blist\[1\].type =3D=3D gdb.BP_BREAKPOINT)" "True" = "Check breakpoint type" +gdb_test "python print (blist\[0\].number)" "1" "Check breakpoint number" +gdb_test "python print (blist\[1\].number)" "2" "Check breakpoint number" +gdb_test "python print (blist\[2\].number)" "3" "Check breakpoint number" =20 # Start with a fresh gdb. clean_restart ${testfile} @@ -93,12 +93,12 @@ gdb_py_test_silent_cmd "python dp1 =3D gdb.Breakpoint (\"$deltst_location= \")" "Set breakpoint" 0 gdb_breakpoint [gdb_get_line_number "Break at end."] gdb_py_test_silent_cmd "python del_list =3D gdb.breakpoints()" "Get Breakp= oint List" 0 -gdb_test "python print len(del_list)" "3" "Number of breakpoints before de= lete" +gdb_test "python print (len(del_list))" "3" "Number of breakpoints before = delete" gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$deltst_locat= ion.*" gdb_py_test_silent_cmd "python dp1.delete()" "Delete Breakpoint" 0 -gdb_test "python print dp1.number" "RuntimeError: Breakpoint 2 is invalid.= *" "Check breakpoint invalidated" +gdb_test "python print (dp1.number)" "RuntimeError: Breakpoint 2 is invali= d.*" "Check breakpoint invalidated" gdb_py_test_silent_cmd "python del_list =3D gdb.breakpoints()" "Get Breakp= oint List" 0 -gdb_test "python print len(del_list)" "2" "Number of breakpoints after del= ete" +gdb_test "python print (len(del_list))" "2" "Number of breakpoints after d= elete" gdb_continue_to_breakpoint "Break at end." ".*/$srcfile:$end_location.*" =20 =20 @@ -115,11 +115,11 @@ gdb_py_test_silent_cmd "python bp1 =3D gdb.Breakpoint (\"$bp_location1\")= " "Set breakpoint" 0 gdb_continue_to_breakpoint "Break at multiply." gdb_py_test_silent_cmd "python bp1.condition =3D \"i =3D=3D 5\"" "Set bre= akpoint" 0 -gdb_test "python print bp1.condition" "i =3D=3D 5" "Test conditional has b= een set" +gdb_test "python print (bp1.condition)" "i =3D=3D 5" "Test conditional has= been set" gdb_continue_to_breakpoint "Break at multiply." gdb_test "print i" "5" "Test conditional breakpoint stopped after five ite= rations" gdb_py_test_silent_cmd "python bp1.condition =3D None" "Clear condition"= 0 -gdb_test "python print bp1.condition" "None" "Test conditional read" +gdb_test "python print (bp1.condition)" "None" "Test conditional read" gdb_continue_to_breakpoint "Break at multiply." gdb_test "print i" "6" "Test breakpoint stopped after six iterations" =20 @@ -134,7 +134,7 @@ gdb_test "end" =20 gdb_py_test_silent_cmd "python blist =3D gdb.breakpoints()" "Get Breakpoin= t List" 0 -gdb_test "python print blist\[len(blist)-1\].commands" "print \"Command fo= r breakpoint has been executed.\".*print result" +gdb_test "python print (blist\[len(blist)-1\].commands)" "print \"Command = for breakpoint has been executed.\".*print result" =20 # Start with a fresh gdb. clean_restart ${testfile} @@ -149,16 +149,16 @@ set ibp_location [gdb_get_line_number "Break at multiply."] gdb_py_test_silent_cmd "python ibp =3D gdb.Breakpoint(\"$ibp_location\", = internal=3DFalse)" "Set invisible breakpoint" 0 gdb_py_test_silent_cmd "python ilist =3D gdb.breakpoints()" "Get Breakpoin= t List" 0 -gdb_test "python print ilist\[0\]" "" "Chec= k invisible bp obj exists" -gdb_test "python print ilist\[0\].location" "py-breakpoint\.c:$ibp_locatio= n*" "Check breakpoint location" -gdb_test "python print ilist\[0\].visible" "True" "Check breakpoint visibi= lity" +gdb_test "python print (ilist\[0\])" "" "Ch= eck invisible bp obj exists" +gdb_test "python print (ilist\[0\].location)" "py-breakpoint\.c:$ibp_locat= ion*" "Check breakpoint location" +gdb_test "python print (ilist\[0\].visible)" "True" "Check breakpoint visi= bility" gdb_test "info breakpoints" "py-breakpoint\.c:$ibp_location.*" "Check info= breakpoints shows visible breakpoints" delete_breakpoints gdb_py_test_silent_cmd "python ibp =3D gdb.Breakpoint(\"$ibp_location\", = internal=3DTrue)" "Set invisible breakpoint" 0 gdb_py_test_silent_cmd "python ilist =3D gdb.breakpoints()" "Get Breakpoin= t List" 0 -gdb_test "python print ilist\[0\]" "" "Chec= k invisible bp obj exists" -gdb_test "python print ilist\[0\].location" "py-breakpoint\.c:$ibp_locatio= n*" "Check breakpoint location" -gdb_test "python print ilist\[0\].visible" "False" "Check breakpoint visib= ility" +gdb_test "python print (ilist\[0\])" "" "Ch= eck invisible bp obj exists" +gdb_test "python print (ilist\[0\].location)" "py-breakpoint\.c:$ibp_locat= ion*" "Check breakpoint location" +gdb_test "python print (ilist\[0\].visible)" "False" "Check breakpoint vis= ibility" gdb_test "info breakpoints" "No breakpoints or watchpoints.*" "Check info = breakpoints does not show invisible breakpoints" gdb_test "maint info breakpoints" "py-breakpoint\.c:$ibp_location.*" "Chec= k maint info breakpoints shows invisible breakpoints" =20 @@ -251,10 +251,10 @@ gdb_py_test_silent_cmd "python never_eval_bp1 =3D bp_also_eval(\"$end_loc= ation\")" "Set breakpoint" 0 gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$bp_location2= .*" gdb_test "print i" "3" "Check inferior value matches python accounting" -gdb_test "python print eval_bp1.inf_i" "3" "Check python accounting matche= s inferior" -gdb_test "python print also_eval_bp1.count" "4" \ +gdb_test "python print (eval_bp1.inf_i)" "3" "Check python accounting matc= hes inferior" +gdb_test "python print (also_eval_bp1.count)" "4" \ "Check non firing same-location breakpoint eval function was also call= ed at each stop." -gdb_test "python print eval_bp1.count" "4" \ +gdb_test "python print (eval_bp1.count)" "4" \ "Check non firing same-location breakpoint eval function was also call= ed at each stop." =20 delete_breakpoints @@ -279,10 +279,10 @@ delete_breakpoints gdb_breakpoint [gdb_get_line_number "Break at multiply."] gdb_py_test_silent_cmd "python check_eval =3D bp_eval(\"$bp_location2\")"= "Set breakpoint" 0 -gdb_test "python print check_eval.count" "0" \ +gdb_test "python print (check_eval.count)" "0" \ "Test that evaluate function has not been yet executed (ie count =3D 0= )" gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$bp_location2= .*" -gdb_test "python print check_eval.count" "1" \ +gdb_test "python print (check_eval.count)" "1" \ "Test that evaluate function is run when location also has normal bp" =20 gdb_py_test_multiple "Sub-class a watchpoint" \ @@ -298,5 +298,5 @@ delete_breakpoints gdb_py_test_silent_cmd "python wp1 =3D wp_eval (\"result\", type=3Dgdb.BP= _WATCHPOINT, wp_class=3Dgdb.WP_WRITE)" "Set watchpoint" 0 gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value =3D.*New value = =3D 788.*" "Test watchpoint write" -gdb_test "python print never_eval_bp1.count" "0" \ +gdb_test "python print (never_eval_bp1.count)" "0" \ "Check that this unrelated breakpoints eval function was never called." Index: gdb/testsuite/gdb.python/py-cmd.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-cmd.exp,v retrieving revision 1.9 diff -u -r1.9 py-cmd.exp --- gdb/testsuite/gdb.python/py-cmd.exp 1 Mar 2012 19:30:25 -0000 1.9 +++ gdb/testsuite/gdb.python/py-cmd.exp 9 Nov 2012 22:26:56 -0000 @@ -35,7 +35,7 @@ " def __init__ (self):" "" \ " super (test_cmd, self).__init__ (\"test_cmd\", gdb.COMMAND_OBSCURE)= " "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"test_cmd output, arg =3D %s\" % arg" "" \ + " print (\"test_cmd output, arg =3D %s\" % arg)" "" \ "test_cmd ()" "" \ "end" "" =20 @@ -49,7 +49,7 @@ " def __init__ (self):" "" \ " super (prefix_cmd, self).__init__ (\"prefix_cmd\", gdb.COMMAND_OBSC= URE, gdb.COMPLETE_NONE, True)" "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"prefix_cmd output, arg =3D %s\" % arg" "" \ + " print (\"prefix_cmd output, arg =3D %s\" % arg)" "" \ "prefix_cmd ()" "" \ "end" "" =20 @@ -61,7 +61,7 @@ " def __init__ (self):" "" \ " super (subcmd, self).__init__ (\"prefix_cmd subcmd\", gdb.COMMAND_O= BSCURE)" "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"subcmd output, arg =3D %s\" % arg" "" \ + " print (\"subcmd output, arg =3D %s\" % arg)" "" \ "subcmd ()" "" \ "end" "" =20 @@ -75,7 +75,7 @@ " def __init__ (self):" "" \ " super (prefix_cmd2, self).__init__ (\"prefix_cmd2\", gdb.COMMAND_OB= SCURE, prefix =3D True, completer_class =3D gdb.COMPLETE_FILENAME)" "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"prefix_cmd2 output, arg =3D %s\" % arg" "" \ + " print (\"prefix_cmd2 output, arg =3D %s\" % arg)" "" \ "prefix_cmd2 ()" "" \ "end" "" =20 @@ -87,7 +87,7 @@ " def __init__ (self):" "" \ " super (subcmd, self).__init__ (\"prefix_cmd2 subcmd\", gdb.COMMAND_= OBSCURE)" "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"subcmd output, arg =3D %s\" % arg" "" \ + " print (\"subcmd output, arg =3D %s\" % arg)" "" \ "subcmd ()" "" \ "end" "" =20 @@ -101,7 +101,7 @@ " def __init__ (self):" "" \ " super (newsubcmd, self).__init__ (\"info newsubcmd\", gdb.COMMAND_O= BSCURE)" "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"newsubcmd output, arg =3D %s\" % arg" "" \ + " print (\"newsubcmd output, arg =3D %s\" % arg)" "" \ "newsubcmd ()" "" \ "end" "" =20 @@ -123,19 +123,19 @@ =20 # Test gdb.string_to_argv. =20 -gdb_test "python print gdb.string_to_argv (\"1 2 3\")" \ +gdb_test "python print (gdb.string_to_argv (\"1 2 3\"))" \ {\['1', '2', '3'\]} \ "string_to_argv (\"1 2 3\")" =20 -gdb_test "python print gdb.string_to_argv (\"'1 2' 3\")" \ +gdb_test "python print (gdb.string_to_argv (\"'1 2' 3\"))" \ {\['1 2', '3'\]} \ "string_to_argv (\"'1 2' 3\")" =20 -gdb_test "python print gdb.string_to_argv ('\"1 2\" 3')" \ +gdb_test "python print (gdb.string_to_argv ('\"1 2\" 3'))" \ {\['1 2', '3'\]} \ "string_to_argv ('\"1 2\" 3')" =20 -gdb_test "python print gdb.string_to_argv ('1\\ 2 3')" \ +gdb_test "python print (gdb.string_to_argv ('1\\ 2 3'))" \ {\['1 2', '3'\]} \ "string_to_argv ('1\\ 2 3')" =20 @@ -147,7 +147,7 @@ " def __init__ (self):" "" \ " super (test_help, self).__init__ (\"test_help\", gdb.COMMAND_USER)"= "" \ " def invoke (self, arg, from_tty):" "" \ - " print \"test_cmd output, arg =3D %s\" % arg" "" \ + " print (\"test_cmd output, arg =3D %s\" % arg)" "" \ "test_help ()" "" \ "end" "" =20 Index: gdb/testsuite/gdb.python/py-events.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-events.exp,v retrieving revision 1.12 diff -u -r1.12 py-events.exp --- gdb/testsuite/gdb.python/py-events.exp 22 Jun 2012 17:59:33 -0000 1.12 +++ gdb/testsuite/gdb.python/py-events.exp 9 Nov 2012 22:26:56 -0000 @@ -43,7 +43,7 @@ =20 if { [skip_python_tests] } { continue } =20 -gdb_test_no_output "python execfile ('${pyfile}')" "" +gdb_test_no_output "python exec (open ('${pyfile}').read ())" "" =20 gdb_test "Test_Newobj_Events" "New ObjectFile Event tester registered." "R= egister new objfile event handler" =20 Index: gdb/testsuite/gdb.python/py-events.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-events.py,v retrieving revision 1.6 diff -u -r1.6 py-events.py --- gdb/testsuite/gdb.python/py-events.py 17 Feb 2012 19:24:27 -0000 1.6 +++ gdb/testsuite/gdb.python/py-events.py 9 Nov 2012 22:26:56 -0000 @@ -19,46 +19,46 @@ =20 def signal_stop_handler (event): if (isinstance (event, gdb.StopEvent)): - print "event type: stop" + print ("event type: stop") if (isinstance (event, gdb.SignalEvent)): - print "stop reason: signal" - print "stop signal: %s" % (event.stop_signal) + print ("stop reason: signal") + print ("stop signal: %s" % (event.stop_signal)) if ( event.inferior_thread is not None) : - print "thread num: %s" % (event.inferior_thread.num); + print ("thread num: %s" % (event.inferior_thread.num)) =20 def breakpoint_stop_handler (event): if (isinstance (event, gdb.StopEvent)): - print "event type: stop" + print ("event type: stop") if (isinstance (event, gdb.BreakpointEvent)): - print "stop reason: breakpoint" - print "first breakpoint number: %s" % (event.breakpoint.number) + print ("stop reason: breakpoint") + print ("first breakpoint number: %s" % (event.breakpoint.number)) for bp in event.breakpoints: - print "breakpoint number: %s" % (bp.number) + print ("breakpoint number: %s" % (bp.number)) if ( event.inferior_thread is not None) : - print "thread num: %s" % (event.inferior_thread.num); + print ("thread num: %s" % (event.inferior_thread.num)) else: - print "all threads stopped" + print ("all threads stopped") =20 def exit_handler (event): if (isinstance (event, gdb.ExitedEvent)): - print "event type: exit" - print "exit code: %d" % (event.exit_code) - print "exit inf: %d" % (event.inferior.num) - print "dir ok: %s" % str('exit_code' in dir(event)) + print ("event type: exit") + print ("exit code: %d" % (event.exit_code)) + print ("exit inf: %d" % (event.inferior.num)) + print ("dir ok: %s" % str('exit_code' in dir(event))) =20 def continue_handler (event): if (isinstance (event, gdb.ContinueEvent)): - print "event type: continue" + print ("event type: continue") if ( event.inferior_thread is not None) : - print "thread num: %s" % (event.inferior_thread.num); + print ("thread num: %s" % (event.inferior_thread.num)) =20 def new_objfile_handler (event): if (isinstance (event, gdb.NewObjFileEvent)): - print "event type: new_objfile" + print ("event type: new_objfile") if (event.new_objfile is not None): - print "new objfile name: %s" % (event.new_objfile.filename) + print ("new objfile name: %s" % (event.new_objfile.filename)) else: - print "new objfile is None" + print ("new objfile is None") =20 class test_events (gdb.Command): """Test events.""" @@ -71,7 +71,7 @@ gdb.events.stop.connect (breakpoint_stop_handler) gdb.events.exited.connect (exit_handler) gdb.events.cont.connect (continue_handler) - print "Event testers registered." + print ("Event testers registered.") =20 test_events () =20 @@ -83,6 +83,6 @@ =20 def invoke (self, arg, from_tty): gdb.events.new_objfile.connect (new_objfile_handler) - print "New ObjectFile Event tester registered." + print ("New ObjectFile Event tester registered.") =20 test_newobj_events () Index: gdb/testsuite/gdb.python/py-evsignal.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-evsignal.exp,v retrieving revision 1.4 diff -u -r1.4 py-evsignal.exp --- gdb/testsuite/gdb.python/py-evsignal.exp 22 Jun 2012 17:59:33 -0000 1.4 +++ gdb/testsuite/gdb.python/py-evsignal.exp 9 Nov 2012 22:26:56 -0000 @@ -31,7 +31,7 @@ =20 if { [skip_python_tests] } { continue } =20 -gdb_test_no_output "python execfile ('${pyfile}')" "" +gdb_test_no_output "python exec (open ('${pyfile}').read ())" "" =20 gdb_test "Test_Events" "Event testers registered." gdb_test_no_output "set non-stop on" Index: gdb/testsuite/gdb.python/py-evthreads.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-evthreads.exp,v retrieving revision 1.9 diff -u -r1.9 py-evthreads.exp --- gdb/testsuite/gdb.python/py-evthreads.exp 22 Jun 2012 17:59:33 -0000 1.9 +++ gdb/testsuite/gdb.python/py-evthreads.exp 9 Nov 2012 22:26:56 -0000 @@ -36,7 +36,7 @@ =20 if { [skip_python_tests] } { continue } =20 -gdb_test_no_output "python execfile ('${pyfile}')" "" +gdb_test_no_output "python exec (open ('${pyfile}').read ())" "" =20 gdb_test "Test_Events" "Event testers registered." gdb_test_no_output "set non-stop on" Index: gdb/testsuite/gdb.python/py-finish-breakpoint.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-finish-breakpoint.exp,v retrieving revision 1.7 diff -u -r1.7 py-finish-breakpoint.exp --- gdb/testsuite/gdb.python/py-finish-breakpoint.exp 22 Jun 2012 17:59:33 = -0000 1.7 +++ gdb/testsuite/gdb.python/py-finish-breakpoint.exp 9 Nov 2012 22:26:56 -= 0000 @@ -23,6 +23,13 @@ =20 load_lib gdb-python.exp =20 +if { $gdb_py_is_py24 =3D=3D 1 } { + # Python 2.4, 2.5 do not support the "ValueError as e" syntax used in + # the py-finish-breakpoint.py script. + untested py-finish-breakpoint.exp + return 0 +} + set libfile "py-events-shlib" set libsrc $srcdir/$subdir/$libfile.c set lib_sl [standard_output_file $libfile-nodebug.so] @@ -74,17 +81,17 @@ "Temporary breakpoint.*" "set FinishBreakpoint with default frame= value" gdb_test "python finishbp =3D MyFinishBreakpoint (gdb.parse_and_eval ('a')= , gdb.newest_frame ())" \ "Temporary breakpoint.*" "set FinishBreakpoint" -gdb_test "python print finishbp.return_value" "None.*" \ +gdb_test "python print (finishbp.return_value)" "None.*" \ "check return_value at init" =20 # check normal bp hit =20 gdb_test "continue" "MyFinishBreakpoint stop with.*return_value is: -5.*#0= .*increase.*" \ "check MyFinishBreakpoint hit" -gdb_test "python print finishbp.return_value" "-5.*" "check return_value" +gdb_test "python print (finishbp.return_value)" "-5.*" "check return_value" =20 -gdb_test "python print finishbp_default.hit_count" "1.*" "check finishBP o= n default frame has been hit" -gdb_test "python print finishbp.is_valid()" "False.*"\ +gdb_test "python print (finishbp_default.hit_count)" "1.*" "check finishBP= on default frame has been hit" +gdb_test "python print (finishbp.is_valid())" "False.*"\ "ensure that finish bp is invalid afer normal hit" =20 # check FinishBreakpoint in main no allowed @@ -119,7 +126,7 @@ "SimpleFinishBreakpoint init" \ "set finish breakpoint" gdb_test "continue" "SimpleFinishBreakpoint stop.*" "check FinishBreakpoin= t hit" -gdb_test "python print finishBP.return_value" "None" "check return value w= ithout debug symbol" +gdb_test "python print (finishBP.return_value)" "None" "check return value= without debug symbol" =20 # # Test FinishBreakpoint in function returned by longjmp=20 @@ -143,7 +150,7 @@ "set BP after the jump" gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" \ "check FinishBP out of scope notification" -gdb_test "python print finishbp.is_valid()" "False.*"\ +gdb_test "python print (finishbp.is_valid())" "False.*"\ "ensure that finish bp is invalid afer out of scope notification" =20 # Index: gdb/testsuite/gdb.python/py-finish-breakpoint.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-finish-breakpoint.py,v retrieving revision 1.3 diff -u -r1.3 py-finish-breakpoint.py --- gdb/testsuite/gdb.python/py-finish-breakpoint.py 20 Jan 2012 20:00:14 -= 0000 1.3 +++ gdb/testsuite/gdb.python/py-finish-breakpoint.py 9 Nov 2012 22:26:56 -0= 000 @@ -15,75 +15,75 @@ =20 # This file is part of the GDB testsuite. It tests python Finish # Breakpoints. -=09=09 +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 class MyFinishBreakpoint (gdb.FinishBreakpoint): - def __init__(self, val, frame): - gdb.FinishBreakpoint.__init__ (self, frame) - print "MyFinishBreakpoint init" - self.val =3D val -=09=09 - def stop(self): - print "MyFinishBreakpoint stop with %d" % int (self.val.dereference ()) - print "return_value is: %d" % int (self.return_value) - gdb.execute ("where 1") - return True -=09 - def out_of_scope(self): - print "MyFinishBreakpoint out of scope" + def __init__(self, val, frame): + gdb.FinishBreakpoint.__init__ (self, frame) + print ("MyFinishBreakpoint init") + self.val =3D val +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 + def stop(self): + print ("MyFinishBreakpoint stop with %d" % int (self.val.d= ereference ())) + print ("return_value is: %d" % int (self.return_value)) + gdb.execute ("where 1") + return True +=20=20=20=20=20=20=20=20 + def out_of_scope(self): + print ("MyFinishBreakpoint out of scope") =20 class TestBreakpoint(gdb.Breakpoint): def __init__(self): gdb.Breakpoint.__init__ (self, spec=3D"test_1", internal=3D1) self.silent =3D True self.count =3D 0 - print "TestBreakpoint init" + print ("TestBreakpoint init") =20=20=20=20=20=20=20=20=20 def stop(self): - self.count +=3D 1 - try: - TestFinishBreakpoint (gdb.newest_frame (), self.count) + self.count +=3D 1 + try: + TestFinishBreakpoint (gdb.newest_frame (), self.count) except ValueError as e: - print e + print (e) return False =20 class TestFinishBreakpoint (gdb.FinishBreakpoint): def __init__ (self, frame, count): - self.count =3D count + self.count =3D count gdb.FinishBreakpoint.__init__ (self, frame, internal=3D1) =20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20 def stop(self): - print "-->", self.number + print ("-->", self.number) if (self.count =3D=3D 3): - print "test stop: %d" % self.count + print ("test stop: %d" % self.count) return True else: - print "test don't stop: %d" % self.count + print ("test don't stop: %d" % self.count) return False=20 =20=20=20=20=20=20=20=20=20 =20=20=20=20=20 def out_of_scope(self): - print "test didn't finish: %d" % self.count + print ("test didn't finish: %d" % self.count) =20 class TestExplicitBreakpoint(gdb.Breakpoint): - def stop(self): - try: - SimpleFinishBreakpoint (gdb.newest_frame ()) - except ValueError as e: - print e - return False + def stop(self): + try: + SimpleFinishBreakpoint (gdb.newest_frame ()) + except ValueError as e: + print (e) + return False =20 class SimpleFinishBreakpoint(gdb.FinishBreakpoint): - def __init__(self, frame): - gdb.FinishBreakpoint.__init__ (self, frame) -=09=09 - print "SimpleFinishBreakpoint init" -=09=09 - def stop(self): - print "SimpleFinishBreakpoint stop"=20 - return True -=09 - def out_of_scope(self): - print "SimpleFinishBreakpoint out of scope" + def __init__(self, frame): + gdb.FinishBreakpoint.__init__ (self, frame) +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 + print ("SimpleFinishBreakpoint init") +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 + def stop(self): + print ("SimpleFinishBreakpoint stop" ) + return True +=20=20=20=20=20=20=20=20 + def out_of_scope(self): + print ("SimpleFinishBreakpoint out of scope") =20 -print "Python script imported" +print ("Python script imported") Index: gdb/testsuite/gdb.python/py-finish-breakpoint2.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp,v retrieving revision 1.5 diff -u -r1.5 py-finish-breakpoint2.exp --- gdb/testsuite/gdb.python/py-finish-breakpoint2.exp 22 Jun 2012 17:59:33= -0000 1.5 +++ gdb/testsuite/gdb.python/py-finish-breakpoint2.exp 9 Nov 2012 22:26:56 = -0000 @@ -45,10 +45,10 @@ gdb_breakpoint "throw_exception_1" gdb_test "continue" "Breakpoint .*throw_exception_1.*" "run to exception 1" =20 -gdb_test "python print len(gdb.breakpoints())" "3" "check BP count" +gdb_test "python print (len(gdb.breakpoints()))" "3" "check BP count" gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" "init Exce= ptionFinishBreakpoint" "set FinishBP after the exception" gdb_test "continue" ".*stopped at ExceptionFinishBreakpoint.*" "check Fini= shBreakpoint in catch()" -gdb_test "python print len(gdb.breakpoints())" "3" "check finish BP remova= l" +gdb_test "python print (len(gdb.breakpoints()))" "3" "check finish BP remo= val" =20 gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" "continue to seco= nd exception" gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" "init Exce= ptionFinishBreakpoint" "set FinishBP after the exception" Index: gdb/testsuite/gdb.python/py-finish-breakpoint2.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-finish-breakpoint2.py,v retrieving revision 1.2 diff -u -r1.2 py-finish-breakpoint2.py --- gdb/testsuite/gdb.python/py-finish-breakpoint2.py 4 Jan 2012 08:27:49 -= 0000 1.2 +++ gdb/testsuite/gdb.python/py-finish-breakpoint2.py 9 Nov 2012 22:26:56 -= 0000 @@ -19,15 +19,15 @@ class ExceptionFinishBreakpoint(gdb.FinishBreakpoint): def __init__(self, frame): gdb.FinishBreakpoint.__init__ (self, frame, internal=3D1) - self.silent =3D True; - print "init ExceptionFinishBreakpoint" + self.silent =3D True + print ("init ExceptionFinishBreakpoint") =20=20=20=20=20=20=20=20=20 def stop(self): - print "stopped at ExceptionFinishBreakpoint" + print ("stopped at ExceptionFinishBreakpoint") return True=20 =20=20=20=20=20 def out_of_scope(self): - print "exception did not finish ..." + print ("exception did not finish ...") =20 =20 -print "Python script imported" +print ("Python script imported") Index: gdb/testsuite/gdb.python/py-frame-inline.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-frame-inline.exp,v retrieving revision 1.3 diff -u -r1.3 py-frame-inline.exp --- gdb/testsuite/gdb.python/py-frame-inline.exp 22 Jun 2012 17:59:33 -0000= 1.3 +++ gdb/testsuite/gdb.python/py-frame-inline.exp 9 Nov 2012 22:26:56 -0000 @@ -36,4 +36,4 @@ =20 gdb_test "up" "#1 g .*" =20 -gdb_test "python print gdb.selected_frame().read_var('l')" "\r\n42" +gdb_test "python print (gdb.selected_frame().read_var('l'))" "\r\n42" Index: gdb/testsuite/gdb.python/py-frame.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-frame.exp,v retrieving revision 1.13 diff -u -r1.13 py-frame.exp --- gdb/testsuite/gdb.python/py-frame.exp 22 Jun 2012 17:59:33 -0000 1.13 +++ gdb/testsuite/gdb.python/py-frame.exp 9 Nov 2012 22:26:56 -0000 @@ -39,24 +39,24 @@ gdb_py_test_silent_cmd "python bf1 =3D gdb.selected_frame ()" "get frame" 0 =20 # First test that read_var is unaffected by PR 11036 changes. -gdb_test "python print bf1.read_var(\"i\")" "\"stuff\"" "test i" -gdb_test "python print bf1.read_var(\"f\")" "\"foo\"" "test f" -gdb_test "python print bf1.read_var(\"b\")" "\"bar\"" "test b" +gdb_test "python print (bf1.read_var(\"i\"))" "\"stuff\"" "test i" +gdb_test "python print (bf1.read_var(\"f\"))" "\"foo\"" "test f" +gdb_test "python print (bf1.read_var(\"b\"))" "\"bar\"" "test b" =20 # Test the read_var function in another block other than the current # block (in this case, the super block). Test thar read_var is reading # the correct variables of i and f but they are the correct value and type. gdb_py_test_silent_cmd "python sb =3D bf1.block().superblock" "get superbl= ock" 0 -gdb_test "python print bf1.read_var(\"i\", sb)" "1.1.*" "test i =3D 1.1" -gdb_test "python print bf1.read_var(\"i\", sb).type" "double" "test double= i" -gdb_test "python print bf1.read_var(\"f\", sb)" "2.2.*" "test f =3D 2.2" -gdb_test "python print bf1.read_var(\"f\", sb).type" "double" "test double= f" +gdb_test "python print (bf1.read_var(\"i\", sb))" "1.1.*" "test i =3D 1.1" +gdb_test "python print (bf1.read_var(\"i\", sb).type)" "double" "test doub= le i" +gdb_test "python print (bf1.read_var(\"f\", sb))" "2.2.*" "test f =3D 2.2" +gdb_test "python print (bf1.read_var(\"f\", sb).type)" "double" "test doub= le f" =20 # And again test another outerblock, this time testing "i" is the # correct value and type. gdb_py_test_silent_cmd "python sb =3D sb.superblock" "get superblock" 0 -gdb_test "python print bf1.read_var(\"i\", sb)" "99" "test i =3D 99" -gdb_test "python print bf1.read_var(\"i\", sb).type" "int" "test int i" +gdb_test "python print (bf1.read_var(\"i\", sb))" "99" "test i =3D 99" +gdb_test "python print (bf1.read_var(\"i\", sb).type)" "int" "test int i" =20 gdb_breakpoint "f2" gdb_continue_to_breakpoint "breakpoint at f2" @@ -67,26 +67,26 @@ gdb_py_test_silent_cmd "python f1 =3D gdb.selected_frame ()" "get second f= rame" 0 gdb_py_test_silent_cmd "python f0 =3D f1.newer ()" "get first frame" 0 =20 -gdb_test "python print f1 =3D=3D gdb.newest_frame()" False \ +gdb_test "python print (f1 =3D=3D gdb.newest_frame())" False \ "selected frame -vs- newest frame" -gdb_test "python print bframe =3D=3D gdb.newest_frame()" True \ +gdb_test "python print (bframe =3D=3D gdb.newest_frame())" True \ "newest frame -vs- newest frame" =20 -gdb_test "python print 'result =3D', f0 =3D=3D f1" " =3D False" "test equa= lity comparison (false)" -gdb_test "python print 'result =3D', f0 =3D=3D f0" " =3D True" "test equal= ity comparison (true)" -gdb_test "python print 'result =3D', f0 !=3D f1" " =3D True" "test inequal= ity comparison (true)" -gdb_test "python print 'result =3D', f0 !=3D f0" " =3D False" "test inequa= lity comparison (false)" -gdb_test "python print 'result =3D', f0.is_valid ()" " =3D True" "test Fra= me.is_valid" -gdb_test "python print 'result =3D', f0.name ()" " =3D f2" "test Frame.nam= e" -gdb_test "python print 'result =3D', f0.type () =3D=3D gdb.NORMAL_FRAME" "= =3D True" "test Frame.type" -gdb_test "python print 'result =3D', f0.unwind_stop_reason () =3D=3D gdb.F= RAME_UNWIND_NO_REASON" " =3D True" "test Frame.type" -gdb_test "python print 'result =3D', gdb.frame_stop_reason_string (gdb.FRA= ME_UNWIND_INNER_ID)" " =3D previous frame inner to this frame \\(corrupt st= ack\\?\\)" "test gdb.frame_stop_reason_string" -gdb_test "python print 'result =3D', f0.pc ()" " =3D \[0-9\]+" "test Frame= .pc" -gdb_test "python print 'result =3D', f0.older () =3D=3D f1" " =3D True" "t= est Frame.older" -gdb_test "python print 'result =3D', f1.newer () =3D=3D f0" " =3D True" "t= est Frame.newer" -gdb_test "python print 'result =3D', f0.read_var ('variable_which_surely_d= oesnt_exist')" \ +gdb_test "python print ('result =3D %s' % (f0 =3D=3D f1))" " =3D False" "t= est equality comparison (false)" +gdb_test "python print ('result =3D %s' % (f0 =3D=3D f0))" " =3D True" "te= st equality comparison (true)" +gdb_test "python print ('result =3D %s' % (f0 !=3D f1))" " =3D True" "test= inequality comparison (true)" +gdb_test "python print ('result =3D %s' % (f0 !=3D f0))" " =3D False" "tes= t inequality comparison (false)" +gdb_test "python print ('result =3D %s' % f0.is_valid ())" " =3D True" "te= st Frame.is_valid" +gdb_test "python print ('result =3D %s' % f0.name ())" " =3D f2" "test Fra= me.name" +gdb_test "python print ('result =3D %s' % (f0.type () =3D=3D gdb.NORMAL_FR= AME))" " =3D True" "test Frame.type" +gdb_test "python print ('result =3D %s' % (f0.unwind_stop_reason () =3D=3D= gdb.FRAME_UNWIND_NO_REASON))" " =3D True" "test Frame.type" +gdb_test "python print ('result =3D %s' % gdb.frame_stop_reason_string (gd= b.FRAME_UNWIND_INNER_ID))" " =3D previous frame inner to this frame \\(corr= upt stack\\?\\)" "test gdb.frame_stop_reason_string" +gdb_test "python print ('result =3D %s' % f0.pc ())" " =3D \[0-9\]+" "test= Frame.pc" +gdb_test "python print ('result =3D %s' % (f0.older () =3D=3D f1))" " =3D = True" "test Frame.older" +gdb_test "python print ('result =3D %s' % (f1.newer () =3D=3D f0))" " =3D = True" "test Frame.newer" +gdb_test "python print ('result =3D %s' % f0.read_var ('variable_which_sur= ely_doesnt_exist'))" \ "ValueError: Variable 'variable_which_surely_doesnt_exist' not found.*Er= ror while executing Python code." \ "test Frame.read_var - error" -gdb_test "python print 'result =3D', f0.read_var ('a')" " =3D 1" "test Fra= me.read_var - success" +gdb_test "python print ('result =3D %s' % f0.read_var ('a'))" " =3D 1" "te= st Frame.read_var - success" =20 -gdb_test "python print 'result =3D', gdb.selected_frame () =3D=3D f1" " = =3D True" "test gdb.selected_frame" +gdb_test "python print ('result =3D %s' % (gdb.selected_frame () =3D=3D f1= ))" " =3D True" "test gdb.selected_frame" Index: gdb/testsuite/gdb.python/py-inferior.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-inferior.exp,v retrieving revision 1.13 diff -u -r1.13 py-inferior.exp --- gdb/testsuite/gdb.python/py-inferior.exp 26 Jul 2012 19:09:35 -0000 1.13 +++ gdb/testsuite/gdb.python/py-inferior.exp 9 Nov 2012 22:26:56 -0000 @@ -51,20 +51,20 @@ # Test basic gdb.Inferior attributes and methods. =20 gdb_py_test_silent_cmd "python inferiors =3D gdb.inferiors ()" "get inferi= ors list" 1 -gdb_test "python print inferiors" "\\(,\\)" "verify inferiors list" +gdb_test "python print (inferiors)" "\\(,\\)" "verify inferiors list" gdb_py_test_silent_cmd "python i0 =3D inferiors\[0\]" "get first inferior"= 0 =20 -gdb_test "python print 'result =3D', i0 =3D=3D inferiors\[0\]" " =3D True"= "test equality comparison (true)" -gdb_test "python print 'result =3D', i0.num" " =3D \[0-9\]+" "test Inferio= r.num" -gdb_test "python print 'result =3D', i0.pid" " =3D \[0-9\]+" "test Inferio= r.pid" -gdb_test "python print 'result =3D', i0.was_attached" " =3D False" "test I= nferior.was_attached" -gdb_test "python print i0.threads ()" "\\(,\\)" "test Inferior.threads" +gdb_test "python print ('result =3D %s' % (i0 =3D=3D inferiors\[0\]))" " = =3D True" "test equality comparison (true)" +gdb_test "python print ('result =3D %s' % i0.num)" " =3D \[0-9\]+" "test I= nferior.num" +gdb_test "python print ('result =3D %s' % i0.pid)" " =3D \[0-9\]+" "test I= nferior.pid" +gdb_test "python print ('result =3D %s' % i0.was_attached)" " =3D False" "= test Inferior.was_attached" +gdb_test "python print (i0.threads ())" "\\(,\\)" "test Inferior.threads" =20 # Test the number of inferior threads. =20 gdb_breakpoint check_threads gdb_continue_to_breakpoint "cont to check_threads" ".*pthread_barrier_wait= .*" -gdb_test "python print len (i0.threads ())" "\r\n9" "test Inferior.threads= 2" +gdb_test "python print (len (i0.threads ()))" "\r\n9" "test Inferior.threa= ds 2" =20 # Proceed to the next test. =20 @@ -75,12 +75,17 @@ =20 gdb_py_test_silent_cmd "python addr =3D gdb.selected_frame ().read_var ('s= tr')" \ "read str address" 0 -gdb_py_test_silent_cmd "python str =3D gdb.inferiors()\[0\].read_memory (a= ddr, 5)" \ +gdb_py_test_silent_cmd "python str =3D gdb.inferiors()\[0\].read_memory (a= ddr, 5); print(str)" \ "read str contents" 1 -gdb_py_test_silent_cmd "python str\[1\] =3D 'a'" "change str" 0 +if { $gdb_py_is_py3k =3D=3D 0 } { + gdb_py_test_silent_cmd "python a =3D 'a'" "" 0 +} else { + gdb_py_test_silent_cmd "python a =3D bytes('a', 'ascii')" "" 0 +} +gdb_py_test_silent_cmd "python str\[1\] =3D a" "change str" 0 gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, st= r)" \ "write str" 1 -gdb_test "print str" " =3D \"hallo, testsuite\"" \ +gdb_test "print (str)" " =3D \"hallo, testsuite\"" \ "ensure str was changed in the inferior" =20 # Test memory search. @@ -99,18 +104,18 @@ gdb_test_no_output "py start_addr =3D search_buf.address" gdb_test_no_output "py length =3D search_buf.type.sizeof" =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length,= 'aaa')" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length= , 'aaa'))" \ "${one_pattern_found}" "find string pattern" =20 # Test not finding pattern because search range too small, with # potential find at the edge of the range. =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 10+3, '= aaaa')" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3, = 'aaaa'))" \ "${pattern_not_found}" "pattern not found at end of range" =20 # Increase the search range by 1 and we should find the pattern. =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1,= 'aaa')" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1= , 'aaa'))" \ "${one_pattern_found}" "pattern found at end of range" =20 # Import struct to pack the following patterns. @@ -124,7 +129,7 @@ gdb_test_no_output "py length =3D search_buf.type.sizeof" gdb_test_no_output "py pattern =3D pack('${python_pack_char}H',0x1234)" =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length,= pattern)" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length= , pattern))" \ "${one_pattern_found}" "find 16-bit pattern, with value pattern" =20 # Test 32-bit pattern. @@ -135,7 +140,7 @@ gdb_test_no_output "py length =3D search_buf.type.sizeof" gdb_test_no_output "py pattern =3D pack('${python_pack_char}I',0x12345678)" =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length,= pattern)" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length= , pattern))" \ "${one_pattern_found}" "find 32-bit pattern, with python pattern" =20 # Test 64-bit pattern. @@ -146,7 +151,7 @@ gdb_test_no_output "py length =3D search_buf.type.sizeof" gdb_test_no_output "py pattern =3D pack('${python_pack_char}Q', 0xfedcba98= 76543210)" =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length,= pattern)" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length= , pattern))" \ "${one_pattern_found}" "find 64-bit pattern, with value pattern" =20 # Test mixed-sized patterns. @@ -160,11 +165,11 @@ gdb_test_no_output "py pattern2 =3D pack('${python_pack_char}H', 0x6363)" gdb_test_no_output "py pattern3 =3D pack('${python_pack_char}I', 0x6464646= 4)" =20 -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, pa= ttern1)" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, p= attern1))" \ "${one_pattern_found}" "find mixed-sized pattern" -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, pa= ttern2)" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, p= attern2))" \ "${one_pattern_found}" "find mixed-sized pattern" -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, pa= ttern3)" \ +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, p= attern3))" \ "${one_pattern_found}" "find mixed-sized pattern" =20 # Test search spanning a large range, in the particular case of native @@ -179,13 +184,13 @@ gdb_test_no_output "py end_addr =3D start_addr + gdb.selected_frame ().rea= d_var ('search_buf_size')" gdb_test_no_output "py pattern =3D pack('${python_pack_char}I', 0x12345678= )" gdb_test_no_output "py first =3D gdb.inferiors()\[0\].search_memory (start= _addr,end_addr - start_addr, pattern)" -gdb_test "py print first" "${one_pattern_found}" "search spanning large ra= nge 1st result" +gdb_test "py print (first)" "${one_pattern_found}" "search spanning large = range 1st result" gdb_test_no_output "py start_addr =3D first + 1" gdb_test_no_output "py second =3D gdb.inferiors()\[0\].search_memory (star= t_addr, end_addr - start_addr, pattern)" -gdb_test "py print second" "${one_pattern_found}" "search spanning large r= ange 2nd result" +gdb_test "py print (second)" "${one_pattern_found}" "search spanning large= range 2nd result" gdb_test_no_output "py start_addr =3D second + 1" gdb_test_no_output "py third =3D gdb.inferiors()\[0\].search_memory (start= _addr, end_addr - start_addr, pattern)" -gdb_test "py print third" "${pattern_not_found}" "search spanning large ra= nge 3rd result" +gdb_test "py print (third)" "${pattern_not_found}" "search spanning large = range 3rd result" =20 # For native targets, test a pattern straddling a chunk boundary. =20 @@ -193,7 +198,7 @@ gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] =3D= 0xfdb97531" gdb_test_no_output "py pattern =3D pack('${python_pack_char}I', 0xfdb9= 7531)" gdb_test_no_output "py start_addr =3D gdb.selected_frame ().read_var (= 'search_buf')" - gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, end= _addr - start_addr, pattern)" \ + gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, en= d_addr - start_addr, pattern))" \ "${one_pattern_found}" "find pattern straddling chunk boundary" } =20 @@ -201,28 +206,28 @@ # this testcase as it kills the inferior. =20 gdb_py_test_silent_cmd "python inf_list =3D gdb.inferiors()" "get initial = list" 1 -gdb_test "python print len(inf_list)" "1" "Get inferior list length" -gdb_test "python print inf_list\[0\].is_valid()" "True" \ +gdb_test "python print (len(inf_list))" "1" "Get inferior list length" +gdb_test "python print (inf_list\[0\].is_valid())" "True" \ "Check inferior validity" gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" gdb_py_test_silent_cmd "python inf_list =3D gdb.inferiors()" "get new list= " 1 -gdb_test "python print len(inf_list)" "2" "Get inferior list length" -gdb_test "python print inf_list\[0\].is_valid()" "True" \ +gdb_test "python print (len(inf_list))" "2" "Get inferior list length" +gdb_test "python print (inf_list\[0\].is_valid())" "True" \ "Check inferior validity" -gdb_test "python print inf_list\[1\].is_valid()" "True" \ +gdb_test "python print (inf_list\[1\].is_valid())" "True" \ "Check inferior validity" gdb_test_no_output "remove-inferiors 2" "remove-inferiors 3" -gdb_test "python print inf_list\[0\].is_valid()" "False" \ +gdb_test "python print (inf_list\[0\].is_valid())" "False" \ "Check inferior validity" -gdb_test "python print inf_list\[1\].is_valid()" "True" \ +gdb_test "python print (inf_list\[1\].is_valid())" "True" \ "Check inferior validity" =20 # Test gdb.selected_inferior() gdb_test "inferior 1" ".*" "Switch to first inferior" -gdb_test "py print gdb.selected_inferior().num" "1" "First inferior select= ed" +gdb_test "py print (gdb.selected_inferior().num)" "1" "First inferior sele= cted" =20 gdb_test "add-inferior" "Added inferior 3" "Create new inferior" gdb_test "inferior 3" ".*" "Switch to third inferior" -gdb_test "py print gdb.selected_inferior().num" "3" "Third inferior select= ed" +gdb_test "py print (gdb.selected_inferior().num)" "3" "Third inferior sele= cted" gdb_test "inferior 1" ".*" "Switch to first inferior" gdb_test_no_output "remove-inferiors 3" "Remove second inferior" Index: gdb/testsuite/gdb.python/py-infthread.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-infthread.exp,v retrieving revision 1.9 diff -u -r1.9 py-infthread.exp --- gdb/testsuite/gdb.python/py-infthread.exp 22 Jun 2012 17:59:33 -0000 1.9 +++ gdb/testsuite/gdb.python/py-infthread.exp 9 Nov 2012 22:26:56 -0000 @@ -40,28 +40,28 @@ # Test basic gdb.Inferior attributes and methods. =20 gdb_py_test_silent_cmd "python t0 =3D gdb.selected_thread ()" "test gdb.se= lected_thread" 1 -gdb_test "python print t0" "\\" "verify InferiorThread object" -gdb_test "python print 'result =3D', t0.num" " =3D \[0-9\]+" "test Inferio= r.num" -gdb_test "python print 'result =3D', t0.ptid" " =3D \\(\[0-9\]+, \[0-9\]+,= \[0-9\]+\\)" "test InferiorThread.ptid" +gdb_test "python print (t0)" "\\" "verify InferiorThread object" +gdb_test "python print ('result =3D %s' % t0.num)" " =3D \[0-9\]+" "test I= nferior.num" +gdb_test "python print ('result =3D %s' % str (t0.ptid))" " =3D \\(\[0-9\]= +, \[0-9\]+, \[0-9\]+\\)" "test InferiorThread.ptid" =20 gdb_py_test_silent_cmd "python name =3D gdb.selected_thread().name" \ "get supplied name of current thread" 1 gdb_py_test_silent_cmd "python gdb.selected_thread().name =3D 'hibob'" \ "set name of current thread" 1 -gdb_test "python print gdb.selected_thread().name" "hibob" \ +gdb_test "python print (gdb.selected_thread().name)" "hibob" \ "check name of current thread" gdb_py_test_silent_cmd "python gdb.selected_thread().name =3D None" \ "reset name of current thread" 1 -gdb_test "python print gdb.selected_thread().name =3D=3D name" "True" \ +gdb_test "python print (gdb.selected_thread().name =3D=3D name)" "True" \ "check name of current thread again" =20 -gdb_test "python print 'result =3D', t0.is_stopped ()" " =3D True" "test I= nferiorThread.is_stopped" -gdb_test "python print 'result =3D', t0.is_running ()" " =3D False" "test = InferiorThread.is_running" -gdb_test "python print 'result =3D', t0.is_exited ()" " =3D False" "test I= nferiorThread.is_exited" +gdb_test "python print ('result =3D %s' % t0.is_stopped ())" " =3D True" "= test InferiorThread.is_stopped" +gdb_test "python print ('result =3D %s' % t0.is_running ())" " =3D False" = "test InferiorThread.is_running" +gdb_test "python print ('result =3D %s' % t0.is_exited ())" " =3D False" "= test InferiorThread.is_exited" =20 # Test InferiorThread is_valid. This must always be the last test in # this testcase as it kills the inferior. =20 -gdb_test "python print 'result =3D', t0.is_valid ()" " =3D True" "test Inf= eriorThread.is_valid" +gdb_test "python print ('result =3D %s' % t0.is_valid ())" " =3D True" "te= st InferiorThread.is_valid" gdb_test_no_output "kill inferior 1" "kill inferior 1" -gdb_test "python print 'result =3D', t0.is_valid ()" " =3D False" "test In= feriorThread.is_valid" +gdb_test "python print ('result =3D %s' % t0.is_valid ())" " =3D False" "t= est InferiorThread.is_valid" Index: gdb/testsuite/gdb.python/py-mi.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-mi.exp,v retrieving revision 1.17 diff -u -r1.17 py-mi.exp --- gdb/testsuite/gdb.python/py-mi.exp 6 Aug 2012 18:44:45 -0000 1.17 +++ gdb/testsuite/gdb.python/py-mi.exp 9 Nov 2012 22:26:56 -0000 @@ -44,7 +44,7 @@ =20 set remote_python_file [remote_download host ${srcdir}/${subdir}/${pyfile}] =20 -mi_gdb_test "python execfile ('${remote_python_file}')" "" +mi_gdb_test "python exec (open ('${remote_python_file}').read ())" "" =20 mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${srcfile}] \ "step to breakpoint" Index: gdb/testsuite/gdb.python/py-objfile.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-objfile.exp,v retrieving revision 1.4 diff -u -r1.4 py-objfile.exp --- gdb/testsuite/gdb.python/py-objfile.exp 22 Jun 2012 17:59:33 -0000 1.4 +++ gdb/testsuite/gdb.python/py-objfile.exp 9 Nov 2012 22:26:56 -0000 @@ -37,10 +37,10 @@ gdb_py_test_silent_cmd "python objfile =3D sym\[0\].symtab.objfile" \ "Get backing object file" 1 =20 -gdb_test "python print objfile.filename" ".*py-objfile.*" \ +gdb_test "python print (objfile.filename)" ".*py-objfile.*" \ "Get objfile validity" -gdb_test "python print objfile.is_valid()" "True" \ +gdb_test "python print (objfile.is_valid())" "True" \ "Get objfile validity" gdb_unload -gdb_test "python print objfile.is_valid()" "False" \ +gdb_test "python print (objfile.is_valid())" "False" \ "Get objfile validity after unload" Index: gdb/testsuite/gdb.python/py-parameter.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-parameter.exp,v retrieving revision 1.6 diff -u -r1.6 py-parameter.exp --- gdb/testsuite/gdb.python/py-parameter.exp 16 Jan 2012 16:21:52 -0000 1.6 +++ gdb/testsuite/gdb.python/py-parameter.exp 9 Nov 2012 22:26:56 -0000 @@ -27,7 +27,7 @@ if { [skip_python_tests] } { continue } =20 # We use "." here instead of ":" so that this works on win32 too. -gdb_test "python print gdb.parameter ('directories')" "$srcdir/$subdir.\\\= $cdir.\\\$cwd" +gdb_test "python print (gdb.parameter ('directories'))" "$srcdir/$subdir.\= \\$cdir.\\\$cwd" =20 # Test a simple boolean parameter. gdb_py_test_multiple "Simple gdb booleanparameter" \ @@ -49,11 +49,11 @@ "test_param =3D TestParam ('print test-param')" ""\ "end" =20 -gdb_test "python print test_param.value" "True" "Test parameter value" +gdb_test "python print (test_param.value)" "True" "Test parameter value" gdb_test "show print test-param" "The state of the Test Parameter is on.*"= "Show parameter on" gdb_test "set print test-param off" "Test Parameter has been set to off" "= Turn off parameter" gdb_test "show print test-param" "The state of the Test Parameter is off.*= " "Show parameter off" -gdb_test "python print test_param.value" "False" "Test parameter value" +gdb_test "python print (test_param.value)" "False" "Test parameter value" gdb_test "help show print test-param" "Show the state of the boolean test-= param.*" "Test show help" gdb_test "help set print test-param" "Set the state of the boolean test-pa= ram.*" "Test set help" gdb_test "help set print" "set print test-param -- Set the state of the bo= olean test-param.*" "Test general help" @@ -76,11 +76,11 @@ "test_enum_param =3D TestEnumParam ('print test-enum-param')" ""\ "end" =20 -gdb_test "python print test_enum_param.value" "one" "Test enum parameter v= alue" +gdb_test "python print (test_enum_param.value)" "one" "Test enum parameter= value" gdb_test "show print test-enum-param" "The state of the enum is one.*" "Sh= ow parameter is initial value" gdb_test "set print test-enum-param two" "The state of the enum has been s= et to two" "Set enum to two" gdb_test "show print test-enum-param" "The state of the enum is two.*" "Sh= ow parameter is new value" -gdb_test "python print test_enum_param.value" "two" "Test enum parameter v= alue" +gdb_test "python print (test_enum_param.value)" "two" "Test enum parameter= value" gdb_test "set print test-enum-param three" "Undefined item: \"three\".*" "= Set invalid enum parameter"=20 =20 # Test a file parameter. @@ -100,11 +100,11 @@ "test_file_param =3D TestFileParam ('test-file-param')" ""\ "end" =20 -gdb_test "python print test_file_param.value" "foo.txt" "Test file paramet= er value" +gdb_test "python print (test_file_param.value)" "foo.txt" "Test file param= eter value" gdb_test "show test-file-param" "The name of the file is foo.txt.*" "Show = initial file value" gdb_test "set test-file-param bar.txt" "The name of the file has been chan= ged to bar.txt" "Set new file parameter" 1 gdb_test "show test-file-param" "The name of the file is bar.txt.*" "Show = new file value" -gdb_test "python print test_file_param.value" "bar.txt" "Test new file par= ameter value" +gdb_test "python print (test_file_param.value)" "bar.txt" "Test new file p= arameter value" gdb_test "set test-file-param" "Argument required.*"=20 =20 # Test a parameter that is not documented. @@ -127,7 +127,7 @@ gdb_test "show print test-undoc-param" "The state of the Test Parameter is= on.*" "Show parameter on" gdb_test "set print test-undoc-param off" "Test Parameter has been set to = off" "Turn off parameter" gdb_test "show print test-undoc-param" "The state of the Test Parameter is= off.*" "Show parameter off" -gdb_test "python print test_undoc_param.value" "False" "Test parameter val= ue" +gdb_test "python print (test_undoc_param.value)" "False" "Test parameter v= alue" gdb_test "help show print test-undoc-param" "This command is not documente= d.*" "Test show help" gdb_test "help set print test-undoc-param" "This command is not documented= .*" "Test set help" gdb_test "help set print" "set print test-undoc-param -- This command is n= ot documented.*" "Test general help" @@ -145,7 +145,7 @@ gdb_test "show print test-nodoc-param" "This command is not documented.*" = "Show parameter on" gdb_test "set print test-nodoc-param off" "This command is not documented.= *" "Turn off parameter" gdb_test "show print test-nodoc-param" "This command is not documented.*.*= " "Show parameter off" -gdb_test "python print test_nodoc_param.value" "False" "Test parameter val= ue" +gdb_test "python print (test_nodoc_param.value)" "False" "Test parameter v= alue" gdb_test "help show print test-nodoc-param" "This command is not documente= d.*" "Test show help" gdb_test "help set print test-nodoc-param" "This command is not documented= .*" "Test set help" gdb_test "help set print" "set print test-nodoc-param -- This command is n= ot documented.*" "Test general help" @@ -163,11 +163,11 @@ "test_param =3D TestParam ('print test-param')" ""\ "end" =20 -gdb_test "python print test_param.value" "True" "Test parameter value" +gdb_test "python print (test_param.value)" "True" "Test parameter value" gdb_test "show print test-param" "State of the Test Parameter on.*" "Show = parameter on" gdb_test "set print test-param off" "Set the state of the Test Parameter.*= " "Turn off parameter" gdb_test "show print test-param" "State of the Test Parameter off.*" "Show= parameter off" -gdb_test "python print test_param.value" "False" "Test parameter value" +gdb_test "python print (test_param.value)" "False" "Test parameter value" gdb_test "help show print test-param" "State of the Test Parameter.*" "Tes= t show help" gdb_test "help set print test-param" "Set the state of the Test Parameter.= *" "Test set help" gdb_test "help set print" "set print test-param -- Set the state of the Te= st Parameter.*" "Test general help" Index: gdb/testsuite/gdb.python/py-pp-maint.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-pp-maint.exp,v retrieving revision 1.8 diff -u -r1.8 py-pp-maint.exp --- gdb/testsuite/gdb.python/py-pp-maint.exp 22 Jun 2012 17:59:33 -0000 1.8 +++ gdb/testsuite/gdb.python/py-pp-maint.exp 9 Nov 2012 22:26:56 -0000 @@ -43,7 +43,7 @@ =20 set python_file ${srcdir}/${subdir}/${testfile}.py =20 -gdb_test_no_output "python execfile ('${python_file}')" "" +gdb_test_no_output "python exec (open ('${python_file}').read ())" "" =20 gdb_test "info pretty-printer" \ {.*function_lookup_test.*pp-test.*struct ss.*} Index: gdb/testsuite/gdb.python/py-pp-maint.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-pp-maint.py,v retrieving revision 1.5 diff -u -r1.5 py-pp-maint.py --- gdb/testsuite/gdb.python/py-pp-maint.py 16 Jan 2012 19:44:16 -0000 1.5 +++ gdb/testsuite/gdb.python/py-pp-maint.py 9 Nov 2012 22:26:56 -0000 @@ -37,7 +37,7 @@ return None =20 =20 -class pp_s: +class pp_s (object): def __init__(self, val): self.val =3D val =20 @@ -49,7 +49,7 @@ return "a=3D<" + str(self.val["a"]) + "> b=3D<" + str(self.val["b"= ]) + ">" =20 =20 -class pp_ss: +class pp_ss (object): def __init__(self, val): self.val =3D val =20 Index: gdb/testsuite/gdb.python/py-prettyprint.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.exp,v retrieving revision 1.27 diff -u -r1.27 py-prettyprint.exp --- gdb/testsuite/gdb.python/py-prettyprint.exp 16 Jul 2012 19:15:39 -0000 = 1.27 +++ gdb/testsuite/gdb.python/py-prettyprint.exp 9 Nov 2012 22:26:56 -0000 @@ -55,7 +55,7 @@ =20 set remote_python_file [remote_download host ${srcdir}/${subdir}/${tes= tfile}.py] =20 - gdb_test_no_output "python execfile ('${remote_python_file}')" + gdb_test_no_output "python exec (open ('${remote_python_file}').read (= ))" =20=20=20=20=20 gdb_test "print ss" " =3D a=3D< a=3D<1> b=3D<$hex>> b=3D< a=3D<2> b=3D= <$hex>>" gdb_test "print ssa\[1\]" " =3D a=3D< a=3D<5> b=3D<$hex>> b=3D< a=3D<6= > b=3D<$hex>>" @@ -125,7 +125,7 @@ =20 set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfil= e}.py] =20 -gdb_test_no_output "python execfile ('${remote_python_file}')" +gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" =20 gdb_breakpoint [gdb_get_line_number "eval-break"] gdb_continue_to_breakpoint "eval-break" ".* eval-break .*" Index: gdb/testsuite/gdb.python/py-prettyprint.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.py,v retrieving revision 1.15 diff -u -r1.15 py-prettyprint.py --- gdb/testsuite/gdb.python/py-prettyprint.py 6 Aug 2012 18:44:45 -0000 1.= 15 +++ gdb/testsuite/gdb.python/py-prettyprint.py 9 Nov 2012 22:26:56 -0000 @@ -19,8 +19,17 @@ import re import gdb =20 +def _iterator (pointer, len): + start =3D pointer + end =3D pointer + len + while pointer !=3D end: + if exception_flag: + raise gdb.MemoryError ('hi bob') + yield ('[%d]' % int (pointer - start), pointer.dereference()) + pointer +=3D 1 + # Test returning a Value from a printer. -class string_print: +class string_print (object): def __init__(self, val): self.val =3D val =20 @@ -28,22 +37,7 @@ return self.val['whybother']['contents'] =20 # Test a class-based printer. -class ContainerPrinter: - class _iterator: - def __init__ (self, pointer, len): - self.start =3D pointer - self.pointer =3D pointer - self.end =3D pointer + len - - def __iter__(self): - return self - - def next(self): - if self.pointer =3D=3D self.end: - raise StopIteration - result =3D self.pointer - self.pointer =3D self.pointer + 1 - return ('[%d]' % int (result - self.start), result.dereference= ()) +class ContainerPrinter (object): =20 def __init__(self, val): self.val =3D val @@ -52,31 +46,13 @@ return 'container %s with %d elements' % (self.val['name'], self.v= al['len']) =20 def children(self): - return self._iterator(self.val['elements'], self.val['len']) + return _iterator(self.val['elements'], self.val['len']) =20 # Flag to make NoStringContainerPrinter throw an exception. exception_flag =3D False =20 # Test a printer where to_string is None -class NoStringContainerPrinter: - class _iterator: - def __init__ (self, pointer, len): - self.start =3D pointer - self.pointer =3D pointer - self.end =3D pointer + len - - def __iter__(self): - return self - - def next(self): - if self.pointer =3D=3D self.end: - raise StopIteration - if exception_flag: - raise gdb.MemoryError, 'hi bob' - result =3D self.pointer - self.pointer =3D self.pointer + 1 - return ('[%d]' % int (result - self.start), result.dereference= ()) - +class NoStringContainerPrinter (object): def __init__(self, val): self.val =3D val =20 @@ -84,9 +60,9 @@ return None =20 def children(self): - return self._iterator(self.val['elements'], self.val['len']) + return _iterator(self.val['elements'], self.val['len']) =20 -class pp_s: +class pp_s (object): def __init__(self, val): self.val =3D val =20 @@ -97,42 +73,42 @@ raise Exception("&a(%s) !=3D b(%s)" % (str(a.address), str(b))) return " a=3D<" + str(self.val["a"]) + "> b=3D<" + str(self.val["b= "]) + ">" =20 -class pp_ss: +class pp_ss (object): def __init__(self, val): self.val =3D val =20 def to_string(self): return "a=3D<" + str(self.val["a"]) + "> b=3D<" + str(self.val["b"= ]) + ">" =20 -class pp_sss: +class pp_sss (object): def __init__(self, val): self.val =3D val =20 def to_string(self): return "a=3D<" + str(self.val['a']) + "> b=3D<" + str(self.val["b"= ]) + ">" =20 -class pp_multiple_virtual: +class pp_multiple_virtual (object): def __init__ (self, val): self.val =3D val =20 def to_string (self): return "pp value variable is: " + str (self.val['value']) =20 -class pp_vbase1: +class pp_vbase1 (object): def __init__ (self, val): self.val =3D val =20 def to_string (self): return "pp class name: " + self.val.type.tag =20 -class pp_nullstr: +class pp_nullstr (object): def __init__(self, val): self.val =3D val =20 def to_string(self): return self.val['s'].string(gdb.target_charset()) =20 -class pp_ns: +class pp_ns (object): "Print a std::basic_string of some kind" =20 def __init__(self, val): @@ -147,7 +123,7 @@ =20 pp_ls_encoding =3D None =20 -class pp_ls: +class pp_ls (object): "Print a std::basic_string of some kind" =20 def __init__(self, val): @@ -162,7 +138,7 @@ def display_hint (self): return 'string' =20 -class pp_hint_error: +class pp_hint_error (object): "Throw error from display_hint" =20 def __init__(self, val): @@ -174,7 +150,7 @@ def display_hint (self): raise Exception("hint failed") =20 -class pp_children_as_list: +class pp_children_as_list (object): "Throw error from display_hint" =20 def __init__(self, val): @@ -186,7 +162,7 @@ def children (self): return [('one', 1)] =20 -class pp_outer: +class pp_outer (object): "Print struct outer" =20 def __init__ (self, val): @@ -199,24 +175,24 @@ yield 's', self.val['s'] yield 'x', self.val['x'] =20 -class MemoryErrorString: +class MemoryErrorString (object): "Raise an error" =20 def __init__(self, val): self.val =3D val =20 def to_string(self): - raise gdb.MemoryError ("Cannot access memory."); + raise gdb.MemoryError ("Cannot access memory.") =20 def display_hint (self): return 'string' =20 -class pp_eval_type: +class pp_eval_type (object): def __init__(self, val): self.val =3D val =20 def to_string(self): - gdb.execute("bt", to_string=3DTrue) + gdb.execute("bt", to_string=3DTrue) return "eval=3D<" + str(gdb.parse_and_eval("eval_func (123456789, = 2, 3, 4, 5, 6, 7, 8)")) + ">" =20 def lookup_function (val): Index: gdb/testsuite/gdb.python/py-progspace.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-progspace.exp,v retrieving revision 1.5 diff -u -r1.5 py-progspace.exp --- gdb/testsuite/gdb.python/py-progspace.exp 22 Jun 2012 17:59:33 -0000 1.5 +++ gdb/testsuite/gdb.python/py-progspace.exp 9 Nov 2012 22:26:56 -0000 @@ -31,11 +31,11 @@ # Skip all tests if Python scripting is not enabled. if { [skip_python_tests] } { continue } =20 -gdb_test "python print gdb.current_progspace().filename" "None" \ +gdb_test "python print (gdb.current_progspace().filename)" "None" \ "current progspace filename (None)" -gdb_test "python print gdb.progspaces()" "\\\[\\\]" +gdb_test "python print (gdb.progspaces())" "\\\[\\\]" =20 gdb_load ${binfile} =20 -gdb_test "python print gdb.current_progspace().filename" "py-progspace" \ +gdb_test "python print (gdb.current_progspace().filename)" "py-progspace" \ "current progspace filename (py-progspace)" Index: gdb/testsuite/gdb.python/py-prompt.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prompt.exp,v retrieving revision 1.5 diff -u -r1.5 py-prompt.exp --- gdb/testsuite/gdb.python/py-prompt.exp 22 Jun 2012 17:59:33 -0000 1.5 +++ gdb/testsuite/gdb.python/py-prompt.exp 9 Nov 2012 22:26:56 -0000 @@ -59,24 +59,24 @@ =20 set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing on\""] prompt_gdb_start -gdb_test "python x =3D len(p); print gdb.execute(\"show prompt\", to_strin= g =3D True)" \ +gdb_test "python x =3D len(p); print (gdb.execute(\"show prompt\", to_stri= ng =3D True))" \ ".*prompt is \"$gdb_prompt \".*" \ "show prompt gets the correct result" -gdb_test "python print x, len(p)" "1 2" \ +gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \ "retrieving the prompt causes no extra prompt_hook calls" -gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \ +gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '= " \ "prompt_hook argument is default prompt." gdb_exit =20 =20 set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing off\""] prompt_gdb_start -gdb_test "python x =3D len(p); print gdb.execute(\"show prompt\", to_strin= g =3D True)" \ +gdb_test "python x =3D len(p); print (gdb.execute(\"show prompt\", to_stri= ng =3D True))" \ ".*prompt is \"$gdb_prompt \".*" \ "show prompt gets the correct result 2" -gdb_test "python print x, len(p)" "1 2" \ +gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \ "retrieving the prompt causes no extra prompt_hook calls 2" -gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \ +gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '= " \ "prompt_hook argument is default prompt. 2" gdb_exit =20 @@ -98,12 +98,12 @@ =20 # sync_execution =3D 1 is_running =3D 1 prompt_gdb_start -gdb_test "python x =3D len(p); print gdb.execute(\"show prompt\", to_strin= g =3D True)" \ +gdb_test "python x =3D len(p); print (gdb.execute(\"show prompt\", to_stri= ng =3D True))" \ ".*prompt is \"$gdb_prompt \".*" \ "show prompt gets the correct result 3" -gdb_test "python print x, len(p)" "1 2" \ +gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \ "retrieving the prompt causes no extra prompt_hook calls 3" -gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \ +gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '= " \ "prompt_hook argument is default prompt. 3" gdb_exit =20 @@ -115,12 +115,12 @@ =20 # sync_execution =3D 1 is_running =3D 0 prompt_gdb_start -gdb_test "python x =3D len(p); print gdb.execute(\"show prompt\", to_strin= g =3D True)" \ +gdb_test "python x =3D len(p); print (gdb.execute(\"show prompt\", to_stri= ng =3D True))" \ ".*prompt is \"$gdb_prompt \".*" \ "show prompt gets the correct result 4" -gdb_test "python print x, len(p)" "1 2" \ +gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \ "retrieving the prompt causes no extra prompt_hook calls 4" -gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \ +gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '= " \ "prompt_hook argument is default prompt. 4" gdb_exit =20 Index: gdb/testsuite/gdb.python/py-shared.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-shared.exp,v retrieving revision 1.7 diff -u -r1.7 py-shared.exp --- gdb/testsuite/gdb.python/py-shared.exp 22 Jun 2012 17:59:33 -0000 1.7 +++ gdb/testsuite/gdb.python/py-shared.exp 9 Nov 2012 22:26:56 -0000 @@ -58,8 +58,11 @@ # Test gdb.solib_name gdb_test "p &func1" "" "func1 address" gdb_py_test_silent_cmd "python func1 =3D gdb.history(0)" "Aquire func1 add= ress" 1 -gdb_test "python print gdb.solib_name(long(func1))" "py-shared-sl.sl" "tes= t func1 solib location" +if { $gdb_py_is_py3k =3D=3D 1 } { + gdb_py_test_silent_cmd "python long =3D int" "" 0 +} +gdb_test "python print (gdb.solib_name(long(func1)))" "py-shared-sl.sl" "t= est func1 solib location" =20 gdb_test "p &main" "" "main address" gdb_py_test_silent_cmd "python main =3D gdb.history(0)" "Aquire main addre= ss" 1 -gdb_test "python print gdb.solib_name(long(main))" "None" "test main solib= location" +gdb_test "python print (gdb.solib_name(long(main)))" "None" "test main sol= ib location" Index: gdb/testsuite/gdb.python/py-symbol.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.exp,v retrieving revision 1.16 diff -u -r1.16 py-symbol.exp --- gdb/testsuite/gdb.python/py-symbol.exp 15 Oct 2012 15:20:27 -0000 1.16 +++ gdb/testsuite/gdb.python/py-symbol.exp 9 Nov 2012 22:26:56 -0000 @@ -31,20 +31,20 @@ # point where we don't have a current frame, and we don't want to # require one. gdb_py_test_silent_cmd "python main_func =3D gdb.lookup_global_symbol(\"ma= in\")" "Lookup main" 1 -gdb_test "python print main_func.is_function" "True" "Test main_func.is_fu= nction" -gdb_test "python print gdb.lookup_global_symbol(\"junk\")" "None" "Test lo= okup_global_symbol(\"junk\")" +gdb_test "python print (main_func.is_function)" "True" "Test main_func.is_= function" +gdb_test "python print (gdb.lookup_global_symbol(\"junk\"))" "None" "Test = lookup_global_symbol(\"junk\")" =20 -gdb_test "python print gdb.lookup_global_symbol('main').value()" "$hex .ma= in." \ +gdb_test "python print (gdb.lookup_global_symbol('main').value())" "$hex .= main." \ "print value of main" =20 set qq_line [gdb_get_line_number "line of qq"] -gdb_test "python print gdb.lookup_global_symbol('qq').line" "$qq_line" \ +gdb_test "python print (gdb.lookup_global_symbol('qq').line)" "$qq_line" \ "print line number of qq" =20 -gdb_test "python print gdb.lookup_global_symbol('qq').value()" "72" \ +gdb_test "python print (gdb.lookup_global_symbol('qq').value())" "72" \ "print value of qq" =20 -gdb_test "python print gdb.lookup_global_symbol('qq').needs_frame" \ +gdb_test "python print (gdb.lookup_global_symbol('qq').needs_frame)" \ "False" \ "print whether qq needs a frame" =20 @@ -63,21 +63,21 @@ =20 # Test is_argument attribute. gdb_py_test_silent_cmd "python arg =3D gdb.lookup_symbol(\"arg\")" "Get va= riable a" 0 -gdb_test "python print arg\[0\].is_variable" "False" "Test arg.is_variable" -gdb_test "python print arg\[0\].is_constant" "False" "Test arg.is_constant" -gdb_test "python print arg\[0\].is_argument" "True" "Test arg.is_argument" -gdb_test "python print arg\[0\].is_function" "False" "Test arg.is_function" +gdb_test "python print (arg\[0\].is_variable)" "False" "Test arg.is_variab= le" +gdb_test "python print (arg\[0\].is_constant)" "False" "Test arg.is_consta= nt" +gdb_test "python print (arg\[0\].is_argument)" "True" "Test arg.is_argumen= t" +gdb_test "python print (arg\[0\].is_function)" "False" "Test arg.is_functi= on" =20 # Test is_function attribute. gdb_py_test_silent_cmd "python func =3D frame.block().function" "Get block= " 0 -gdb_test "python print func.is_variable" "False" "Test func.is_variable" -gdb_test "python print func.is_constant" "False" "Test func.is_constant" -gdb_test "python print func.is_argument" "False" "Test func.is_argument" -gdb_test "python print func.is_function" "True" "Test func.is_function" -gdb_test "python print func.name" "func" "Test func.name" -gdb_test "python print func.print_name" "func" "Test func.print_name" -gdb_test "python print func.linkage_name" "func" "Test func.linkage_name" -gdb_test "python print func.addr_class =3D=3D gdb.SYMBOL_LOC_BLOCK" "True"= "Test func.addr_class" +gdb_test "python print (func.is_variable)" "False" "Test func.is_variable" +gdb_test "python print (func.is_constant)" "False" "Test func.is_constant" +gdb_test "python print (func.is_argument)" "False" "Test func.is_argument" +gdb_test "python print (func.is_function)" "True" "Test func.is_function" +gdb_test "python print (func.name)" "func" "Test func.name" +gdb_test "python print (func.print_name)" "func" "Test func.print_name" +gdb_test "python print (func.linkage_name)" "func" "Test func.linkage_name" +gdb_test "python print (func.addr_class =3D=3D gdb.SYMBOL_LOC_BLOCK)" "Tru= e" "Test func.addr_class" =20 gdb_breakpoint [gdb_get_line_number "Break at end."] gdb_continue_to_breakpoint "Break at end." @@ -85,33 +85,33 @@ =20 # Test is_variable attribute. gdb_py_test_silent_cmd "python a =3D gdb.lookup_symbol(\'a\')" "Get variab= le a" 0 -gdb_test "python print a\[0\].is_variable" "True" "Test a.is_variable" -gdb_test "python print a\[0\].is_constant" "False" "Test a.is_constant" -gdb_test "python print a\[0\].is_argument" "False" "Test a.is_argument" -gdb_test "python print a\[0\].is_function" "False" "Test a.is_function" -gdb_test "python print a\[0\].addr_class =3D=3D gdb.SYMBOL_LOC_COMPUTED" "= True" "Test a.addr_class" +gdb_test "python print (a\[0\].is_variable)" "True" "Test a.is_variable" +gdb_test "python print (a\[0\].is_constant)" "False" "Test a.is_constant" +gdb_test "python print (a\[0\].is_argument)" "False" "Test a.is_argument" +gdb_test "python print (a\[0\].is_function)" "False" "Test a.is_function" +gdb_test "python print (a\[0\].addr_class =3D=3D gdb.SYMBOL_LOC_COMPUTED)"= "True" "Test a.addr_class" =20 -gdb_test "python print a\[0\].value()" \ +gdb_test "python print (a\[0\].value())" \ "symbol requires a frame to compute its value.*"\ "try to print value of a without a frame" -gdb_test "python print a\[0\].value(frame)" "0" \ +gdb_test "python print (a\[0\].value(frame))" "0" \ "print value of a" -gdb_test "python print a\[0\].needs_frame" "True" \ +gdb_test "python print (a\[0\].needs_frame)" "True" \ "print whether a needs a frame" =20 # Test is_constant attribute gdb_py_test_silent_cmd "python t =3D gdb.lookup_symbol(\"one\")" "Get vari= able a" 0 -gdb_test "python print t\[0\].is_variable" "False" "Test t.is_variable" -gdb_test "python print t\[0\].is_constant" "True" "Test t.is_constant" -gdb_test "python print t\[0\].is_argument" "False" "Test t.is_argument" -gdb_test "python print t\[0\].is_function" "False" "Test t.is_function" -gdb_test "python print t\[0\].addr_class =3D=3D gdb.SYMBOL_LOC_CONST" "Tru= e" "Test t.addr_class" +gdb_test "python print (t\[0\].is_variable)" "False" "Test t.is_variable" +gdb_test "python print (t\[0\].is_constant)" "True" "Test t.is_constant" +gdb_test "python print (t\[0\].is_argument)" "False" "Test t.is_argument" +gdb_test "python print (t\[0\].is_function)" "False" "Test t.is_function" +gdb_test "python print (t\[0\].addr_class =3D=3D gdb.SYMBOL_LOC_CONST)" "T= rue" "Test t.addr_class" =20 # Test type attribute. -gdb_test "python print t\[0\].type" "enum tag" "Get type" +gdb_test "python print (t\[0\].type)" "enum tag" "Get type" =20 # Test symtab attribute. -gdb_test "python print t\[0\].symtab" "gdb.python/py-symbol.c.*" "Get symt= ab" +gdb_test "python print (t\[0\].symtab)" "gdb.python/py-symbol.c.*" "Get sy= mtab" =20 # C++ tests # Recompile binary. @@ -136,14 +136,14 @@ =20 gdb_py_test_silent_cmd "python cplusframe =3D gdb.selected_frame()" "Get F= rame" 0 gdb_py_test_silent_cmd "python cplusfunc =3D cplusframe.block().function" = "Get block" 0 -gdb_test "python print cplusfunc.is_variable" "False" "Test func.is_variab= le" -gdb_test "python print cplusfunc.is_constant" "False" "Test func.is_consta= nt" -gdb_test "python print cplusfunc.is_argument" "False" "Test func.is_argume= nt" -gdb_test "python print cplusfunc.is_function" "True" "Test func.is_functio= n" -gdb_test "python print cplusfunc.name" "SimpleClass::valueofi().*" "Test f= unc.name" -gdb_test "python print cplusfunc.print_name" "SimpleClass::valueofi().*" "= Test func.print_name" -gdb_test "python print cplusfunc.linkage_name" "SimpleClass::valueofi().*"= "Test func.linkage_name" -gdb_test "python print cplusfunc.addr_class =3D=3D gdb.SYMBOL_LOC_BLOCK" "= True" "Test func.addr_class" +gdb_test "python print (cplusfunc.is_variable)" "False" "Test func.is_vari= able" +gdb_test "python print (cplusfunc.is_constant)" "False" "Test func.is_cons= tant" +gdb_test "python print (cplusfunc.is_argument)" "False" "Test func.is_argu= ment" +gdb_test "python print (cplusfunc.is_function)" "True" "Test func.is_funct= ion" +gdb_test "python print (cplusfunc.name)" "SimpleClass::valueofi().*" "Test= func.name" +gdb_test "python print (cplusfunc.print_name)" "SimpleClass::valueofi().*"= "Test func.print_name" +gdb_test "python print (cplusfunc.linkage_name)" "SimpleClass::valueofi().= *" "Test func.linkage_name" +gdb_test "python print (cplusfunc.addr_class =3D=3D gdb.SYMBOL_LOC_BLOCK)"= "True" "Test func.addr_class" =20 # Test is_valid when the objfile is unloaded. This must be the last # test as it unloads the object file in GDB. @@ -156,8 +156,8 @@ gdb_breakpoint [gdb_get_line_number "Break at end."] gdb_continue_to_breakpoint "Break at end." gdb_py_test_silent_cmd "python a =3D gdb.lookup_symbol(\'a\')" "Get variab= le a" 0 -gdb_test "python print a\[0\].is_valid()" "True" "Test symbol validity" +gdb_test "python print (a\[0\].is_valid())" "True" "Test symbol validity" delete_breakpoints gdb_unload -gdb_test "python print a\[0\].is_valid()" "False" "Test symbol validity" +gdb_test "python print (a\[0\].is_valid())" "False" "Test symbol validity" gdb_test_no_output "python a =3D None" "Test symbol destructor" Index: gdb/testsuite/gdb.python/py-symtab.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symtab.exp,v retrieving revision 1.12 diff -u -r1.12 py-symtab.exp --- gdb/testsuite/gdb.python/py-symtab.exp 15 Oct 2012 15:23:47 -0000 1.12 +++ gdb/testsuite/gdb.python/py-symtab.exp 9 Nov 2012 22:26:56 -0000 @@ -50,29 +50,29 @@ gdb_py_test_silent_cmd "python new_pc =3D gdb.selected_frame().find_sal().= pc" "Get new PC" 0 =20 # Test sal. -gdb_test "python print sal.symtab" ".*gdb.python/py-symbol.c.*" "Test symt= ab" -gdb_test "python print sal.pc" "${decimal}" "Test sal.pc" -gdb_test "python print sal.last =3D=3D (new_pc - 1)" "True" "Test sal.last" -gdb_test "python print sal.line" "$line_no" "Test sal.line" -gdb_test "python print sal.is_valid()" "True" "Test sal.is_valid" +gdb_test "python print (sal.symtab)" ".*gdb.python/py-symbol.c.*" "Test sy= mtab" +gdb_test "python print (sal.pc)" "${decimal}" "Test sal.pc" +gdb_test "python print (sal.last =3D=3D (new_pc - 1))" "True" "Test sal.la= st" +gdb_test "python print (sal.line)" "$line_no" "Test sal.line" +gdb_test "python print (sal.is_valid())" "True" "Test sal.is_valid" =20 # Test symbol table. -gdb_test "python print symtab.filename" ".*gdb.python/py-symbol.c.*" "Test= symtab.filename" -gdb_test "python print symtab.objfile" "" "T= est symtab.objfile" -gdb_test "python print symtab.fullname()" "testsuite/gdb.python/py-symbol.= c.*" "Test symtab.fullname" -gdb_test "python print symtab.is_valid()" "True" "Test symtab.is_valid()" -gdb_test "python print \"qq\" in global_symbols" "True" "Test qq in global= symbols" -gdb_test "python print \"func\" in global_symbols" "True" "Test func in gl= obal symbols" -gdb_test "python print \"main\" in global_symbols" "True" "Test main in gl= obal symbols" -gdb_test "python print \"int\" in static_symbols" "True" "Test int in stat= ic symbols" -gdb_test "python print \"char\" in static_symbols" "True" "Test char in st= atic symbols" -gdb_test "python print \"simple_struct\" in static_symbols" "True" "Test s= imple_struct in static symbols" +gdb_test "python print (symtab.filename)" ".*gdb.python/py-symbol.c.*" "Te= st symtab.filename" +gdb_test "python print (symtab.objfile)" "" = "Test symtab.objfile" +gdb_test "python print (symtab.fullname())" "testsuite/gdb.python/py-symbo= l.c.*" "Test symtab.fullname" +gdb_test "python print (symtab.is_valid())" "True" "Test symtab.is_valid()" +gdb_test "python print (\"qq\" in global_symbols)" "True" "Test qq in glob= al symbols" +gdb_test "python print (\"func\" in global_symbols)" "True" "Test func in = global symbols" +gdb_test "python print (\"main\" in global_symbols)" "True" "Test main in = global symbols" +gdb_test "python print (\"int\" in static_symbols)" "True" "Test int in st= atic symbols" +gdb_test "python print (\"char\" in static_symbols)" "True" "Test char in = static symbols" +gdb_test "python print (\"simple_struct\" in static_symbols)" "True" "Test= simple_struct in static symbols" =20 # Test is_valid when the objfile is unloaded. This must be the last # test as it unloads the object file in GDB. gdb_unload -gdb_test "python print sal.is_valid()" "False" "Test sal.is_valid" -gdb_test "python print symtab.is_valid()" "False" "Test symtab.is_valid()" +gdb_test "python print (sal.is_valid())" "False" "Test sal.is_valid" +gdb_test "python print (symtab.is_valid())" "False" "Test symtab.is_valid(= )" =20 gdb_test_no_output "python sal =3D None" "Test sal destructor" gdb_test_no_output "python symtab =3D None" "Test symtab destructor" Index: gdb/testsuite/gdb.python/py-template.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-template.exp,v retrieving revision 1.12 diff -u -r1.12 py-template.exp --- gdb/testsuite/gdb.python/py-template.exp 22 Jun 2012 17:59:33 -0000 1.12 +++ gdb/testsuite/gdb.python/py-template.exp 9 Nov 2012 22:26:56 -0000 @@ -48,12 +48,12 @@ return } # There is no executable code in main(), so we are where we want to be - gdb_test "print foo" ".*" + gdb_test "print (foo)" ".*" gdb_test_no_output "python foo =3D gdb.history(0)" =20 # Replace '*' with '\*' in regex. regsub -all {\*} $type {\*} t - gdb_test "python print foo.type.template_argument(0)" $t $type + gdb_test "python print (foo.type.template_argument(0))" $t $type } =20 test_template_arg "${binfile}-ci" "const int" Index: gdb/testsuite/gdb.python/py-type.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-type.exp,v retrieving revision 1.25 diff -u -r1.25 py-type.exp --- gdb/testsuite/gdb.python/py-type.exp 10 Aug 2012 20:26:00 -0000 1.25 +++ gdb/testsuite/gdb.python/py-type.exp 9 Nov 2012 22:26:56 -0000 @@ -59,7 +59,7 @@ global gdb_prompt =20 # .fields() of a typedef should still return the underlying field list - gdb_test "python print len(gdb.parse_and_eval('ts').type.fields())" "2" \ + gdb_test "python print (len(gdb.parse_and_eval('ts').type.fields()))" "2= " \ "$lang typedef field list" =20 if {$lang =3D=3D "c++"} { @@ -67,12 +67,12 @@ gdb_py_test_silent_cmd "print c" "print value" 1 gdb_py_test_silent_cmd "python c =3D gdb.history (0)" "get value fro= m history" 1 gdb_py_test_silent_cmd "python fields =3D c.type.fields()" "get fiel= ds" 1 - gdb_test "python print len(fields)" "2" "Check number of fields" - gdb_test "python print fields\[0\].name" "c" "Check class field c na= me" - gdb_test "python print fields\[1\].name" "d" "Check class field d na= me" + gdb_test "python print (len(fields))" "2" "Check number of fields" + gdb_test "python print (fields\[0\].name)" "c" "Check class field c = name" + gdb_test "python print (fields\[1\].name)" "d" "Check class field d = name" =20 - gdb_test "python print c.type =3D=3D gdb.parse_and_eval('d').type" "= False" - gdb_test "python print c.type =3D=3D gdb.parse_and_eval('d').type.fi= elds()\[0\].type" \ + gdb_test "python print (c.type =3D=3D gdb.parse_and_eval('d').type)"= "False" + gdb_test "python print (c.type =3D=3D gdb.parse_and_eval('d').type.f= ields()\[0\].type)" \ "True" } =20 @@ -80,85 +80,85 @@ gdb_py_test_silent_cmd "print st" "print value" 1 gdb_py_test_silent_cmd "python st =3D gdb.history (0)" "get value from h= istory" 1 gdb_py_test_silent_cmd "python fields =3D st.type.fields()" "get fields"= 1 - gdb_test "python print len(fields)" "2" "Check number of fields" - gdb_test "python print fields\[0\].name" "a" "Check structure field a na= me" - gdb_test "python print fields\[1\].name" "b" "Check structure field b na= me" + gdb_test "python print (len(fields))" "2" "Check number of fields" + gdb_test "python print (fields\[0\].name)" "a" "Check structure field a = name" + gdb_test "python print (fields\[1\].name)" "b" "Check structure field b = name" =20 # Regression test for # http://sourceware.org/bugzilla/show_bug.cgi?id=3D12070. - gdb_test "python print 'type' in dir(fields\[0\])" "True" \ + gdb_test "python print ('type' in dir(fields\[0\]))" "True" \ "Check that dir includes name" =20 # Test Python mapping behavior of gdb.Type for structs/classes - gdb_test "python print len(st.type)" "2" "Check number of fields" - gdb_test "python print st.type\['a'\].name" "a" "Check fields lookup by = name" - gdb_test "python print \[v.bitpos for v in st.type.itervalues()\]" {\[= 0L, 32L\]} "Check fields iteration over values" - gdb_test "python print \[(n, v.bitpos) for (n, v) in st.type.items()\]= " {\[\('a', 0L\), \('b', 32L\)\]} "Check fields items list" - gdb_test "python print 'a' in st.type" "True" "Check field name exists t= est" - gdb_test "python print 'nosuch' in st.type" "False" "Check field name no= nexists test" - gdb_test "python print not not st.type" "True" "Check conversion to bool" + gdb_test "python print (len(st.type))" "2" "Check number of fields" + gdb_test "python print (st.type\['a'\].name)" "a" "Check fields lookup b= y name" + gdb_test "python print (\[v.bitpos for v in st.type.itervalues()\])" {= \[0L?, 32L?\]} "Check fields iteration over values" + gdb_test "python print (\[(n, v.bitpos) for (n, v) in st.type.items()\= ])" {\[\('a', 0L?\), \('b', 32L?\)\]} "Check fields items list" + gdb_test "python print ('a' in st.type)" "True" "Check field name exists= test" + gdb_test "python print ('nosuch' in st.type)" "False" "Check field name = nonexists test" + gdb_test "python print (not not st.type)" "True" "Check conversion to bo= ol" =20 # Test rejection of mapping operations on scalar types - gdb_test "python print len (st.type\['a'\].type)" "TypeError: Type is no= t a structure, union, or enum type.*" - gdb_test "python print st.type\['a'\].type.has_key ('x')" "TypeError: Ty= pe is not a structure, union, or enum type.*" - gdb_test "python print st.type\['a'\].type.keys ()" "TypeError: Type is = not a structure, union, or enum type.*" - gdb_test "python print st.type\['a'\].type\['x'\]" "TypeError: Type is n= ot a structure, union, or enum type.*" + gdb_test "python print (len (st.type\['a'\].type))" "TypeError: Type is = not a structure, union, or enum type.*" + gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError: = Type is not a structure, union, or enum type.*" + gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError: Type i= s not a structure, union, or enum type.*" + gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError: Type is= not a structure, union, or enum type.*" =20 # Test conversion to bool on scalar types - gdb_test "python print not not st.type\['a'\].type" "True" + gdb_test "python print (not not st.type\['a'\].type)" "True" =20=20=20 # Test regression PR python/10805 gdb_py_test_silent_cmd "print ar" "print value" 1 gdb_py_test_silent_cmd "python ar =3D gdb.history (0)" "get value from = history" 1 gdb_test "python fields =3D ar.type.fields()" - gdb_test "python print len(fields)" "1" "Check the number of fields" - gdb_test "python print fields\[0\].type" "" "Check array fie= ld type" + gdb_test "python print (len(fields))" "1" "Check the number of fields" + gdb_test "python print (fields\[0\].type)" "" "Check array f= ield type" =20 # Test gdb.Type.array. - gdb_test "python print ar\[0\].cast(ar\[0\].type.array(1))" \ + gdb_test "python print (ar\[0\].cast(ar\[0\].type.array(1)))" \ ".1, 2." "cast to array with one argument" - gdb_test "python print ar\[0\].cast(ar\[0\].type.array(0, 1))" \ + gdb_test "python print (ar\[0\].cast(ar\[0\].type.array(0, 1)))" \ ".1, 2." "cast to array with two arguments" =20 - gdb_test "python print ar\[0\].type =3D=3D ar\[0\].type" "True" + gdb_test "python print (ar\[0\].type =3D=3D ar\[0\].type)" "True" =20 # Test gdb.Type.vector. # Note: vectors cast differently than arrays. Here ar[0] is replicated # for the size of the vector. gdb_py_test_silent_cmd \ "python vec1 =3D ar\[0\].cast(ar\[0\].type.vector(1))" "set vec1" 1 - gdb_test "python print vec1" ".1, 1." "cast to vector with one argument" + gdb_test "python print (vec1)" ".1, 1." "cast to vector with one argumen= t" gdb_py_test_silent_cmd \ "python vec2 =3D ar\[0\].cast(ar\[0\].type.vector(0, 1))" "set vec2"= 1 - gdb_test "python print vec2" ".1, 1." "cast to vector with two arguments" - gdb_test "python print vec1 =3D=3D vec2" "True" + gdb_test "python print (vec2)" ".1, 1." "cast to vector with two argumen= ts" + gdb_test "python print (vec1 =3D=3D vec2)" "True" gdb_py_test_silent_cmd \ "python vec3 =3D ar\[1\].cast(ar\[1\].type.vector(1))" "set vec3" 1 - gdb_test "python print vec1 =3D=3D vec3" "False" + gdb_test "python print (vec1 =3D=3D vec3)" "False" } =20 proc test_enums {} { gdb_py_test_silent_cmd "print e" "print value" 1 gdb_py_test_silent_cmd "python e =3D gdb.history (0)" "get value from h= istory" 1 gdb_py_test_silent_cmd "python fields =3D e.type.fields()" "get value fr= om history" 1 - gdb_test "python print len(fields)" "3" "Check the number of enum fields" - gdb_test "python print fields\[0\].name" "v1" "Check enum field name" - gdb_test "python print fields\[1\].name" "v2" "Check enum field name" + gdb_test "python print (len(fields))" "3" "Check the number of enum fiel= ds" + gdb_test "python print (fields\[0\].name)" "v1" "Check enum field name" + gdb_test "python print (fields\[1\].name)" "v2" "Check enum field name" =20 # Ditto but by mapping operations - gdb_test "python print len(e.type)" "3" "Check the number of enum fields" - gdb_test "python print e.type\['v1'\].name" "v1" "Check enum field looku= p by name" - gdb_test "python print e.type\['v3'\].name" "v3" "Check enum field looku= p by name" - gdb_test "python print \[v.enumval for v in e.type.itervalues()\]" {\[= 0L, 1L, 2L\]} "Check num fields iteration over values" - gdb_test "python print \[(n, v.enumval) for (n, v) in e.type.items()\]= " {\[\('v1', 0L\), \('v2', 1L\), \('v3', 2L\)\]} "Check enum fields items l= ist" + gdb_test "python print (len(e.type))" "3" "Check the number of enum fiel= ds" + gdb_test "python print (e.type\['v1'\].name)" "v1" "Check enum field loo= kup by name" + gdb_test "python print (e.type\['v3'\].name)" "v3" "Check enum field loo= kup by name" + gdb_test "python print (\[v.enumval for v in e.type.itervalues()\])" {= \[0L?, 1L?, 2L?\]} "Check num fields iteration over values" + gdb_test "python print (\[(n, v.enumval) for (n, v) in e.type.items()\= ])" {\[\('v1', 0L?\), \('v2', 1L?\), \('v3', 2L?\)\]} "Check enum fields it= ems list" } proc test_base_class {} { gdb_py_test_silent_cmd "print d" "print value" 1 gdb_py_test_silent_cmd "python d =3D gdb.history (0)" "get value from h= istory" 1 gdb_py_test_silent_cmd "python fields =3D d.type.fields()" "get value fr= om history" 1 - gdb_test "python print len(fields)" "3" "Check the number of fields" - gdb_test "python print fields\[0\].is_base_class" "True" "Check base cla= ss" - gdb_test "python print fields\[1\].is_base_class" "False" "Check base cl= ass" + gdb_test "python print (len(fields))" "3" "Check the number of fields" + gdb_test "python print (fields\[0\].is_base_class)" "True" "Check base c= lass" + gdb_test "python print (fields\[1\].is_base_class)" "False" "Check base = class" } =20 proc test_range {} { @@ -166,21 +166,21 @@ # Test a valid range request. gdb_py_test_silent_cmd "print ar" "print value" 1 gdb_py_test_silent_cmd "python ar =3D gdb.history (0)" "get value from h= istory" 1 - gdb_test "python print len(ar.type.range())" "2" "Check correct tuple le= ngth" - gdb_test "python print ar.type.range()\[0\]" "0" "Check low range" - gdb_test "python print ar.type.range()\[1\]" "1" "Check high range" + gdb_test "python print (len(ar.type.range()))" "2" "Check correct tuple = length" + gdb_test "python print (ar.type.range()\[0\])" "0" "Check low range" + gdb_test "python print (ar.type.range()\[1\])" "1" "Check high range" =20 # Test a range request on a ranged type. gdb_py_test_silent_cmd "print ar" "print value" 1 gdb_py_test_silent_cmd "python ar =3D gdb.history (0)" "get value from = history" 1 gdb_py_test_silent_cmd "python fields =3D ar.type.fields()" "get fields"= 1 - gdb_test "python print fields\[0\].type.range()\[0\]" "0" "Check range t= ype low bound" - gdb_test "python print fields\[0\].type.range()\[1\]" "1" "Check range t= ype high bound" + gdb_test "python print (fields\[0\].type.range()\[0\])" "0" "Check range= type low bound" + gdb_test "python print (fields\[0\].type.range()\[1\])" "1" "Check range= type high bound" =20 # Test where a range does not exist. gdb_py_test_silent_cmd "print st" "print value" 1 gdb_py_test_silent_cmd "python st =3D gdb.history (0)" "get value from h= istory" 1 - gdb_test "python print st.type.range()" "RuntimeError: This type does no= t have a range.*" "Check range for non ranged type." + gdb_test "python print (st.type.range())" "RuntimeError: This type does = not have a range.*" "Check range for non ranged type." } =20 # Some tests of template arguments. @@ -190,8 +190,8 @@ "get type of temvar" \ 1 =20 - gdb_test "python print ttype.template_argument(0)" "D" - gdb_test "python print isinstance(ttype.template_argument(0), gdb.Type= )" \ + gdb_test "python print (ttype.template_argument(0))" "D" + gdb_test "python print (isinstance(ttype.template_argument(0), gdb.Typ= e))" \ "True" =20 # The next two tests require a GCC that emits DW_TAG_template_*. @@ -202,16 +202,16 @@ set have_older_gcc 1 } if $have_older_gcc { setup_xfail *-*-* } - gdb_test "python print ttype.template_argument(1)" "23" + gdb_test "python print (ttype.template_argument(1))" "23" if $have_older_gcc { setup_xfail *-*-* } - gdb_test "python print isinstance(ttype.template_argument(1), gdb.Valu= e)" \ + gdb_test "python print (isinstance(ttype.template_argument(1), gdb.Val= ue))" \ "True" =20 if {[test_compiler_info {gcc-[0-3]-*}] || [test_compiler_info {gcc-4-[0-5]-*}]} { setup_xfail "gcc/46955" *-*-* } - gdb_test "python print ttype.template_argument(2)" "&C::c" + gdb_test "python print (ttype.template_argument(2))" "&C::c" } =20 # Perform C Tests. Index: gdb/testsuite/gdb.python/py-value-cc.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-value-cc.exp,v retrieving revision 1.2 diff -u -r1.2 py-value-cc.exp --- gdb/testsuite/gdb.python/py-value-cc.exp 22 Jun 2012 17:59:33 -0000 1.2 +++ gdb/testsuite/gdb.python/py-value-cc.exp 9 Nov 2012 22:26:56 -0000 @@ -34,13 +34,13 @@ gdb_breakpoint [gdb_get_line_number "Break here."] gdb_continue_to_breakpoint "Break here" ".*Break here.*" =20 -gdb_test "python print str(gdb.parse_and_eval(\"a\").type)" "const A &" -gdb_test "python print str(gdb.parse_and_eval(\"a\").referenced_value().ty= pe)" "const A" -gdb_test "python print str(gdb.parse_and_eval(\"int_ref\").type)" "int &" -gdb_test "python print str(gdb.parse_and_eval(\"int_ref\").referenced_valu= e().type)" "int" -gdb_test "python print str(gdb.parse_and_eval(\"int_ref\").referenced_valu= e())" "10" +gdb_test "python print (str(gdb.parse_and_eval(\"a\").type))" "const A &" +gdb_test "python print (str(gdb.parse_and_eval(\"a\").referenced_value().t= ype))" "const A" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").type))" "int &" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").referenced_val= ue().type))" "int" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").referenced_val= ue()))" "10" =20 -gdb_test "python print str(gdb.parse_and_eval(\"int_ptr_ref\").dereference= ().type)" "int" -gdb_test "python print str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_= value().type)" "int_ptr" -gdb_test "python print str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_= value().dereference())" "10" -gdb_test "python print str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_= value().referenced_value())" "10" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").dereferenc= e().type))" "int" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced= _value().type))" "int_ptr" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced= _value().dereference()))" "10" +gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced= _value().referenced_value()))" "10" Index: gdb/testsuite/gdb.python/py-value.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-value.exp,v retrieving revision 1.31 diff -u -r1.31 py-value.exp --- gdb/testsuite/gdb.python/py-value.exp 6 Sep 2012 17:57:41 -0000 1.31 +++ gdb/testsuite/gdb.python/py-value.exp 9 Nov 2012 22:26:57 -0000 @@ -32,20 +32,25 @@ =20 proc test_value_creation {} { global gdb_prompt + global gdb_py_is_py3k =20 gdb_py_test_silent_cmd "python i =3D gdb.Value (True)" "create boolean v= alue" 1 gdb_py_test_silent_cmd "python i =3D gdb.Value (5)" "create integer valu= e" 1 - gdb_py_test_silent_cmd "python i =3D gdb.Value (5L)" "create long value"= 1 + if { $gdb_py_is_py3k =3D=3D 0 } { + gdb_py_test_silent_cmd "python i =3D gdb.Value (5L)" "create long valu= e" 1 + } gdb_py_test_silent_cmd "python f =3D gdb.Value (1.25)" "create double va= lue" 1 gdb_py_test_silent_cmd "python a =3D gdb.Value ('string test')" "create = 8-bit string value" 1 - gdb_test "python print a" "\"string test\"" "print 8-bit string" - gdb_test "python print a.__class__" "" "verify type of= 8-bit string" - gdb_py_test_silent_cmd "python a =3D gdb.Value (u'unicode test')" "creat= e unicode value" 1 - gdb_test "python print a" "\"unicode test\"" "print Unicode string" - gdb_test "python print a.__class__" "" "verify type of= unicode string" + gdb_test "python print (a)" "\"string test\"" "print 8-bit string" + gdb_test "python print (a.__class__)" "<(type|class) 'gdb.Value'>" "veri= fy type of 8-bit string" + if { $gdb_py_is_py3k =3D=3D 0 } { + gdb_py_test_silent_cmd "python a =3D gdb.Value (u'unicode test')" "cre= ate unicode value" 1 + gdb_test "python print (a)" "\"unicode test\"" "print Unicode string" + gdb_test "python print (a.__class__)" "<(type|class) 'gdb.Value'>" "ve= rify type of unicode string" + } =20 # Test address attribute is None in a non-addressable value - gdb_test "python print 'result =3D', i.address" "=3D None" "Test address= attribute in non-addressable value" + gdb_test "python print ('result =3D %s' % i.address)" "=3D None" "Test a= ddress attribute in non-addressable value" } =20 proc test_value_numeric_ops {} { @@ -55,42 +60,42 @@ gdb_py_test_silent_cmd "python j =3D gdb.Value (2)" "create second integ= er value" 0 gdb_py_test_silent_cmd "python f =3D gdb.Value (1.25)" "create first dou= ble value" 0 gdb_py_test_silent_cmd "python g =3D gdb.Value (2.5)" "create second dou= ble value" 0 - gdb_test "python print 'result =3D ' + str(i+j)" " =3D 7" "add two integ= er values" - gdb_test "python print (i+j).__class__" "" "verify typ= e of integer add result" + gdb_test "python print ('result =3D ' + str(i+j))" " =3D 7" "add two int= eger values" + gdb_test "python print ((i+j).__class__)" "<(type|class) 'gdb.Value'>" "= verify type of integer add result" =20 - gdb_test "python print 'result =3D ' + str(f+g)" " =3D 3.75" "add two do= uble values" - gdb_test "python print 'result =3D ' + str(i-j)" " =3D 3" "subtract two = integer values" - gdb_test "python print 'result =3D ' + str(f-g)" " =3D -1.25" "subtract = two double values" - gdb_test "python print 'result =3D ' + str(i*j)" " =3D 10" "multiply two= integer values" - gdb_test "python print 'result =3D ' + str(f*g)" " =3D 3.125" "multiply = two double values" - gdb_test "python print 'result =3D ' + str(i/j)" " =3D 2" "divide two in= teger values" - gdb_test "python print 'result =3D ' + str(f/g)" " =3D 0.5" "divide two = double values" - gdb_test "python print 'result =3D ' + str(i%j)" " =3D 1" "take remainde= r of two integer values" + gdb_test "python print ('result =3D ' + str(f+g))" " =3D 3.75" "add two = double values" + gdb_test "python print ('result =3D ' + str(i-j))" " =3D 3" "subtract tw= o integer values" + gdb_test "python print ('result =3D ' + str(f-g))" " =3D -1.25" "subtrac= t two double values" + gdb_test "python print ('result =3D ' + str(i*j))" " =3D 10" "multiply t= wo integer values" + gdb_test "python print ('result =3D ' + str(f*g))" " =3D 3.125" "multipl= y two double values" + gdb_test "python print ('result =3D ' + str(i/j))" " =3D 2" "divide two = integer values" + gdb_test "python print ('result =3D ' + str(f/g))" " =3D 0.5" "divide tw= o double values" + gdb_test "python print ('result =3D ' + str(i%j))" " =3D 1" "take remain= der of two integer values" # Remainder of float is implemented in Python but not in GDB's value sys= tem. =20 - gdb_test "python print 'result =3D ' + str(i**j)" " =3D 25" "integer val= ue raised to the power of another integer value" - gdb_test "python print 'result =3D ' + str(g**j)" " =3D 6.25" "double va= lue raised to the power of integer value" + gdb_test "python print ('result =3D ' + str(i**j))" " =3D 25" "integer v= alue raised to the power of another integer value" + gdb_test "python print ('result =3D ' + str(g**j))" " =3D 6.25" "double = value raised to the power of integer value" =20 - gdb_test "python print 'result =3D ' + str(-i)" " =3D -5" "negated integ= er value" - gdb_test "python print 'result =3D ' + str(+i)" " =3D 5" "positive integ= er value" - gdb_test "python print 'result =3D ' + str(-f)" " =3D -1.25" "negated do= uble value" - gdb_test "python print 'result =3D ' + str(+f)" " =3D 1.25" "positive do= uble value" - gdb_test "python print 'result =3D ' + str(abs(j-i))" " =3D 3" "absolute= of integer value" - gdb_test "python print 'result =3D ' + str(abs(f-g))" " =3D 1.25" "absol= ute of double value" + gdb_test "python print ('result =3D ' + str(-i))" " =3D -5" "negated int= eger value" + gdb_test "python print ('result =3D ' + str(+i))" " =3D 5" "positive int= eger value" + gdb_test "python print ('result =3D ' + str(-f))" " =3D -1.25" "negated = double value" + gdb_test "python print ('result =3D ' + str(+f))" " =3D 1.25" "positive = double value" + gdb_test "python print ('result =3D ' + str(abs(j-i)))" " =3D 3" "absolu= te of integer value" + gdb_test "python print ('result =3D ' + str(abs(f-g)))" " =3D 1.25" "abs= olute of double value" =20 # Test gdb.Value mixed with Python types. =20 - gdb_test "python print 'result =3D ' + str(i-1)" " =3D 4" "subtract inte= ger value from python integer" - gdb_test "python print (i-1).__class__" "" "verify typ= e of mixed integer subtraction result" - gdb_test "python print 'result =3D ' + str(f+1.5)" " =3D 2.75" "add doub= le value with python float" + gdb_test "python print ('result =3D ' + str(i-1))" " =3D 4" "subtract in= teger value from python integer" + gdb_test "python print ((i-1).__class__)" "<(type|class) 'gdb.Value'>" "= verify type of mixed integer subtraction result" + gdb_test "python print ('result =3D ' + str(f+1.5))" " =3D 2.75" "add do= uble value with python float" =20 - gdb_test "python print 'result =3D ' + str(1-i)" " =3D -4" "subtract pyt= hon integer from integer value" - gdb_test "python print 'result =3D ' + str(1.5+f)" " =3D 2.75" "add pyth= on float with double value" + gdb_test "python print ('result =3D ' + str(1-i))" " =3D -4" "subtract p= ython integer from integer value" + gdb_test "python print ('result =3D ' + str(1.5+f))" " =3D 2.75" "add py= thon float with double value" =20 # Conversion test. gdb_test "print evalue" " =3D TWO" gdb_test_no_output "python evalue =3D gdb.history (0)" - gdb_test "python print int (evalue)" "2" + gdb_test "python print (int (evalue))" "2" =20 # Test pointer arithmethic =20 @@ -100,19 +105,19 @@ gdb_test "print (void *) 5" ".*" "" gdb_test_no_output "python b =3D gdb.history (0)" "" =20 - gdb_test "python print 'result =3D ' + str(a+5)" " =3D 0x7( <.*>)?" "add= pointer value with python integer" - gdb_test "python print 'result =3D ' + str(b-2)" " =3D 0x3( <.*>)?" "sub= tract python integer from pointer value" - gdb_test "python print 'result =3D ' + str(b-a)" " =3D 3" "subtract two = pointer values" + gdb_test "python print ('result =3D ' + str(a+5))" " =3D 0x7( <.*>)?" "a= dd pointer value with python integer" + gdb_test "python print ('result =3D ' + str(b-2))" " =3D 0x3( <.*>)?" "s= ubtract python integer from pointer value" + gdb_test "python print ('result =3D ' + str(b-a))" " =3D 3" "subtract tw= o pointer values" =20 # Test some invalid operations. =20 - gdb_test_multiple "python print 'result =3D ' + str(i+'foo')" "catch err= or in python type conversion" { + gdb_test_multiple "python print ('result =3D ' + str(i+'foo'))" "catch e= rror in python type conversion" { -re "Argument to arithmetic operation not a number or boolean.*$gdb_= prompt $" {pass "catch error in python type conversion"} -re "result =3D .*$gdb_prompt $" {fail "catch error in python= type conversion"} -re "$gdb_prompt $" {fail "catch error in python type conver= sion"} } =20 - gdb_test_multiple "python print 'result =3D ' + str(i+gdb.Value('foo'))"= "catch throw of GDB error" { + gdb_test_multiple "python print ('result =3D ' + str(i+gdb.Value('foo'))= )" "catch throw of GDB error" { -re "Traceback.*$gdb_prompt $" {pass "catch throw of GDB error"} -re "result =3D .*$gdb_prompt $" {fail "catch throw of GDB error"} -re "$gdb_prompt $" {fail "catch throw of GDB error"} @@ -125,9 +130,9 @@ "python" "" \ "def test_bool (val):" "" \ " if val:" "" \ - " print 'yay'" "" \ + " print ('yay')" "" \ " else:" "" \ - " print 'nay'" "" \ + " print ('nay')" "" \ "end" "" =20 gdb_test "py test_bool (gdb.Value (True))" "yay" "check evaluation of tr= ue boolean value in expression" @@ -144,40 +149,41 @@ } =20 proc test_value_compare {} { - gdb_test "py print gdb.Value (1) < gdb.Value (1)" "False" "less than, eq= ual" - gdb_test "py print gdb.Value (1) < gdb.Value (2)" "True" "less than, les= s" - gdb_test "py print gdb.Value (2) < gdb.Value (1)" "False" "less than, gr= eater" - gdb_test "py print gdb.Value (2) < None" "False" "less than, None" - - gdb_test "py print gdb.Value (1) <=3D gdb.Value (1)" "True" "less or equ= al, equal" - gdb_test "py print gdb.Value (1) <=3D gdb.Value (2)" "True" "less or equ= al, less" - gdb_test "py print gdb.Value (2) <=3D gdb.Value (1)" "False" "less or eq= ual, greater" - gdb_test "py print gdb.Value (2) <=3D None" "False" "less or equal, None" - - gdb_test "py print gdb.Value (1) =3D=3D gdb.Value (1)" "True" "equality = of gdb.Values" - gdb_test "py print gdb.Value (1) =3D=3D gdb.Value (2)" "False" "inequali= ty of gdb.Values" - gdb_test "py print gdb.Value (1) =3D=3D 1.0" "True" "equality of gdb.Val= ue with Python value" - gdb_test "py print gdb.Value (1) =3D=3D 2" "False" "inequality of gdb.Va= lue with Python value" - gdb_test "py print gdb.Value (1) =3D=3D None" "False" "inequality of gdb= .Value with None" - - gdb_test "py print gdb.Value (1) !=3D gdb.Value (1)" "False" "inequality= , false" - gdb_test "py print gdb.Value (1) !=3D gdb.Value (2)" "True" "inequality,= true" - gdb_test "py print gdb.Value (1) !=3D None" "True" "inequality, None" - - gdb_test "py print gdb.Value (1) > gdb.Value (1)" "False" "greater than,= equal" - gdb_test "py print gdb.Value (1) > gdb.Value (2)" "False" "greater than,= less" - gdb_test "py print gdb.Value (2) > gdb.Value (1)" "True" "greater than, = greater" - gdb_test "py print gdb.Value (2) > None" "True" "greater than, None" - - gdb_test "py print gdb.Value (1) >=3D gdb.Value (1)" "True" "greater or = equal, equal" - gdb_test "py print gdb.Value (1) >=3D gdb.Value (2)" "False" "greater or= equal, less" - gdb_test "py print gdb.Value (2) >=3D gdb.Value (1)" "True" "greater or = equal, greater" - gdb_test "py print gdb.Value (2) >=3D None" "True" "greater or equal, No= ne" + gdb_test "py print (gdb.Value (1) < gdb.Value (1))" "False" "less than, = equal" + gdb_test "py print (gdb.Value (1) < gdb.Value (2))" "True" "less than, l= ess" + gdb_test "py print (gdb.Value (2) < gdb.Value (1))" "False" "less than, = greater" + gdb_test "py print (gdb.Value (2) < None)" "False" "less than, None" + + gdb_test "py print (gdb.Value (1) <=3D gdb.Value (1))" "True" "less or e= qual, equal" + gdb_test "py print (gdb.Value (1) <=3D gdb.Value (2))" "True" "less or e= qual, less" + gdb_test "py print (gdb.Value (2) <=3D gdb.Value (1))" "False" "less or = equal, greater" + gdb_test "py print (gdb.Value (2) <=3D None)" "False" "less or equal, No= ne" + + gdb_test "py print (gdb.Value (1) =3D=3D gdb.Value (1))" "True" "equalit= y of gdb.Values" + gdb_test "py print (gdb.Value (1) =3D=3D gdb.Value (2))" "False" "inequa= lity of gdb.Values" + gdb_test "py print (gdb.Value (1) =3D=3D 1.0)" "True" "equality of gdb.V= alue with Python value" + gdb_test "py print (gdb.Value (1) =3D=3D 2)" "False" "inequality of gdb.= Value with Python value" + gdb_test "py print (gdb.Value (1) =3D=3D None)" "False" "inequality of g= db.Value with None" + + gdb_test "py print (gdb.Value (1) !=3D gdb.Value (1))" "False" "inequali= ty, false" + gdb_test "py print (gdb.Value (1) !=3D gdb.Value (2))" "True" "inequalit= y, true" + gdb_test "py print (gdb.Value (1) !=3D None)" "True" "inequality, None" + + gdb_test "py print (gdb.Value (1) > gdb.Value (1))" "False" "greater tha= n, equal" + gdb_test "py print (gdb.Value (1) > gdb.Value (2))" "False" "greater tha= n, less" + gdb_test "py print (gdb.Value (2) > gdb.Value (1))" "True" "greater than= , greater" + gdb_test "py print (gdb.Value (2) > None)" "True" "greater than, None" + + gdb_test "py print (gdb.Value (1) >=3D gdb.Value (1))" "True" "greater o= r equal, equal" + gdb_test "py print (gdb.Value (1) >=3D gdb.Value (2))" "False" "greater = or equal, less" + gdb_test "py print (gdb.Value (2) >=3D gdb.Value (1))" "True" "greater o= r equal, greater" + gdb_test "py print (gdb.Value (2) >=3D None)" "True" "greater or equal, = None" } =20 proc test_value_in_inferior {} { global gdb_prompt global testfile + global gdb_py_is_py3k =20 gdb_breakpoint [gdb_get_line_number "break to inspect struct and union"] =20 @@ -188,8 +194,10 @@ =20 gdb_py_test_silent_cmd "python s =3D gdb.history (0)" "get value from hi= story" 1 =20 - gdb_test "python print 'result =3D ' + str(s\['a'\])" " =3D 3" "access e= lement inside struct using 8-bit string name" - gdb_test "python print 'result =3D ' + str(s\[u'a'\])" " =3D 3" "access = element inside struct using unicode name" + gdb_test "python print ('result =3D ' + str(s\['a'\]))" " =3D 3" "access= element inside struct using 8-bit string name" + if { $gdb_py_is_py3k =3D=3D 0 } { + gdb_test "python print ('result =3D ' + str(s\[u'a'\]))" " =3D 3" "acc= ess element inside struct using unicode name" + } =20 # Test dereferencing the argv pointer =20 @@ -201,14 +209,14 @@ =20 # Check that the dereferenced value is sane if { ! [target_info exists noargs] } { - gdb_test "python print arg0" "0x.*$testfile\"" "verify dereferenced va= lue" + gdb_test "python print (arg0)" "0x.*$testfile\"" "verify dereferenced = value" } =20 # Smoke-test is_optimized_out attribute - gdb_test "python print 'result =3D', arg0.is_optimized_out" "=3D False" = "Test is_optimized_out attribute" + gdb_test "python print ('result =3D %s' % arg0.is_optimized_out)" "=3D F= alse" "Test is_optimized_out attribute" =20 # Test address attribute - gdb_test "python print 'result =3D', arg0.address" "=3D 0x\[\[:xdigit:\]= \]+" "Test address attribute" + gdb_test "python print ('result =3D %s' % arg0.address)" "=3D 0x\[\[:xdi= git:\]\]+" "Test address attribute" =20 # Test displaying a variable that is temporarily at a bad address. # But if we can examine what's at memory address 0, then we'll also be @@ -227,7 +235,7 @@ if {$can_read_0} { untested $test } else { - gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryErro= r: Cannot access memory at address 0x0.*" $test + gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryEr= ror: Cannot access memory at address 0x0.*" $test } =20 # Test Python lazy value handling @@ -236,40 +244,40 @@ untested $test } else { gdb_test "python inval =3D gdb.parse_and_eval('*(int*)0')" - gdb_test "python print inval.is_lazy" "True" + gdb_test "python print (inval.is_lazy)" "True" gdb_test "python inval2 =3D inval+1" "gdb.MemoryError: Cannot access m= emory at address 0x0.*" $test gdb_test "python inval.fetch_lazy ()" "gdb.MemoryError: Cannot access = memory at address 0x0.*" $test } gdb_test "python argc_lazy =3D gdb.parse_and_eval('argc')" gdb_test "python argc_notlazy =3D gdb.parse_and_eval('argc')" gdb_test "python argc_notlazy.fetch_lazy()" - gdb_test "python print argc_lazy.is_lazy" "True" - gdb_test "python print argc_notlazy.is_lazy" "False" + gdb_test "python print (argc_lazy.is_lazy)" "True" + gdb_test "python print (argc_notlazy.is_lazy)" "False" gdb_test "print argc" " =3D 1" "sanity check argc" - gdb_test "python print argc_lazy.is_lazy" "\r\nTrue" + gdb_test "python print (argc_lazy.is_lazy)" "\r\nTrue" gdb_test_no_output "set argc=3D2" - gdb_test "python print argc_notlazy" "\r\n1" - gdb_test "python print argc_lazy" "\r\n2" - gdb_test "python print argc_lazy.is_lazy" "False" + gdb_test "python print (argc_notlazy)" "\r\n1" + gdb_test "python print (argc_lazy)" "\r\n2" + gdb_test "python print (argc_lazy.is_lazy)" "False" =20 # Test string fetches, both partial and whole. gdb_test "print st" "\"divide et impera\"" gdb_py_test_silent_cmd "python st =3D gdb.history (0)" "get value from h= istory" 1 - gdb_test "python print st.string ()" "divide et impera" "Test string w= ith no length" - gdb_test "python print st.string (length =3D -1)" "divide et impera" "Te= st string (length =3D -1) is all of the string" - gdb_test "python print st.string (length =3D 6)" "divide" - gdb_test "python print \"---\"+st.string (length =3D 0)+\"---\"" "------= " "Test string (length =3D 0) is empty" - gdb_test "python print len(st.string (length =3D 0))" "0" "Test length i= s 0" + gdb_test "python print (st.string ())" "divide et impera" "Test string= with no length" + gdb_test "python print (st.string (length =3D -1))" "divide et impera" "= Test string (length =3D -1) is all of the string" + gdb_test "python print (st.string (length =3D 6))" "divide" + gdb_test "python print (\"---\"+st.string (length =3D 0)+\"---\")" "----= --" "Test string (length =3D 0) is empty" + gdb_test "python print (len(st.string (length =3D 0)))" "0" "Test length= is 0" =20 =20 # Fetch a string that has embedded nulls. gdb_test "print nullst" "\"divide\\\\000et\\\\000impera\".*" gdb_py_test_silent_cmd "python nullst =3D gdb.history (0)" "get value fr= om history" 1 - gdb_test "python print nullst.string ()" "divide" "Test string to first = null" + gdb_test "python print (nullst.string ())" "divide" "Test string to firs= t null" # Python cannot print strings that contain the null (\0) character. # For the purposes of this test, use repr() gdb_py_test_silent_cmd "python nullst =3D nullst.string (length =3D 9)" = "get string beyond null" 1 - gdb_test "python print repr(nullst)" "u'divide\\\\x00et'" + gdb_test "python print (repr(nullst))" "u?'divide\\\\x00et'" } =20 proc test_lazy_strings {} { @@ -280,14 +288,14 @@ gdb_py_test_silent_cmd "python sptr =3D gdb.history (0)" "Get value from= history" 1 =20 gdb_py_test_silent_cmd "python lstr =3D sptr.lazy_string()" "Aquire lazy= string" 1 - gdb_test "python print lstr.type" "const char \*." "Test type name equal= ity" - gdb_test "python print sptr.type" "const char \*." "Test type name equal= ity" + gdb_test "python print (lstr.type)" "const char \*." "Test type name equ= ality" + gdb_test "python print (sptr.type)" "const char \*." "Test type name equ= ality" gdb_test "print sn" "0x0" gdb_py_test_silent_cmd "python snptr =3D gdb.history (0)" "Get value fro= m history" 1 gdb_test "python snstr =3D snptr.lazy_string(length=3D5)" ".*Cannot crea= te a lazy string with address.*" "Test lazy string" gdb_py_test_silent_cmd "python snstr =3D snptr.lazy_string(length=3D0)" = "Succesfully create a lazy string" 1 - gdb_test "python print snstr.length" "0" "Test lazy string length" - gdb_test "python print snstr.address" "0" "Test lazy string address" + gdb_test "python print (snstr.length)" "0" "Test lazy string length" + gdb_test "python print (snstr.address)" "0" "Test lazy string address" } =20 =20 @@ -299,14 +307,14 @@ gdb_py_test_silent_cmd "python fp1 =3D gdb.history (0)" "get value fro= m history" 1 gdb_test "python fp1 =3D fp1.dereference()" "" gdb_test "python result =3D fp1()" "" - gdb_test "python print result" "void" + gdb_test "python print (result)" "void" =20 # Correct inferior call with arguments. gdb_test "p/x fp2" " =3D $hex.*" gdb_py_test_silent_cmd "python fp2 =3D gdb.history (0)" "get value fro= m history" 1 gdb_test "python fp2 =3D fp2.dereference()" "" gdb_test "python result2 =3D fp2(10,20)" "" - gdb_test "python print result2" "30" + gdb_test "python print (result2)" "30" =20 # Incorrect to call an int value. gdb_test "p i" " =3D $decimal.*" @@ -322,10 +330,10 @@ =20 # A few objfile tests. proc test_objfiles {} { - gdb_test "python\nok=3DFalse\nfor file in gdb.objfiles():\n if 'py-va= lue' in file.filename:\n ok=3DTrue\nprint ok\nend" "True" \ + gdb_test "python\nok=3DFalse\nfor file in gdb.objfiles():\n if 'py-va= lue' in file.filename:\n ok=3DTrue\nprint (ok)\nend" "True" \ "py-value in file.filename" =20 - gdb_test "python print gdb.objfiles()\[0\].pretty_printers" "\\\[\\\]" + gdb_test "python print (gdb.objfiles()\[0\].pretty_printers)" "\\\[\\\= ]" =20 gdb_test "python gdb.objfiles()\[0\].pretty_printers =3D 0" \ "pretty_printers attribute must be a list.*Error while executing Pyt= hon code." @@ -354,7 +362,7 @@ "delete PTR type" 1 =20 # Now see if the value's type is still valid. - gdb_test "python print castval.type" "PTR ." \ + gdb_test "python print (castval.type)" "PTR ." \ "print value's type" } =20 @@ -379,18 +387,18 @@ "Obtain address" 1 gdb_py_test_silent_cmd "python rptr =3D gdb.history(0)" \ "Obtains value from GDB" 1 - gdb_test "python print rptr\[0\]" "2" "Check pointer passed as refere= nce" + gdb_test "python print (rptr\[0\])" "2" "Check pointer passed as refe= rence" =20 # Just the most basic test of dynamic_cast -- it is checked in # the C++ tests. - gdb_test "python print bool(gdb.parse_and_eval('base').dynamic_cast(g= db.lookup_type('Derived').pointer()))" \ + gdb_test "python print (bool(gdb.parse_and_eval('base').dynamic_cast(= gdb.lookup_type('Derived').pointer())))" \ True =20 # Likewise. - gdb_test "python print gdb.parse_and_eval('base').dynamic_type" \ + gdb_test "python print (gdb.parse_and_eval('base').dynamic_type)" \ "Derived \[*\]" # A static type case. - gdb_test "python print gdb.parse_and_eval('5').dynamic_type" \ + gdb_test "python print (gdb.parse_and_eval('5').dynamic_type)" \ "int" } =20 @@ -403,40 +411,40 @@ "Create a value for subscript test" 1 =20 # Try to access an int with a subscript. This should fail. - gdb_test "python print intv" "1" "Baseline print of a Python value" - gdb_test "python print intv\[0\]" "gdb.error: Cannot subscript requested = type.*" \ + gdb_test "python print (intv)" "1" "Baseline print of a Python value" + gdb_test "python print (intv\[0\])" "gdb.error: Cannot subscript requeste= d type.*" \ "Attempt to access an integer with a subscript" =20 # Try to access a string with a subscript. This should pass. - gdb_test "python print stringv" "foo." "Baseline print of a Python value" - gdb_test "python print stringv\[0\]" "f." "Attempt to access a string wit= h a subscript" + gdb_test "python print (stringv)" "foo." "Baseline print of a Python valu= e" + gdb_test "python print (stringv\[0\])" "f." "Attempt to access a string w= ith a subscript" =20 # Try to access an int array via a pointer with a subscript. This should= pass. gdb_py_test_silent_cmd "print p" "Build pointer to array" 1 gdb_py_test_silent_cmd "python pointer =3D gdb.history(0)" "" 1 - gdb_test "python print pointer\[0\]" "1" "Access array via pointer with i= nt subscript" - gdb_test "python print pointer\[intv\]" "2" "Access array via pointer wit= h value subscript" + gdb_test "python print (pointer\[0\])" "1" "Access array via pointer with= int subscript" + gdb_test "python print (pointer\[intv\])" "2" "Access array via pointer w= ith value subscript" =20 # Try to access a single dimension array with a subscript to the # result. This should fail. - gdb_test "python print pointer\[intv\]\[0\]" "gdb.error: Cannot subscript= requested type.*" \ + gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error: Cannot subscri= pt requested type.*" \ "Attempt to access an integer with a subscript" =20 # Lastly, test subscript access to an array with multiple # dimensions. This should pass. gdb_py_test_silent_cmd "print {\"fu \",\"foo\",\"bar\"}" "Build array" 1 gdb_py_test_silent_cmd "python marray =3D gdb.history(0)" "" 1 - gdb_test "python print marray\[1\]\[2\]" "o." "Test multiple subscript" + gdb_test "python print (marray\[1\]\[2\])" "o." "Test multiple subscript" } =20 # A few tests of gdb.parse_and_eval. proc test_parse_and_eval {} { - gdb_test "python print gdb.parse_and_eval ('23')" "23" \ + gdb_test "python print (gdb.parse_and_eval ('23'))" "23" \ "parse_and_eval constant test" - gdb_test "python print gdb.parse_and_eval ('5 + 7')" "12" \ + gdb_test "python print (gdb.parse_and_eval ('5 + 7'))" "12" \ "parse_and_eval simple expression test" - gdb_test "python print type(gdb.parse_and_eval ('5 + 7'))" \ - ".type 'gdb.Value'."\ + gdb_test "python print (type(gdb.parse_and_eval ('5 + 7')))" \ + ".(type|class) 'gdb.Value'."\ "parse_and_eval type test" } =20 @@ -449,10 +457,10 @@ "three =3D gdb.Value(3)" "" \ "vdict =3D {one:\"one str\",two:\"two str\",three:\"three str\"}" "" \ "end" - gdb_test "python print vdict\[one\]" "one str" "Test dictionary hash" - gdb_test "python print vdict\[two\]" "two str" "Test dictionary hash" - gdb_test "python print vdict\[three\]" "three str" "Test dictionary ha= sh" - gdb_test "python print one.__hash__() =3D=3D hash(one)" "True" "Test i= nbuilt hash" + gdb_test "python print (vdict\[one\])" "one str" "Test dictionary hash" + gdb_test "python print (vdict\[two\])" "two str" "Test dictionary hash" + gdb_test "python print (vdict\[three\])" "three str" "Test dictionary = hash" + gdb_test "python print (one.__hash__() =3D=3D hash(one))" "True" "Test= inbuilt hash" } =20 # Build C and C++ versions of executable Index: gdb/testsuite/gdb.python/python.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/python.exp,v retrieving revision 1.37 diff -u -r1.37 python.exp --- gdb/testsuite/gdb.python/python.exp 20 Sep 2012 20:54:11 -0000 1.37 +++ gdb/testsuite/gdb.python/python.exp 9 Nov 2012 22:26:57 -0000 @@ -33,7 +33,7 @@ # Skip all tests if Python scripting is not enabled. if { [skip_python_tests] } { continue } =20 -gdb_test_multiple "python print 23" "verify python support" { +gdb_test_multiple "python print (23)" "verify python support" { -re "not supported.*$gdb_prompt $" { unsupported "python support is disabled" =20 @@ -49,21 +49,21 @@ =20 gdb_py_test_multiple "multi-line python command" \ "python" "" \ - "print 23" "" \ + "print (23)" "" \ "end" "23" =20 gdb_py_test_multiple "show python command" \ "define zzq" "Type commands for definition of .* just \"end\"\\.*" \ "python" "" \ - "print 23" "" \ + "print (23)" "" \ "end" "" \ "end" "" \ - "show user zzq" "User command \"zzq\":.* python.*print 23.* end" + "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end" =20 gdb_py_test_multiple "indented multi-line python command" \ "python" "" \ "def foo ():" "" \ - " print 'hello, world!'" "" \ + " print ('hello, world!')" "" \ "foo ()" "" \ "end" "hello, world!" =20 @@ -71,15 +71,15 @@ =20 gdb_test "source -s source2.py" "yes" "source -s source2.py" =20 -gdb_test "python print gdb.current_objfile()" "None" -gdb_test "python print gdb.objfiles()" "\\\[\\\]" +gdb_test "python print (gdb.current_objfile())" "None" +gdb_test "python print (gdb.objfiles())" "\\\[\\\]" =20 # Test http://bugs.python.org/issue4434 workaround in configure.ac -gdb_test "python import itertools; print 'IMPOR'+'TED'" "IMPORTED" "python= X.Y/lib-dynload/*.so" +gdb_test "python import itertools; print ('IMPOR'+'TED')" "IMPORTED" "pyth= onX.Y/lib-dynload/*.so" =20 gdb_test_no_output \ "python x =3D gdb.execute('printf \"%d\", 23', to_string =3D True)" -gdb_test "python print x" "23" +gdb_test "python print (x)" "23" =20 # Test post_event. gdb_py_test_multiple "post event insertion" \ @@ -92,7 +92,7 @@ "gdb.post_event(Foo())" "" \ "end" "" =20 -gdb_test "python print someVal" "1" "test post event execution" +gdb_test "python print (someVal)" "1" "test post event execution" gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is no= t callable.*" "Test non callable class" =20 # Test (no) pagination of the executed command. @@ -101,7 +101,7 @@ gdb_test_no_output "set height $lines" =20 set test "verify pagination beforehand" -gdb_test_multiple "python print \"\\n\" * $lines" $test { +gdb_test_multiple "python print (\"\\n\" * $lines)" $test { -re "---Type " { exp_continue } @@ -114,10 +114,10 @@ } gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination bef= orehand: q" =20 -gdb_test "python if gdb.execute('python print \"\\\\n\" * $lines', to_stri= ng=3DTrue) =3D=3D \"\\n\" * [expr $lines + 1]: print \"yes\"" "yes" "gdb.ex= ecute does not page" +gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_st= ring=3DTrue) =3D=3D \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gd= b.execute does not page" =20 set test "verify pagination afterwards" -gdb_test_multiple "python print \"\\n\" * $lines" $test { +gdb_test_multiple "python print (\"\\n\" * $lines)" $test { -re "---Type " { exp_continue } @@ -134,18 +134,18 @@ =20 gdb_test_no_output "python a =3D gdb.execute('help', to_string=3DTrue)" "c= ollect help from uiout" =20 -gdb_test "python print a" ".*aliases -- Aliases of other commands.*" "veri= fy help to uiout" +gdb_test "python print (a)" ".*aliases -- Aliases of other commands.*" "ve= rify help to uiout" =20 # Test PR 12212, using InfThread.selected_thread() when no inferior is # loaded. gdb_py_test_silent_cmd "python nothread =3D gdb.selected_thread()" "Attemp= t to aquire thread with no inferior" 1 -gdb_test "python print nothread =3D=3D None" "True" "Ensure that no thread= s are returned" +gdb_test "python print (nothread =3D=3D None)" "True" "Ensure that no thre= ads are returned" =20 gdb_py_test_multiple "register atexit function" \ "python" "" \ "import atexit" "" \ "def printit(arg):" "" \ - " print arg" "" \ + " print (arg)" "" \ "atexit.register(printit, 'good bye world')" "" \ "end" "" =20 @@ -176,33 +176,33 @@ "gdb.error: No source file named main.c.*" "test decode_line no source= named main" =20 gdb_py_test_silent_cmd "python symtab =3D gdb.decode_line()" "test decode_= line current location" 1 -gdb_test "python print len(symtab)" "2" "Test decode_line current location" -gdb_test "python print symtab\[0\]" "None" "Test decode_line expression pa= rse" -gdb_test "python print len(symtab\[1\])" "1" "Test decode_line current loc= ation" -gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python.c.*" = "Test decode_line current locationn filename" -gdb_test "python print symtab\[1\]\[0\].line" "22" "Test decode_line curre= nt location line number" +gdb_test "python print (len(symtab))" "2" "Test decode_line current locati= on" +gdb_test "python print (symtab\[0\])" "None" "Test decode_line expression = parse" +gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line current l= ocation" +gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*gdb.python/python.c.*= " "Test decode_line current locationn filename" +gdb_test "python print (symtab\[1\]\[0\].line)" "22" "Test decode_line cur= rent location line number" =20 gdb_py_test_silent_cmd "python symtab =3D gdb.decode_line(\"python.c:26 if= foo\")" "test decode_line python.c:26" 1 -gdb_test "python print len(symtab)" "2" "Test decode_line python.c:26 leng= th" -gdb_test "python print symtab\[0\]" "if foo" "Test decode_line expression = parse" -gdb_test "python print len(symtab\[1\])" "1" "Test decode_line python.c:26= length" -gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python.c.*" = "Test decode_line python.c:26 filename" -gdb_test "python print symtab\[1\]\[0\].line" "26" "Test decode_line pytho= n.c:26 line number" +gdb_test "python print (len(symtab))" "2" "Test decode_line python.c:26 le= ngth" +gdb_test "python print (symtab\[0\])" "if foo" "Test decode_line expressio= n parse" +gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line python.c:= 26 length" +gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*gdb.python/python.c.*= " "Test decode_line python.c:26 filename" +gdb_test "python print (symtab\[1\]\[0\].line)" "26" "Test decode_line pyt= hon.c:26 line number" =20 gdb_test "python gdb.decode_line(\"randomfunc\")" \ "gdb.error: Function \"randomfunc\" not defined.*" "test decode_line r= andomfunc" gdb_py_test_silent_cmd "python symtab =3D gdb.decode_line(\"func1\")" "tes= t decode_line func1()" 1 -gdb_test "python print len(symtab)" "2" "Test decode_line func1 length" -gdb_test "python print len(symtab\[1\])" "1" "Test decode_line func1 lengt= h" -gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python-1.c.*= " "Test decode_line func1 filename" -gdb_test "python print symtab\[1\]\[0\].line" "19" "Test decode_line func1= line number" +gdb_test "python print (len(symtab))" "2" "Test decode_line func1 length" +gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line func1 len= gth" +gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*gdb.python/python-1.c= .*" "Test decode_line func1 filename" +gdb_test "python print (symtab\[1\]\[0\].line)" "19" "Test decode_line fun= c1 line number" gdb_py_test_silent_cmd {python symtab =3D gdb.decode_line ("func1,func2")}= \ "test decode_line func1,func2" 1 -gdb_test {python print symtab[0]} ",func2" "stop at comma in linespec" +gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec" =20 # gdb.write -gdb_test "python print sys.stderr" ".*gdb.GdbOutputErrorFile instance at.*= " "Test stderr location" -gdb_test "python print sys.stdout" ".*gdb.GdbOutputFile instance at.*" "Te= st stdout location" +gdb_test "python print (sys.stderr)" ".*gdb.GdbOutputErrorFile (instance|o= bject) at.*" "Test stderr location" +gdb_test "python print (sys.stdout)" ".*gdb.GdbOutputFile (instance|object= ) at.*" "Test stdout location" gdb_test "python gdb.write(\"Foo\\n\")" "Foo" "Test default write" gdb_test "python gdb.write(\"Error stream\\n\", stream=3Dgdb.STDERR)" "Err= or stream" "Test stderr write" gdb_test "python gdb.write(\"Normal stream\\n\", stream=3Dgdb.STDOUT)" "No= rmal stream" "Test stdout write" @@ -362,7 +362,7 @@ "end" "" =20 gdb_test_multiple "python gdb.prompt_hook =3D error_prompt" "set the hook"= { - -re "Python Exception Python exceptio= n called.*" { + -re "Python Exception <(type 'exceptions.|class ')RuntimeError'> Pytho= n exception called.*" { pass "set hook" } } @@ -395,9 +395,9 @@ runto [gdb_get_line_number "Break at func2 call site."] =20 gdb_py_test_silent_cmd "python line =3D gdb.selected_frame().find_sal().li= ne" "Get line number of func2 call site" 1 -gdb_test "python print gdb.find_pc_line(gdb.selected_frame().pc()).line = =3D=3D line" "True" "Test find_pc_line at func2 call site" +gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line = =3D=3D line)" "True" "Test find_pc_line at func2 call site" =20 gdb_py_test_silent_cmd "step" "Step into func2" 1 gdb_py_test_silent_cmd "up" "Step out of func2" 1 =20 -gdb_test "python print gdb.find_pc_line(gdb.selected_frame().pc()).line > = line" "True" "Test find_pc_line with resume address" +gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line >= line)" "True" "Test find_pc_line with resume address" Index: gdb/testsuite/gdb.python/source2.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/source2.py,v retrieving revision 1.3 diff -u -r1.3 source2.py --- gdb/testsuite/gdb.python/source2.py 4 Jan 2012 08:27:49 -0000 1.3 +++ gdb/testsuite/gdb.python/source2.py 9 Nov 2012 22:26:57 -0000 @@ -15,4 +15,4 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . =20 -print 'y%ss' % 'e' +print ('y%ss' % 'e') Index: gdb/testsuite/lib/gdb.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.222 diff -u -r1.222 gdb.exp --- gdb/testsuite/lib/gdb.exp 6 Nov 2012 15:21:24 -0000 1.222 +++ gdb/testsuite/lib/gdb.exp 9 Nov 2012 22:26:57 -0000 @@ -1541,13 +1541,30 @@ =20 proc skip_python_tests {} { global gdb_prompt - gdb_test_multiple "python print 'test'" "verify python support" { + global gdb_py_is_py3k + global gdb_py_is_py24 + + gdb_test_multiple "python print ('test')" "verify python support" { -re "not supported.*$gdb_prompt $" { unsupported "Python support is disabled." return 1 } -re "$gdb_prompt $" {} } + gdb_py_is_py3k =3D 0 + gdb_py_is_py24 =3D 0 + gdb_test_multiple "python print (sys.version_info\[0\])" "get python v= ersion" { + -re "3.*$gdb_prompt $" { + set gdb_py_is_py3k 1 + } + } + if { gdb_py_is3k =3D=3D 0 } { + gdb_test_multiple "python print (sys.version_info\[1\])" "get pyth= on version" { + -re "\[45\].*$gdb_prompt $" { + set gdb_py_is_py24 1 + } + } + } =20 return 0 }