Home | History | Annotate | Line # | Download | only in gas
      1   1.1  christos /* This file is debug.c
      2  1.10  christos    Copyright (C) 1987-2025 Free Software Foundation, Inc.
      3   1.1  christos 
      4   1.1  christos    This file is part of GAS, the GNU Assembler.
      5   1.1  christos 
      6   1.1  christos    GAS is free software; you can redistribute it and/or modify
      7   1.1  christos    it under the terms of the GNU General Public License as published by
      8   1.1  christos    the Free Software Foundation; either version 3, or (at your option)
      9   1.1  christos    any later version.
     10   1.1  christos 
     11   1.1  christos    GAS is distributed in the hope that it will be useful,
     12   1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   1.1  christos    GNU General Public License for more details.
     15   1.1  christos 
     16   1.1  christos    You should have received a copy of the GNU General Public License
     17   1.1  christos    along with GAS; see the file COPYING.  If not, write to
     18   1.1  christos    the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
     19   1.1  christos 
     20   1.1  christos /* Routines for debug use only.  */
     21   1.1  christos 
     22   1.1  christos #include "as.h"
     23   1.1  christos #include "subsegs.h"
     24   1.1  christos 
     25  1.10  christos void
     26  1.10  christos dmp_frags (void)
     27   1.1  christos {
     28   1.1  christos   asection *s;
     29   1.1  christos   frchainS *chp;
     30   1.1  christos   char *p;
     31   1.1  christos 
     32   1.1  christos   for (s = stdoutput->sections; s; s = s->next)
     33   1.1  christos     for (chp = seg_info (s)->frchainP; chp; chp = chp->frch_next)
     34   1.1  christos       {
     35   1.1  christos 	switch (s)
     36   1.1  christos 	  {
     37   1.1  christos 	  case SEG_DATA:
     38   1.1  christos 	    p = "Data";
     39   1.1  christos 	    break;
     40   1.1  christos 	  case SEG_TEXT:
     41   1.1  christos 	    p = "Text";
     42   1.1  christos 	    break;
     43   1.1  christos 	  default:
     44   1.1  christos 	    p = "???";
     45   1.1  christos 	    break;
     46   1.1  christos 	  }
     47   1.1  christos 	printf ("\nSEGMENT %s %d\n", p, chp->frch_subseg);
     48   1.1  christos 	dmp_frag (chp->frch_root, "\t");
     49   1.1  christos       }
     50   1.1  christos }
     51   1.1  christos 
     52  1.10  christos void
     53  1.10  christos dmp_frag (struct frag *fp, char *indent)
     54   1.1  christos {
     55   1.1  christos   for (; fp; fp = fp->fr_next)
     56   1.1  christos     {
     57   1.1  christos       printf ("%sFRAGMENT @ 0x%x\n", indent, fp);
     58   1.1  christos       switch (fp->fr_type)
     59   1.1  christos 	{
     60   1.1  christos 	case rs_align:
     61   1.1  christos 	  printf ("%srs_align(%d)\n", indent, fp->fr_offset);
     62   1.1  christos 	  break;
     63   1.1  christos 	case rs_fill:
     64   1.1  christos 	  printf ("%srs_fill(%d)\n", indent, fp->fr_offset);
     65   1.1  christos 	  printf ("%s", indent);
     66   1.1  christos 	  var_chars (fp, fp->fr_var + fp->fr_fix);
     67   1.1  christos 	  printf ("%s\t repeated %d times,", indent, fp->fr_offset);
     68   1.1  christos 	  printf (" fixed length if # chars == 0)\n");
     69   1.1  christos 	  break;
     70   1.1  christos 	case rs_org:
     71   1.1  christos 	  printf ("%srs_org(%d+sym @0x%x)\n", indent,
     72   1.1  christos 		  fp->fr_offset, fp->fr_symbol);
     73   1.1  christos 	  printf ("%sfill with ", indent);
     74   1.1  christos 	  var_chars (fp, 1);
     75   1.1  christos 	  printf ("\n");
     76   1.1  christos 	  break;
     77   1.1  christos 	case rs_machine_dependent:
     78   1.1  christos 	  printf ("%smachine_dep\n", indent);
     79   1.1  christos 	  break;
     80   1.1  christos 	default:
     81   1.1  christos 	  printf ("%sunknown type\n", indent);
     82   1.1  christos 	  break;
     83   1.1  christos 	}
     84   1.1  christos       printf ("%saddr=%d(0x%x)\n", indent, fp->fr_address, fp->fr_address);
     85   1.1  christos       printf ("%sfr_fix=%d\n", indent, fp->fr_fix);
     86   1.1  christos       printf ("%sfr_var=%d\n", indent, fp->fr_var);
     87   1.1  christos       printf ("%sfr_offset=%d\n", indent, fp->fr_offset);
     88   1.1  christos       printf ("%schars @ 0x%x\n", indent, fp->fr_literal);
     89   1.1  christos       printf ("\n");
     90   1.1  christos     }
     91   1.1  christos }
     92   1.1  christos 
     93  1.10  christos void
     94  1.10  christos var_chars (struct frag *fp, int n)
     95   1.1  christos {
     96   1.1  christos   unsigned char *p;
     97   1.1  christos 
     98   1.1  christos   for (p = (unsigned char *) fp->fr_literal; n; n--, p++)
     99   1.1  christos     {
    100   1.1  christos       printf ("%02x ", *p);
    101   1.1  christos     }
    102   1.1  christos }
    103   1.1  christos 
    104   1.1  christos /* end of debug.c */
    105