⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printcmds.exp

📁 gdb-6.8 Linux下的调试程序 最新版本
💻 EXP
📖 第 1 页 / 共 2 页
字号:
    gdb_test "p ctable1\[247\]" " = 247 '\\\\367'"    gdb_test "p ctable1\[248\]" " = 248 '\\\\370'"    gdb_test "p ctable1\[249\]" " = 249 '\\\\371'"    gdb_test "p ctable1\[250\]" " = 250 '\\\\372'"    gdb_test "p ctable1\[251\]" " = 251 '\\\\373'"    gdb_test "p ctable1\[252\]" " = 252 '\\\\374'"    gdb_test "p ctable1\[253\]" " = 253 '\\\\375'"    gdb_test "p ctable1\[254\]" " = 254 '\\\\376'"    gdb_test "p ctable1\[255\]" " = 255 '\\\\377'"}# Test interaction of the number of print elements to print and the# repeat count, set to the default of 10.proc test_print_repeats_10 {} {    global gdb_prompt    for { set x 1; } { $x <= 16 } { incr x; } {	gdb_test "set print elements $x" ""	for { set e 1; } { $e <= 16 } {incr e; } {	    set v [expr $e - 1];	    set command "p &ctable2\[${v}*16\]"	    if { $x < $e } {		set aval $x;	    } else {		set aval $e;	    }	    set xval [expr $x - $e];	    if { $xval < 0 } {		set xval 0;	    }	    if { $aval > 10 } {		set a "'a' <repeats $aval times>";		if { $xval > 0 } {		    set a "${a}, \\\"";		}	    } else {		set a "\\\"[string range "aaaaaaaaaaaaaaaa" 1 $aval]";		if { $xval > 10 } {		    set a "$a\\\", ";		}	    }	    set xstr "";	    if { $xval > 10 } {		set xstr "'X' <repeats $xval times>";	    } else {		if { $xval > 0 } {		    set xstr "[string range "XXXXXXXXXXXXXXXX" 1 $xval]\\\"";		} else {		    if { $aval <= 10 } {			set xstr "\\\"";		    }		}	    }	    if { $aval < 16 } {		set xstr "${xstr}\[.\]\[.\]\[.\]"	    }	    set string " = \[(\]unsigned char \[*\]\[)\] ${a}${xstr}";	    gdb_test "$command" "$string" "$command with print elements set to $x";	}    }}proc test_print_strings {} {    global gdb_prompt    # We accept "(unsigned char *) " before the string.  char vs. unsigned char    # is already tested elsewhere.    # Test that setting print elements unlimited doesn't completely suppress    # printing; this was a bug in older gdb's.    gdb_test "set print elements 0" ""    gdb_test "p teststring" \	" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 0"    gdb_test "set print elements 1" ""    gdb_test "p teststring" \	" = (.unsigned char .. )?\"t\"\\.\\.\\." "p teststring with elements set to 1"    gdb_test "set print elements 5" ""    gdb_test "p teststring" \	" = (.unsigned char .. )?\"tests\"\\.\\.\\." "p teststring with elements set to 5"    gdb_test "set print elements 19" ""    gdb_test "p teststring" \	" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 19"    gdb_test "set print elements 20" ""    gdb_test "p teststring" \	" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 20"    gdb_test "set print elements 8" ""    gdb_test "p &ctable1\[0\]" \	" = \\(unsigned char \\*\\) \"\""    gdb_test "p &ctable1\[1\]" \	" = \\(unsigned char \\*\\) \"\\\\001\\\\002\\\\003\\\\004\\\\005\\\\006\\\\a\\\\b\"..."    gdb_test "p &ctable1\[1*8\]" \	" = \\(unsigned char \\*\\) \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\016\\\\017\"..."    gdb_test "p &ctable1\[2*8\]" \	" = \\(unsigned char \\*\\) \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..."    gdb_test "p &ctable1\[3*8\]" \	" = \\(unsigned char \\*\\) \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..."    gdb_test "p &ctable1\[4*8\]" \	" = \\(unsigned char \\*\\) \" !\\\\\"#\\\$%&'\"..."    gdb_test "p &ctable1\[5*8\]" \	" = \\(unsigned char \\*\\) \"\\(\\)\\*\\+,-./\"..."    gdb_test "p &ctable1\[6*8\]" \	" = \\(unsigned char \\*\\) \"01234567\"..."    gdb_test "p &ctable1\[7*8\]" \	" = \\(unsigned char \\*\\) \"89:;<=>\\?\"..."    gdb_test "p &ctable1\[8*8\]" \	" = \\(unsigned char \\*\\) \"@ABCDEFG\"..."    gdb_test "p &ctable1\[9*8\]" \	" = \\(unsigned char \\*\\) \"HIJKLMNO\"..."    gdb_test "p &ctable1\[10*8\]" \	" = \\(unsigned char \\*\\) \"PQRSTUVW\"..."    gdb_test "p &ctable1\[11*8\]" \	" = \\(unsigned char \\*\\) \"XYZ\\\[\\\\\\\\\\\]\\^_\"..."    gdb_test "p &ctable1\[12*8\]" \	" = \\(unsigned char \\*\\) \"`abcdefg\"..."    gdb_test "p &ctable1\[13*8\]" \	" = \\(unsigned char \\*\\) \"hijklmno\"..."    gdb_test "p &ctable1\[14*8\]" \	" = \\(unsigned char \\*\\) \"pqrstuvw\"..."    gdb_test "p &ctable1\[15*8\]" \	" = \\(unsigned char \\*\\) \"xyz\[{|}\]+\\~\\\\177\"..."    gdb_test "p &ctable1\[16*8\]" \	" = \\(unsigned char \\*\\) \"\\\\200\\\\201\\\\202\\\\203\\\\204\\\\205\\\\206\\\\207\"..."    gdb_test "p &ctable1\[17*8\]" \	" = \\(unsigned char \\*\\) \"\\\\210\\\\211\\\\212\\\\213\\\\214\\\\215\\\\216\\\\217\"..."    gdb_test "p &ctable1\[18*8\]" \	" = \\(unsigned char \\*\\) \"\\\\220\\\\221\\\\222\\\\223\\\\224\\\\225\\\\226\\\\227\"..."    gdb_test "p &ctable1\[19*8\]" \	" = \\(unsigned char \\*\\) \"\\\\230\\\\231\\\\232\\\\233\\\\234\\\\235\\\\236\\\\237\"..."    gdb_test "p &ctable1\[20*8\]" \	" = \\(unsigned char \\*\\) \"\\\\240\\\\241\\\\242\\\\243\\\\244\\\\245\\\\246\\\\247\"..."    gdb_test "p &ctable1\[21*8\]" \	" = \\(unsigned char \\*\\) \"\\\\250\\\\251\\\\252\\\\253\\\\254\\\\255\\\\256\\\\257\"..."    gdb_test "p &ctable1\[22*8\]" \	" = \\(unsigned char \\*\\) \"\\\\260\\\\261\\\\262\\\\263\\\\264\\\\265\\\\266\\\\267\"..."    gdb_test "p &ctable1\[23*8\]" \	" = \\(unsigned char \\*\\) \"\\\\270\\\\271\\\\272\\\\273\\\\274\\\\275\\\\276\\\\277\"..."    gdb_test "p &ctable1\[24*8\]" \	" = \\(unsigned char \\*\\) \"\\\\300\\\\301\\\\302\\\\303\\\\304\\\\305\\\\306\\\\307\"..."    gdb_test "p &ctable1\[25*8\]" \	" = \\(unsigned char \\*\\) \"\\\\310\\\\311\\\\312\\\\313\\\\314\\\\315\\\\316\\\\317\"..."    gdb_test "p &ctable1\[26*8\]" \	" = \\(unsigned char \\*\\) \"\\\\320\\\\321\\\\322\\\\323\\\\324\\\\325\\\\326\\\\327\"..."    gdb_test "p &ctable1\[27*8\]" \	" = \\(unsigned char \\*\\) \"\\\\330\\\\331\\\\332\\\\333\\\\334\\\\335\\\\336\\\\337\"..."    gdb_test "p &ctable1\[28*8\]" \	" = \\(unsigned char \\*\\) \"\\\\340\\\\341\\\\342\\\\343\\\\344\\\\345\\\\346\\\\347\"..."    gdb_test "p &ctable1\[29*8\]" \	" = \\(unsigned char \\*\\) \"\\\\350\\\\351\\\\352\\\\353\\\\354\\\\355\\\\356\\\\357\"..."    gdb_test "p &ctable1\[30*8\]" \	" = \\(unsigned char \\*\\) \"\\\\360\\\\361\\\\362\\\\363\\\\364\\\\365\\\\366\\\\367\"..."    gdb_test "p &ctable1\[31*8\]" \	" = \\(unsigned char \\*\\) \"\\\\370\\\\371\\\\372\\\\373\\\\374\\\\375\\\\376\\\\377\"..."}proc test_print_int_arrays {} {    global gdb_prompt    gdb_test "set print elements 24" ""    gdb_test_escape_braces "p int1dim" \	" = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"    gdb_test_escape_braces "p int2dim" \	" = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}}"    gdb_test_escape_braces "p int3dim" \	" = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}"    gdb_test_escape_braces "p int4dim" \	" = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}"}proc test_print_typedef_arrays {} {    global gdb_prompt    gdb_test "set print elements 24" ""    gdb_test_escape_braces "p a1" \	" = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}"    gdb_test "p a1\[0\]" " = 2"    gdb_test "p a1\[9\]" " = 20"    gdb_test "p a2" \	" = \"abcd\""    gdb_test "p a2\[0\]" " = 97 'a'"    gdb_test "p a2\[3\]" " = 100 'd'"}proc test_artificial_arrays {} {    # Send \026@ instead of just @ in case the kill character is @.    gdb_test_escape_braces "p int1dim\[0\]\026@2" " = {0, 1}" {p int1dim[0]@2}    gdb_test_escape_braces "p int1dim\[0\]\026@2\026@3" \	"({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \	{p int1dim[0]@2@3}    gdb_test_escape_braces {p/x (short [])0x12345678} \	" = ({0x1234, 0x5678}|{0x5678, 0x1234})"}proc test_print_char_arrays {} {    global gdb_prompt    global hex    gdb_test "set print elements 24" ""    gdb_test "set print address on" ""    gdb_test "p arrays" \	" = {array1 = \"abc\", array2 = \"d\", array3 = \"e\", array4 = \"fg\", array5 = \"hij\"}"    gdb_test "p parrays"		" = \\(struct some_arrays \\*\\) $hex"    gdb_test "p parrays->array1"	" = \"abc\""    gdb_test "p &parrays->array1"	" = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"    gdb_test "p parrays->array2"	" = \"d\""    gdb_test "p &parrays->array2"	" = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex"    gdb_test "p parrays->array3"	" = \"e\""    gdb_test "p &parrays->array3"	" = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex"    gdb_test "p parrays->array4"	" = \"fg\""    gdb_test "p &parrays->array4"	" = \\(unsigned char \\(\\*\\)\\\[2\\\]\\) $hex"    gdb_test "p parrays->array5"	" = \"hij\""    gdb_test "p &parrays->array5"	" = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"    gdb_test "set print address off" ""}proc test_print_string_constants {} {    global gdb_prompt    gdb_test "set print elements 50" ""    if [target_info exists gdb,cannot_call_functions] {	setup_xfail "*-*-*" 2416	fail "This target can not call functions"	return    }    # We need to up this because this can be really slow on some boards.    # (Test may involve inferior malloc() calls).    set timeout 60;    gdb_test "p \"a string\""		" = \"a string\""    gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\""    gdb_test "p \"abcd\"\[2\]"	" = 99 'c'"    gdb_test "p sizeof (\"abcdef\")"	" = 7"    gdb_test "ptype \"foo\""		" = char \\\[4\\\]"    gdb_test "p *\"foo\""		" = 102 'f'"    gdb_test "ptype *\"foo\""		" = char"    gdb_test "p &*\"foo\""		" = \"foo\""    setup_kfail "gdb/538" *-*-*    gdb_test "ptype &*\"foo\""	"type = char \\*"    gdb_test "p (char *)\"foo\""	" = \"foo\""}proc test_print_array_constants {} {    if [target_info exists gdb,cannot_call_functions] {	setup_xfail "*-*-*" 2416	fail "This target can not call functions"	return    }    # We need to up this because this can be really slow on some boards.    # (Test may involve inferior malloc() calls).    set timeout 60;    gdb_test "print {'a','b','c'}"	" = \"abc\""    gdb_test_escape_braces "print {0,1,2}"    " = {0, 1, 2}"    gdb_test_escape_braces "print {(long)0,(long)1,(long)2}"  " = {0, 1, 2}"    gdb_test_escape_braces "print {{0,1,2},{3,4,5}}"  " = {{0, 1, 2}, {3, 4, 5}}"    gdb_test "print {4,5,6}\[2\]"	" = 6"    gdb_test "print *&{4,5,6}\[1\]"	" = 5"}proc test_printf {} {    gdb_test "printf \"x=%d,y=%d,z=%d\\n\", 5, 6, 7" "x=5,y=6,z=7"    gdb_test "printf \"string=%.4sxx\\n\", teststring" "string=testxx"    gdb_test "printf \"string=%sxx\\n\", teststring" \	"string=teststring contentsxx"    gdb_test "printf \"%f is fun\\n\", 1.0" "1\.0+ is fun"    # Test mixing args of different sizes.    gdb_test "printf \"x=%d,y=%f,z=%d\\n\", 5, 6.0, 7" "x=5,y=6\.0+,z=7"    gdb_test "printf \"%x %f, %c %x, %x, %f\\n\", 0xbad, -99.541, 'z',\0xfeedface, 0xdeadbeef, 5.0" "bad -99.54\[0-9\]+, z feedface, deadbeef, 5.0+"}#Test printing DFP values with printfproc test_printf_with_dfp {} {    # Test various dfp values, covering 32-bit, 64-bit and 128-bit ones    # _Decimal32 constants, which can support up to 7 digits    gdb_test "printf \"%Hf\\n\",1.2df" "1.2"    gdb_test "printf \"%Hf\\n\",-1.2df" "-1.2"    gdb_test "printf \"%Hf\\n\",1.234567df" "1.234567"    gdb_test "printf \"%Hf\\n\",-1.234567df" "-1.234567"    gdb_test "printf \"%Hf\\n\",1234567.df" "1234567"    gdb_test "printf \"%Hf\\n\",-1234567.df" "-1234567"    gdb_test "printf \"%Hf\\n\",1.2E1df" "12"    gdb_test "printf \"%Hf\\n\",1.2E10df" "1.2E\\+10"    gdb_test "printf \"%Hf\\n\",1.2E-10df" "1.2E-10"    # The largest exponent for 32-bit dfp value is 96.    gdb_test "printf \"%Hf\\n\",1.2E96df" "1.200000E\\+96"    # _Decimal64 constants, which can support up to 16 digits    gdb_test "printf \"%Df\\n\",1.2dd" "1.2"    gdb_test "printf \"%Df\\n\",-1.2dd" "-1.2"    gdb_test "printf \"%Df\\n\",1.234567890123456dd" "1.234567890123456"    gdb_test "printf \"%Df\\n\",-1.234567890123456dd" "-1.234567890123456"    gdb_test "printf \"%Df\\n\",1234567890123456.dd" "1234567890123456"    gdb_test "printf \"%Df\\n\",-1234567890123456.dd" "-1234567890123456"    gdb_test "printf \"%Df\\n\",1.2E1dd" "12"    gdb_test "printf \"%Df\\n\",1.2E10dd" "1.2E\\+10"    gdb_test "printf \"%Df\\n\",1.2E-10dd" "1.2E-10"    # The largest exponent for 64-bit dfp value is 384.    gdb_test "printf \"%Df\\n\",1.2E384dd" "1.200000000000000E\\+384"    # _Decimal128 constants, which can support up to 34 digits    gdb_test "printf \"%DDf\\n\",1.2dl" "1.2"    gdb_test "printf \"%DDf\\n\",-1.2dl" "-1.2"    gdb_test "printf \"%DDf\\n\",1.234567890123456789012345678901234dl" "1.234567890123456789012345678901234"    gdb_test "printf \"%DDf\\n\",-1.234567890123456789012345678901234dl" "-1.234567890123456789012345678901234"    gdb_test "printf \"%DDf\\n\",1234567890123456789012345678901234.dl" "1234567890123456789012345678901234"    gdb_test "printf \"%DDf\\n\",-1234567890123456789012345678901234.dl" "-1234567890123456789012345678901234"    gdb_test "printf \"%DDf\\n\",1.2E1dl" "12"    gdb_test "printf \"%DDf\\n\",1.2E10dl" "1.2E\\+10"    gdb_test "printf \"%DDf\\n\",1.2E-10dl" "1.2E-10"    # The largest exponent for 128-bit dfp value is 6144.    gdb_test "printf \"%DDf\\n\",1.2E6144dl" "1.200000000000000000000000000000000E\\+6144"}# Escape a left curly brace to prevent it from being interpreted as # the beginning of a boundproc gdb_test_escape_braces { args } {    set pattern [lindex $args 1]    regsub -all {\{[0-9]} $pattern {\\&} esc_pattern    gdb_test [lindex $args 0] $esc_pattern [lindex $args 2]}# Start with a fresh gdb.gdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirgdb_test "print \$pc" "No registers\\."# FIXME: should also test "print $pc" when there is an execfile but no# remote debugging target, process or corefile.gdb_load ${binfile}gdb_test "set print sevenbit-strings" ""gdb_test "set print address off" ""gdb_test "set width 0" ""if [set_lang_c] then {    gdb_test "p ctable1\[120\]" "120 'x'" "p ctable1\[120\] #1"    if [runto_main] then {	test_integer_literals_accepted	test_integer_literals_rejected	test_character_literals_accepted	test_print_all_chars	test_print_repeats_10	test_print_strings	test_print_int_arrays	test_print_typedef_arrays	test_artificial_arrays	test_print_char_arrays# We used to do the runto main here.	test_print_string_constants	test_print_array_constants	test_printf	test_printf_with_dfp    }} else {    fail "C print command tests suppressed"}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -