133965Sjdp/* This file is debug.c 2218822Sdim Copyright 1987, 1988, 1989, 1990, 1991, 1992, 2000, 2006 378828Sobrien Free Software Foundation, Inc. 433965Sjdp 533965Sjdp This file is part of GAS, the GNU Assembler. 633965Sjdp 733965Sjdp GAS is free software; you can redistribute it and/or modify 833965Sjdp it under the terms of the GNU General Public License as published by 933965Sjdp the Free Software Foundation; either version 2, or (at your option) 1033965Sjdp any later version. 1133965Sjdp 1233965Sjdp GAS is distributed in the hope that it will be useful, 1333965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1433965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1533965Sjdp GNU General Public License for more details. 1633965Sjdp 1733965Sjdp You should have received a copy of the GNU General Public License 1833965Sjdp along with GAS; see the file COPYING. If not, write to 19218822Sdim the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 2033965Sjdp 2133965Sjdp/* Routines for debug use only. */ 2233965Sjdp 2333965Sjdp#include "as.h" 2433965Sjdp#include "subsegs.h" 2533965Sjdp 2633965Sjdpdmp_frags () 2733965Sjdp{ 28218822Sdim asection *s; 2933965Sjdp frchainS *chp; 3033965Sjdp char *p; 3133965Sjdp 32218822Sdim for (s = stdoutput->sections; s; s = s->next) 33218822Sdim for (chp = seg_info (s)->frchainP; chp; chp = chp->frch_next) 34218822Sdim { 35218822Sdim switch (s) 36218822Sdim { 37218822Sdim case SEG_DATA: 38218822Sdim p = "Data"; 39218822Sdim break; 40218822Sdim case SEG_TEXT: 41218822Sdim p = "Text"; 42218822Sdim break; 43218822Sdim default: 44218822Sdim p = "???"; 45218822Sdim break; 46218822Sdim } 47218822Sdim printf ("\nSEGMENT %s %d\n", p, chp->frch_subseg); 48218822Sdim dmp_frag (chp->frch_root, "\t"); 49218822Sdim } 5033965Sjdp} 5133965Sjdp 5233965Sjdpdmp_frag (fp, indent) 5333965Sjdp struct frag *fp; 5433965Sjdp char *indent; 5533965Sjdp{ 5633965Sjdp for (; fp; fp = fp->fr_next) 5733965Sjdp { 5833965Sjdp printf ("%sFRAGMENT @ 0x%x\n", indent, fp); 5933965Sjdp switch (fp->fr_type) 6033965Sjdp { 6133965Sjdp case rs_align: 6233965Sjdp printf ("%srs_align(%d)\n", indent, fp->fr_offset); 6333965Sjdp break; 6433965Sjdp case rs_fill: 6533965Sjdp printf ("%srs_fill(%d)\n", indent, fp->fr_offset); 6633965Sjdp printf ("%s", indent); 6733965Sjdp var_chars (fp, fp->fr_var + fp->fr_fix); 6877298Sobrien printf ("%s\t repeated %d times,", indent, fp->fr_offset); 6933965Sjdp printf (" fixed length if # chars == 0)\n"); 7033965Sjdp break; 7133965Sjdp case rs_org: 7233965Sjdp printf ("%srs_org(%d+sym @0x%x)\n", indent, 7333965Sjdp fp->fr_offset, fp->fr_symbol); 7433965Sjdp printf ("%sfill with ", indent); 7533965Sjdp var_chars (fp, 1); 7633965Sjdp printf ("\n"); 7733965Sjdp break; 7833965Sjdp case rs_machine_dependent: 7933965Sjdp printf ("%smachine_dep\n", indent); 8033965Sjdp break; 8133965Sjdp default: 8233965Sjdp printf ("%sunknown type\n", indent); 8333965Sjdp break; 8433965Sjdp } 8533965Sjdp printf ("%saddr=%d(0x%x)\n", indent, fp->fr_address, fp->fr_address); 8633965Sjdp printf ("%sfr_fix=%d\n", indent, fp->fr_fix); 8733965Sjdp printf ("%sfr_var=%d\n", indent, fp->fr_var); 8833965Sjdp printf ("%sfr_offset=%d\n", indent, fp->fr_offset); 8933965Sjdp printf ("%schars @ 0x%x\n", indent, fp->fr_literal); 9033965Sjdp printf ("\n"); 9133965Sjdp } 9233965Sjdp} 9333965Sjdp 9433965Sjdpvar_chars (fp, n) 9533965Sjdp struct frag *fp; 9633965Sjdp int n; 9733965Sjdp{ 9833965Sjdp unsigned char *p; 9933965Sjdp 10033965Sjdp for (p = (unsigned char *) fp->fr_literal; n; n--, p++) 10133965Sjdp { 10233965Sjdp printf ("%02x ", *p); 10333965Sjdp } 10433965Sjdp} 10533965Sjdp 10633965Sjdp/* end of debug.c */ 107