linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mariano Moreyra" <moremari@aca.org.ar>
To: "'John T. Williams'" <jtwilliams@vt.edu>,
	linux-c-programming@vger.kernel.org
Subject: RE: viewing machine code
Date: Thu, 11 Dec 2003 11:06:41 -0300	[thread overview]
Message-ID: <000401c3bff0$00babc40$0c81640a@aca.org.ar> (raw)
In-Reply-To: <000d01c3bf64$d94e0670$ed64a8c0@descartes>

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

      reply	other threads:[~2003-12-11 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-10 21:30 viewing machine code John T. Williams
2003-12-11 14:06 ` Mariano Moreyra [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000401c3bff0$00babc40$0c81640a@aca.org.ar' \
    --to=moremari@aca.org.ar \
    --cc=jtwilliams@vt.edu \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=mariano_moreyra@aca.org.ar \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).