Skip to content
Snippets Groups Projects
Commit 548945a3 authored by cshapiro's avatar cshapiro
Browse files

Use longs to hold pointer values. Eliminates truncation on 64-bit

systems and a compiler warning on 32-bit systems.
parent ba775ff3
No related branches found
No related tags found
No related merge requests found
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/backtrace.c,v 1.14 2005/09/15 18:26:51 rtoy Exp $ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/backtrace.c,v 1.15 2008/03/21 10:41:43 cshapiro Exp $
* *
* Simple backtrace facility. More or less from Rob's lisp version. * Simple backtrace facility. More or less from Rob's lisp version.
*/ */
...@@ -257,12 +257,12 @@ stack_pointer_p(unsigned long p) ...@@ -257,12 +257,12 @@ stack_pointer_p(unsigned long p)
} }
static int static int
ra_pointer_p(unsigned ra) ra_pointer_p(unsigned long ra)
{ {
return ra > 4096 && !stack_pointer_p(ra); return ra > 4096 && !stack_pointer_p(ra);
} }
static unsigned static unsigned long
deref(unsigned long p, int offset) deref(unsigned long p, int offset)
{ {
return *((unsigned long *) p + offset); return *((unsigned long *) p + offset);
...@@ -329,9 +329,9 @@ print_entry_points(struct code *code) ...@@ -329,9 +329,9 @@ print_entry_points(struct code *code)
/* See also X86-CALL-CONTEXT in code:debug-int. */ /* See also X86-CALL-CONTEXT in code:debug-int. */
static int static int
x86_call_context(unsigned fp, unsigned *ra, unsigned *ocfp) x86_call_context(unsigned long fp, unsigned long *ra, unsigned long *ocfp)
{ {
unsigned lisp_ocfp, lisp_ra, c_ocfp, c_ra; unsigned long lisp_ocfp, lisp_ra, c_ocfp, c_ra;
int lisp_valid_p, c_valid_p; int lisp_valid_p, c_valid_p;
if (!stack_pointer_p(fp)) if (!stack_pointer_p(fp))
...@@ -348,7 +348,7 @@ x86_call_context(unsigned fp, unsigned *ra, unsigned *ocfp) ...@@ -348,7 +348,7 @@ x86_call_context(unsigned fp, unsigned *ra, unsigned *ocfp)
&& ra_pointer_p(c_ra)); && ra_pointer_p(c_ra));
if (lisp_valid_p && c_valid_p) { if (lisp_valid_p && c_valid_p) {
unsigned lisp_path_fp, c_path_fp, dummy; unsigned long lisp_path_fp, c_path_fp, dummy;
int lisp_path_p = x86_call_context(lisp_ocfp, &lisp_path_fp, &dummy); int lisp_path_p = x86_call_context(lisp_ocfp, &lisp_path_fp, &dummy);
int c_path_p = x86_call_context(c_ocfp, &c_path_fp, &dummy); int c_path_p = x86_call_context(c_ocfp, &c_path_fp, &dummy);
...@@ -413,8 +413,8 @@ array_of_type_p(lispobj obj, int type) ...@@ -413,8 +413,8 @@ array_of_type_p(lispobj obj, int type)
struct compiled_debug_function * struct compiled_debug_function *
debug_function_from_pc(struct code *code, unsigned long pc) debug_function_from_pc(struct code *code, unsigned long pc)
{ {
unsigned code_header_len = sizeof(lispobj) * HeaderValue(code->header); unsigned long code_header_len = sizeof(lispobj) * HeaderValue(code->header);
unsigned offset = pc - (unsigned) code - code_header_len; unsigned long offset = pc - (unsigned long) code - code_header_len;
if (LowtagOf(code->debug_info) == type_InstancePointer) { if (LowtagOf(code->debug_info) == type_InstancePointer) {
struct compiled_debug_info *di struct compiled_debug_info *di
...@@ -423,7 +423,7 @@ debug_function_from_pc(struct code *code, unsigned long pc) ...@@ -423,7 +423,7 @@ debug_function_from_pc(struct code *code, unsigned long pc)
if (array_of_type_p(di->function_map, type_SimpleVector)) { if (array_of_type_p(di->function_map, type_SimpleVector)) {
struct vector *v = (struct vector *) PTR(di->function_map); struct vector *v = (struct vector *) PTR(di->function_map);
int i, len = fixnum_value(v->length); long i, len = fixnum_value(v->length);
struct compiled_debug_function *df struct compiled_debug_function *df
= (struct compiled_debug_function *) PTR(v->data[0]); = (struct compiled_debug_function *) PTR(v->data[0]);
...@@ -433,7 +433,7 @@ debug_function_from_pc(struct code *code, unsigned long pc) ...@@ -433,7 +433,7 @@ debug_function_from_pc(struct code *code, unsigned long pc)
int elsewhere_p = offset >= fixnum_value(df->elsewhere_pc); int elsewhere_p = offset >= fixnum_value(df->elsewhere_pc);
for (i = 1;; i += 2) { for (i = 1;; i += 2) {
unsigned next_pc; unsigned long next_pc;
if (i == len) if (i == len)
return ((struct compiled_debug_function *) return ((struct compiled_debug_function *)
...@@ -467,15 +467,14 @@ debug_function_from_pc(struct code *code, unsigned long pc) ...@@ -467,15 +467,14 @@ debug_function_from_pc(struct code *code, unsigned long pc)
void void
backtrace(int nframes) backtrace(int nframes)
{ {
unsigned fp; unsigned long fp;
int i; int i;
asm("movl %%ebp,%0":"=g"(fp)); asm("movl %%ebp,%0":"=g"(fp));
for (i = 0; i < nframes; ++i) { for (i = 0; i < nframes; ++i) {
lispobj *p; lispobj *p;
unsigned long ra; unsigned long ra, next_fp;
unsigned next_fp;
if (!x86_call_context(fp, &ra, &next_fp)) if (!x86_call_context(fp, &ra, &next_fp))
break; break;
...@@ -495,7 +494,7 @@ backtrace(int nframes) ...@@ -495,7 +494,7 @@ backtrace(int nframes)
} else if (p) } else if (p)
printf("<Not implemented, type = %d>", (int) TypeOf(*p)); printf("<Not implemented, type = %d>", (int) TypeOf(*p));
else else
printf("Foreign fp = 0x%x, ra = 0x%lx", next_fp, ra); printf("Foreign fp = 0x%lx, ra = 0x%lx", next_fp, ra);
putchar('\n'); putchar('\n');
fp = next_fp; fp = next_fp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment