public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Query regarding assembly level debugging support
@ 2004-12-02  9:15 Tarun
  2004-12-02 14:10 ` Peter Barada
  2004-12-02 14:24 ` Daniel Jacobowitz
  0 siblings, 2 replies; 5+ messages in thread
From: Tarun @ 2004-12-02  9:15 UTC (permalink / raw)
  To: gdb; +Cc: acmet, Ms.Ranjeeta, rm@acmet.com

Hi All,

    I am generating object file in Elf/Dwarf format. The prime target is
to be able to debug the assembly code. That is we are able to step
through the assembly code showing line numbers and relative addresses.
The Dwarf (version 2.0) sections currently being included are 
- debug_line
- debug_abbrev
- debug_info.

     The linked out file is loaded without errors on GDB. When we run
the respective out file on GDB, the control of debugger moves to label
main in the assembly code ( Breakpoint 1, 0xa00200ec in main ()). When I
try to move to next instruction using "nexti", the control moves to next
address (Displaying: 0xa00200f0 in main ()). This continues till the
last address is reached. Only the address increments within the assembly
file are displayed and not the actual assembly source.

      When I try to single step using "step", the message prompted is
"Single stepping until exit from function main, which has no line number
information". Whereas if I disassemble one of the addresses give above,
entire assembly code which I am trying to debug is displayed.

      Does this mean that GDB does not support debugging of the assembly
code?

Regards,
Tarun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Query regarding assembly level debugging support
  2004-12-02  9:15 Query regarding assembly level debugging support Tarun
@ 2004-12-02 14:10 ` Peter Barada
  2004-12-08  7:04   ` Tarun
  2004-12-02 14:24 ` Daniel Jacobowitz
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Barada @ 2004-12-02 14:10 UTC (permalink / raw)
  To: tarun; +Cc: gdb, acmet, ranjeeta, rm_nair


>     The linked out file is loaded without errors on GDB. When we run
>the respective out file on GDB, the control of debugger moves to label
>main in the assembly code ( Breakpoint 1, 0xa00200ec in main ()). When I
>try to move to next instruction using "nexti", the control moves to next
>address (Displaying: 0xa00200f0 in main ()). This continues till the
>last address is reached. Only the address increments within the assembly
>file are displayed and not the actual assembly source.
>
>      When I try to single step using "step", the message prompted is
>"Single stepping until exit from function main, which has no line number
>information". Whereas if I disassemble one of the addresses give above,
>entire assembly code which I am trying to debug is displayed.
>
>      Does this mean that GDB does not support debugging of the assembly
>code?

Peope have been using GDB to debug assembler code for years.  A
couple of tricks:

1) Use stepi/nexti commands to step or next one *instruction* as
   opposed to source line
2) Use the 'disp/i $pc' to have GDB display the assembler instruction
   that will be executed next.
3) Use 'i reg' to dump the registers, or 'p $reg' where 'reg' is the
   register name.

-- 
Peter Barada
peter@the-baradas.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Query regarding assembly level debugging support
  2004-12-02  9:15 Query regarding assembly level debugging support Tarun
  2004-12-02 14:10 ` Peter Barada
@ 2004-12-02 14:24 ` Daniel Jacobowitz
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-12-02 14:24 UTC (permalink / raw)
  To: Tarun; +Cc: gdb, acmet, Ms.Ranjeeta, rm@acmet.com

On Thu, Dec 02, 2004 at 02:48:15PM +0530, Tarun wrote:
> Hi All,
> 
>     I am generating object file in Elf/Dwarf format. The prime target is
> to be able to debug the assembly code. That is we are able to step
> through the assembly code showing line numbers and relative addresses.
> The Dwarf (version 2.0) sections currently being included are 
> - debug_line
> - debug_abbrev
> - debug_info.
> 
>      The linked out file is loaded without errors on GDB. When we run
> the respective out file on GDB, the control of debugger moves to label
> main in the assembly code ( Breakpoint 1, 0xa00200ec in main ()). When I
> try to move to next instruction using "nexti", the control moves to next
> address (Displaying: 0xa00200f0 in main ()). This continues till the
> last address is reached. Only the address increments within the assembly
> file are displayed and not the actual assembly source.
> 
>       When I try to single step using "step", the message prompted is
> "Single stepping until exit from function main, which has no line number
> information". Whereas if I disassemble one of the addresses give above,
> entire assembly code which I am trying to debug is displayed.
> 
>       Does this mean that GDB does not support debugging of the assembly
> code?

Are you saying that your source code is assembly, and your assembler
creates debug information for it?  This should work in GDB; make sure
that the .debug_line information is correct.

-- 
Daniel Jacobowitz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Query regarding assembly level debugging support
  2004-12-02 14:10 ` Peter Barada
