gdb

record mode confuses disassembler

Bug #1157109 reported by Christophe Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GDB
Fix Released
Undecided
Muhammad Omair Javaid
gdb
New
Undecided
Muhammad Omair Javaid

Bug Description

As of current GDB trunk (2013-03-18), using record mode can confuse the disassembler.

I attach test1.c and test1.thumb (compiled in the default thumb mode with gcc -g -o test1.thumb test1.c).

$ gdb test1.thumb
GNU gdb (GDB) 7.6.50.20130317-cvs
[...]
(gdb) b main
Breakpoint 1 at 0x8396: file test1.c, line 5.
(gdb) b test1.c:8
Breakpoint 2 at 0x83b0: file test1.c, line 8.
(gdb) r
Starting program: /home/lyon/test1.thumb

Breakpoint 1, main () at test1.c:5
5 int i=0;
(gdb) target record-full
(gdb) disassemble main
Dump of assembler code for function main:
   0x00008390 <+0>: push {r7, lr}
   0x00008392 <+2>: sub sp, #8
   0x00008394 <+4>: add r7, sp, #0
=> 0x00008396 <+6>: mov.w r3, #0
   0x0000839a <+10>: str r3, [r7, #4]
   0x0000839c <+12>: movw r0, #33808 ; 0x8410
   0x000083a0 <+16>: movt r0, #0
   0x000083a4 <+20>: blx 0x82e4 <puts>
   0x000083a8 <+24>: ldr r3, [r7, #4]
   0x000083aa <+26>: add.w r3, r3, #1
   0x000083ae <+30>: str r3, [r7, #4]
   0x000083b0 <+32>: mov r0, r3
   0x000083b2 <+34>: add.w r7, r7, #8
   0x000083b6 <+38>: mov sp, r7
   0x000083b8 <+40>: pop {r7, pc}
End of assembler dump.
(gdb) c
Continuing.
Process record doesnt support thumb32 instruction 0x300f04f at address 0x8396.
main () at test1.c:5
5 int i=0;
Process record: failed to record execution log.
(gdb) disassemble main
Dump of assembler code for function main:
   0x00008390 <+0>: push {r7, lr}
   0x00008392 <+2>: sub sp, #8
   0x00008394 <+4>: add r7, sp, #0
=> 0x00008396 <+6>: mov.w r3, #0
   0x0000839a <+10>: ; <UNDEFINED> instruction: 0xde01
   0x0000839c <+12>: movw r0, #33808 ; 0x8410
   0x000083a0 <+16>: movt r0, #0
   0x000083a4 <+20>: blx 0x82e4 <puts>
   0x000083a8 <+24>: ldr r3, [r7, #4]
   0x000083aa <+26>: add.w r3, r3, #1
   0x000083ae <+30>: str r3, [r7, #4]
   0x000083b0 <+32>: mov r0, r3
   0x000083b2 <+34>: add.w r7, r7, #8
   0x000083b6 <+38>: mov sp, r7
   0x000083b8 <+40>: pop {r7, pc}
End of assembler dump.

Notice how instruction at 0x8396 became UNDEFINED.

Revision history for this message
Christophe Lyon (christophe-lyon) wrote :
Revision history for this message
Christophe Lyon (christophe-lyon) wrote :
Changed in gdb-linaro:
assignee: nobody → Muhammad Omair Javaid (omair-javaid)
Changed in gdb:
assignee: nobody → Muhammad Omair Javaid (omair-javaid)
Revision history for this message
Muhammad Omair Javaid (omair-javaid) wrote :

Christophe,

Target record is not functional for arm at this stage, however I am unable to reproduce this behavior with instructions provided.
I have used gdb 7.6 sources as well as latest gdb cvs repository for testing.

GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7l-unknown-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/linaro/omair/bug_triage/test1.thumb...done.
(gdb) b main
Breakpoint 1 at 0x83c2: file test1.c, line 5.
(gdb) b test1.c:8
Breakpoint 2 at 0x83cc: file test1.c, line 8.
(gdb) r
Starting program: /home/linaro/omair/bug_triage/test1.thumb

Breakpoint 1, main () at test1.c:5
5 int i=0;
(gdb) target record-full
(gdb) disassemble main
Dump of assembler code for function main:
   0x000083bc <+0>: push {r7}
   0x000083be <+2>: sub sp, #12
   0x000083c0 <+4>: add r7, sp, #0
=> 0x000083c2 <+6>: movs r3, #0
   0x000083c4 <+8>: str r3, [r7, #4]
   0x000083c6 <+10>: ldr r3, [r7, #4]
   0x000083c8 <+12>: adds r3, #1
   0x000083ca <+14>: str r3, [r7, #4]
   0x000083cc <+16>: mov r0, r3
   0x000083ce <+18>: add.w r7, r7, #12
   0x000083d2 <+22>: mov sp, r7
   0x000083d4 <+24>: pop {r7}
   0x000083d6 <+26>: bx lr
End of assembler dump.
(gdb) c
Continuing.

Breakpoint 2, main () at test1.c:8
8 }
(gdb) disassemble main
Dump of assembler code for function main:
   0x000083bc <+0>: push {r7}
   0x000083be <+2>: sub sp, #12
   0x000083c0 <+4>: add r7, sp, #0
   0x000083c2 <+6>: movs r3, #0
   0x000083c4 <+8>: str r3, [r7, #4]
   0x000083c6 <+10>: ldr r3, [r7, #4]
   0x000083c8 <+12>: adds r3, #1
   0x000083ca <+14>: str r3, [r7, #4]
=> 0x000083cc <+16>: mov r0, r3
   0x000083ce <+18>: add.w r7, r7, #12
   0x000083d2 <+22>: mov sp, r7
   0x000083d4 <+24>: pop {r7}
   0x000083d6 <+26>: bx lr
End of assembler dump.
(gdb)

Revision history for this message
Muhammad Omair Javaid (omair-javaid) wrote :

More information is required from reporter to fix this problem.

Changed in gdb-linaro:
status: New → Incomplete
Revision history for this message
Christophe Lyon (christophe-lyon) wrote :

Did you re-compile the C source I attached or did you use the binary I supplied?

Your disassembly does not match the contents of test1.thumb I supplied.

Revision history for this message
Muhammad Omair Javaid (omair-javaid) wrote : Re: [Bug 1157109] Re: record mode confuses disassembler
Download full text (3.2 KiB)

I recompiled the code with no changes on a pandaboard. (Linux
3.5.0-213-omap4 #20-Ubuntu SMP PREEMPT)

GCC version: 4.7.2

Let me recheck this with your binaries.

thanks!

On 20 September 2013 14:47, Christophe Lyon <email address hidden> wrote:
> Did you re-compile the C source I attached or did you use the binary I
> supplied?
>
> Your disassembly does not match the contents of test1.thumb I supplied.
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/1157109
>
> Title:
> record mode confuses disassembler
>
> Status in GNU Debugger:
> New
> Status in Linaro GDB:
> Incomplete
>
> Bug description:
> As of current GDB trunk (2013-03-18), using record mode can confuse
> the disassembler.
>
> I attach test1.c and test1.thumb (compiled in the default thumb mode
> with gcc -g -o test1.thumb test1.c).
>
> $ gdb test1.thumb
> GNU gdb (GDB) 7.6.50.20130317-cvs
> [...]
> (gdb) b main
> Breakpoint 1 at 0x8396: file test1.c, line 5.
> (gdb) b test1.c:8
> Breakpoint 2 at 0x83b0: file test1.c, line 8.
> (gdb) r
> Starting program: /home/lyon/test1.thumb
>
> Breakpoint 1, main () at test1.c:5
> 5 int i=0;
> (gdb) target record-full
> (gdb) disassemble main
> Dump of assembler code for function main:
> 0x00008390 <+0>: push {r7, lr}
> 0x00008392 <+2>: sub sp, #8
> 0x00008394 <+4>: add r7, sp, #0
> => 0x00008396 <+6>: mov.w r3, #0
> 0x0000839a <+10>: str r3, [r7, #4]
> 0x0000839c <+12>: movw r0, #33808 ; 0x8410
> 0x000083a0 <+16>: movt r0, #0
> 0x000083a4 <+20>: blx 0x82e4 <puts>
> 0x000083a8 <+24>: ldr r3, [r7, #4]
> 0x000083aa <+26>: add.w r3, r3, #1
> 0x000083ae <+30>: str r3, [r7, #4]
> 0x000083b0 <+32>: mov r0, r3
> 0x000083b2 <+34>: add.w r7, r7, #8
> 0x000083b6 <+38>: mov sp, r7
> 0x000083b8 <+40>: pop {r7, pc}
> End of assembler dump.
> (gdb) c
> Continuing.
> Process record doesnt support thumb32 instruction 0x300f04f at address 0x8396.
> main () at test1.c:5
> 5 int i=0;
> Process record: failed to record execution log.
> (gdb) disassemble main
> Dump of assembler code for function main:
> 0x00008390 <+0>: push {r7, lr}
> 0x00008392 <+2>: sub sp, #8
> 0x00008394 <+4>: add r7, sp, #0
> => 0x00008396 <+6>: mov.w r3, #0
> 0x0000839a <+10>: ; <UNDEFINED> instruction: 0xde01
> 0x0000839c <+12>: movw r0, #33808 ; 0x8410
> 0x000083a0 <+16>: movt r0, #0
> 0x000083a4 <+20>: blx 0x82e4 <puts>
> 0x000083a8 <+24>: ldr r3, [r7, #4]
> 0x000083aa <+26>: add.w r3, r3, #1
> 0x000083ae <+30>: str r3, [r7, #4]
> 0x000083b0 <+32>: mov r0, r3
> 0x000083b2 <+34>: add.w r7, r7, #8
> 0x000083b6 <+38>: mov sp, r7
> 0x000083b8 <+40>: pop {r7, pc}
> End of assembler dump.
>
>
> Notice how instruction at 0x8396 became UNDEFINED.
>
> To manage notifications about...

Read more...

Revision history for this message
Muhammad Omair Javaid (omair-javaid) wrote :
Download full text (3.4 KiB)

I have reproduced the issue with the binary you have attached.

Thanks!

On 20 September 2013 15:00, Omair Javaid <email address hidden> wrote:
> I recompiled the code with no changes on a pandaboard. (Linux
> 3.5.0-213-omap4 #20-Ubuntu SMP PREEMPT)
>
> GCC version: 4.7.2
>
> Let me recheck this with your binaries.
>
> thanks!
>
> On 20 September 2013 14:47, Christophe Lyon <email address hidden> wrote:
>> Did you re-compile the C source I attached or did you use the binary I
>> supplied?
>>
>> Your disassembly does not match the contents of test1.thumb I supplied.
>>
>> --
>> You received this bug notification because you are a bug assignee.
>> https://bugs.launchpad.net/bugs/1157109
>>
>> Title:
>> record mode confuses disassembler
>>
>> Status in GNU Debugger:
>> New
>> Status in Linaro GDB:
>> Incomplete
>>
>> Bug description:
>> As of current GDB trunk (2013-03-18), using record mode can confuse
>> the disassembler.
>>
>> I attach test1.c and test1.thumb (compiled in the default thumb mode
>> with gcc -g -o test1.thumb test1.c).
>>
>> $ gdb test1.thumb
>> GNU gdb (GDB) 7.6.50.20130317-cvs
>> [...]
>> (gdb) b main
>> Breakpoint 1 at 0x8396: file test1.c, line 5.
>> (gdb) b test1.c:8
>> Breakpoint 2 at 0x83b0: file test1.c, line 8.
>> (gdb) r
>> Starting program: /home/lyon/test1.thumb
>>
>> Breakpoint 1, main () at test1.c:5
>> 5 int i=0;
>> (gdb) target record-full
>> (gdb) disassemble main
>> Dump of assembler code for function main:
>> 0x00008390 <+0>: push {r7, lr}
>> 0x00008392 <+2>: sub sp, #8
>> 0x00008394 <+4>: add r7, sp, #0
>> => 0x00008396 <+6>: mov.w r3, #0
>> 0x0000839a <+10>: str r3, [r7, #4]
>> 0x0000839c <+12>: movw r0, #33808 ; 0x8410
>> 0x000083a0 <+16>: movt r0, #0
>> 0x000083a4 <+20>: blx 0x82e4 <puts>
>> 0x000083a8 <+24>: ldr r3, [r7, #4]
>> 0x000083aa <+26>: add.w r3, r3, #1
>> 0x000083ae <+30>: str r3, [r7, #4]
>> 0x000083b0 <+32>: mov r0, r3
>> 0x000083b2 <+34>: add.w r7, r7, #8
>> 0x000083b6 <+38>: mov sp, r7
>> 0x000083b8 <+40>: pop {r7, pc}
>> End of assembler dump.
>> (gdb) c
>> Continuing.
>> Process record doesnt support thumb32 instruction 0x300f04f at address 0x8396.
>> main () at test1.c:5
>> 5 int i=0;
>> Process record: failed to record execution log.
>> (gdb) disassemble main
>> Dump of assembler code for function main:
>> 0x00008390 <+0>: push {r7, lr}
>> 0x00008392 <+2>: sub sp, #8
>> 0x00008394 <+4>: add r7, sp, #0
>> => 0x00008396 <+6>: mov.w r3, #0
>> 0x0000839a <+10>: ; <UNDEFINED> instruction: 0xde01
>> 0x0000839c <+12>: movw r0, #33808 ; 0x8410
>> 0x000083a0 <+16>: movt r0, #0
>> 0x000083a4 <+20>: blx 0x82e4 <puts>
>> 0x000083a8 <+24>: ldr r3, [r7, #4]
>> 0x000083aa <+26>: add.w r3, r3, #1
>> 0x000083ae <+30>: str r3, [r7, #4]
>> 0x000083b0 <+32>: mov r0, r3
>> 0x000083...

Read more...

Changed in gdb-linaro:
status: Incomplete → In Progress
Revision history for this message
Christophe Lyon (christophe-lyon) wrote :

OK. Thanks.

Are you sure your compiler defaults to -mthumb? If not, you have to add this flag.

Changed in gdb-linaro:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.