🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Terlinden / Boris the 1st Wed, 19 Jul 1989 15:23
possible bug fixes to 3.2 "gdb"
#203
Author: David Terlinden / Boris the 1st
Date: Wed, 19 Jul 1989 15:23
183 lines
6829 bytes
I believe the following changes should be made to 3.2 "gdb".  Since the
changes are minor, I am not trying to give exact patches which may be
applied, but boxed suggested corrections are given.  Originally I was
working on a much older version of "gdb", but I've checked the 3.2
sources by eye to see if the same corrections seem to be necessary.

coffread.c

	read_section_header()
		Add an additional parameter for the optional header size.
		In the case of relocatable files, the optional header is
		not present, and the optional header size as given in the
		file header is 0.  By allowing optional header size to
		vary, "gdb" may be used to passively examing ".o" files
		(disassemble functions, etc.).

	process_coff_symbol()
		Do not put structure tags of the form ".xfake" in the
		symbol table.  Fake symbols are generated by compiler
		for certain anonymous structures, but it is not desirable
		to have "gdb" use these symbols when printing things.
		Do something like this:

=========================================================================
|#define	FAKE	"\.[0-9][0-9]*fake"
|extern	char	*re_comp();
|extern	int	re_exec();
|
|	  case C_STRTAG:
|	  case C_UNTAG:
|	  case C_ENTAG:
|	    (void)re_comp (FAKE);
|	    /*
|	     * It would be more effecient to do the "re_comp()" once and for
|	     * all in some ancestor function, but this may be unsafe if other
|	     * regular expressions are being used elsewhere.
|	     */
|	    SYMBOL_CLASS (sym) = LOC_TYPEDEF;
|	    SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
|	    if  (
|		TYPE_NAME (SYMBOL_TYPE (sym)) == 0
|		&& re_exec (SYMBOL_NAME (sym)) == 0
|		&& (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0
|		)
|	      TYPE_NAME (SYMBOL_TYPE (sym))
|		= concat ("",
|			  (cs->c_sclass == C_ENTAG
|			   ? "enum "
|			   : (cs->c_sclass == C_STRTAG
|			      ? "struct " : "union ")),
|			  SYMBOL_NAME (sym));
|	    add_symbol_to_list (sym, &file_symbols);
|	    break;
=========================================================================
	
	read_setcion_hdr()
		This function should return the number of the section read.
		Certain weird COFF ``executables'', e.g. our OS, do not have
		text section as section 1.  These may still be examined
		passively by "gdb" if "gdb" knows where the text section
		really is.  Use a global "text_section_number" for this
		purpose.

=========================================================================
|/*
| * return section number if found or -1 if not
| */
|read_section_hdr (chan, section_name, section_hdr, nsects, opthdrsize)
|    register int chan;
|    register char *section_name;
|    SCNHDR *section_hdr;
|    register int nsects;
|    int	opthdrsize;		/* size of optional header, can be 0 */
|{
|  register int i;
|
|  if (lseek (chan, (long)(FILHSZ + opthdrsize) , 0) < 0)
|    return -1;
|
|  for (i = 1; i <= nsects; i++)
|    {
|      if (myread (chan, (char *)section_hdr, SCNHSZ) < 0)
|	return -1;
|      if (strncmp (section_hdr->s_name, section_name, 8) == 0)
|	return i;
|    }
|    return -1;
|}
=========================================================================

	symbol_file_command()
		Set "text_section_number".

=========================================================================
|  if ( (tmp=read_section_hdr (desc, _TEXT, &text_hdr, num_sections,
|							file_hdr.f_opthdr)) < 0)
|    {
|      text_section_number = 0;		/* bad */
|      error ("\"%s\": can't read text section header", name);
|    }
|  else
|    text_section_number = tmp;		/* good, normally is 1 */
=========================================================================
    
	read_coff_symtab()
		Use "text_section_number" in case "C_EXT".

=========================================================================
|	  case C_EXT:
|	    if (cs->c_secnum == N_ABS && strcmp (cs->c_name, _ETEXT) == 0)
|	      {
|		end_of_text_addr = cs->c_value;
|	      }
|	    if (cs->c_type == T_NULL)
|	      {
|		if (cs->c_secnum <= 0 || cs->c_secnum == text_section_number)
|		  /*
|		   * N_DEBUG, N_ABS, N_UNDEF, or text section
|		   */
|		  {
|		    record_misc_function (cs->c_name, cs->c_value);
|		    break;
|		  }
|		else
|		  cs->c_type = T_INT;
|	      }
|	    (void) process_coff_symbol (cs, &main_aux);
|	    break;
|
|
|static	int	text_section_number;	/* the section number of the COFF text
|					   section -- This is usually 1 but
|					   need not be */
=========================================================================

	symbol_file_command()
		Take out this line which is totally wrong:
		"make_cleanup (free_current_contents, &name);"
		You can't free a stack variable, and the '&' is wrong also.
	
	decode_base_type()
		Allow "T_NULL" so as to handle, for example, functions
		returning "void" or pointers to such functions.

=========================================================================
|      case T_NULL:
|	/* We used to say "shouldn't show up here", but functions returning
|	   type void will get to here. */
|        return builtin_type_void;
=========================================================================

*-dep.c
	exec_file_command()
		For COFF, only use information from section headers.
		Avoid use of optional header, which is not always present.

source.c
	print_source_lines()
		Subtract 1 from "nlines" in error message, since "nlines"
		is deliberately one too many.

=========================================================================
|  if (line < 1 || line >= s->nlines)
|    {
|      close (desc);
|      error ("Line number out of range; %s has %d lines.",
|	     s->filename, s->nlines-1);	/* "nlines" is purposely 1 too many */
|    }
=========================================================================

values.c
	modify_field()
		Reject values too big to fit in the field in question.  Other-
		wise adjoining fields may be corrupted.

=========================================================================
|  if (fieldval & ~((1<<bitsize)-1))
|    error ("Set will not be done.  New value %d won't fit in %d bit(s).",
|      fieldval, bitsize);
=========================================================================

------------D. Terlinden, TTI 3100 Ocean Park Blvd, Sta. Monica CA 90405
	(213) 450-9111, x3124
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads