From: Nicholas N. <nj...@ca...> - 2002-10-02 11:23:31
|
On 30 Sep 2002, Jeremy Fitzhardinge wrote: > I'm writing a skin to generate gprof-like output, so I need to see all > the edges in the control flow graph. In particular, I'd like to insert > some instrumentation code which is run IFF a conditional branch is > taken. > > I see a few options: > * something to properly represent uInstr sequences with > conditionals within the ucode for one real instruction (ie, > some way of representing jumps to real addresses rather than > simulated addresses). Sounds messy. > * Intercept the jump target address and generate a completely > new piece of code at some place within the simulated address > space. Ugly. > * Introduce a new exceptional value for ebp when it is passed > back into the dispatcher to trigger a call into the skin. > Would need some way to attach some kind of argument values for > the call (encode in %edx?). Seems like the least nasty. > > Any opinions? Best way I can think of doing it, which only requires skin changes rather than core changes, is this: using the `extended_UCode' need, add a new UInstr PRE_JCC, which gets inserted by SK_(instrument) before conditional JMPs, evaluates the condition, and calls a C function (or whatever) if it's true. This would duplicate the condition evaluation but that shouldn't matter since they're trivial (just checking an EFLAGS bit I think). It's a bit nasty that something as simple as this requires a new UInstr... Oh, and apologies for the delay in replying. N |