Skip to content
Snippets Groups Projects
Commit eea0dd4e authored by Oleg Hahm's avatar Oleg Hahm Committed by GitHub
Browse files

Merge pull request #5681 from LudwigKnuepfer/pr/fix-5664

cpu/native: rewrite cpu_print_last_instruction
parents b5cb68bd 49e76997
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,9 @@ static int crashed = 0;
/* WARNING: this function NEVER returns! */
NORETURN void core_panic(core_panic_t crash_code, const char *message)
{
#ifdef NDEBUG
(void) crash_code;
#endif
if (crashed == 0) {
/* print panic message to console (if possible) */
......
/*
* Copyright (C) 2013 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
* Copyright (C) 2013 - 2016 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
......@@ -27,13 +27,14 @@ extern "C" {
#endif
/**
* @brief Prints the last instruction's address
* @brief Prints the address the callee will return to
*/
static inline void cpu_print_last_instruction(void)
__attribute__((always_inline)) static inline void cpu_print_last_instruction(void)
{
void *p;
__asm__("1: mov 1b, %0" : "=r" (p));
printf("%p\n", p);
/* __builtin_return_address will return the address the calling function
* will return to - since cpu_print_last_instruction is forced inline,
* it is the return address of the user of this function */
printf("%p\n", __builtin_return_address(0));
}
#ifdef __cplusplus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment