This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: [PATCH] Avoid emitting invalid stabs


On Fri, Jul 20, 2001 at 02:27:08PM +0200, Jakub Jelinek wrote:
> 2001-07-20  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* dbxout.c (dbxout_symbol_location): Avoid emitting invalid register
> 	numbers.
> 

Here is the test, gcc on IA-32 creates at -O something like:
$ gcc -O -g foo.i -S  && grep buf:r foo.s
.stabs "buf:r(0,26)=*(0,27)=ar(0,28)=r(0,28);0000000000000;0037777777777;;0;-1;(0,2)",64,0,41,136847069

(note the last number).

typedef unsigned int size_t;
extern char *_dl_next_ld_env_entry (char ***position) __attribute__ ((regparm (3), stdcall));
static inline char * __attribute__ ((unused))
_itoa_word (unsigned long value, char *buflim,
            unsigned int base, int upper_case)
{
  extern const char _itoa_upper_digits[], _itoa_lower_digits[];
  const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
  char *bp = buflim;
  switch (base)
    {
    default:
      do
        *--bp = digits[value % base];
      while ((value /= base) != 0);
    }
  return bp;
}
enum mode { normal, list, verify, trace };
extern unsigned int _dl_osversion;
extern int _dl_correct_cache_id;
static void
process_envvars (enum mode *modep)
{
  char **runp = ((void *)0);
  char *envline;
  enum mode mode = normal;
  char *debug_output = ((void *)0);
  while ((envline = _dl_next_ld_env_entry (&runp)) != ((void *)0))
    {
      size_t len = strcspn (envline, "=");
      switch (len - 3)
        {
          case 13: if (memcmp (&envline[3], "ASSUME_KERNEL", 13) == 0) {
	    unsigned long int i, j, osversion = 0; char *p = &envline[17], *q; for (i = 0; i < 3; i++, p = q + 1) { j = __strtoul_internal (p,&q, 0, 0); if (j >= 255 || p == q || (i < 2 && *q && *q != '.')) { osversion = 0; break; } osversion |= j << (16 - 8 * i); if (!*q) break; }
          }
        }
    }
    {
      const int flags = 01 | 02000 | 0100 | 0400000;
      size_t name_len = strlen (debug_output);
      char buf[name_len + 12];
      char *startp;
      buf[name_len + 11] = '\0';
      startp = _itoa_word (__getpid (), &buf[name_len + 11], 10, 0);
      *--startp = '.';
    }
}


	Jakub


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