home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / gcc / bug / 2298 < prev    next >
Encoding:
Internet Message Format  |  1992-09-09  |  5.5 KB

  1. Path: sparky!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!watson.ibm.com!rocky
  2. From: rocky@watson.ibm.com (Rocky Bernstein)
  3. Newsgroups: gnu.gcc.bug
  4. Subject: romp-ibm-aos debug table offset info
  5. Message-ID: <9209091914.AA18786@rs6ktext.watson.ibm.com>
  6. Date: 9 Sep 92 11:14:43 GMT
  7. Sender: gnulists@ai.mit.edu
  8. Reply-To: rocky@watson.ibm.com
  9. Distribution: gnu
  10. Organization: GNUs Not Usenet
  11. Lines: 133
  12. Approved: bug-gcc@prep.ai.mit.edu
  13.  
  14. I've been trying to get dbx on the RT/PC AOS to understand gcc 2.2.1's
  15. output. The call trace back seems to be wrong often, unless one is in
  16. the prolog code. gcc 2.2.1's romp.c code is slightly simplistic about
  17. the offset information that it encodes in the debug table at the end
  18. of a procedure.
  19.  
  20. Here is the line from output_epilog in romp.c used
  21. to write this information when there is a frame:
  22.     fprintf (file, "\t.byte 0x%xd, 53\n", nargs);
  23.  
  24. >From my understanding of the how the debug offset info is encoded,
  25. this is interpreted as follows:
  26.    There are nargs passed to the routine; THE FRAME POINTER IS R13;
  27.    THE DISTANCE BETWEEN THE CURRENT AND PREVIOUS FRAME POINTERS
  28.    IS 53*4 BYTES.
  29.  
  30. The last of two pieces of information I think are (often, probably)
  31. wrong: the frame pointer for gcc on romp is r1, although r13 could
  32. conceivably be used as well. The problem with using r13 is that dbx
  33. (and perhaps other debuggers) check to see if the program is in a
  34. subroutine prolog; if so, they use r1 for addressing the stack.
  35. Thus, a scheme that is to work the same in the subroutine prolog or
  36. not, must use r1.
  37.  
  38. The other problem with the romp code is the fact that
  39. the distance between frame pointers is not always 212
  40. bytes. (In fact, it rarely is). Better would be to consult the
  41. variable total_size in output_epilog for the number of bytes between
  42. the current and previous frame pointers.
  43.  
  44. At the end the diffs that I made to correct this. The comments give
  45. my understanding of the funny way that the offset information is
  46. encoded.
  47.  
  48. There is one problem with the below code. It requires that stabs
  49. entries for local variables be changed by a constant value. (But from
  50. what I've seen, as things stand the stabs entries are probably wrong
  51. too.)  In the scheme below, the first local would have offest -4
  52. rather than something like 60 as is now the case.
  53.  
  54. I'd like to make this change and test it out, but I don't see how to
  55. do it in the right way.
  56.  
  57. 1) Is anyone any using debuggers with gcc 2.2.1 on romp-ibm-aos?
  58. Do they work?
  59.  
  60. 2) How do I tell gcc what value to start with for a local offset in
  61. the stabs entry?
  62.  
  63. Thanks,
  64.  
  65. R. Bernstein
  66.  
  67. diff romp.c romp.c.orig
  68. 1078a1079
  69. >   rtx insn;
  70. 1126,1183d1126
  71. < /* output offset information used by debuggers.
  72. <
  73. <    This is the exactly the total_size value of output_epilog
  74. <    which is added to the frame pointer. However the value in the debug
  75. <    table is encoded in a funny, space-saving way as follows:
  76. <
  77. <    The first byte contains two fields: a 2-bit size field and the first
  78. <    6 bits of an offset value. The 2-bit size field is in the
  79. <    high-order position and specifies how many subsequent bytes follow after
  80. <    this one. An offset value is at most 4-bytes long.
  81. <
  82. <    The last 6 bits of the first byte start the offset value. In many cases,
  83. <    where procedures have small local storage this is enough. Note that in
  84. <    this case the high-order size field is zero so the byte can (almost) be
  85. <    used as is (see below). Thus, the byte value of 0x0d is encodes a offset
  86. <    size of 13 words, or 52 bytes.
  87. <
  88. <    For procedures with a local space larger than 60 bytes, the 6 bits
  89. <    is the high-order 6 bits. The remaining bytes follow in Big Endian order
  90. <    as necessary. Thus, the short value of 16907 (= 16384+523) encodes an
  91. <    offset of 2092 bytes (523 words).
  92. <     
  93. <    The total offset value is in words (not bytes), so the end value
  94. <    has to be multiplied by 4 before it can be used in address
  95. <    computations by a debugger. I suppose that using by word units rather
  96. <    than bytes the space taken up by 2-bit length field
  97. <    at the beginning is compensated for.
  98. < */
  99. <
  100. < void output_encoded_offset(file, reg_offset)
  101. <      FILE *file;
  102. <      int reg_offset;
  103. < {
  104. <   /* Convert the offset value to 4-byte words rather than bytes. */
  105. <   reg_offset >>= 2;
  106. <
  107. <   /* Now output 1-4 bytes in encoded form. */
  108. <   if (reg_offset < (1<<6)) {
  109. <     /* Fits into one byte */
  110. <     fprintf(file, "\t.byte %d\n", reg_offset);
  111. <     }
  112. <   else if (reg_offset < (1<<(6+8))) {
  113. <     /* Fits into two bytes */
  114. <     fprintf(file, "\t.short %d\n", (1<<(6+8)) + reg_offset);
  115. <   }
  116. <   else if (reg_offset < (1<<(6+8+8))) {
  117. <     /* Fits in three bytes */
  118. <     fprintf(file, "\t.byte %d\n", (2<<6) + (reg_offset >> (6+8)));
  119. <     fprintf(file, "\t.short %d\n", reg_offset % (1<<(6+8)));
  120. <   }
  121. <   else {
  122. <     /* Better fit in 4 bytes */
  123. <     fprintf(file, "\t.short %d", (3<<(6+8)) + (reg_offset >> (6+8)));
  124. <     fprintf(file, "\t.short %d\n", reg_offset % (1<<(6+8)));
  125. <   }
  126. < }
  127. <
  128. <
  129. 1247,1249d1189
  130. <
  131. <       /* debug table info:
  132. <      table header, usual-type stack frame, and first register saved. */
  133. 1253,1259c1193,1194
  134. <
  135. <       /* debug table info: the number of parameter words
  136. <      and the register used as the frame pointer (r1). */
  137. <       if (frame_pointer_needed) {
  138. <     fprintf (file, "\t.byte 0x%x1\n", nargs);
  139. <     output_encoded_offset(file, total_size);
  140. <       }
  141. ---
  142. >       if (frame_pointer_needed)
  143. >     fprintf (file, "\t.byte 0x%xd, 53\n", nargs);
  144. 1267,1268d1201
  145. <       /* debug table info:
  146. <      table header, no stack frame, and no parameters saved. */
  147.