From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31739 invoked by alias); 5 Mar 2009 21:15:19 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 31700 invoked by uid 9674); 5 Mar 2009 21:15:18 -0000 Date: Thu, 05 Mar 2009 21:15:00 -0000 Message-ID: <20090305211518.31685.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-python: Merge commit 'origin/archer-tromey-python' into archer-jankratochvil-python X-Git-Refname: refs/heads/archer-jankratochvil-python X-Git-Reftype: branch X-Git-Oldrev: 5cb172eb14db3f9b01bb8229fb001617ee447b9b X-Git-Newrev: a0d288848d0d1ae00798d5f5a86ee8d48ea8f87c X-SW-Source: 2009-q1/txt/msg00265.txt.bz2 List-Id: The branch, archer-jankratochvil-python has been updated via a0d288848d0d1ae00798d5f5a86ee8d48ea8f87c (commit) via a9edccdb7bff2cbea16f21972531097a8bcccc90 (commit) via f61c9e6e4488ddec2eb88bfef2aaa3fb12aba9db (commit) from 5cb172eb14db3f9b01bb8229fb001617ee447b9b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: gdb/python/lib/gdb/command/require.py | 4 ++-- gdb/python/python-function.c | 17 ++--------------- gdb/value.c | 29 ++++++++++------------------- gdb/value.h | 5 ++++- 4 files changed, 18 insertions(+), 37 deletions(-) First 500 lines of diff: diff --git a/gdb/python/lib/gdb/command/require.py b/gdb/python/lib/gdb/command/require.py index f75faad..1fbc1e8 100644 --- a/gdb/python/lib/gdb/command/require.py +++ b/gdb/python/lib/gdb/command/require.py @@ -1,6 +1,6 @@ # Demand-loading commands. -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 2008, 2009 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ class RequireSubcommand (gdb.Command): exec ('import gdb.' + self.name + '.' + cmd, globals ()) def complete (self, text, word): - dir = gdb.pythonlibdir + '/gdb/' + self.name + dir = gdb.pythondir + '/gdb/' + self.name result = [] for file in os.listdir(dir): if not file.startswith (word) or not file.endswith ('.py'): diff --git a/gdb/python/python-function.c b/gdb/python/python-function.c index 5e346d6..608ac28 100644 --- a/gdb/python/python-function.c +++ b/gdb/python/python-function.c @@ -1,6 +1,6 @@ /* Convenience functions implemented in Python. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009 Free Software Foundation, Inc. This file is part of GDB. @@ -97,19 +97,6 @@ fnpy_call (void *cookie, int argc, struct value **argv) return value; } -/* Called when destroying a struct internal_function. */ - -static void -fnpy_destroy (void *cookie) -{ - PyGILState_STATE state; - - state = PyGILState_Ensure (); - Py_DECREF ((PyObject *) cookie); - PyGILState_Release (state); - -} - /* Initializer for a Function object. It takes one argument, the name of the function. */ @@ -131,7 +118,7 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) if (! docstring) docstring = _("This function is not documented."); - add_internal_function (name, docstring, fnpy_call, self, fnpy_destroy); + add_internal_function (name, docstring, fnpy_call, self); return 0; } diff --git a/gdb/value.c b/gdb/value.c index b5998bb..7fda20b 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -58,10 +58,6 @@ struct internal_function /* User data for the handler. */ void *cookie; - - /* Function called to destroy the cookie when the function object is - destroyed. */ - void (*destroyer) (void *cookie); }; static struct cmd_list_element *functionlist; @@ -974,6 +970,7 @@ create_internalvar (const char *name) var->value = allocate_value (builtin_type_void); var->endian = gdbarch_byte_order (current_gdbarch); var->make_value = NULL; + var->canonical = 0; release_value (var->value); var->next = internalvars; internalvars = var; @@ -1103,6 +1100,9 @@ set_internalvar (struct internalvar *var, struct value *val) { struct value *newval; + if (var->canonical) + error (_("Cannot overwrite convenience function %s"), var->name); + newval = value_copy (val); newval->modifiable = 1; @@ -1134,22 +1134,15 @@ internalvar_name (struct internalvar *var) static struct value * value_create_internal_function (const char *name, internal_function_fn handler, - void *cookie, - void (*destroyer) (void *)) + void *cookie) { struct value *result = allocate_value (internal_fn_type); gdb_byte *addr = value_contents_writeable (result); struct internal_function **fnp = (struct internal_function **) addr; - /* The internal_function object is leaked here -- to make it truly - deletable, we would have to reference count it and add special - code to value_free and value_copy. The setup here is a bit odd - in general. It would be better to have a special case in - help_command. */ struct internal_function *ifn = XNEW (struct internal_function); ifn->name = xstrdup (name); ifn->handler = handler; ifn->cookie = cookie; - ifn->destroyer = destroyer; *fnp = ifn; return result; } @@ -1191,19 +1184,17 @@ function_destroyer (struct cmd_list_element *self, void *ignore) /* Add a new internal function. NAME is the name of the function; DOC is a documentation string describing the function. HANDLER is called when the function is invoked. COOKIE is an arbitrary - pointer which is passed to HANDLER and is intended for "user data". - DESTROYER is invoked when the function is destroyed. */ + pointer which is passed to HANDLER and is intended for "user + data". */ void add_internal_function (const char *name, const char *doc, - internal_function_fn handler, - void *cookie, void (*destroyer) (void *)) + internal_function_fn handler, void *cookie) { struct cmd_list_element *cmd; struct internalvar *var = lookup_internalvar (name); - struct value *fnval = value_create_internal_function (name, handler, cookie, - destroyer); - release_value (fnval); + struct value *fnval = value_create_internal_function (name, handler, cookie); set_internalvar (var, fnval); + var->canonical = 1; cmd = add_cmd (xstrdup (name), no_class, function_command, (char *) doc, &functionlist); diff --git a/gdb/value.h b/gdb/value.h index d70f1bc..138b050 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -321,6 +321,9 @@ struct internalvar struct value *value; internalvar_make_value make_value; int endian; + /* True if this internalvar is the canonical name for a convenience + function. */ + int canonical; }; @@ -676,7 +679,7 @@ typedef struct value *(*internal_function_fn) (void *cookie, void add_internal_function (const char *name, const char *doc, internal_function_fn handler, - void *cookie, void (*destroyer) (void *)); + void *cookie); struct value *call_internal_function (struct value *function, int argc, struct value **argv); hooks/post-receive -- Repository for Project Archer.