From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: How to debug strange value changes of a variable? Date: Thu, 01 Jan 2015 01:23:26 +0100 Message-ID: <874msbnybl.fsf@mbork.pl> References: <87mw64ocjp.fsf@mbork.pl> <87bnmj7chm.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1420071850 29519 80.91.229.3 (1 Jan 2015 00:24:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Jan 2015 00:24:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 01 01:24:01 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y6TYV-0005QS-Kq for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 01:23:59 +0100 Original-Received: from localhost ([::1]:41698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6TYU-0007on-S8 for geh-help-gnu-emacs@m.gmane.org; Wed, 31 Dec 2014 19:23:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6TYJ-0007k6-N6 for help-gnu-emacs@gnu.org; Wed, 31 Dec 2014 19:23:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6TYF-00031p-01 for help-gnu-emacs@gnu.org; Wed, 31 Dec 2014 19:23:47 -0500 Original-Received: from msg.wmi.amu.edu.pl ([150.254.78.50]:39837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6TYE-00031X-Q5 for help-gnu-emacs@gnu.org; Wed, 31 Dec 2014 19:23:42 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 61327414B1 for ; Thu, 1 Jan 2015 01:23:41 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mmNLk5s0BoT2 for ; Thu, 1 Jan 2015 01:23:41 +0100 (CET) Original-Received: from localhost (117-116.echostar.pl [213.156.117.116]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id E58ED42061 for ; Thu, 1 Jan 2015 01:23:40 +0100 (CET) In-reply-to: <87bnmj7chm.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 150.254.78.50 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101816 Archived-At: On 2014-12-31, at 22:09, Michael Heerdegen wrote: > Marcin Borkowski writes: > >> Now somehow mu4e (I know it is to blame, since in stock message-mode, >> with emacs -Q, and without mu4e, everything works as expected!) messes >> around with the value of this variable /after the first increment/ (or >> so it seems: it looks like that after some initialization - including >> incf'ing that variable from its inital value of -1 - it somehow comes >> back to its original (default) value). I'd like to check what function >> and when changes its value. Is there any way to use Edebug (or anything >> else) for this? > > Are you sure you reference the variable's value with the same buffer > current? That's important of course. Yes, this I did check. > Also note that changing a buffer's major mode removes all buffer local > bindings in the current buffer. That could maybe happen in your case. Thank you, thank you, thank you, thank you so much! I'd *never* think of that (I didn't even know that). That was it! The first time my function was called, the buffer was in fundamental mode; all subsequent times, it was in mu4e-compose-mode. That should explain everything. Now the question is: what to do. I could dive into mu4e sources (which I'm just a bit too lazy to do now). I could just start mu4e-compose-mode myself in my function and see what happens (I'll try that). Other than that, I don't have many ideas. >> I know about edebug-set-global-break-condition, but this doesn't help a >> lot: it can stop when the variable has some value, but does not tell me >> /which/ piece of code changed it. > > Indeed, that is not much helpful in this case, unless you instrument all > code that could be responsible, but that may slow down things > drastically. What's more, some things might be done by functions written in C... > Did you define the variable we speak about by yourself? If you did, > normally only your own code should change the variables binding. Yes. >> (A similar question is to find out what calls such-and-such function. >> This one seems easier: I can just instrument the said function and then >> press `d' in Edebug to see the backtrace. Am I right?) > > Yes, you could. But for such questions, the ordinary debugger is IMHO > much simpler and more helpful (`debug-on-entry'). Load the elisp source > files before using it to avoid seeing byte code in the debugger output. Thanks for the tip! > Michael. Thank you again and a happy new year! -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University