Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
demoitem committed Oct 25, 2023
1 parent 5a2fa57 commit 88372d6
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions m3-libs/m3core/src/runtime/AMD64_LINUX/RTStackC.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ extern "C" {
#define EHObjRegNo 0
#define EHTypeRegNo 1

//Obsolete defs used with LatchEHReg
//#define REG "rax"
//#define EHRegNo 1
//#define REG "rdx"

//declare a personality function
void * __m3_personality_v0();

Expand Down Expand Up @@ -58,7 +53,7 @@ extern char * RTException__AllocBuf(int size);
typedef struct {
unsigned long pc;
unsigned long sp;
unsigned long bp;
unsigned long bp; //not used
long lock;
unsigned long exceptionRef;
long tTypeIndex;
Expand Down Expand Up @@ -144,7 +139,7 @@ void RTStack__CurFrame (Frame *f)
{
unw_context_t *uc;
unw_cursor_t *cursor;
unw_word_t ip, sp, bp = 0;
unw_word_t ip, sp = 0;

//we alloc in m3 otherwise a serious memory leak
//uc = (unw_context_t *) malloc(sizeof(unw_context_t));
Expand All @@ -158,13 +153,9 @@ void RTStack__CurFrame (Frame *f)
unw_get_reg(cursor, UNW_REG_IP, &ip);
unw_get_reg(cursor, UNW_REG_SP, &sp);

//if using the copy exception model must use bp for stack pointer
//unw_get_reg(cursor, UNW_X86_64_RBP, &bp);

f->cursor = cursor;
f->pc = ip;
f->sp = sp;
f->bp = bp;
RTStack__GetProcInfo(f);

if (f->lock != FrameLock) abort ();
Expand All @@ -178,7 +169,7 @@ void RTStack__CurFrame (Frame *f)

void RTStack__PrevFrame (Frame* callee, Frame* caller)
{
unw_word_t ip, sp, bp = 0;
unw_word_t ip, sp = 0;
int res;

if (!callee->cursor) abort();
Expand All @@ -191,18 +182,13 @@ void RTStack__PrevFrame (Frame* callee, Frame* caller)
unw_get_reg(caller->cursor, UNW_REG_IP, &ip);
unw_get_reg(caller->cursor, UNW_REG_SP, &sp);

//if using the copy exception model must use bp for stack pointer
//unw_get_reg(caller->cursor, UNW_X86_64_RBP, &bp);

caller->pc = ip;
caller->sp = sp;
caller->bp = bp;
RTStack__GetProcInfo(caller);

} else {
caller->pc = 0;
caller->sp = 0;
caller->bp = 0;
}
if (caller->lock != FrameLock) abort ();
}
Expand All @@ -220,16 +206,14 @@ void RTStack__Unwind (Frame *target)
if (!target->cursor) abort();
if (target->lock != FrameLock) abort ();

//for the copy exc model we have to disable the 2 set regs below
//
//set the IP to landingPad
unw_set_reg(target->cursor, UNW_REG_IP, target->landingPad);

//set the eh register zero to return the exception object
unw_set_reg(target->cursor,
__builtin_eh_return_data_regno(EHObjRegNo),
target->exceptionRef);
//

//set the eh register one to the tTypeIndex for gcc
unw_set_reg(target->cursor,
__builtin_eh_return_data_regno(EHTypeRegNo),
Expand All @@ -243,18 +227,6 @@ void RTStack__Unwind (Frame *target)
}
}

/*
* Latch the exception pointer from the builtin eh reg
* This is defined as int* but we are just returning a pointer
* of size address.
* - obsolete - used in building versions before introduction of landingpad
*/
int *RTStack__LatchEHReg() {
// register int *ehReg asm(REG);
// return ehReg;
}


/*
//a test of generating a backtrace with libunwind.
//
Expand Down

0 comments on commit 88372d6

Please sign in to comment.