linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* viewing machine code
@ 2003-12-10 21:30 John T. Williams
  2003-12-11 14:06 ` Mariano Moreyra
  0 siblings, 1 reply; 2+ messages in thread
From: John T. Williams @ 2003-12-10 21:30 UTC (permalink / raw)
  To: linux-c-programming

is there anyway to get gdb to display the hex code being exicuted?

ie prentend that 0xF8 is the command for add, and I am exicuting the code

addl 04,
is there a way to get gdb to type
0xF804 when exicuting that command.  sort of a step through the program at
the machine code level?



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

* RE: viewing machine code
  2003-12-10 21:30 viewing machine code John T. Williams
@ 2003-12-11 14:06 ` Mariano Moreyra
  0 siblings, 0 replies; 2+ messages in thread
From: Mariano Moreyra @ 2003-12-11 14:06 UTC (permalink / raw)
  To: 'John T. Williams', linux-c-programming

There is a way to see the hex machine code...
May be there are better ways...but this is the only way that I found to see
hex machine code with gdb
First, you have to see the memory address where that instruction is.
You can do that with "info line"

Next, you have to use the command "x/NFU ADDR" where

 N, the repeat count
     The repeat count is a decimal integer; the default is 1.  It
     specifies how much memory (counting by units U) to display.

 F, the display format
     The display format is one of the formats used by `print', `s'
     (null-terminated string), or `i' (machine instruction).  The
     default is `x' (hexadecimal) initially.  The default changes each
     time you use either `x' or `print'.

 U, the unit size
     The unit size is any of

    `b'
          Bytes.

    `h'
          Halfwords (two bytes).

    `w'
          Words (four bytes).  This is the initial default.

    `g'
          Giant words (eight bytes).

     Each time you specify a unit size with `x', that size becomes the
     default unit the next time you use `x'.  (For the `s' and `i'
     formats, the unit size is ignored and is normally not written.)

 ADDR, starting display address
     ADDR is the address where you want GDB to begin displaying memory.
     The expression need not have a pointer value (though it may); it
     is always interpreted as an integer address of a byte of memory.
     *Note Expressions: Expressions, for more information on
     expressions.  The default for ADDR is usually just after the last
     address examined--but several other commands also set the default
     address: `info breakpoints' (to the address of the last breakpoint
     listed), `info line' (to the starting address of a line), and
     `print' (if you use it to display a value from memory).


specifying how many bytes does your instruction have, and giving the memory
address you obtained with info line
It's not a direct way, but it works :)
If someone has a better way to do this with gdb....let me know please!!

Mariano Moreyra

P.S: Sorry about my english!!! I have to practice more, and take lessons!!
:)




-----Mensaje original-----
De: linux-c-programming-owner@vger.kernel.org
[mailto:linux-c-programming-owner@vger.kernel.org]En nombre de John T.
Williams
Enviado el: Miércoles, 10 de Diciembre de 2003 18:31
Para: linux-c-programming@vger.kernel.org
Asunto: viewing machine code


is there anyway to get gdb to display the hex code being exicuted?

ie prentend that 0xF8 is the command for add, and I am exicuting the code

addl 04,
is there a way to get gdb to type
0xF804 when exicuting that command.  sort of a step through the program at
the machine code level?


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

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

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

end of thread, other threads:[~2003-12-11 14:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-10 21:30 viewing machine code John T. Williams
2003-12-11 14:06 ` Mariano Moreyra

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 NNTP newsgroup(s).