From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 16 22:10:14 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 805F5158 for ; Fri, 16 Aug 2013 22:10:14 +0000 (UTC) (envelope-from shrikanth07@gmail.com) Received: from mail-vc0-x22f.google.com (mail-vc0-x22f.google.com [IPv6:2607:f8b0:400c:c03::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 44AE623DF for ; Fri, 16 Aug 2013 22:10:14 +0000 (UTC) Received: by mail-vc0-f175.google.com with SMTP id ia10so1807952vcb.6 for ; Fri, 16 Aug 2013 15:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=zP0N8fpsUQbUNggk/ylZVsR2seCxTwwOc7Jfr64DScg=; b=DNv7WTwZwy2nd8ZBY1Qym1r26ZMTBrcEeYe2QxW8O0ZcE4QmTWve0nsTrWWmUVCYHb qZBaw6n5ScUe/Hw/ahbX39z4D6lhl9wrrTSFYzhoo1q81f2l5rTx+UWkl+SJsVEFgJtQ 6vWsU3LBBKOi0V1dEUB1D83W0BUO+feObtCyCDj8rdoPKFyx3jQoXPNonjMiIrPdoiSk GayHWIrEdyY4ftpPNsq2nASoYWrqAxiCWmz8vQnoAXrvc8Apzjb2yYBu07WfJ7SEIMGi LhnOo/C6VhzkGQy99IkuP3jOAYG2mn3rR2ITxPohkJho9ZYZzofEakxj/CcSatjia5lH wU/A== MIME-Version: 1.0 X-Received: by 10.52.233.33 with SMTP id tt1mr2654039vdc.2.1376691013449; Fri, 16 Aug 2013 15:10:13 -0700 (PDT) Received: by 10.58.232.41 with HTTP; Fri, 16 Aug 2013 15:10:13 -0700 (PDT) Date: Fri, 16 Aug 2013 15:10:13 -0700 Message-ID: Subject: User Space DTrace and dumping function arguments for user space From: Shrikanth Kamath To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Aug 2013 22:10:14 -0000 Can we dump function arguments for user space functions just like for functions in kernel space? Can FBT provider dump arguments for user space functions if we do dtrace -l -f -v? I was DTrace'ing "top" utility, (the "top" utility has both the CTF and the Dwarf debug sections built in the object file) I am trying to inspect get_system_info function called by "top", I confirm it is present to be probed root% dtrace -l | grep get_system_info 55154 pid8488 top get_system_info entry But I cannot dump the arguments to the function... root% dtrace -l -f get_system_info -v ID PROVIDER MODULE FUNCTION NAME 55154 pid8488 top get_system_info entry Probe Description Attributes Identifier Names: Private Data Semantics: Private Dependency Class: Unknown Argument Attributes Identifier Names: Private Data Semantics: Private Dependency Class: Unknown Argument Types None Testing with a simple script, pid8488::get_system_info:entry { this->info = (struct system_info *)copyin(args[0], sizeof(struct system_info)); ... } ...if I use the args[0] notation it says the following, dtrace: failed to compile script top_d.d: line 17: index 0 is out of range for pid8488::get_system_info:entry args[ ] Instead if I replace with arg0, it compiles but the values are not neccesarily sane. Example the ncpus member of struct system_info shows a garbage value. The complete script is pid8488::get_system_info:entry { this->info = (struct system_info *)copyin(arg0, sizeof(struct system_info)); printf("last pid [%d] \n", this->info->last_pid); } pid8488::get_process_info:entry { this->info = (struct system_info *)copyin(arg0, sizeof(struct system_info)); printf("ncpus [%d] \n", this->info->ncpus); } Running this 55154 get_system_info:entry last pid [8513] 55155 get_process_info:entry ncpus [134558720] Supposed to be showing number of cpus? Anything wrong with the scripting?