This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hitachi djprobe mechanism


[trimming the CC list and assuming all CCed persons are subscribed to
systemtap]

On Mon, 2005-08-01 at 16:31 -0400, Karim Yaghmour wrote:

> > step 3: (after all CPU pass safety check) replace with jmp
> >          instruction without first byte. leave int 3 instruction
> >          unchanged at this time (new step).
> 
> This still fails to cover the very simple case I explained earlier:
> 	if (...)
> 		goto label;
> 	<more code>
> 	single_byte_asm_instruction_code();
> label:
> 	foo();
> 
> You still can't replace the instruction right before the label, and you'd
> have to have an integrated disassembler to go through all the code and
> make sure it too doesn't have a reference to the address of "label:".

This problem probably should be addressed in userspace and the way this
should be solved is by calculating the location of the basic blocks of
the function in which you want to insert the probe. Then, any basic
block bigger than 5 bytes will be an acceptable candidate for probe
insertion.

Clearly, this is one of the reasons the kerninst people built a system-
wide daemon which did perform the basic-block calculation.

The attached ugly perl script evaluates the basic blocks and outputs
statistics about their size. Please, note the "evaluate" verb used
above. It means that I am pretty sure this script is not 100% reliable
but it should give non-skewed results given the size of most binaries.
Beware: this thing will suck away your CPU time.

objdump -d -j .text /usr/lib/libgtk.so |./analysis.pl --print-stats
[...]
percentage of basic blocks bigger than 5 bytes: 97.45
bytes percentage of basic blocks bigger than 5 bytes: 99.68


objdump -d -j .text /usr/lib/libgtk-x11-2.0.so |./analysis.pl --print-
stats
[...]
percentage of basic blocks bigger than 5 bytes: 92.87
bytes percentage of basic blocks bigger than 5 bytes: 99.09


objdump -d -j .text /usr/X11R6/bin/X |./analysis.pl --print-stats
[...]
percentage of basic blocks bigger than 5 bytes: 96.63
bytes percentage of basic blocks bigger than 5 bytes: 99.60


objdump -d -j .text /usr/X11R6/lib/libX11.so |./analysis.pl --print-
stats
[...]
percentage of basic blocks bigger than 5 bytes: 96.98
bytes percentage of basic blocks bigger than 5 bytes: 99.60


I must say that I am pretty surprised by this rather positive result
which means that if you perform a proper bb-analysis of your binaries,
you should be able to put a probe almost anywhere in your binary without
much complicated instruction relocation work (modulo the issues related
to inserting and removing the probe itself).

regards,
Mathieu
-- 

Attachment: analysis.pl
Description: Perl program


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]