<commit_before>/**
 * @file stack_iter.c
 * @brief 
 * @author <NAME> <<EMAIL>>
 * @version 0.1
 * @date 2016-02-29
 */

#include <stddef.h>

#include <hal/context.h>
#include <util/lang.h>
#include <util/math.h>

#include "stack_iter.h"

void stack_iter_context(stack_iter_t *f, struct context *ctx) {
}

void stack_iter_current(stack_iter_t *f) {
}

int stack_iter_next(stack_iter_t *f) {
	return 0;
}

void *stack_iter_get_fp(stack_iter_t *f) {
	return NULL;
}

void *stack_iter_get_retpc(stack_iter_t *f) {
	return NULL;
}<commit_msg>(arm) stack_iter: Implement getting current stack<commit_after>/**
 * @file stack_iter.c
 * @brief 
 * @author <NAME> <<EMAIL>>
 * @version 0.1
 * @date 2016-02-29
 */

#include <stddef.h>

#include <hal/context.h>
#include <util/lang.h>
#include <util/math.h>

#include "stack_iter.h"

void stack_iter_context(stack_iter_t *f, struct context *ctx) {
}

void stack_iter_current(stack_iter_t *f) {
	__asm__ __volatile__ (
		"mov %[fp], FP\n\t"
		"mov %[lr], LR\n\t"
		"mov %[pc], PC\n\t"
		: [fp]"=r"(f->fp),
		  [lr]"=r"(f->lr),
		  [pc]"=r"(f->pc) : :
	);
	
	/* We can't just take those registers
	 * because caller requests _his_ context,
	 * not the context of stack_iter_current(),
	 * so we have to make one unwind operation
	 * by hand */

	f->fp = (void*) *((int*)f->fp - 3);
	f->pc = (void*) *((int*)f->fp);
	f->lr = (void*) *((int*)f->fp - 1);
	f->fp = (void*) *((int*)f->fp - 3);
}

int stack_iter_next(stack_iter_t *f) {
	return 0;
}

void *stack_iter_get_fp(stack_iter_t *f) {
	return NULL;
}

void *stack_iter_get_retpc(stack_iter_t *f) {
	return NULL;
}
{'fraction_non_alphanumeric': 0.18940809968847352, 'fraction_numerical': 0.01557632398753894, 'mean_word_length': 4.0344827586206895, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 28, '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': '3813393', 'n_tokens_mistral': 731, 'n_tokens_neox': 684, 'n_words': 150}