From: Jan Kratochvil Date: Mon, 11 Jan 2010 17:58:16 +0000 (+0000) Subject: gdb/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;ds=sidebyside;h=b5cfddf53bc50bebe17c82cb8352b6fa08b27cdd;p=binutils-gdb.git gdb/ Implement binary numbers parsing. * c-exp.y (parse_number): New case 'b' and 'B'. gdb/testsuite/ Implement binary numbers parsing. * gdb.base/printcmds.exp (test_integer_literals_accepted) (test_integer_literals_rejected): New binary tests. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8a12029a02d..34dcb5dc7e3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-01-11 Jan Kratochvil + + Implement binary numbers parsing. + * c-exp.y (parse_number): New case 'b' and 'B'. + 2010-01-11 Jan Kratochvil Tristan Gingold diff --git a/gdb/c-exp.y b/gdb/c-exp.y index ba5fddcb338..2ea5c6fbe30 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1411,6 +1411,16 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere) } break; + case 'b': + case 'B': + if (len >= 3) + { + p += 2; + base = 2; + len -= 2; + } + break; + case 't': case 'T': case 'd': diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 93cf035cf1d..fe1c4be0dcb 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-01-11 Jan Kratochvil + + Implement binary numbers parsing. + * gdb.base/printcmds.exp (test_integer_literals_accepted) + (test_integer_literals_rejected): New binary tests. + 2010-01-09 Ralf Wildenhues * gdb.cell/configure: Regenerate. diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 76265bb32a6..74ea6ede309 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -78,6 +78,13 @@ proc test_integer_literals_accepted {} { gdb_test "p 0xabcdef" " = 11259375" gdb_test "p 0xAbCdEf" " = 11259375" gdb_test "p/x 0x123" " = 0x123" + + # Test various binary values. + + gdb_test "p 0b0" " = 0" + gdb_test "p 0b1111" " = 15" + gdb_test "p 0B1111" " = 15" + gdb_test "p -0b1111" " = -15" } proc test_character_literals_accepted {} { @@ -99,7 +106,8 @@ proc test_character_literals_accepted {} { proc test_integer_literals_rejected {} { global gdb_prompt - test_print_reject "p 0x" + test_print_reject "p 0x" + test_print_reject "p 0b" gdb_test "p ''" "(Empty character constant\\.|A character constant must contain at least one character\\.)" gdb_test "p '''" "(Empty character constant\\.|A character constant must contain at least one character\\.)" test_print_reject "p '\\'" @@ -131,6 +139,11 @@ proc test_integer_literals_rejected {} { test_print_reject "p 0xG" test_print_reject "p 0xAG" + + # Test various binary values. + + test_print_reject "p 0b2" + test_print_reject "p 0b12" } proc test_print_all_chars {} {