gdb.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* gdb.c -as supports gdb-
  2. Copyright (C) 1987 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. /* This code is independent of the underlying operating system. */
  16. #include "as.h"
  17. static long int size; /* 0 or size of GDB symbol file. */
  18. static char * where; /* Where we put symbol file in memory. */
  19. #define SUSPECT /* JF */
  20. long int /* 0 means don't call gdb_... routines */
  21. gdb_begin (filename) /* because we failed to establish file */
  22. /* in memory. */
  23. char * filename; /* NULL: we have nothing to do. */
  24. {
  25. long int gdb_file_size();
  26. char * xmalloc();
  27. void gdb_file_begin();
  28. void gdb_file_read();
  29. void gdb_block_begin();
  30. void gdb_symbols_begin();
  31. gdb_file_begin();
  32. size = 0;
  33. if (filename && (size = gdb_file_size (filename)))
  34. {
  35. where = xmalloc( (long) size );
  36. gdb_file_read (where, filename); /* Read, then close file. */
  37. gdb_block_begin();
  38. gdb_symbols_begin();
  39. }
  40. return (size);
  41. }
  42. void
  43. gdb_end()
  44. {
  45. void gdb_file_end();
  46. gdb_file_end();
  47. }
  48. void
  49. gdb_emit (filename) /* Append GDB symbols to object file. */
  50. char * filename;
  51. {
  52. void gdb_block_emit();
  53. void gdb_symbols_emit();
  54. void gdb_lines_emit();
  55. void output_file_append();
  56. gdb_block_emit ();
  57. gdb_symbols_emit ();
  58. gdb_lines_emit();
  59. output_file_append (where, size, filename);
  60. }
  61. /*
  62. Notes: We overwrite what was there.
  63. We assume all overwrites are 4-char numbers.
  64. */
  65. void
  66. gdb_alter (offset, value) /* put value into GDB file + offset. */
  67. long int offset;
  68. long int value;
  69. {
  70. void md_number_to_chars();
  71. #ifdef SUSPECT
  72. if (offset > size - sizeof(long int) || offset < 0)
  73. {
  74. as_warn( "gdb_alter: offset=%d. size=%ld.\n", offset, size );
  75. }
  76. else
  77. {
  78. #endif
  79. md_number_to_chars (where + offset, value, 4);
  80. #ifdef SUSPECT
  81. }
  82. #endif
  83. }
  84. /* end: gdb.c */