public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Steven Johnson <sbjohnson@ozemail.com.au>
To: gdb@sourceware.cygnus.com
Subject: Command Hooks (Post rather than Pre)
Date: Mon, 14 Aug 2000 19:37:00 -0000	[thread overview]
Message-ID: <3998AA1F.9353BD64@ozemail.com.au> (raw)

Proposition,

Its possible to have a hook that runs before a command, but it is not yet
possible
to have a hook that runs after a command.

Does anyone other than me think this might be usefull?

I want to use it to introduce some generic load modifications, for example:

I have a target that does not have any RAM to run the application in, It must
be run from flash. So I would have 2 hooks, one before and one after the load.

Hook Before Load:
  Remaps target dram to the position where the program will be loaded.
  Remaps target flash to somewhere out of the way.

Load:
  Transfers program to the target, which gets stored in the dram, (But can not
  be run from there as then i wont have any dram for the program to use :(

Hook After Load:
  Transfers a tiny flash burning stub to the target.
  Executes tiny flash burning stub to erase and burn the flash with the
  contents of dram.
  After executing, remaps the dram and flash back to their proper locations.

This is the exact procedure i want to use, but im sure having hooks that
execute after a command may be a usefull general addition to gdb. 
I propose (and have in fact implemented) the following:

define hookpost-[command]
  ... Any GDB Commands ...
end

define hookpre-[command]       
  ... Any GDB Commands ...
end

the last one is just for symetry, and would be identical to the existing:

define hook-[command]
  ... Any GDB Commands ...
end

Which i have left alone BTW.

Anyway, Im fishing for comments on this before I submit it.

One thing I would like to add is a parameter to the hookpost- defined command,
so that it can be
told if the command it is running after was successful. Im not sure how to
find this out, does
anyone know? Further Im not sure how to actually pass the parameter to the GDB
Command?

What happens currently if a hook calls the command it is hooked to? Do we end
up with recursion that will eventually crash GDB? for example:

define hook-foo
  foo
end

Wouldn't this repeatedly call hook-foo until something overflowed in GDB and
crashed it? Is this worth defending against. My preference would be to have
the command available, but once you were in the hook further hooking was
prevented. So that the above example would execute like this:
gdb> foo

runs hook-foo
  foo
  runs foo
runs foo
ends

instead of:
runs hook-foo
  foo
  runs hook-foo
    foo
    runs hook-foo
      foo
      runs hook-foo
        foo
        runs hook-foo
          ... and so on ...
    

Steven Johnson

             reply	other threads:[~2000-08-14 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-14 19:37 Steven Johnson [this message]
2000-08-15  0:30 ` Steven Johnson

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=3998AA1F.9353BD64@ozemail.com.au \
    --to=sbjohnson@ozemail.com.au \
    --cc=gdb@sourceware.cygnus.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).