Changeset 14977


Ignore:
Timestamp:
Sep 9, 2011, 3:14:48 PM (13 years ago)
Author:
R. Matthew Emerson
Message:

In print_lisp_frame(), when we're looking at an exception
callback frame, try to figure out and print the relative
pc of the function.

A new function pc_from_xcf(), patterend after the similarly
named lisp function, does the dirty work. It does not yet try
to decode the case where the nominal function and the containing
object are not the same thing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/xlbt.c

    r14619 r14977  
    1919#include <signal.h>
    2020
    21 
     21static LispObj
     22function_to_function_vector(LispObj f)
     23{
     24#ifdef X8664
     25  return f - fulltag_function + fulltag_misc;
     26#else
     27  return f;
     28#endif
     29}
     30
     31static Boolean
     32functionp(LispObj f)
     33{
     34#ifdef X8664
     35  return fulltag_of(f) == fulltag_function;
     36#else
     37  return fulltag_of(f) == fulltag_misc &&
     38    header_subtag(header_of(f)) == subtag_function;
     39#endif
     40}
     41
     42static LispObj
     43tra_function(LispObj tra)
     44{
     45  LispObj f = 0;
     46
     47#ifdef X8664
     48  if (tag_of(tra) == tag_tra) {
     49    if ((*((unsigned short *)tra) == RECOVER_FN_FROM_RIP_WORD0) &&
     50        (*((unsigned char *)(tra+2)) == RECOVER_FN_FROM_RIP_BYTE2)) {
     51      int sdisp = (*(int *) (tra+3));
     52      f = RECOVER_FN_FROM_RIP_LENGTH+tra+sdisp;
     53    }
     54  }
     55#else
     56  if (fulltag_of(tra) == fulltag_tra) {
     57    if (*((unsigned char *)tra) == RECOVER_FN_OPCODE) {
     58      natural n = *((natural *)(tra + 1));
     59      f = (LispObj)n;
     60    }
     61  }
     62#endif
     63  return f;
     64}
     65
     66#if 0
     67/* untested */
     68static int
     69tra_offset(LispObj tra)
     70{
     71#ifdef X8664
     72  if (tag_of(tra) == tag_tra) {
     73    if ((*((unsigned short *)tra) == RECOVER_FN_FROM_RIP_WORD0) &&
     74        (*((unsigned char *)(tra+2)) == RECOVER_FN_FROM_RIP_BYTE2)) {
     75      int sdisp = (*(int *) (tra+3));
     76
     77      sdisp = - sdisp;
     78      sdisp -= RECOVER_FN_FROM_RIP_LENGTH;
     79      return sdisp;
     80    }
     81  }
     82#else
     83  if (fulltag_of(tra) == fulltag_tra) {
     84    if (*((unsigned char *)tra) == RECOVER_FN_OPCODE) {
     85      int n = *((int *)(tra + 1));
     86      n = n - tra;
     87      n = -n;
     88      return n;
     89    }
     90  }
     91#endif
     92  return 0;
     93}
     94#endif
     95
     96natural
     97pc_from_xcf(xcf *xcf)
     98{
     99  if (functionp(xcf->nominal_function)) {
     100    LispObj fv = function_to_function_vector(xcf->nominal_function);
     101    if (fv == xcf->containing_uvector) {
     102      unsigned tag;
     103
     104#ifdef X8664
     105      tag = tag_function;
     106#else
     107      tag = fulltag_misc;
     108#endif
     109      return unbox_fixnum(xcf->relative_pc) - tag;
     110    } else {
     111      LispObj tra = xcf->ra0;
     112      LispObj f = tra_function(tra);
     113
     114      if (f && f == xcf->nominal_function)
     115        return 0; /* punt for now */
     116    }
     117  }
     118  return 0;
     119}
    22120
    23121void
     
    43141  }
    44142  if (pc == 0) {
     143    natural rpc = pc_from_xcf((xcf *)frame);
     144
    45145    fun = ((xcf *)frame)->nominal_function;
    46     Dprintf("(#x%08X) #x%08X : %s + ??", frame, pc, print_lisp_object(fun));
     146    fprintf(dbgout, "(#x%08X) #x%08X : %s + ", frame, pc,
     147            print_lisp_object(fun));
     148    if (rpc)
     149      fprintf(dbgout, "%d\n", rpc);
     150    else
     151      fprintf(dbgout, "??\n", rpc);
    47152    return;
    48153  }
     
    61166  }
    62167  if (pc == 0) {
     168    natural rpc = pc_from_xcf((xcf *)frame);
     169
    63170    fun = ((xcf *)frame)->nominal_function;
    64     Dprintf("(#x%016lX) #x%016lX : %s + ??", frame, pc, print_lisp_object(fun));
     171    fprintf(dbgout, "(#x%016lX) #x%016lX : %s + ", frame, pc,
     172            print_lisp_object(fun));
     173    if (rpc)
     174      fprintf(dbgout, "%d\n", rpc);
     175    else
     176      fprintf(dbgout, "??\n");
    65177    return;
    66178  }
Note: See TracChangeset for help on using the changeset viewer.