Bill | 1 Jun 2008 09:51
Picon

Disassemble in GDB

I wrote a simple hello world in c. how can i disassemble main() with
gdb?

Cheers, Bill

--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Claudio Fontana | 1 Jun 2008 12:15
Picon

Re: Disassemble in GDB

On Sun, Jun 1, 2008 at 9:51 AM, Bill <bill.clinton <at> fredastaire.ch> wrote:
> I wrote a simple hello world in c. how can i disassemble main() with
> gdb?
>
> Cheers, Bill

Read The Fine gdb Manual.

'info gdb' or
http://sourceware.org/gdb/current/onlinedocs/gdb_toc.html
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

lynx.abraxas | 1 Jun 2008 17:01
Picon
Favicon

precise debugging of inline asm

Hello!

The  mentioning  of  gdb  in  this  mailinglist  gave  me  the  idea to ask my
unresolved question here as well:

Trying to port cpt2 to linux I have an inline assembly part of about 100 lines
that causes a segmentation fault while juggling around with memory. When I use
gdb for debugging it sadly only points me to the line  where  the  inline  asm
starts.  I  haven't  been able to figure out how to get a more precise info in
what line the actual segmentation fault comes from.
Does anybody here know if that is at all possible and if so, how? Would labels
to each line help?

Thanks for any help or hints.
Lynx

--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Frank Kotler | 1 Jun 2008 16:32
Picon

Re: Disassemble in GDB

Bill wrote:
> I wrote a simple hello world in c. how can i disassemble main() with
> gdb?

"disassemble main"

Use the "-g" switch when you compile it. (note the effect of the "-O" 
switch, while you're at it)

Best,
Frank

--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Claudio Fontana | 1 Jun 2008 19:27
Picon

Re: precise debugging of inline asm

lynx.abraxas <at> freenet.de wrote:
> Hello!
> 
> 
> The  mentioning  of  gdb  in  this  mailinglist  gave  me  the  idea to ask my
> unresolved question here as well:
> 
> Trying to port cpt2 to linux I have an inline assembly part of about 100 lines
> that causes a segmentation fault while juggling around with memory. When I use
> gdb for debugging it sadly only points me to the line  where  the  inline  asm
> starts.  I  haven't  been able to figure out how to get a more precise info in
> what line the actual segmentation fault comes from.
> Does anybody here know if that is at all possible and if so, how? Would labels
> to each line help?
> 
> Thanks for any help or hints.
> Lynx

On x86, try for example

(gdb) disassemble $eip $eip+20

Also see
(gdb) info registers

Cld
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
(Continue reading)

lynx.abraxas | 8 Jun 2008 14:36
Picon
Favicon

Re: precise debugging of inline asm

On 01/06/08 19:27:26, Claudio Fontana wrote:
> On x86, try for example
>
> (gdb) disassemble $eip $eip+20
>
> Also see
> (gdb) info registers

Thanks  Claudio  Fontana. That did the trick. So the first line of output from
disassemble $eip $eip+20 is then the line where the segfault occured? In  this
example "mov    %cx,(%esi,%edx,2)"?

(gdb) disassemble $eip $eip+20
Dump of assembler code from 0x87b29f8 to 0x87b2a0c:
0x087b29f8 <.lable1+3>: mov    %cx,(%esi,%edx,2)
0x087b29fc <.lable1+7>: inc    %edx
0x087b29fd <.lable1+8>: jne    0x87b29ca <.lable0>
0x087b29ff <.lable1+10>:        mov    %ebp,0xffffffd0(%ebp)
0x087b2a02 <.lable1+13>:        pop    %ebx
0x087b2a03 <.lable1+14>:        mov    %eax,0xffffffa8(%ebp)
0x087b2a06 <.lable1+17>:        addl   $0x1,0xffffffb0(%ebp)
0x087b2a0a <.lable1+21>:        cmpl   $0x2f,0xffffffb0(%ebp)
End of assembler dump.

Well  investigating  that  I  think I should be sure of what each line does so
here I have some more questions:

As in the code below, will gcc not  use  registers  in  the  clobber  list  as
registers for %0 - %5 ?
Or asked differently: How would one code an asm swap?
(Continue reading)

Frank Kotler | 17 Jun 2008 10:27
Picon

Nasm 2.03.01 released on SourceForge

Nasm 2.03.01 has been released on SourceForge:

<http://sourceforge.net/project/showfiles.php?group_id=6208>

This is a bugfix release, and it *does* repair a buffer overflow. You 
might want to upgrade. Big thanks to H. Peter Anvin (of iPath, Inc) for 
getting on top of this!

Also, "-F" implies "-g". We no longer have to use both.

Best,
Frank

--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane