From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28581 invoked by alias); 16 Aug 2003 18:39:55 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 28573 invoked from network); 16 Aug 2003 18:39:54 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 16 Aug 2003 18:39:54 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 6257C2B7F; Sat, 16 Aug 2003 14:39:49 -0400 (EDT) Message-ID: <3F3E7A75.4030405@redhat.com> Date: Sat, 16 Aug 2003 18:39:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bob Rossi Cc: gdb-patches@sources.redhat.com Subject: Re: [patch, rfc] Delete "set prompt-escape-char" command References: <3F32DD86.90407@redhat.com> <20030808010142.GA22345@white> Content-Type: multipart/mixed; boundary="------------060102090203040102030401" X-SW-Source: 2003-08/txt/msg00257.txt.bz2 This is a multi-part message in MIME format. --------------060102090203040102030401 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 695 > Geez, I would hope that the NEWS would mention it. Good point, the attached, which I've committed, includes a NEWS entry. > (gdb) apropos prompt > end -- Ends a list of commands or actions > set prompt -- Set gdb's prompt > set prompt-escape-char -- Set escape character for formatting of gdb's prompt > show prompt -- Show gdb's prompt > show prompt-escape-char -- Show escape character for formatting of gdb's prompt > > I was tempted to use that feature for my front end, but decided not too. I'd like to know how :-) It isn't documented and its behavior, without very careful study of the source, is impossible to decipher and pretty much guarenteed to be non-portable :-( Andrew --------------060102090203040102030401 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 9374 2003-08-16 Andrew Cagney * NEWS: Mention that "set prompt-escape-char" was deleted. * top.c (get_prompt_1): Delete function. (gdb_prompt_escape): (init_main): Do not clear "gdb_prompt_escape". Delete "set prompt-escape-char" command. (MAX_PROMPT_SIZE): Delete macro. (get_prompt): Simplify, do not call get_prompt_1. Index: NEWS =================================================================== RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.116 diff -u -r1.116 NEWS --- NEWS 8 Aug 2003 22:26:37 -0000 1.116 +++ NEWS 16 Aug 2003 18:37:04 -0000 @@ -3,6 +3,12 @@ *** Changes since GDB 6.0: +* "set prompt-escape-char" command deleted. + +The command "set prompt-escape-char" has been deleted. This command, +and its very obscure effet on GDB's prompt, was never documented, +tested, nor mentioned in the NEWS file. + *** Changes in GDB 6.0: * GDB supports logging output to a file Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.74 diff -u -r1.74 top.c --- top.c 4 Aug 2003 17:08:23 -0000 1.74 +++ top.c 16 Aug 2003 18:37:04 -0000 @@ -1388,267 +1388,13 @@ /* get_prompt: access method for the GDB prompt string. */ -#define MAX_PROMPT_SIZE 256 - -/* - * int get_prompt_1 (char * buf); - * - * Work-horse for get_prompt (called via catch_errors). - * Argument is buffer to hold the formatted prompt. - * - * Returns: 1 for success (use formatted prompt) - * 0 for failure (use gdb_prompt_string). - */ - -static int gdb_prompt_escape; - -static int -get_prompt_1 (void *data) -{ - char *formatted_prompt = data; - char *local_prompt; - - if (event_loop_p) - local_prompt = PROMPT (0); - else - local_prompt = gdb_prompt_string; - - - if (gdb_prompt_escape == 0) - { - return 0; /* do no formatting */ - } - else - /* formatted prompt */ - { - char fmt[40], *promptp, *outp, *tmp; - struct value *arg_val; - DOUBLEST doubleval; - LONGEST longval; - CORE_ADDR addrval; - - int i, len; - struct type *arg_type, *elt_type; - - promptp = local_prompt; - outp = formatted_prompt; - - while (*promptp != '\0') - { - int available = MAX_PROMPT_SIZE - (outp - formatted_prompt) - 1; - - if (*promptp != gdb_prompt_escape) - { - if (available >= 1) /* overflow protect */ - *outp++ = *promptp++; - } - else - { - /* GDB prompt string contains escape char. Parse for arg. - Two consecutive escape chars followed by arg followed by - a comma means to insert the arg using a default format. - Otherwise a printf format string may be included between - the two escape chars. eg: - %%foo, insert foo using default format - %2.2f%foo, insert foo using "%2.2f" format - A mismatch between the format string and the data type - of "foo" is an error (which we don't know how to protect - against). */ - - fmt[0] = '\0'; /* assume null format string */ - if (promptp[1] == gdb_prompt_escape) /* double esc char */ - { - promptp += 2; /* skip past two escape chars. */ - } - else - { - /* extract format string from between two esc chars */ - i = 0; - do - { - fmt[i++] = *promptp++; /* copy format string */ - } - while (i < sizeof (fmt) - 1 && - *promptp != gdb_prompt_escape && - *promptp != '\0'); - - if (*promptp != gdb_prompt_escape) - error ("Syntax error at prompt position %d", - (int) (promptp - local_prompt)); - else - { - promptp++; /* skip second escape char */ - fmt[i++] = '\0'; /* terminate the format string */ - } - } - - arg_val = parse_to_comma_and_eval (&promptp); - if (*promptp == ',') - promptp++; /* skip past the comma */ - arg_type = check_typedef (VALUE_TYPE (arg_val)); - switch (TYPE_CODE (arg_type)) - { - case TYPE_CODE_ARRAY: - elt_type = check_typedef (TYPE_TARGET_TYPE (arg_type)); - if (TYPE_LENGTH (arg_type) > 0 && - TYPE_LENGTH (elt_type) == 1 && - TYPE_CODE (elt_type) == TYPE_CODE_INT) - { - int len = TYPE_LENGTH (arg_type); - - if (VALUE_LAZY (arg_val)) - value_fetch_lazy (arg_val); - tmp = VALUE_CONTENTS (arg_val); - - if (len > available) - len = available; /* overflow protect */ - - /* FIXME: how to protect GDB from crashing - from bad user-supplied format string? */ - if (fmt[0] != 0) - sprintf (outp, fmt, tmp); - else - strncpy (outp, tmp, len); - outp[len] = '\0'; - } - break; - case TYPE_CODE_PTR: - elt_type = check_typedef (TYPE_TARGET_TYPE (arg_type)); - addrval = value_as_address (arg_val); - - if (TYPE_LENGTH (elt_type) == 1 && - TYPE_CODE (elt_type) == TYPE_CODE_INT && - addrval != 0) - { - /* display it as a string */ - char *default_fmt = "%s"; - char *tmp; - int err = 0; - - /* Limiting the number of bytes that the following call - will read protects us from sprintf overflow later. */ - i = target_read_string (addrval, /* src */ - &tmp, /* dest */ - available, /* len */ - &err); - if (err) /* read failed */ - error ("%s on target_read", safe_strerror (err)); - - tmp[i] = '\0'; /* force-terminate string */ - /* FIXME: how to protect GDB from crashing - from bad user-supplied format string? */ - sprintf (outp, fmt[0] == 0 ? default_fmt : fmt, - tmp); - xfree (tmp); - } - else - { - /* display it as a pointer */ - char *default_fmt = "0x%x"; - - /* FIXME: how to protect GDB from crashing - from bad user-supplied format string? */ - if (available >= 16 /*? */ ) /* overflow protect */ - sprintf (outp, fmt[0] == 0 ? default_fmt : fmt, - (long) addrval); - } - break; - case TYPE_CODE_FLT: - { - char *default_fmt = "%g"; - - doubleval = value_as_double (arg_val); - /* FIXME: how to protect GDB from crashing - from bad user-supplied format string? */ - if (available >= 16 /*? */ ) /* overflow protect */ - sprintf (outp, fmt[0] == 0 ? default_fmt : fmt, - (double) doubleval); - break; - } - case TYPE_CODE_INT: - { - char *default_fmt = "%d"; - - longval = value_as_long (arg_val); - /* FIXME: how to protect GDB from crashing - from bad user-supplied format string? */ - if (available >= 16 /*? */ ) /* overflow protect */ - sprintf (outp, fmt[0] == 0 ? default_fmt : fmt, - (long) longval); - break; - } - case TYPE_CODE_BOOL: - { - /* no default format for bool */ - longval = value_as_long (arg_val); - if (available >= 8 /*? */ ) /* overflow protect */ - { - if (longval) - strcpy (outp, ""); - else - strcpy (outp, ""); - } - break; - } - case TYPE_CODE_ENUM: - { - /* no default format for enum */ - longval = value_as_long (arg_val); - len = TYPE_NFIELDS (arg_type); - /* find enum name if possible */ - for (i = 0; i < len; i++) - if (TYPE_FIELD_BITPOS (arg_type, i) == longval) - break; /* match -- end loop */ - - if (i < len) /* enum name found */ - { - char *name = TYPE_FIELD_NAME (arg_type, i); - - strncpy (outp, name, available); - /* in casel available < strlen (name), */ - outp[available] = '\0'; - } - else - { - if (available >= 16 /*? */ ) /* overflow protect */ - sprintf (outp, "%ld", (long) longval); - } - break; - } - case TYPE_CODE_VOID: - *outp = '\0'; - break; /* void type -- no output */ - default: - error ("bad data type at prompt position %d", - (int) (promptp - local_prompt)); - break; - } - outp += strlen (outp); - } - } - *outp++ = '\0'; /* terminate prompt string */ - return 1; - } -} - char * get_prompt (void) { - static char buf[MAX_PROMPT_SIZE]; - - if (catch_errors (get_prompt_1, buf, "bad formatted prompt: ", - RETURN_MASK_ALL)) - { - return &buf[0]; /* successful formatted prompt */ - } + if (event_loop_p) + return PROMPT (0); else - { - /* Prompt could not be formatted. */ - if (event_loop_p) - return PROMPT (0); - else - return gdb_prompt_string; - } + return gdb_prompt_string; } void @@ -1946,7 +1692,6 @@ if (annotation_level > 1) set_async_annotation_level (NULL, 0, NULL); } - gdb_prompt_escape = 0; /* default to none. */ /* Set the important stuff up for command editing. */ command_editing_p = 1; @@ -1985,13 +1730,6 @@ add_show_from_set (c, &showlist); set_cmd_sfunc (c, set_async_prompt); } - - add_show_from_set - (add_set_cmd ("prompt-escape-char", class_support, var_zinteger, - (char *) &gdb_prompt_escape, - "Set escape character for formatting of gdb's prompt", - &setlist), - &showlist); add_com ("dont-repeat", class_support, dont_repeat_command, "Don't repeat this command.\n\ Primarily used inside of user-defined commands that should not be repeated when\n\ --------------060102090203040102030401--