debug.c 2.6 KB

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