Workarounds for very useful developer userspace tracing scripts
argetek senvx
argetek.senvx@gmail.com
Sat Jun 9 20:12:00 GMT 2007
Thanks, Jim!
Although a bit painful for folks like me not needing to mess with the
kernel (anymore :-}), yet gotta admit this seems very very cool (not
minding the interface - any stap guys listening? :-}).
I patched my Ubuntu Feisty kernel 2.6.20-16-386 with the utrace patch
set. Can you please point me to a uprobes patch that would apply to
this cleanly?
I also checked a *dry-run* application of your patch on a Fedora7 box
I have remote access to (kernel 2.6.21-1.3194.fc7 has utrace already):
------------------------------------------------------------------------
2.6.21-1.3194.fc7-x86_64$ patch -up1 --dry-run < ~/uprobes.patch
patching file Documentation/uprobes.txt
patching file arch/i386/Kconfig
Hunk #1 FAILED at 1231.
1 out of 1 hunk FAILED -- saving rejects to file arch/i386/Kconfig.rej
patching file include/asm-i386/uprobes.h
patching file include/linux/uprobes.h
patching file kernel/Makefile
Hunk #1 succeeded at 56 (offset 1 line).
patching file kernel/uprobes.c
can't find file to patch at input line 2237
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|_
|
|Uprobes is enhanced to use "single-stepping out of line" (SSOL)
|to avoid probe misses in multithreaded applications. SSOL also
|reduces probe overhead by 25-30%.
|
|After a breakpoint has been hit and uprobes has run the probepoint's
|handler(s), uprobes must execute the probed instruction in the
|context of the probed process. There are two commonly accepted
|ways to do this:
|
|o Single-stepping inline (SSIL): Temporarily replace the breakpoint
|instruction with the original instruction; single-step the instruction;
|restore the breakpoint instruction; and allow the thread to continue.
|This method is typically used by interactive debuggers such as gdb,
|and is also used in the uprobes base patch. This approach doesn't
|work acceptably for multithreaded programs, because while the
|breakpoint is temporarily removed, other threads can sail past the
|probepoint. It also requires two writes to the probed process's
|text for every probe hit.
|
|o Single-stepping out of line (SSOL): Place a copy of the original
|instruction somewhere in the probed process's address space;
|single-step the copy; fix up the thread state as necessary; and allow
|the thread to continue. This approach is used by kprobes.
|
|This implementation of SSOL entails two major components:
|
|1) Allocation and management of an "SSOL area." Before handling
|the first probe hit, uprobes allocates a VM area in the probed
|process's address space, and divides it into "instruction slots."
|The first time a probepoint is hit, an instruction slot is allocated
|to it and a copy of the probed instruction is placed there. Multiple
|threads can march through that probepoint simultaneously, all using
|the same slot. Currently, we allocate a VM area only for probed
|processes (rather than at exec time for every process), its size
|is one page, and it never grows. Slots are recycled, as necessary,
|on a least-recently-used basis.
|
|2) Architecture-specific fix-ups for certain instructions. If the
|effect of an instruction depends on its address, the thread's
|registers and/or stack must be fixed up after the instruction-copy
|is single-stepped. For i386 uprobes, the fixups were stolen from
|i386 kprobes.
|
|---
|
| Documentation/uprobes.txt | 25 +--
| arch/i386/Kconfig | 4
| arch/i386/kernel/Makefile | 1
| arch/i386/kernel/uprobes.c | 135 +++++++++++++++++
| include/asm-i386/mmu.h | 1
| include/linux/uprobes.h | 87 +++++++++++
| kernel/uprobes.c | 342
+++++++++++++++++++++++++++++++++++++++++++--
| 7 files changed, 569 insertions(+), 26 deletions(-)
|
|diff -puN Documentation/uprobes.txt~2-uprobes-ssol Documentation/uprobes.txt
|--- linux-2.6.21-rc6/Documentation/uprobes.txt~2-uprobes-ssol
2007-05-24 15:41:01.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/Documentation/uprobes.txt 2007-05-24
15:41:28.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
2 out of 2 hunks ignored
patching file arch/i386/Kconfig
Hunk #1 succeeded at 83 (offset -4 lines).
patching file arch/i386/kernel/Makefile
Hunk #1 FAILED at 41.
1 out of 1 hunk FAILED -- saving rejects to file arch/i386/kernel/Makefile.rej
patching file arch/i386/kernel/uprobes.c
patching file include/asm-i386/mmu.h
Hunk #1 succeeded at 17 with fuzz 2 (offset 4 lines).
can't find file to patch at input line 2458
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -puN include/linux/uprobes.h~2-uprobes-ssol include/linux/uprobes.h
|--- linux-2.6.21-rc6/include/linux/uprobes.h~2-uprobes-ssol
2007-05-24 15:41:01.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/include/linux/uprobes.h 2007-05-24
15:41:28.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
4 out of 4 hunks ignored
can't find file to patch at input line 2576
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -puN kernel/uprobes.c~2-uprobes-ssol kernel/uprobes.c
|--- linux-2.6.21-rc6/kernel/uprobes.c~2-uprobes-ssol 2007-05-24
15:41:01.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/kernel/uprobes.c 2007-05-24
15:56:25.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
15 out of 15 hunks ignored
can't find file to patch at input line 3053
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|_
|
|This patch implements user-space return probes (uretprobes). Similar to
|kretprobes, uretprobes works by bouncing a probed function's return off
|a known trampoline, at which time the user-specified handler is run.
|
|Uretprobes works by first inserting a uprobe at the entry to the
|specified function. When the function is called and the probe is hit,
|uretprobes makes a copy of the return address, then replaces the
|return address with the address of the trampoline.
|
|When the function returns, control passes to the trampoline and
|then to uprobes. Uprobes runs the user-specified handler, then
|allows the thread to continue at the real return address.
|
|Uprobes uses one slot of the SSOL area for the trampoline.
|
|---
|
| Documentation/uprobes.txt | 247 +++++++++++++++++++++++++++++++++++++----
| arch/i386/Kconfig | 4
| arch/i386/kernel/uprobes.c | 40 ++++++
| include/asm-i386/uprobes.h | 10 +
| include/linux/uprobes.h | 42 ++++++-
| kernel/uprobes.c | 265
+++++++++++++++++++++++++++++++++++++++++++--
| 6 files changed, 568 insertions(+), 40 deletions(-)
|
|diff -puN Documentation/uprobes.txt~3-uretprobes Documentation/uprobes.txt
|--- linux-2.6.21-rc6/Documentation/uprobes.txt~3-uretprobes
2007-05-25 13:42:45.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/Documentation/uprobes.txt 2007-05-25
14:43:48.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
14 out of 14 hunks ignored
patching file arch/i386/Kconfig
Hunk #1 succeeded at 83 (offset -8 lines).
can't find file to patch at input line 3428
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -puN arch/i386/kernel/uprobes.c~3-uretprobes arch/i386/kernel/uprobes.c
|--- linux-2.6.21-rc6/arch/i386/kernel/uprobes.c~3-uretprobes
2007-05-25 13:42:45.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/arch/i386/kernel/uprobes.c 2007-05-25
14:43:48.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 3475
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -puN include/asm-i386/uprobes.h~3-uretprobes include/asm-i386/uprobes.h
|--- linux-2.6.21-rc6/include/asm-i386/uprobes.h~3-uretprobes
2007-05-25 13:42:45.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/include/asm-i386/uprobes.h 2007-05-25
14:43:48.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
2 out of 2 hunks ignored
can't find file to patch at input line 3500
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -puN include/linux/uprobes.h~3-uretprobes include/linux/uprobes.h
|--- linux-2.6.21-rc6/include/linux/uprobes.h~3-uretprobes
2007-05-25 13:42:45.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/include/linux/uprobes.h 2007-05-25
14:48:52.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
7 out of 7 hunks ignored
can't find file to patch at input line 3601
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -puN kernel/uprobes.c~3-uretprobes kernel/uprobes.c
|--- linux-2.6.21-rc6/kernel/uprobes.c~3-uretprobes 2007-05-25
13:42:45.000000000 -0700
|+++ linux-2.6.21-rc6-jimk/kernel/uprobes.c 2007-05-25
14:43:48.000000000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
20 out of 20 hunks ignored
------------------------------------------------------------------------
Also, as you can see some of the files (probably added by the patch)
prompt for a 'file to patch'. Am I missing something?
Regards,
~ argetek
More information about the Systemtap
mailing list