@ 2004-12-08  7:04   ` Tarun
  2004-12-08 13:57     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Tarun @ 2004-12-08  7:04 UTC (permalink / raw)
  To: 'Peter Barada'; +Cc: gdb, acmet, ranjeeta, rm_nair



> -----Original Message-----
> From: Peter Barada [mailto:peter@the-baradas.com]
> Sent: Thursday, December 02, 2004 7:40 PM
> To: tarun@acmet.com
> Cc: gdb@sources.redhat.com; acmet@vsnl.net; ranjeeta@acmet.com;
> rm_nair@acmet.com
> Subject: Re: Query regarding assembly level debugging support
> 
> 
> >     The linked out file is loaded without errors on GDB. When we run
> >the respective out file on GDB, the control of debugger moves to
label
> >main in the assembly code ( Breakpoint 1, 0xa00200ec in main ()).
When I
> >try to move to next instruction using "nexti", the control moves to
next
> >address (Displaying: 0xa00200f0 in main ()). This continues till the
> >last address is reached. Only the address increments within the
assembly
> >file are displayed and not the actual assembly source.
> >
> >      When I try to single step using "step", the message prompted is
> >"Single stepping until exit from function main, which has no line
number
> >information". Whereas if I disassemble one of the addresses give
above,
> >entire assembly code which I am trying to debug is displayed.
> >
> >      Does this mean that GDB does not support debugging of the
assembly
> >code?
> 
> Peope have been using GDB to debug assembler code for years.  A
> couple of tricks:
> 
> 1) Use stepi/nexti commands to step or next one *instruction* as
>    opposed to source line
> 2) Use the 'disp/i $pc' to have GDB display the assembler instruction
>    that will be executed next.
> 3) Use 'i reg' to dump the registers, or 'p $reg' where 'reg' is the
>    register name.
> 
Thanks for the information. But my query still remains "Can we step
through assembly code?"
I know GDB supports assembly-level debugging but that refers to inline
assembly. To make the point clear, please look at snip below. For the
sample code segment:
<snip>
       /* Print the top of the stack if no index is specified. */
       if (which < 0)
         {
           which = stack->top - 1;
           if (which < 0)   
<snip>

The inline assembly is (assume) represented as: 
<snip>
       /* Print the top of the stack if no index is specified. */
       if (which < 0)
		.frame	$fp,16,$31	<-
		.mask	0x40000000,-8  <-
		.fmask	0x00000000,0   <-
		subu	$sp,$sp,16        <-
         {
           which = stack->top - 1;
		li	$2,20	            <-
		sw	$2,0($fp)           <-
           if (which < 0)   
<snip>


Does GDB refer to stepping through the above code as assembly-level
debugging?

If yes, then my requirement is little different. I want to debug the
assembly code itself keeping it as the source code (and not the C
source). To be more specific I want to debug hand written assembly code
(and not the one generated by compiler)


Regards,
Tarun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Query regarding assembly level debugging support
  2004-12-08  7:04   ` Tarun
@ 2004-12-08 13:57     ` Daniel Jacobowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-12-08 13:57 UTC (permalink / raw)
  To: Tarun; +Cc: 'Peter Barada', gdb, acmet, ranjeeta, rm_nair

On Wed, Dec 08, 2004 at 12:32:12PM +0530, Tarun wrote:
> Thanks for the information. But my query still remains "Can we step
> through assembly code?"
> I know GDB supports assembly-level debugging but that refers to inline
> assembly. To make the point clear, please look at snip below. For the
> sample code segment:
> <snip>
>        /* Print the top of the stack if no index is specified. */
>        if (which < 0)
>          {
>            which = stack->top - 1;
>            if (which < 0)   
> <snip>
> 
> The inline assembly is (assume) represented as: 
> <snip>
>        /* Print the top of the stack if no index is specified. */
>        if (which < 0)
> 		.frame	$fp,16,$31	<-
> 		.mask	0x40000000,-8  <-
> 		.fmask	0x00000000,0   <-
> 		subu	$sp,$sp,16        <-
>          {
>            which = stack->top - 1;
> 		li	$2,20	            <-
> 		sw	$2,0($fp)           <-
>            if (which < 0)   
> <snip>
> 
> 
> Does GDB refer to stepping through the above code as assembly-level
> debugging?

No.

> If yes, then my requirement is little different. I want to debug the
> assembly code itself keeping it as the source code (and not the C
> source). To be more specific I want to debug hand written assembly code
> (and not the one generated by compiler)

Please see my earlier response:

  Are you saying that your source code is assembly, and your assembler
  creates debug information for it?  This should work in GDB; make sure
  that the .debug_line information is correct.

-- 
Daniel Jacobowitz

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-12-08 13:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-02  9:15 Query regarding assembly level debugging support Tarun
2004-12-02 14:10 ` Peter Barada
2004-12-08  7:04   ` Tarun
2004-12-08 13:57     ` Daniel Jacobowitz
2004-12-02 14:24 ` Daniel Jacobowitz

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).