aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.mi
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.mi')
-rw-r--r--gdb/testsuite/gdb.mi/mi-disassemble.exp56
-rw-r--r--gdb/testsuite/gdb.mi/mi2-disassemble.exp56
2 files changed, 108 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-disassemble.exp b/gdb/testsuite/gdb.mi/mi-disassemble.exp
index 2c34ac1..7141201 100644
--- a/gdb/testsuite/gdb.mi/mi-disassemble.exp
+++ b/gdb/testsuite/gdb.mi/mi-disassemble.exp
@@ -60,6 +60,29 @@ proc test_disassembly_only {} {
"data-disassemble file & line, assembly only"
}
+proc test_disassembly_with_opcodes {} {
+ global mi_gdb_prompt
+ global hex
+ global decimal
+
+ set line_main_head [gdb_get_line_number "main ("]
+ set line_main_body [expr $line_main_head + 2]
+
+ # Test disassembly with opcodes for the current function.
+ # Tests:
+ # -data-disassemble -s $pc -e "$pc+8" -- 2
+ # -data-disassembly -f basics.c -l $line_main_body -- 2
+
+ mi_gdb_test "print/x \$pc" "" ""
+ mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 2" \
+ "111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}.*\]" \
+ "data-disassemble from pc to pc+12 assembly with opcodes"
+
+ mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -- 2" \
+ "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",opcodes=\".*\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]" \
+ "data-disassemble file & line, assembly with opcodes"
+}
+
proc test_disassembly_lines_limit {} {
global mi_gdb_prompt
global hex
@@ -116,6 +139,33 @@ proc test_disassembly_mixed {} {
"data-disassemble range assembly mixed"
}
+proc test_disassembly_mixed_with_opcodes {} {
+ global mi_gdb_prompt
+ global hex
+ global decimal
+
+ set line_callee2_head [gdb_get_line_number "callee2 ("]
+ set line_callee2_open_brace [expr $line_callee2_head + 1]
+
+ # Test disassembly mixed with opcodes for the current function.
+ # Tests:
+ # -data-disassembly -f basics.c -l $line_callee2_open_brace -- 3
+ # -data-disassembly -s $pc -e "$pc+8" -- 3
+
+ mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 3" \
+ "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",opcodes=\".*\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
+ "data-disassemble file, line assembly mixed with opcodes"
+
+ #
+ # In mixed mode, the lowest level of granularity is the source line.
+ # So we are going to get the disassembly for the source line at
+ # which we are now, even if we have specified that the range is only 2 insns.
+ #
+ mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 3" \
+ "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
+ "data-disassemble range assembly mixed with opcodes"
+}
+
proc test_disassembly_mixed_lines_limit {} {
global mi_gdb_prompt
global hex
@@ -168,18 +218,20 @@ proc test_disassembly_bogus_args {} {
"data-disassemble bogus address"
mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
- "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+ "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mode.\"" \
"data-disassemble mix different args"
mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
- "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \
+ "789\\^error,msg=\"mi_cmd_disassemble: Mode argument must be 0, 1, 2, or 3.\"" \
"data-disassemble wrong mode arg"
}
mi_run_to_main
test_disassembly_only
+test_disassembly_with_opcodes
test_disassembly_mixed
+test_disassembly_mixed_with_opcodes
test_disassembly_bogus_args
test_disassembly_lines_limit
test_disassembly_mixed_lines_limit
diff --git a/gdb/testsuite/gdb.mi/mi2-disassemble.exp b/gdb/testsuite/gdb.mi/mi2-disassemble.exp
index 8a04397..53f65e5 100644
--- a/gdb/testsuite/gdb.mi/mi2-disassemble.exp
+++ b/gdb/testsuite/gdb.mi/mi2-disassemble.exp
@@ -60,6 +60,29 @@ proc test_disassembly_only {} {
"data-disassemble file & line, assembly only"
}
+proc test_disassembly_with_opcodes {} {
+ global mi_gdb_prompt
+ global hex
+ global decimal
+
+ set line_main_head [gdb_get_line_number "main ("]
+ set line_main_body [expr $line_main_head + 2]
+
+ # Test disassembly with opcodes for the current function.
+ # Tests:
+ # -data-disassemble -s $pc -e "$pc+8" -- 2
+ # -data-disassembly -f basics.c -l $line_main_body -- 2
+
+ mi_gdb_test "print/x \$pc" "" ""
+ mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 2" \
+ "111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}.*\]" \
+ "data-disassemble from pc to pc+12 assembly with opcodes"
+
+ mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -- 2" \
+ "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",opcodes=\".*\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]" \
+ "data-disassemble file & line, assembly with opcodes"
+}
+
proc test_disassembly_lines_limit {} {
global mi_gdb_prompt
global hex
@@ -116,6 +139,33 @@ proc test_disassembly_mixed {} {
"data-disassemble range assembly mixed"
}
+proc test_disassembly_mixed_with_opcodes {} {
+ global mi_gdb_prompt
+ global hex
+ global decimal
+
+ set line_callee2_head [gdb_get_line_number "callee2 ("]
+ set line_callee2_open_brace [expr $line_callee2_head + 1]
+
+ # Test disassembly mixed with opcodes for the current function.
+ # Tests:
+ # -data-disassembly -f basics.c -l $line_callee2_open_brace -- 3
+ # -data-disassembly -s $pc -e "$pc+8" -- 3
+
+ mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 3" \
+ "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",opcodes=\".*\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
+ "data-disassemble file, line assembly mixed with opcodes"
+
+ #
+ # In mixed mode, the lowest level of granularity is the source line.
+ # So we are going to get the disassembly for the source line at
+ # which we are now, even if we have specified that the range is only 2 insns.
+ #
+ mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 3" \
+ "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
+ "data-disassemble range assembly mixed with opcodes"
+}
+
proc test_disassembly_mixed_lines_limit {} {
global mi_gdb_prompt
global hex
@@ -168,18 +218,20 @@ proc test_disassembly_bogus_args {} {
"data-disassemble bogus address"
mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
- "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+ "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mode.\"" \
"data-disassemble mix different args"
mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
- "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \
+ "789\\^error,msg=\"mi_cmd_disassemble: Mode argument must be 0, 1, 2, or 3.\"" \
"data-disassemble wrong mode arg"
}
mi_run_to_main
test_disassembly_only
+test_disassembly_with_opcodes
test_disassembly_mixed
+test_disassembly_mixed_with_opcodes
test_disassembly_bogus_args
test_disassembly_lines_limit
test_disassembly_mixed_lines_limit