From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28586 invoked by alias); 26 Mar 2007 10:23:37 -0000 Received: (qmail 28577 invoked by uid 22791); 26 Mar 2007 10:23:36 -0000 X-Spam-Check-By: sourceware.org Received: from sophia.inria.fr (HELO sophia.inria.fr) (138.96.64.20) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 26 Mar 2007 11:23:27 +0100 Received: from localhost (localhost [127.0.0.1]) by sophia.inria.fr (8.13.8/8.13.8) with ESMTP id l2QANNHR022926; Mon, 26 Mar 2007 12:23:23 +0200 Received: from [194.254.174.199] (vis199b.inria.fr [194.254.174.199]) (authenticated bits=0) by sophia.inria.fr (8.13.8/8.13.8) with ESMTP id l2QANK83022879 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Mon, 26 Mar 2007 12:23:20 +0200 Subject: Re: Log every call and exit in embedded system From: mathieu lacage To: Andrew STUBBS Cc: John Zoidberg , gdb@sourceware.org In-Reply-To: <46079A7F.4020308@st.com> References: <46079A7F.4020308@st.com> Content-Type: text/plain Date: Mon, 26 Mar 2007 10:23:00 -0000 Message-Id: <1174904601.2370.5.camel@mathieu> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-1.fc6) Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (sophia.inria.fr [138.96.64.20]); Mon, 26 Mar 2007 12:23:21 +0200 (MEST) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-03/txt/msg00310.txt.bz2 On Mon, 2007-03-26 at 11:03 +0100, Andrew STUBBS wrote: > John Zoidberg wrote: > > Is this the only way? Can anyone give me any suggestions or hints? > > The way profiling works is that the compiler inserts a call to a > function (mcount?) at each function call (*). I'm not sure on the > precise rules for this, or whether it varies between target types, but > these are details that you can certainly dig up from somewhere. with gcc, -finstrument-functions generates calls to: void __cyg_profile_func_enter (void *this_fn, void *call_site); void __cyg_profile_func_exit (void *this_fn, void *call_site); > If you provide your own implementation for this function then it can do > anything you like. Printing a call graph at run time should not be too > hard (though it may be tricky if your print mechanisms are also > instrumented). I actually wrote a tool to do this: http://cutebugs.net/bozo-profiler/ Mathieu