From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7240 invoked by alias); 28 Mar 2011 20:24:01 -0000 Received: (qmail 7224 invoked by uid 22791); 28 Mar 2011 20:24:00 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 28 Mar 2011 20:23:53 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2SKNqp8007363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 28 Mar 2011 16:23:52 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2SKNqoJ001741; Mon, 28 Mar 2011 16:23:52 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p2SKNpnh010049; Mon, 28 Mar 2011 16:23:51 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 0D7B6378BE8; Mon, 28 Mar 2011 14:23:50 -0600 (MDT) From: Tom Tromey To: Kevin Pouget Cc: gdb-patches@sourceware.org Subject: Re: [RFC - Python] New ObjFile event References: Date: Mon, 28 Mar 2011 20:28:00 -0000 In-Reply-To: (Kevin Pouget's message of "Mon, 28 Mar 2011 04:06:29 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg01144.txt.bz2 >>>>> "Kevin" == Kevin Pouget writes: Kevin> following this discussion at Kevin> http://sourceware.org/ml/gdb/2011-03/msg00136.html, I would like to Kevin> suggest a patch for the Python event system. Based on the ''exited", Kevin> "cont", ... events, this patch allows a python script to register an Kevin> interest to the loading of new object files in the debuggee. GDB Kevin> observer "observer_attach_new_objfile" is used to trigger the Python Kevin> callback. It seems like a good idea. Do you have copyright assignment paperwork in place? If not, let me know and I can get you started. This is a requirement before we can accept a non-trivial patch. Kevin> and, likewise, allows Python's "gdb.current_objfile ()" to return Kevin> the current object file. I'm ambivalent about this part. It seems to me that the objfile should be an attribute of the event. Also setting it globally is ok, if you really want that, but it isn't a necessity. Kevin> There is still one thing I'm not happy with in the code, it's how to Kevin> 'properly' access "gdbpy_current_objfile" ? I commented out "static" Kevin> and declared it "extern" when I needed it, but that's certainly not Kevin> the best way: Dropping the `static' is ok. GDB is already full of this kind of thing. Kevin> please let me know what you thing about it Looks pretty good! Here are some notes on the patch itself. In addition to these, this patch needs a ChangeLog entry, a documentation update, and a test case. Kevin> +extern struct objfile *gdbpy_current_objfile; Should be in python-internal.h. Kevin> +static void Kevin> +python_new_objfile (struct objfile *objfile) New functions need an introductory comment. Kevin> + /* Will be NULL when clearing the symtab. */ Kevin> + if (objfile) Kevin> + cleanup = ensure_python_env (get_objfile_arch (objfile), current_language); Is this comment stale? It doesn't seem relevant. When can objfile==NULL? Kevin> - Kevin> + observer_attach_new_objfile (python_new_objfile); Kevin> + Gratuitous whitespace change. Kevin> int Kevin> emit_new_objfile_event (struct objfile *objfile) Kevin> { Kevin> PyObject *event; [...] Kevin> event = create_new_objfile_event_object (); Kevin> if (event) Kevin> return evpy_emit_event (event, gdb_py_events.newobjfile); Kevin> return -1; I think this should attach the objfile to the event object. Tom