Skip to content

Commit

Permalink
core/stack: Rename backtrace functions, get rid of wrappers
Browse files Browse the repository at this point in the history
Rename ___backtrace() to backtrace_create() and ___print_backtrace() to
backtrace_print(). Get rid of __backtrace() and __print_backtrace()
wrappers.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
ajdlinux authored and stewartsmith committed Mar 28, 2019
1 parent e5a7411 commit b965b9d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
13 changes: 7 additions & 6 deletions core/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
static struct bt_entry bt_buf[STACK_BUF_ENTRIES];

/* Dumps backtrace to buffer */
void __nomcount ___backtrace(struct bt_entry *entries, unsigned int max_ents,
struct bt_metadata *metadata)
void __nomcount backtrace_create(struct bt_entry *entries,
unsigned int max_ents,
struct bt_metadata *metadata)
{
unsigned long *fp = __builtin_frame_address(0);
unsigned long top_adj = top_of_ram;
Expand Down Expand Up @@ -61,8 +62,8 @@ void __nomcount ___backtrace(struct bt_entry *entries, unsigned int max_ents,
metadata->pir = mfspr(SPR_PIR);
}

void ___print_backtrace(struct bt_entry *entries, struct bt_metadata *metadata,
char *out_buf, unsigned int *len, bool symbols)
void backtrace_print(struct bt_entry *entries, struct bt_metadata *metadata,
char *out_buf, unsigned int *len, bool symbols)
{
static char bt_text_buf[4096];
int i, l = 0, max;
Expand Down Expand Up @@ -127,8 +128,8 @@ void backtrace(void)

lock(&bt_lock);

___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata);
___print_backtrace(bt_buf, &metadata, NULL, NULL, true);
backtrace_create(bt_buf, STACK_BUF_ENTRIES, &metadata);
backtrace_print(bt_buf, &metadata, NULL, NULL, true);

unlock(&bt_lock);
}
Expand Down
4 changes: 2 additions & 2 deletions hw/fsp/fsp-attn.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ static void update_sp_attn_area(const char *msg)
cpu_to_be32((uint32_t)((uint64_t)__builtin_return_address(0) & 0xffffffff));

snprintf(ti_attn->msg.version, VERSION_LEN, "%s", version);
___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata);
backtrace_create(bt_buf, STACK_BUF_ENTRIES, &metadata);
metadata.token = OPAL_LAST + 1;
len = BT_FRAME_LEN;
___print_backtrace(bt_buf, &metadata, ti_attn->msg.bt_buf, &len, false);
backtrace_print(bt_buf, &metadata, ti_attn->msg.bt_buf, &len, false);
snprintf(ti_attn->msg.file_info, FILE_INFO_LEN, "%s", msg);

ti_attn->msg_len = VERSION_LEN + BT_FRAME_LEN +
Expand Down
5 changes: 2 additions & 3 deletions hw/ipmi/ipmi-attn.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ static void ipmi_log_terminate_event(const char *msg)
ti_size = IPMI_TI_BUFFER_SIZE - ti_len;

/* Backtrace */
___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata);
backtrace_create(bt_buf, STACK_BUF_ENTRIES, &metadata);
metadata.token = OPAL_LAST + 1;
___print_backtrace(bt_buf, &metadata, ti_buffer + ti_len, &ti_size,
true);
backtrace_print(bt_buf, &metadata, ti_buffer + ti_len, &ti_size, true);

/* Create eSEL event and commit */
elog_buf = opal_elog_create(&e_info(OPAL_RC_ATTN), 0);
Expand Down
32 changes: 5 additions & 27 deletions include/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,35 +125,13 @@ struct bt_metadata {
extern void *boot_stack_top;

/* Create a backtrace */
void ___backtrace(struct bt_entry *entries, unsigned int max_ents,
struct bt_metadata *metadata);

static inline void __backtrace(struct bt_entry *entries, unsigned int *count)
{
struct bt_metadata metadata;

___backtrace(entries, *count, &metadata);

*count = metadata.ents;
}
void backtrace_create(struct bt_entry *entries, unsigned int max_ents,
struct bt_metadata *metadata);

/* Convert a backtrace to ASCII */
extern void ___print_backtrace(struct bt_entry *entries,
struct bt_metadata *metadata, char *out_buf,
unsigned int *len, bool symbols);

static inline void __print_backtrace(unsigned int pir, struct bt_entry *entries,
unsigned int count, char *out_buf,
unsigned int *len, bool symbols)
{
struct bt_metadata metadata = {
.ents = count,
.token = OPAL_LAST + 1,
.r1_caller = 0,
.pir = pir
};
___print_backtrace(entries, &metadata, out_buf, len, symbols);
}
extern void backtrace_print(struct bt_entry *entries,
struct bt_metadata *metadata, char *out_buf,
unsigned int *len, bool symbols);

/* For use by debug code, create and print backtrace, uses a static buffer */
extern void backtrace(void);
Expand Down

0 comments on commit b965b9d

Please sign in to comment.