Module Name: src
Committed By: dholland
Date: Sun Jul 31 19:22:25 UTC 2016
Modified Files:
src/sys/arch/ia64/unwind: stackframe.c stackframe.h
Log Message:
KNF
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/unwind/stackframe.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ia64/unwind/stackframe.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/ia64/unwind/stackframe.c
diff -u src/sys/arch/ia64/unwind/stackframe.c:1.7 src/sys/arch/ia64/unwind/stackframe.c:1.8
--- src/sys/arch/ia64/unwind/stackframe.c:1.7 Sun Jul 31 19:12:41 2016
+++ src/sys/arch/ia64/unwind/stackframe.c Sun Jul 31 19:22:25 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: stackframe.c,v 1.7 2016/07/31 19:12:41 dholland Exp $ */
+/* $NetBSD: stackframe.c,v 1.8 2016/07/31 19:22:25 dholland Exp $ */
/* Contributed to the NetBSD foundation by Cherry G. Mathew <[email protected]>
* This file contains routines to use decoded unwind descriptor entries
@@ -19,21 +19,21 @@
//#define UNWIND_DIAGNOSTIC
-/* Global variables:
- array of struct recordchain
- size of record chain array.
-*/
+/*
+ * Global variables:
+ * array of struct recordchain
+ * size of record chain array.
+ */
struct recordchain strc[MAXSTATERECS];
int rec_cnt = 0;
-/* Build a recordchain of a region, given the pointer to unwind table
+/*
+ * Build a recordchain of a region, given the pointer to unwind table
* entry, and the number of entries to decode.
*/
-
-void buildrecordchain(uint64_t unwind_infop, struct recordchain *xxx)
+void
+buildrecordchain(uint64_t unwind_infop, struct recordchain *xxx)
{
-
-
uint64_t unwindstart, unwindend;
uint64_t unwindlen;
uint64_t region_len = 0;
@@ -76,7 +76,8 @@ void buildrecordchain(uint64_t unwind_in
if ((nextrecp = unwind_decode_R2(recptr, &strc[rec_cnt].udesc))){
region_len = strc[rec_cnt].udesc.R2.rlen;
- region_type = false; /* R2 regions are prologue regions */
+ /* R2 regions are prologue regions */
+ region_type = false;
strc[rec_cnt].type = R2;
recptr = nextrecp;
continue;
@@ -90,7 +91,8 @@ void buildrecordchain(uint64_t unwind_in
continue;
}
- if(region_type == false) { /* Prologue Region */
+ if(region_type == false) {
+ /* Prologue Region */
if ((nextrecp = unwind_decode_P1(recptr, &strc[rec_cnt].udesc))){
strc[rec_cnt].type = P1;
recptr = nextrecp;
@@ -208,8 +210,6 @@ void buildrecordchain(uint64_t unwind_in
}
printf("Skipping body desc slot :: %d \n", rec_cnt);
-
-
}
}
@@ -220,20 +220,20 @@ void buildrecordchain(uint64_t unwind_in
}
#endif /* UNWIND_DIAGNOSTIC */
-
}
-/* Debug support: dump a record chain entry */
-void dump_recordchain(struct recordchain *rchain)
+/*
+ * Debug support: dump a record chain entry
+ */
+void
+dump_recordchain(struct recordchain *rchain)
{
switch(rchain->type) {
case R1:
-
-
printf("\t R1:");
if(rchain->udesc.R1.r)
printf("body (");
@@ -574,12 +574,14 @@ void dump_recordchain(struct recordchain
}
-/* State record stuff..... based on section 11. and Appendix A. of the
- *"Itanium Software Conventions and Runtime Architecture Guide"
+/*
+ * State record stuff..... based on section 11. and Appendix A. of the
+ * "Itanium Software Conventions and Runtime Architecture Guide"
*/
-/* Global variables:
+/*
+ * Global variables:
* 1. Two arrays of staterecords: recordstack[], recordstackcopy[]
* XXX: Since we don't use malloc, we have two arbitrary sized arrays
* providing guaranteed memory from the BSS. See the TODO file
@@ -593,12 +595,13 @@ struct staterecord current_state;
struct staterecord *unwind_rsp, *unwind_rscp;
-uint64_t spill_base = 0; /* Base of spill area in memory stack frame as a psp relative offset */
+/* Base of spill area in memory stack frame as a psp relative offset */
+uint64_t spill_base = 0;
-/* Initialises a staterecord from a given template,
+/*
+ * Initialises a staterecord from a given template,
* with default values as described by the Runtime Spec.
*/
-
void
initrecord(struct staterecord *target)
{
@@ -617,27 +620,27 @@ initrecord(struct staterecord *target)
}
-/* Modifies a staterecord structure by parsing
+/*
+ * Modifies a staterecord structure by parsing
* a single record chain structure.
* regionoffset is the offset within a (prologue) region
* where the stack unwinding began.
*/
-
-void modifyrecord(struct staterecord *srec, struct recordchain *rchain,
- uint64_t regionoffset)
+void
+modifyrecord(struct staterecord *srec, struct recordchain *rchain,
+ uint64_t regionoffset)
{
-
-
- uint64_t grno = 32; /* Default start save GR for prologue_save
- * GRs.
- */
-
+ /*
+ * Default start save GR for prologue_save GRs.
+ */
+ uint64_t grno = 32;
switch (rchain->type) {
case R2:
- /* R2, prologue_gr is the only region encoding
+ /*
+ * R2, prologue_gr is the only region encoding
* with register save info.
*/
@@ -689,7 +692,8 @@ void modifyrecord(struct staterecord *sr
break;
- /* XXX: P4 spill_mask and P7: spill_base are for GRs, FRs, and BRs.
+ /*
+ * XXX: P4 spill_mask and P7: spill_base are for GRs, FRs, and BRs.
* We're not particularly worried about those right now.
*/
@@ -816,7 +820,8 @@ void modifyrecord(struct staterecord *sr
}
-void dump_staterecord(struct staterecord *srec)
+void
+dump_staterecord(struct staterecord *srec)
{
printf("rp.where: ");
switch(srec->rp.where) {
@@ -866,14 +871,14 @@ void dump_staterecord(struct staterecord
printf(", pfs.when = %lu, ", srec->pfs.when);
printf("pfs.offset = %lu \n", srec->pfs.offset);
-
-
}
-/* Push a state record on the record stack. */
-
-void pushrecord(struct staterecord *srec)
+/*
+ * Push a state record on the record stack.
+ */
+void
+pushrecord(struct staterecord *srec)
{
if(unwind_rsp >= recordstack + MAXSTATERECS) {
printf("Push exceeded array size!!! \n");
@@ -885,9 +890,11 @@ void pushrecord(struct staterecord *srec
}
-/* Pop n state records off the record stack. */
-
-void poprecord(struct staterecord *srec, int n)
+/*
+ * Pop n state records off the record stack.
+ */
+void
+poprecord(struct staterecord *srec, int n)
{
if(unwind_rsp == recordstack) {
printf("Popped beyond end of Stack!!! \n");
@@ -901,16 +908,22 @@ void poprecord(struct staterecord *srec,
}
-/* Clone the whole record stack upto this one. */
-void clonerecordstack(u_int label)
+/*
+ * Clone the whole record stack upto this one.
+ */
+void
+clonerecordstack(u_int label)
{
memcpy(recordstackcopy, recordstack,
(unwind_rsp - recordstack) * sizeof(struct staterecord));
unwind_rscp = unwind_rsp;
}
-/* Discard the current stack, and adopt a clone. */
-void switchrecordstack(u_int label)
+/*
+ * Discard the current stack, and adopt a clone.
+ */
+void
+switchrecordstack(u_int label)
{
memcpy((void *) recordstack, (void *) recordstackcopy,
(unwind_rscp - recordstackcopy) * sizeof(struct staterecord));
@@ -918,7 +931,8 @@ void switchrecordstack(u_int label)
}
-/* In the context of a procedure:
+/*
+ * In the context of a procedure:
* Parses through a record chain, building, pushing and/or popping staterecords,
* or cloning/destroying stacks of staterecords as required.
* Parameters are:
@@ -926,27 +940,32 @@ void switchrecordstack(u_int label)
* procoffset: offset of point of interest, in slots, within procedure starting from slot 0
* This routine obeys [1]
*/
-struct staterecord *buildrecordstack(struct recordchain *rchain, uint64_t procoffset)
+struct staterecord *
+buildrecordstack(struct recordchain *rchain, uint64_t procoffset)
{
-
uint64_t rlen = 0; /* Current region length, defaults to zero, if not specified */
uint64_t roffset = 0; /* Accumulated region length */
uint64_t rdepth = 0; /* Offset within current region */
bool rtype;
+ int i;
- unwind_rsp = recordstack; /* Start with bottom of staterecord stack. */
+ /* Start with bottom of staterecord stack. */
+ unwind_rsp = recordstack;
initrecord(¤t_state);
- int i;
-
-
for (i = 0;i < rec_cnt;i++) {
switch (rchain[i].type) {
case R1:
rlen = rchain[i].udesc.R1.rlen;
- if (procoffset < roffset) goto out; /* Overshot Region containing procoffset. Bailout. */
+ if (procoffset < roffset) {
+ /*
+ * Overshot Region containing
+ * procoffset. Bail out.
+ */
+ goto out;
+ }
rdepth = procoffset - roffset;
roffset += rlen;
rtype = rchain[i].udesc.R1.r;
@@ -957,7 +976,13 @@ struct staterecord *buildrecordstack(str
case R3:
rlen = rchain[i].udesc.R3.rlen;
- if (procoffset < roffset) goto out; /* Overshot Region containing procoffset. Bailout. */
+ if (procoffset < roffset) {
+ /*
+ * Overshot Region containing
+ * procoffset. Bail out.
+ */
+ goto out;
+ }
rdepth = procoffset - roffset;
roffset += rlen;
rtype = rchain[i].udesc.R3.r;
@@ -968,14 +993,20 @@ struct staterecord *buildrecordstack(str
case R2:
rlen = rchain[i].udesc.R2.rlen;
- if (procoffset < roffset) goto out; /* Overshot Region containing procoffset. Bailout. */
+ if (procoffset < roffset) {
+ /*
+ * Overshot Region containing
+ * procoffset. Bail out.
+ */
+ goto out;
+ }
rdepth = procoffset - roffset;
roffset += rlen;
rtype = false; /* prologue region */
pushrecord(¤t_state);
/* R2 has save info. Continue down. */
-
+ /* FALLTHROUGH */
case P1:
case P2:
case P3:
@@ -1017,17 +1048,12 @@ out:
return ¤t_state;
}
-void updateregs(struct unwind_frame *uwf, struct staterecord *srec, uint64_t procoffset)
+void
+updateregs(struct unwind_frame *uwf, struct staterecord *srec, uint64_t procoffset)
{
-
-#ifdef UNWIND_DIAGNOSTIC
- printf("updateregs(): \n");
- printf("procoffset (slots) = %lu \n", procoffset);
-#endif
/* XXX: Update uwf for regs other than rp and pfs*/
uint64_t roffset = 0;
-
/* Uses shadow arrays to update uwf from srec in a loop. */
/* Count of number of regstate elements in struct staterecord */
int statecount = sizeof(struct staterecord)/sizeof(struct regstate);
@@ -1036,9 +1062,13 @@ void updateregs(struct unwind_frame *uwf
/* Pointer to current unwind_frame element */
uint64_t *gr = (void *) uwf;
-
int i;
+#ifdef UNWIND_DIAGNOSTIC
+ printf("updateregs(): \n");
+ printf("procoffset (slots) = %lu \n", procoffset);
+#endif
+
for(i = 0; i < statecount; i++) {
switch (stptr[i].where) {
case IMMED: /* currently only mem_stack_f */
@@ -1112,11 +1142,11 @@ void updateregs(struct unwind_frame *uwf
}
-/* Locates unwind table entry, given unwind table entry info.
+/*
+ * Locates unwind table entry, given unwind table entry info.
* Expects the variables ia64_unwindtab, and ia64_unwindtablen
* to be set appropriately.
*/
-
struct uwtable_ent *
get_unwind_table_entry(uint64_t iprel)
{
@@ -1124,10 +1154,9 @@ get_unwind_table_entry(uint64_t iprel)
extern uint64_t ia64_unwindtab, ia64_unwindtablen;
struct uwtable_ent *uwt;
-
-
int tabent;
+
for(uwt = (struct uwtable_ent *) ia64_unwindtab, tabent = 0;
/* The Runtime spec tells me the table entries are sorted. */
uwt->end <= iprel && tabent < ia64_unwindtablen;
@@ -1159,7 +1188,6 @@ get_unwind_table_entry(uint64_t iprel)
/*
* Reads unwind table info and updates register values.
*/
-
void
patchunwindframe(struct unwind_frame *uwf, uint64_t iprel, uint64_t relocoffset)
{
@@ -1176,7 +1204,6 @@ patchunwindframe(struct unwind_frame *uw
}
#endif
-
uwt = get_unwind_table_entry(iprel);
if (uwt == NULL) return;
@@ -1185,8 +1212,9 @@ patchunwindframe(struct unwind_frame *uw
if (infoptr > relocoffset) {
buildrecordchain(infoptr, NULL);
+ } else {
+ return;
}
- else return;
slotoffset = iprel & 3;
@@ -1197,4 +1225,3 @@ patchunwindframe(struct unwind_frame *uw
updateregs(uwf, srec, procoffset);
}
-
Index: src/sys/arch/ia64/unwind/stackframe.h
diff -u src/sys/arch/ia64/unwind/stackframe.h:1.2 src/sys/arch/ia64/unwind/stackframe.h:1.3
--- src/sys/arch/ia64/unwind/stackframe.h:1.2 Sun Feb 28 15:52:16 2010
+++ src/sys/arch/ia64/unwind/stackframe.h Sun Jul 31 19:22:25 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: stackframe.h,v 1.2 2010/02/28 15:52:16 snj Exp $ */
+/* $NetBSD: stackframe.h,v 1.3 2016/07/31 19:22:25 dholland Exp $ */
/*
* Contributed to the NetBSD foundation by Cherry G. Mathew
@@ -87,16 +87,12 @@ void dump_staterecord(struct staterecord
void clonerecordstack(u_int);
void switchrecordstack(u_int);
-struct uwtable_ent *
-get_unwind_table_entry(uint64_t);
-void
-patchunwindframe(struct unwind_frame *, uint64_t, uint64_t);
-void
-updateregs(struct unwind_frame *uwf, struct staterecord *, uint64_t) ;
+struct uwtable_ent *get_unwind_table_entry(uint64_t);
+void patchunwindframe(struct unwind_frame *, uint64_t, uint64_t);
+void updateregs(struct unwind_frame *uwf, struct staterecord *, uint64_t);
struct uwtable_ent * get_unwind_table_entry(uint64_t ip);
-struct staterecord *
-buildrecordstack(struct recordchain *, uint64_t);
+struct staterecord *buildrecordstack(struct recordchain *, uint64_t);
void dump_recordchain(struct recordchain *);
/* Convenience macros to decompose CFM & ar.pfs. */