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