<commit_before>/**
 * @file
 * @brief TODO: brief
 *
 * @date 24 Aug, 2012
 * @author <NAME>
 */

#include <stdio.h>
#include <asm/stack.h>

struct stackframe {
	void* fp;
	void* pc;
	struct stack_frame* sf;
};

// TODO: __builtin_extract_return_address!!!
void stackframe_set_current(struct stackframe* f) {
	f->fp = __builtin_frame_address(0);
	f->pc = __builtin_return_address(0);
	f->sf = NULL;
}

// TODO: May be add type of previous: through interruption or not?
// TODO: __builtin_extract_return_address!!!
int stackframe_set_prev(struct stackframe *f) {
	f->sf = f->fp;
	f->fp = f->sf->reg_window.fp;
	if (f->fp == NULL) {
		f->pc = NULL;
		f->sf = NULL;
		return 0;
	}
	f->pc = f->sf->reg_window.ret_pc;

	return 1;
}

void reg_window_print(struct reg_window* rw) {
    printk("%%L: %08x %08x  %08x %08x  %08x %08x  %08x %08x\n",
                    rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
                    rw->locals[4], rw->locals[5], rw->locals[6], rw->locals[7]);
    printk("%%I: %08x %08x  %08x %08x  %08x %08x  %08x %08x\n",
                    rw->ins[0], rw->ins[1], rw->ins[2], rw->ins[3],
                    rw->ins[4], rw->ins[5], (uint32_t) rw->fp, (uint32_t) rw->ret_pc);
}

void stackframe_print(struct stackframe* f) {
	printk("frame_address = 0x%p, return_address = 0x%p  \n", f->fp, f->pc);
	if (f->sf != NULL) {
        reg_window_print(&f->sf->reg_window);
	}
    printk("\n");
}
<commit_msg>backtrace: Add 8 to return_address in SPARC arch<commit_after>/**
 * @file
 * @brief TODO: brief
 *
 * @date 24 Aug, 2012
 * @author <NAME>
 */

#include <stdio.h>
#include <asm/stack.h>

#define RET_ADDR_SHIFT 8

struct stackframe {
	void* fp;
	void* pc;
	struct stack_frame* sf;
};

void stackframe_set_current(struct stackframe* f) {
	f->fp = __builtin_frame_address(0);
	f->pc = __builtin_return_address(0) + RET_ADDR_SHIFT;
	f->sf = NULL;
}

// TODO: May be add type of previous: through interruption or not?
int stackframe_set_prev(struct stackframe *f) {
	f->sf = f->fp;
	f->fp = f->sf->reg_window.fp;
	if (f->fp == NULL) {
		f->pc = NULL;
		f->sf = NULL;
		return 0;
	}
	f->pc = f->sf->reg_window.ret_pc + RET_ADDR_SHIFT;

	return 1;
}

void reg_window_print(struct reg_window* rw) {
    printk("%%L: %08x %08x  %08x %08x  %08x %08x  %08x %08x\n",
                    rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
                    rw->locals[4], rw->locals[5], rw->locals[6], rw->locals[7]);
    printk("%%I: %08x %08x  %08x %08x  %08x %08x  %08x %08x\n",
                    rw->ins[0], rw->ins[1], rw->ins[2], rw->ins[3],
                    rw->ins[4], rw->ins[5], (uint32_t) rw->fp, (uint32_t) rw->ret_pc);
}

void stackframe_print(struct stackframe* f) {
	printk("frame_address = 0x%p, return_address = 0x%p  \n", f->fp, f->pc);
	if (f->sf != NULL) {
        reg_window_print(&f->sf->reg_window);
	}
    printk("\n");
}

{'fraction_non_alphanumeric': 0.19550949913644214, 'fraction_numerical': 0.043523316062176166, 'mean_word_length': 3.0560224089635852, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4618494', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1223, 'n_words': 260}