This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [mi] organize possible exec async mi oc command reasons


On Wed, May 18, 2005 at 12:00:11AM -0400, Bob Rossi wrote:
> I have a feeling that I messed up the internal_error coding style
> function call in _initialize_gdb_mi_common, but I have no idea how to
> fix it. The constant char* error message is longer than 80 char's. Any
> ideas? (I even ran gdb_indent on it, but it didn't help)

There's lots of ways to do this.  You have:

  if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL)
    internal_error (__FILE__, __LINE__,
      _("_initialize_gdb_mi_common: async_reason_string_lookup[] is inconsistent"));

You could do:

  if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL)
    internal_error (__FILE__, __LINE__, _("\
_initialize_gdb_mi_common: async_reason_string_lookup[] is inconsistent"));

Or:
  if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL)
    internal_error (__FILE__, __LINE__,
		    _("_initialize_gdb_mi_common: "
		      "async_reason_string_lookup[] is inconsistent"));

Or:
  if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL)
    internal_error
      (__FILE__, __LINE__,
       _("_initialize_gdb_mi_common: async_reason_string_lookup[] is inconsistent"));

Except that last one is still past 80 chars.

Or, you could do this:
  if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL)
    internal_error (__FILE__, __LINE__,
		    _("async_reason_string_lookup[] is inconsistent"));

Or my personal favorite of the bunch:
  if (ARRAY_SIZE (async_reason_string_lookup) != EXEC_ASYNC_LAST + 1)
    internal_error (__FILE__, __LINE__,
		    _("async_reason_string_lookup is inconsistent"));

Which won't access out of bounds memory if someone shortens the array. 
No one ever will, of course, but...

> 
> 2005-05-17  Bob Rossi  <bob@brasko.net>
> 	* Makefile.in (SUBDIR_MI_OBS, SUBDIR_MI_SRCS): Add mi-common.
> 	(gdb/mi/ headers): Add mi_common_h.
> 	(breakpoint.o, infrun.o): Add dependencies mi_common_h.
> 	* breakpoint.c (include): Add include 'mi/mi-common.h'.
> 	(print_it_typical): Use async_reason_lookup.
> 	(watchpoint_check): Ditto.
> 	* infrun.c (include): Add include 'mi/mi-common.h'.
> 	(print_stop_reason): Use async_reason_lookup.
> 	* mi/mi-common.h: New file.
> 	* mi/mi-common.c: Ditto.

The other half of your changelog was lost in the patch below :-)

> -	    ui_out_field_string (uiout, "reason", "watchpoint-trigger");
> +	    ui_out_field_string (uiout, "reason", 
> +				 async_reason_lookup
> +				 (EXEC_ASYNC_WATCHPOINT_TRIGGER));

This is fine, but if the indentation bugs you, here's an alternative:

	    ui_out_field_string
	      (uiout, "reason",
	       async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));


> +@item read-watchpoint-trigger
> +A read watchpoint was triggered

This one lost a trailing period.

> /* Represents the reason why GDB is sending an asyncronous command to the
>    front end.  
>    NOTE: When modifing this, don't forget to update gdb.texinfo!  */

In general stray line breaks in comments will get eaten by
gdb_indent.sh.  You can just put the NOTE on the same line.  Also,
"asynchronous" with an h.

>     /* This is here only to represent the number of enum's */

"the number of enums.  "

-- 
Daniel Jacobowitz
CodeSourcery, LLC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]