From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18640 invoked by alias); 9 Jun 2007 23:20:41 -0000 Received: (qmail 18633 invoked by uid 22791); 9 Jun 2007 23:20:40 -0000 X-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: sourceware.org Received: from e6.ny.us.ibm.com (HELO e6.ny.us.ibm.com) (32.97.182.146) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 09 Jun 2007 23:20:38 +0000 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e6.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id l59NLfYX028216 for ; Sat, 9 Jun 2007 19:21:41 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l59NKY5D558036 for ; Sat, 9 Jun 2007 19:20:36 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l59NKY4Z029623 for ; Sat, 9 Jun 2007 19:20:34 -0400 Received: from [9.47.18.79] (dyn9047018079.beaverton.ibm.com [9.47.18.79]) by d01av02.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l59NKXHO029618 for ; Sat, 9 Jun 2007 19:20:34 -0400 Subject: Debugging uprobes with SystemTap From: Jim Keniston To: systemtap Content-Type: text/plain Date: Sat, 09 Jun 2007 23:20:00 -0000 Message-Id: <1181427643.3661.22.camel@ibm-ni9dztukfq8.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2007-q2/txt/msg00548.txt.bz2 FWIW, here's the stap script I ended up with while chasing down the bug fixed by today's uprobes patch. I'd actually been using a bare-knuckles-kprobes module for quite a while, but it was getting more and more crufty as I tried out different things. The ability to get the entry-time value of an arg ($regs) at function-return time was key. The fact that $regs->eip gave me the entry-time value of eip was a nuisance that had to be worked around. And bz1155 is a pain (gcc inlines functions that I don't declare inline, and then the dwarf info isn't sufficient for stap to get the args). Jim ----- cut here ----- %{ #include #include #include #include %} global signals_since_register probe begin { printf("Probing...\n"); } probe kernel.function("register_uprobe"), kernel.function("unregister_uprobe") { printf("%d: %s\n", tid(), probefunc()); } probe kernel.function("register_uprobe").return { printf("%d: %s returns %d\n", tid(), probefunc(), $return); } probe kernel.function("unregister_uprobe").return { printf("%d: %s returns\n", tid(), probefunc()); } probe kernel.function("register_uprobe") { signals_since_register = 0 } probe kernel.function("uprobe_report_signal") { signals_since_register++; if (signals_since_register <= 10) printf("%d: In %s, eip=%#x, esp=%#x, signo=%d\n", tid(), probefunc(), $regs->eip, $regs->esp, $info->si_signo); } /* Is there a more straightforward way to do this? */ function regs_eip:long(regs:long) %{ struct pt_regs *r = (struct pt_regs*)(long)THIS->regs; THIS->__retvalue = (long) r->eip; %} function regs_esp:long(regs:long) %{ struct pt_regs *r = (struct pt_regs*)(long)THIS->regs; THIS->__retvalue = (long) r->esp; %} probe kernel.function("uprobe_report_signal").return { if (signals_since_register <= 10) printf("%d: %s returns %#x; eip=%#x, esp=%#x\n", tid(), probefunc(), $return, regs_eip($regs), regs_esp($regs)); } function trampoline_addr:long() %{ THIS->__retvalue = (long) current->mm->context.uprobes_ssol_area; %} /* gcc inlines this, and can't tell us uproc's value. Dang. */ probe kernel.inline("uretprobe_set_trampoline") { printf("%d: %s called; area->insns=%#x\n", tid(), probefunc(), trampoline_addr()); }