From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: How to debug modification to a variable value? Date: Tue, 26 Jan 2010 09:43:09 +0100 Message-ID: <87636p5k9u.fsf@thinkpad.tsdh.de> References: <87636pvrdj.fsf@thinkpad.tsdh.de> <52428.130.55.118.19.1264458645.squirrel@webmail.lanl.gov> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1264496269 19929 80.91.229.12 (26 Jan 2010 08:57:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Jan 2010 08:57:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: herring@lanl.gov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 26 09:57:41 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NZhEw-00029n-R7 for ged-emacs-devel@m.gmane.org; Tue, 26 Jan 2010 09:57:39 +0100 Original-Received: from localhost ([127.0.0.1]:46717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZhEx-00059F-VW for ged-emacs-devel@m.gmane.org; Tue, 26 Jan 2010 03:57:39 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZh1I-0006kQ-K4 for emacs-devel@gnu.org; Tue, 26 Jan 2010 03:43:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZh1E-0006fB-Lm for emacs-devel@gnu.org; Tue, 26 Jan 2010 03:43:32 -0500 Original-Received: from [199.232.76.173] (port=59594 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZh1E-0006f4-EN for emacs-devel@gnu.org; Tue, 26 Jan 2010 03:43:28 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]:43692) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NZh1D-00023H-UV for emacs-devel@gnu.org; Tue, 26 Jan 2010 03:43:28 -0500 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZh1D-0004Jx-3K for emacs-devel@gnu.org; Tue, 26 Jan 2010 03:43:27 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 6CC0B78A3DB5; Tue, 26 Jan 2010 09:43:26 +0100 (CET) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10172-07; Tue, 26 Jan 2010 09:43:25 +0100 (CET) X-CHKRCPT: Envelopesender noch tassilo@member.fsf.org Original-Received: from thinkpad.tsdh.de (wlan-150.uni-koblenz.de [141.26.93.150]) by deliver.uni-koblenz.de (Postfix) with ESMTP id EA03878A3DB0; Tue, 26 Jan 2010 09:43:24 +0100 (CET) Mail-Copies-To: never Mail-Followup-To: herring@lanl.gov, emacs-devel@gnu.org In-Reply-To: <52428.130.55.118.19.1264458645.squirrel@webmail.lanl.gov> (Davis Herring's message of "Mon, 25 Jan 2010 14:30:45 -0800 (PST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) X-Virus-Scanned: amavisd-new at uni-koblenz.de X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:120422 Archived-At: "Davis Herring" writes: Hi Davis, >> Now, my problem was that under some circumstances after saving, the >> buffer-local value of `tg-schema-alist' was gone, i.e. set to nil. > > There's a difference between "gone" and "set to nil", even for > automatically-buffer-local variables. Does it still have a > buffer-local value (which is wrong), or is it using the default > (again)? C-h v will say. "Gone" means, it has the buffer-local value nil. So there seems to be no call to `kill-local-variable'. >> I double-checked `greql-set-fontlock-types-regex' that it doesn't >> modify `tg-schema-alist', and it doesn't. I also removed all >> destructive function calls in there, although it operates only on a >> list created by `mapcar', and that's a copy anyway, right? > > Destructive operations on lists can't set the value of a variable to nil, > nor can they invoke `kill-local-variable'. `set[qf]?' is of course > destructive, as are `kill-local-variable' and `kill-all-local-variables'; > have you looked for all of those? There's no `kill-[all-]local-variable[s]', and the `setq' of that variable is isolated in one command (see end of this message), which is never called internally, only by a keybinding. >> So what I need is some way to be put in the debugger when the value >> of `tg-schema-alist' is modified. Is that feasible? I tried adding >> an after advice to `setq' which does exactly that, but that screwed >> my emacs instance. I guess it's no good idea to advice such >> primitives... > > I don't that you can do this in the Emacs debugger, but you should be > able to use a watchpoint in gdb for this purpose. Find where the > buffer-local value of the variable is stored, set the watchpoint, and > then save. Sounds good, but how do I do that? Especially the "find where the buffer-local value of the variable is stored" part... > Meanwhile, my psychic powers suggest that you have a `let' binding of > the variable in question and switch buffers within the `let', or else > that something is reasserting your major mode so that > `kill-all-local-variables' is getting called. Hm, the problem occured while I was using many different frames, which I didn't use till now, so something in this direction seems possible. But between the variable is set buffer-locally to some alist and the variable is set buffer-locally to nil, there was only one C-x C-s without switching frames/buffers at all. > You could test for the latter with the `permanent-local' property. Oh, I didn't know that property. ,----[ (info "(elisp)Creating Buffer-Local") ] | A buffer-local variable is "permanent" if the variable name (a | symbol) has a `permanent-local' property that is non-`nil'. Permanent | locals are appropriate for data pertaining to where the file came from | or how to save it, rather than with how to edit the contents. `---- I don't know if this is appropriate for `tg-schema-alist'. It determines the completion possibilities and highlighting, and is not strictly related to the current buffer/file, but to another file a user can select and switch. > PS - Sorry if some of these instructions are obvious; They are not, at least to me. So thanks a lot! > I don't know just what you know! Sure, I just wantet to avoid posting the whole code, if not absolutely neccessary. It's free sofware, and you can svn checkout it from [1] using anonymous/secret as user/password. But basically, there are two modes: tg-mode has a simple parser for a schema description language, and greql-mode which is a mode for a graph query language, which is used for querying graphs conforming to some TG schema. So tg-mode contains --8<---------------cut here---------------start------------->8--- (defvar tg-schema-alist nil "The schema of the current TG file.") (make-variable-buffer-local 'tg-schema-alist) --8<---------------cut here---------------end--------------->8--- and in greql-mode (which requires tg-mode), there is the only function modifying the value of `tg-schema-alist' by assigning the buffer-local value of a temporary buffer to the buffer-local value in the query buffer. --8<---------------cut here---------------start------------->8--- (defun greql-set-graph (graph) "Set `greql-graph' to GRAPH and parse it with `tg-parse-schema'." (interactive "fGraph file: ") (setq greql-graph graph) (let ((g greql-graph) schema-alist unique-name-map) (with-temp-buffer (insert-file-contents g) (tg-init-schema) (setq schema-alist tg-schema-alist) (setq unique-name-map tg-unique-name-hashmap)) (setq tg-schema-alist schema-alist) (setq tg-unique-name-hashmap unique-name-map)) ;; Setup schema element font locking (greql-set-fontlock-types-regex)) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo __________ [1] https://svn.uni-koblenz.de/ist/projects/jgralab/trunk/utils