Amiga-C (163/223)

From:dmcdonx
Date:21 Aug 2001 at 17:12:56
Subject:[amiga-c] Re: 680x0 Status Register

--- In amiga-c@y..., Stephen Illingworth <stephen.t.illingworth@b...>
> Use the CreateNewProcess() function and patch the AddTask()
> function to fill in the tc_TrapCode field, or setup the task
> structure manually and call AddTask() direct.
>
> Which method is the more suitable would you say?
>
> The second method seems superior to me, but it has the
> disadvantage of not performing the magic of the CreateProcess()
> function. What exactly happens inside that function? And in
> particular, how does the initalPC argument of AddTask() relate to
> the loadsegged exe?

It's best to let the OS do the drudgery for you and to work
at the process level. This can be achieved without patching any
OS functions. Load the program using LoadSeg() or a custom loader
and change the code in the first segment to jump to the debugger's
task initialization function, then launch the process normally.
The initial PC is implied using this method (first segment in the
SegList) so you know which code to modify. The modification is
fairly simple, copy the first six bytes of the first segment's
code and change it to "JMP $xxxxxxxx" where $xxxxxxxx is the
address of the debugger's task initializer. Launching the
process will then vector straight into the debugger's task
initialization function from where you can install handlers and
place the task into trace mode or whatever, as well as restore
the original six bytes. After that the debugger has complete
control over the task and can perform typical debugging functions
like single stepping, running, inserting breakpoints and so on.

> > If you need an example of getting a trace handler up and
> > running I think I've got a minimal implementation somewhere.
>
> It seems straight forward enough, and I have the example from the
> Libraries RKM, but it wouldn't harm anyone if you sent it anyway.

I'll dig it up and post it when I can.

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Secure all your Web servers now: Get your FREE Guide and learn to: DEPLOY THE LATEST ENCRYPTION,
DELIVER TRANSPARENT PROTECTION, and More!
http://us.click.yahoo.com/VihfLB/nT7CAA/yigFAA/dpFolB/TM
---------------------------------------------------------------------~->

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/