* [patch][python] 2/3 Python representation of GDB line tables (Testsuite)
@ 2013-10-08 12:04 Phil Muldoon
2013-10-23 20:53 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Phil Muldoon @ 2013-10-08 12:04 UTC (permalink / raw)
To: gdb-patches
This patch in the series contains the testsuite code for Python
linetables.
Cheers,
Phil
2013-10-08 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-linetable.S: New file.
* gdb.python/py-linetable.c: New file.
* gdb.python/py-linetable.exp: New file.
---
diff --git a/gdb/testsuite/gdb.python/py-linetable.S b/gdb/testsuite/gdb.python/py-linetable.S
new file mode 100644
index 0000000..5957222
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-linetable.S
@@ -0,0 +1,345 @@
+ .file "py-linetable.c"
+ .text
+.Ltext0:
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .file 1 "./py-linetable.c"
+ .loc 1 20 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ movl %edi, -4(%rbp)
+ movl %esi, -8(%rbp)
+ .loc 1 21 0
+ movl -4(%rbp), %eax
+ cmpl -8(%rbp), %eax
+ jne .L2
+ .loc 1 22 0
+ movl $1, %eax
+ jmp .L3
+.L2:
+ .loc 1 24 0
+ movl $0, %eax
+.L3:
+ .loc 1 25 0
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .globl bar
+ .type bar, @function
+bar:
+.LFB1:
+ .loc 1 28 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ movl %edi, -4(%rbp)
+ movl %esi, -8(%rbp)
+ .loc 1 29 0
+ cmpl $0, -8(%rbp)
+ jne .L5
+ .loc 1 30 0
+ movl $1, %eax
+ jmp .L6
+.L5:
+ .loc 1 32 0
+ movl $0, %eax
+.L6:
+ .loc 1 33 0
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE1:
+ .size bar, .-bar
+ .globl main
+ .type main, @function
+main:
+.LFB2:
+ .loc 1 37 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ subq $16, %rsp
+ .loc 1 39 0
+ movl $5, %esi
+ movl $5, %edi
+ call foo
+ testl %eax, %eax
+ je .L8
+ .loc 1 39 0 is_stmt 0 discriminator 1
+ movl $0, %esi
+ movl $5, %edi
+ call bar
+ testl %eax, %eax
+ je .L8
+ .loc 1 40 0 is_stmt 1
+ movl $0, %eax
+ jmp .L9
+.L8:
+ .loc 1 42 0
+ movl $0, -4(%rbp)
+ jmp .L10
+.L11:
+ .loc 1 44 0
+ addl $1, -4(%rbp)
+.L10:
+ .loc 1 42 0 discriminator 1
+ cmpl $499, -4(%rbp)
+ jle .L11
+ .loc 1 45 0
+ movl $0, %eax
+.L9:
+ .loc 1 46 0
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE2:
+ .size main, .-main
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0xcf
+ .value 0x4
+ .long .Ldebug_abbrev0
+ .byte 0x8
+ .uleb128 0x1
+ .long .LASF0
+ .byte 0x1
+ .long .LASF1
+ .long .LASF2
+ .quad .Ltext0
+ .quad .Letext0
+ .long .Ldebug_line0
+ .uleb128 0x2
+ .string "foo"
+ .byte 0x1
+ .byte 0x13
+ .long 0x67
+ .quad .LFB0
+ .quad .LFE0
+ .uleb128 0x1
+ .byte 0x9c
+ .long 0x67
+ .uleb128 0x3
+ .string "a"
+ .byte 0x1
+ .byte 0x13
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -20
+ .uleb128 0x3
+ .string "b"
+ .byte 0x1
+ .byte 0x13
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -24
+ .byte 0
+ .uleb128 0x4
+ .byte 0x4
+ .byte 0x5
+ .string "int"
+ .uleb128 0x2
+ .string "bar"
+ .byte 0x1
+ .byte 0x1b
+ .long 0x67
+ .quad .LFB1
+ .quad .LFE1
+ .uleb128 0x1
+ .byte 0x9c
+ .long 0xa8
+ .uleb128 0x3
+ .string "a"
+ .byte 0x1
+ .byte 0x1b
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -20
+ .uleb128 0x3
+ .string "b"
+ .byte 0x1
+ .byte 0x1b
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -24
+ .byte 0
+ .uleb128 0x5
+ .long .LASF3
+ .byte 0x1
+ .byte 0x24
+ .long 0x67
+ .quad .LFB2
+ .quad .LFE2
+ .uleb128 0x1
+ .byte 0x9c
+ .uleb128 0x6
+ .string "i"
+ .byte 0x1
+ .byte 0x26
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -20
+ .byte 0
+ .byte 0
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1
+ .uleb128 0x11
+ .byte 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x1b
+ .uleb128 0xe
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x10
+ .uleb128 0x17
+ .byte 0
+ .byte 0
+ .uleb128 0x2
+ .uleb128 0x2e
+ .byte 0x1
+ .uleb128 0x3f
+ .uleb128 0x19
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x27
+ .uleb128 0x19
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0x18
+ .uleb128 0x2117
+ .uleb128 0x19
+ .uleb128 0x1
+ .uleb128 0x13
+ .byte 0
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x5
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0x18
+ .byte 0
+ .byte 0
+ .uleb128 0x4
+ .uleb128 0x24
+ .byte 0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0x8
+ .byte 0
+ .byte 0
+ .uleb128 0x5
+ .uleb128 0x2e
+ .byte 0x1
+ .uleb128 0x3f
+ .uleb128 0x19
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x27
+ .uleb128 0x19
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0x18
+ .uleb128 0x2116
+ .uleb128 0x19
+ .byte 0
+ .byte 0
+ .uleb128 0x6
+ .uleb128 0x34
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0x18
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c
+ .value 0x2
+ .long .Ldebug_info0
+ .byte 0x8
+ .byte 0
+ .value 0
+ .value 0
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ .string "GNU C 4.7.2 20121109 (Red Hat 4.7.2-8) -mtune=generic -march=x86-64 -g -O0"
+.LASF1:
+ .string "./py-linetable.c"
+.LASF3:
+ .string "main"
+.LASF2:
+ .string "/home/pmuldoon/bugs/linetable/gdb/gdb/testsuite/gdb.python"
+ .ident "GCC: (GNU) 4.7.2 20121109 (Red Hat 4.7.2-8)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.python/py-linetable.c b/gdb/testsuite/gdb.python/py-linetable.c
new file mode 100644
index 0000000..b358fff
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-linetable.c
@@ -0,0 +1,46 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2013 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+foo (int a, int b)
+{
+ if (a == b)
+ return 1;
+
+ return 0;
+}
+
+bar (int a, int b)
+{
+ if (a + b == a)
+ return 1;
+
+ return 0;
+}
+
+int
+main (void)
+{
+ int i;
+ if (foo (5,5) && bar (5,0))
+ return 0;
+
+ for (i = 0;
+ i<500;
+ i++);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
new file mode 100644
index 0000000..767ad2c
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -0,0 +1,75 @@
+# Copyright 2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+load_lib gdb-python.exp
+set opts {}
+standard_testfile .S
+
+if [info exists COMPILE] {
+ # make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
+ standard_testfile
+ lappend opts debug optimize=-O2
+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+ verbose "Skipping ${testfile}."
+ return
+}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+
+gdb_py_test_silent_cmd "python lt = gdb.selected_frame().find_sal().symtab.linetable()" \
+ "get instruction" 0
+
+gdb_py_test_multiple "input simple command" \
+ "python" "" \
+ "def list_lines():" "" \
+ " for l in lt:" "" \
+ " print 'L' +str(l.line)+' A '+hex(l.pc)" "" \
+ "end" ""
+
+gdb_test "python list_lines()" \
+ "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
+ "test linetable iterator addr"
+gdb_test "python print len(lt.line(42))" "2" \
+ "Test length of a multiple pc line"
+gdb_test "python print len(lt.line(20))" "1" \
+ "Test length of a single pc line"
+gdb_test "python print lt.line(1)" "None" \
+ "Test None returned for line with no pc"
+
+# Test gdb.Linetable.sourcelines ()
+gdb_py_test_silent_cmd "python fset = lt.source_lines()" \
+ "Get all source lines into a frozen set" 0
+gdb_test "python print sorted(fset)" \
+ "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
+ "Test frozen set contains line numbers"
+
+# Test gdb.Linetable.has_pcs ()
+gdb_test "python print lt.has_pcs(20)" \
+ "True.*" \
+ "Test has_pcs at line 20"
+gdb_test "python print lt.has_pcs(44)" \
+ "True.*" \
+ "Test has_pcs at line 40"
+gdb_test "python print lt.has_pcs(10)" \
+ "False.*" \
+ "Test has_pcs at line 10"
--
1.8.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][python] 2/3 Python representation of GDB line tables (Testsuite)
2013-10-08 12:04 [patch][python] 2/3 Python representation of GDB line tables (Testsuite) Phil Muldoon
@ 2013-10-23 20:53 ` Tom Tromey
2013-11-07 15:46 ` Phil Muldoon
2013-11-07 16:37 ` Phil Muldoon
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2013-10-23 20:53 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> This patch in the series contains the testsuite code for Python
Phil> linetables.
Phil> diff --git a/gdb/testsuite/gdb.python/py-linetable.S
Phil> b/gdb/testsuite/gdb.python/py-linetable.S
Phil> new file mode 100644
Phil> index 0000000..5957222
Phil> --- /dev/null
Phil> +++ b/gdb/testsuite/gdb.python/py-linetable.S
Phil> @@ -0,0 +1,345 @@
Phil> + .file "py-linetable.c"
Phil> + .text
Phil> +.Ltext0:
Normally we hack in a comment header at the top.
I wonder whether assembly is truly needed in this case.
Phil> +#
Phil> +# You should have received a copy of the GNU General Public License
Phil> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
Phil> +load_lib gdb-python.exp
Phil> +set opts {}
Phil> +standard_testfile .S
Blank line between comments and code.
Phil> +gdb_py_test_silent_cmd "python lt =
Phil> gdb.selected_frame().find_sal().symtab.linetable()" \
Your patch got wrapped.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][python] 2/3 Python representation of GDB line tables (Testsuite)
2013-10-23 20:53 ` Tom Tromey
@ 2013-11-07 15:46 ` Phil Muldoon
2013-11-07 16:07 ` Tom Tromey
2013-11-07 16:37 ` Phil Muldoon
1 sibling, 1 reply; 6+ messages in thread
From: Phil Muldoon @ 2013-11-07 15:46 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 23/10/13 21:53, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> This patch in the series contains the testsuite code for Python
> Phil> linetables.
>
> Phil> diff --git a/gdb/testsuite/gdb.python/py-linetable.S
> Phil> b/gdb/testsuite/gdb.python/py-linetable.S
> Phil> new file mode 100644
> Phil> index 0000000..5957222
> Phil> --- /dev/null
> Phil> +++ b/gdb/testsuite/gdb.python/py-linetable.S
> Phil> @@ -0,0 +1,345 @@
> Phil> + .file "py-linetable.c"
> Phil> + .text
> Phil> +.Ltext0:
>
> Normally we hack in a comment header at the top.
>
> I wonder whether assembly is truly needed in this case.
It was included at Jan's suggestion. To ensure compatibility between
compiler versions. However, the test is compiled unoptimized so I
suspect the potential of change in the linetable between versions is
slim. I have no strong opinion. What do you think?
>
> Phil> +#
> Phil> +# You should have received a copy of the GNU General Public License
> Phil> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> Phil> +load_lib gdb-python.exp
> Phil> +set opts {}
> Phil> +standard_testfile .S
>
> Blank line between comments and code.
>
> Phil> +gdb_py_test_silent_cmd "python lt =
> Phil> gdb.selected_frame().find_sal().symtab.linetable()" \
>
> Your patch got wrapped.
No idea how this happened. It was produced by git format-patch, and
the file inserted into the email (IE, not copy and pasted). So that
was weird.
Regards
Phil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][python] 2/3 Python representation of GDB line tables (Testsuite)
2013-11-07 15:46 ` Phil Muldoon
@ 2013-11-07 16:07 ` Tom Tromey
0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2013-11-07 16:07 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>> Normally we hack in a comment header at the top.
>> I wonder whether assembly is truly needed in this case.
Phil> It was included at Jan's suggestion. To ensure compatibility between
Phil> compiler versions. However, the test is compiled unoptimized so I
Phil> suspect the potential of change in the linetable between versions is
Phil> slim. I have no strong opinion. What do you think?
I think it's fine.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][python] 2/3 Python representation of GDB line tables (Testsuite)
2013-10-23 20:53 ` Tom Tromey
2013-11-07 15:46 ` Phil Muldoon
@ 2013-11-07 16:37 ` Phil Muldoon
2013-11-07 17:08 ` Tom Tromey
1 sibling, 1 reply; 6+ messages in thread
From: Phil Muldoon @ 2013-11-07 16:37 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 23/10/13 21:53, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> This patch in the series contains the testsuite code for Python
> Phil> linetables.
>
> Phil> diff --git a/gdb/testsuite/gdb.python/py-linetable.S
> Phil> b/gdb/testsuite/gdb.python/py-linetable.S
> Phil> new file mode 100644
> Phil> index 0000000..5957222
> Phil> --- /dev/null
> Phil> +++ b/gdb/testsuite/gdb.python/py-linetable.S
> Phil> @@ -0,0 +1,345 @@
> Phil> + .file "py-linetable.c"
> Phil> + .text
> Phil> +.Ltext0:
>
> Normally we hack in a comment header at the top.
Added,
Cheers,
Phil
--
diff --git a/gdb/testsuite/gdb.python/py-linetable.S b/gdb/testsuite/gdb.python/py-linetable.S
new file mode 100644
index 0000000..f376ba7
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-linetable.S
@@ -0,0 +1,362 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+ .file "py-linetable.c"
+ .text
+.Ltext0:
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .file 1 "./py-linetable.c"
+ .loc 1 20 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ movl %edi, -4(%rbp)
+ movl %esi, -8(%rbp)
+ .loc 1 21 0
+ movl -4(%rbp), %eax
+ cmpl -8(%rbp), %eax
+ jne .L2
+ .loc 1 22 0
+ movl $1, %eax
+ jmp .L3
+.L2:
+ .loc 1 24 0
+ movl $0, %eax
+.L3:
+ .loc 1 25 0
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .globl bar
+ .type bar, @function
+bar:
+.LFB1:
+ .loc 1 28 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ movl %edi, -4(%rbp)
+ movl %esi, -8(%rbp)
+ .loc 1 29 0
+ cmpl $0, -8(%rbp)
+ jne .L5
+ .loc 1 30 0
+ movl $1, %eax
+ jmp .L6
+.L5:
+ .loc 1 32 0
+ movl $0, %eax
+.L6:
+ .loc 1 33 0
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE1:
+ .size bar, .-bar
+ .globl main
+ .type main, @function
+main:
+.LFB2:
+ .loc 1 37 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ subq $16, %rsp
+ .loc 1 39 0
+ movl $5, %esi
+ movl $5, %edi
+ call foo
+ testl %eax, %eax
+ je .L8
+ .loc 1 39 0 is_stmt 0 discriminator 1
+ movl $0, %esi
+ movl $5, %edi
+ call bar
+ testl %eax, %eax
+ je .L8
+ .loc 1 40 0 is_stmt 1
+ movl $0, %eax
+ jmp .L9
+.L8:
+ .loc 1 42 0
+ movl $0, -4(%rbp)
+ jmp .L10
+.L11:
+ .loc 1 44 0
+ addl $1, -4(%rbp)
+.L10:
+ .loc 1 42 0 discriminator 1
+ cmpl $499, -4(%rbp)
+ jle .L11
+ .loc 1 45 0
+ movl $0, %eax
+.L9:
+ .loc 1 46 0
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE2:
+ .size main, .-main
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0xcf
+ .value 0x4
+ .long .Ldebug_abbrev0
+ .byte 0x8
+ .uleb128 0x1
+ .long .LASF0
+ .byte 0x1
+ .long .LASF1
+ .long .LASF2
+ .quad .Ltext0
+ .quad .Letext0
+ .long .Ldebug_line0
+ .uleb128 0x2
+ .string "foo"
+ .byte 0x1
+ .byte 0x13
+ .long 0x67
+ .quad .LFB0
+ .quad .LFE0
+ .uleb128 0x1
+ .byte 0x9c
+ .long 0x67
+ .uleb128 0x3
+ .string "a"
+ .byte 0x1
+ .byte 0x13
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -20
+ .uleb128 0x3
+ .string "b"
+ .byte 0x1
+ .byte 0x13
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -24
+ .byte 0
+ .uleb128 0x4
+ .byte 0x4
+ .byte 0x5
+ .string "int"
+ .uleb128 0x2
+ .string "bar"
+ .byte 0x1
+ .byte 0x1b
+ .long 0x67
+ .quad .LFB1
+ .quad .LFE1
+ .uleb128 0x1
+ .byte 0x9c
+ .long 0xa8
+ .uleb128 0x3
+ .string "a"
+ .byte 0x1
+ .byte 0x1b
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -20
+ .uleb128 0x3
+ .string "b"
+ .byte 0x1
+ .byte 0x1b
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -24
+ .byte 0
+ .uleb128 0x5
+ .long .LASF3
+ .byte 0x1
+ .byte 0x24
+ .long 0x67
+ .quad .LFB2
+ .quad .LFE2
+ .uleb128 0x1
+ .byte 0x9c
+ .uleb128 0x6
+ .string "i"
+ .byte 0x1
+ .byte 0x26
+ .long 0x67
+ .uleb128 0x2
+ .byte 0x91
+ .sleb128 -20
+ .byte 0
+ .byte 0
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1
+ .uleb128 0x11
+ .byte 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x1b
+ .uleb128 0xe
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x10
+ .uleb128 0x17
+ .byte 0
+ .byte 0
+ .uleb128 0x2
+ .uleb128 0x2e
+ .byte 0x1
+ .uleb128 0x3f
+ .uleb128 0x19
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x27
+ .uleb128 0x19
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0x18
+ .uleb128 0x2117
+ .uleb128 0x19
+ .uleb128 0x1
+ .uleb128 0x13
+ .byte 0
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x5
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0x18
+ .byte 0
+ .byte 0
+ .uleb128 0x4
+ .uleb128 0x24
+ .byte 0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0x8
+ .byte 0
+ .byte 0
+ .uleb128 0x5
+ .uleb128 0x2e
+ .byte 0x1
+ .uleb128 0x3f
+ .uleb128 0x19
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x27
+ .uleb128 0x19
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0x18
+ .uleb128 0x2116
+ .uleb128 0x19
+ .byte 0
+ .byte 0
+ .uleb128 0x6
+ .uleb128 0x34
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0x18
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c
+ .value 0x2
+ .long .Ldebug_info0
+ .byte 0x8
+ .byte 0
+ .value 0
+ .value 0
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ .string "GNU C 4.7.2 20121109 (Red Hat 4.7.2-8) -mtune=generic -march=x86-64 -g -O0"
+.LASF1:
+ .string "./py-linetable.c"
+.LASF3:
+ .string "main"
+.LASF2:
+ .string "gdb/testsuite/gdb.python"
+ .ident "GCC: (GNU) 4.7.2 20121109 (Red Hat 4.7.2-8)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.python/py-linetable.c b/gdb/testsuite/gdb.python/py-linetable.c
new file mode 100644
index 0000000..b358fff
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-linetable.c
@@ -0,0 +1,46 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2013 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+foo (int a, int b)
+{
+ if (a == b)
+ return 1;
+
+ return 0;
+}
+
+bar (int a, int b)
+{
+ if (a + b == a)
+ return 1;
+
+ return 0;
+}
+
+int
+main (void)
+{
+ int i;
+ if (foo (5,5) && bar (5,0))
+ return 0;
+
+ for (i = 0;
+ i<500;
+ i++);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
new file mode 100644
index 0000000..767ad2c
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -0,0 +1,75 @@
+# Copyright 2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+load_lib gdb-python.exp
+set opts {}
+standard_testfile .S
+
+if [info exists COMPILE] {
+ # make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
+ standard_testfile
+ lappend opts debug optimize=-O2
+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+ verbose "Skipping ${testfile}."
+ return
+}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+
+gdb_py_test_silent_cmd "python lt = gdb.selected_frame().find_sal().symtab.linetable()" \
+ "get instruction" 0
+
+gdb_py_test_multiple "input simple command" \
+ "python" "" \
+ "def list_lines():" "" \
+ " for l in lt:" "" \
+ " print 'L' +str(l.line)+' A '+hex(l.pc)" "" \
+ "end" ""
+
+gdb_test "python list_lines()" \
+ "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
+ "test linetable iterator addr"
+gdb_test "python print len(lt.line(42))" "2" \
+ "Test length of a multiple pc line"
+gdb_test "python print len(lt.line(20))" "1" \
+ "Test length of a single pc line"
+gdb_test "python print lt.line(1)" "None" \
+ "Test None returned for line with no pc"
+
+# Test gdb.Linetable.sourcelines ()
+gdb_py_test_silent_cmd "python fset = lt.source_lines()" \
+ "Get all source lines into a frozen set" 0
+gdb_test "python print sorted(fset)" \
+ "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
+ "Test frozen set contains line numbers"
+
+# Test gdb.Linetable.has_pcs ()
+gdb_test "python print lt.has_pcs(20)" \
+ "True.*" \
+ "Test has_pcs at line 20"
+gdb_test "python print lt.has_pcs(44)" \
+ "True.*" \
+ "Test has_pcs at line 40"
+gdb_test "python print lt.has_pcs(10)" \
+ "False.*" \
+ "Test has_pcs at line 10"
--
1.8.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][python] 2/3 Python representation of GDB line tables (Testsuite)
2013-11-07 16:37 ` Phil Muldoon
@ 2013-11-07 17:08 ` Tom Tromey
0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2013-11-07 17:08 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> +#
Phil> +# You should have received a copy of the GNU General Public License
Phil> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
Phil> +load_lib gdb-python.exp
Phil> +set opts {}
Phil> +standard_testfile .S
Could you please add a blank line between the comments and the code?
Ok with that fix.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-07 17:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-08 12:04 [patch][python] 2/3 Python representation of GDB line tables (Testsuite) Phil Muldoon
2013-10-23 20:53 ` Tom Tromey
2013-11-07 15:46 ` Phil Muldoon
2013-11-07 16:07 ` Tom Tromey
2013-11-07 16:37 ` Phil Muldoon
2013-11-07 17:08 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).