• Andrew Morton's avatar
    [PATCH] show_stack() portability and cleanup patch · 0d5ff9d0
    Andrew Morton authored
    From: David Mosberger <davidm@napali.hpl.hp.com>
    
    This is an attempt at sanitizing the interface for stack trace dumping
    somewhat.  It's basically the last thing which prevents 2.5.x from working
    out-of-the-box for ia64.  ia64 apparently cannot reasonably implement the
    show_stack interface declared in sched.h.
    
    Here is the rationale: modern calling conventions don't maintain a frame
    pointer and it's not possible to get a reliable stack trace with only a stack
    pointer as the starting point.  You really need more machine state to start
    with.  For a while, I thought the solution is to pass a task pointer to
    show_stack(), but it turns out that this would negatively impact x86 because
    it's sometimes useful to show only portions of a stack trace (e.g., starting
    from the point at which a trap occurred).  Thus, this patch _adds_ the task
    pointer instead:
    
     extern void show_stack(struct task_struct *tsk, unsigned long *sp);
    
    The idea here is that show_stack(tsk, sp) will show the backtrace of task
    "tsk", starting from the stack frame that "sp" is pointing to.  If tsk is
    NULL, the trace will be for the current task.  If "sp" is NULL, all stack
    frames of the task are shown.  If both are NULL, you'll get the full trace of
    the current task.
    
    I _think_ this should make everyone happy.
    
    The patch also removes the declaration of show_trace() in linux/sched.h (it
    never was a generic function; some platforms, in particular x86, may want to
    update accordingly).
    
    Finally, the patch replaces the one call to show_trace_task() with the
    equivalent call show_stack(task, NULL).
    
    The patch below is for Alpha and i386, since I can (compile-)test those (I'll
    provide the ia64 update through my regular updates).  The other arches will
    break visibly and updating the code should be trivial:
    
    - add a task pointer argument to show_stack() and pass NULL as the first
      argument where needed
    
    - remove show_trace_task()
    
    - declare show_trace() in a platform-specific header file if you really
      want to keep it around
    0d5ff9d0
sched.c 62.1 KB