From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11224 invoked by alias); 9 Jan 2014 17:56:12 -0000 Mailing-List: contact insight-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sourceware.org Received: (qmail 11214 invoked by uid 89); 9 Jan 2014 17:56:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Jan 2014 17:56:10 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s09Hu92S012928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Jan 2014 12:56:09 -0500 Received: from barimba (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s09Hu8Oo029940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 9 Jan 2014 12:56:08 -0500 From: Tom Tromey To: Insight List Subject: RFA: avoid deprecated_set_hook Date: Thu, 09 Jan 2014 17:56:00 -0000 Message-ID: <87a9f59gzs.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-q1/txt/msg00004.txt.bz2 Insight is the last user of deprecated_set_hook. I'd like to remove that. This patch changes Insight to use the command_param_changed observer instead. I think this is equivalent, and in fact simplifies the code. I tested this by running Insight on /bin/cat and then changing the disassembly flavor. This was the only user of the param-changing event that I could see in the tree. Ok? Tom 2014-01-09 Tom Tromey * generic/gdbtk-hooks.c (gdbtk_add_hooks): Use command_param_changed observer, not deprecated_set_hook. (gdbtk_param_changed): Rename from gdbtk_set_hook. Simplify. Index: generic/gdbtk-hooks.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v retrieving revision 1.60 diff -u -r1.60 gdbtk-hooks.c --- generic/gdbtk-hooks.c 2 Jul 2013 17:07:29 -0000 1.60 +++ generic/gdbtk-hooks.c 9 Jan 2014 17:54:26 -0000 @@ -1,7 +1,7 @@ /* Startup code for Insight. Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 200, 2002, 2003, 2004, - 2008, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + 2008, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. Written by Stu Grossman of Cygnus Support. @@ -98,7 +98,7 @@ static void gdbtk_error_begin (void); void report_error (void); static void gdbtk_annotate_signal (void); -static void gdbtk_set_hook (struct cmd_list_element *cmdblk); +static void gdbtk_param_changed (const char *, const char *); /* * gdbtk_fputs can't be static, because we need to call it in gdbtk.c. @@ -125,10 +125,10 @@ observer_attach_breakpoint_deleted (gdbtk_delete_breakpoint); observer_attach_architecture_changed (gdbtk_architecture_changed); observer_attach_memory_changed (gdbtk_memory_changed); + observer_attach_command_param_changed (gdbtk_param_changed); /* Hooks */ deprecated_call_command_hook = gdbtk_call_command; - deprecated_set_hook = gdbtk_set_hook; deprecated_readline_begin_hook = gdbtk_readline_begin; deprecated_readline_hook = gdbtk_readline; deprecated_readline_end_hook = gdbtk_readline_end; @@ -547,66 +547,16 @@ the first argument and the new value as the second argument. */ static void -gdbtk_set_hook (struct cmd_list_element *cmdblk) +gdbtk_param_changed (const char *param, const char *value) { Tcl_DString cmd; - char *p; char *buffer = NULL; Tcl_DStringInit (&cmd); Tcl_DStringAppendElement (&cmd, "gdbtk_tcl_set_variable"); - /* Append variable name as sublist. */ - Tcl_DStringStartSublist (&cmd); - p = cmdblk->prefixname; - while (p && *p) - { - char *q = strchr (p, ' '); - char save = '\0'; - if (q) - { - save = *q; - *q = '\0'; - } - Tcl_DStringAppendElement (&cmd, p); - if (q) - *q = save; - p = q + 1; - } - Tcl_DStringAppendElement (&cmd, cmdblk->name); - Tcl_DStringEndSublist (&cmd); - - switch (cmdblk->var_type) - { - case var_string_noescape: - case var_filename: - case var_enum: - case var_string: - Tcl_DStringAppendElement (&cmd, (*(char **) cmdblk->var - ? *(char **) cmdblk->var - : "(null)")); - break; - - case var_boolean: - Tcl_DStringAppendElement (&cmd, (*(int *) cmdblk->var ? "1" : "0")); - break; - - case var_uinteger: - case var_zinteger: - buffer = xstrprintf ("%u", *(unsigned int *) cmdblk->var); - Tcl_DStringAppendElement (&cmd, buffer); - break; - - case var_integer: - buffer = xstrprintf ("%d", *(int *) cmdblk->var); - Tcl_DStringAppendElement (&cmd, buffer); - break; - - default: - /* This case should already be trapped by the hook caller. */ - Tcl_DStringAppendElement (&cmd, "error"); - break; - } + Tcl_DStringAppendElement (&cmd, param); + Tcl_DStringAppendElement (&cmd, value); if (Tcl_Eval (gdbtk_interp, Tcl_DStringValue (&cmd)) != TCL_OK) report_error ();