Back to index

cell-binutils  2.17cvs20070401
debug.c
Go to the documentation of this file.
00001 /* This file is debug.c
00002    Copyright 1987, 1988, 1989, 1990, 1991, 1992, 2000, 2006
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to
00019    the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 /* Routines for debug use only.  */
00022 
00023 #include "as.h"
00024 #include "subsegs.h"
00025 
00026 dmp_frags ()
00027 {
00028   asection *s;
00029   frchainS *chp;
00030   char *p;
00031 
00032   for (s = stdoutput->sections; s; s = s->next)
00033     for (chp = seg_info (s)->frchainP; chp; chp = chp->frch_next)
00034       {
00035        switch (s)
00036          {
00037          case SEG_DATA:
00038            p = "Data";
00039            break;
00040          case SEG_TEXT:
00041            p = "Text";
00042            break;
00043          default:
00044            p = "???";
00045            break;
00046          }
00047        printf ("\nSEGMENT %s %d\n", p, chp->frch_subseg);
00048        dmp_frag (chp->frch_root, "\t");
00049       }
00050 }
00051 
00052 dmp_frag (fp, indent)
00053      struct frag *fp;
00054      char *indent;
00055 {
00056   for (; fp; fp = fp->fr_next)
00057     {
00058       printf ("%sFRAGMENT @ 0x%x\n", indent, fp);
00059       switch (fp->fr_type)
00060        {
00061        case rs_align:
00062          printf ("%srs_align(%d)\n", indent, fp->fr_offset);
00063          break;
00064        case rs_fill:
00065          printf ("%srs_fill(%d)\n", indent, fp->fr_offset);
00066          printf ("%s", indent);
00067          var_chars (fp, fp->fr_var + fp->fr_fix);
00068          printf ("%s\t repeated %d times,", indent, fp->fr_offset);
00069          printf (" fixed length if # chars == 0)\n");
00070          break;
00071        case rs_org:
00072          printf ("%srs_org(%d+sym @0x%x)\n", indent,
00073                 fp->fr_offset, fp->fr_symbol);
00074          printf ("%sfill with ", indent);
00075          var_chars (fp, 1);
00076          printf ("\n");
00077          break;
00078        case rs_machine_dependent:
00079          printf ("%smachine_dep\n", indent);
00080          break;
00081        default:
00082          printf ("%sunknown type\n", indent);
00083          break;
00084        }
00085       printf ("%saddr=%d(0x%x)\n", indent, fp->fr_address, fp->fr_address);
00086       printf ("%sfr_fix=%d\n", indent, fp->fr_fix);
00087       printf ("%sfr_var=%d\n", indent, fp->fr_var);
00088       printf ("%sfr_offset=%d\n", indent, fp->fr_offset);
00089       printf ("%schars @ 0x%x\n", indent, fp->fr_literal);
00090       printf ("\n");
00091     }
00092 }
00093 
00094 var_chars (fp, n)
00095      struct frag *fp;
00096      int n;
00097 {
00098   unsigned char *p;
00099 
00100   for (p = (unsigned char *) fp->fr_literal; n; n--, p++)
00101     {
00102       printf ("%02x ", *p);
00103     }
00104 }
00105 
00106 /* end of debug.c */