Browse Source

Backtrace formatting cleanup

Scott Lahteine 7 years ago
parent
commit
4b25543633
2 changed files with 79 additions and 80 deletions
  1. 3
    3
      Marlin/src/backtrace/unwarm.cpp
  2. 76
    77
      Marlin/src/backtrace/unwarm_arm.cpp

+ 3
- 3
Marlin/src/backtrace/unwarm.cpp View File

46
   do {
46
   do {
47
     regFile[t].o = REG_VAL_INVALID;
47
     regFile[t].o = REG_VAL_INVALID;
48
     t++;
48
     t++;
49
-  } while(t < 13);
49
+  } while (t < 13);
50
 }
50
 }
51
 
51
 
52
 
52
 
107
 
107
 
108
     // Scan backwards until we find the function name
108
     // Scan backwards until we find the function name
109
     uint32_t v;
109
     uint32_t v;
110
-    while(state->cb->readW(pf-4,&v)) {
110
+    while (state->cb->readW(pf-4,&v)) {
111
 
111
 
112
       // Check if name descriptor is valid
112
       // Check if name descriptor is valid
113
       if ((v & 0xFFFFFF00) == 0xFF000000 && (v & 0xFF) > 1) {
113
       if ((v & 0xFFFFFF00) == 0xFF000000 && (v & 0xFF) > 1) {
118
       }
118
       }
119
 
119
 
120
       // Go backwards to the previous word
120
       // Go backwards to the previous word
121
-      pf -= 4;;
121
+      pf -= 4;
122
     }
122
     }
123
   }
123
   }
124
 
124
 

+ 76
- 77
Marlin/src/backtrace/unwarm_arm.cpp View File

33
  */
33
  */
34
 static bool isDataProc(uint32_t instr) {
34
 static bool isDataProc(uint32_t instr) {
35
 
35
 
36
-  uint8_t opcode = (instr & 0x01e00000) >> 21;
36
+  uint8_t opcode = (instr & 0x01E00000) >> 21;
37
   bool    S      = (instr & 0x00100000) ? true : false;
37
   bool    S      = (instr & 0x00100000) ? true : false;
38
 
38
 
39
-  if((instr & 0xfc000000) != 0xe0000000) {
39
+  if ((instr & 0xFC000000) != 0xE0000000) {
40
     return false;
40
     return false;
41
-  } else
42
-  if(!S && opcode >= 8 && opcode <= 11) {
41
+  }
42
+  else if (!S && opcode >= 8 && opcode <= 11) {
43
     /* TST, TEQ, CMP and CMN all require S to be set */
43
     /* TST, TEQ, CMP and CMN all require S to be set */
44
     return false;
44
     return false;
45
-  } else {
46
-    return true;
47
   }
45
   }
46
+  else
47
+    return true;
48
 }
48
 }
49
 
49
 
50
 UnwResult UnwStartArm(UnwState * const state) {
50
 UnwResult UnwStartArm(UnwState * const state) {
56
     uint32_t instr;
56
     uint32_t instr;
57
 
57
 
58
     /* Attempt to read the instruction */
58
     /* Attempt to read the instruction */
59
-    if(!state->cb->readW(state->regData[15].v, &instr)) {
59
+    if (!state->cb->readW(state->regData[15].v, &instr)) {
60
       return UNWIND_IREAD_W_FAIL;
60
       return UNWIND_IREAD_W_FAIL;
61
     }
61
     }
62
 
62
 
63
     UnwPrintd4("A %x %x %08x:", state->regData[13].v, state->regData[15].v, instr);
63
     UnwPrintd4("A %x %x %08x:", state->regData[13].v, state->regData[15].v, instr);
64
 
64
 
65
     /* Check that the PC is still on Arm alignment */
65
     /* Check that the PC is still on Arm alignment */
66
-    if(state->regData[15].v & 0x3) {
66
+    if (state->regData[15].v & 0x3) {
67
       UnwPrintd1("\nError: PC misalignment\n");
67
       UnwPrintd1("\nError: PC misalignment\n");
68
       return UNWIND_INCONSISTENT;
68
       return UNWIND_INCONSISTENT;
69
     }
69
     }
70
 
70
 
71
     /* Check that the SP and PC have not been invalidated */
71
     /* Check that the SP and PC have not been invalidated */
72
-    if(!M_IsOriginValid(state->regData[13].o) || !M_IsOriginValid(state->regData[15].o)) {
72
+    if (!M_IsOriginValid(state->regData[13].o) || !M_IsOriginValid(state->regData[15].o)) {
73
       UnwPrintd1("\nError: PC or SP invalidated\n");
73
       UnwPrintd1("\nError: PC or SP invalidated\n");
74
       return UNWIND_INCONSISTENT;
74
       return UNWIND_INCONSISTENT;
75
     }
75
     }
78
      *  This is tested prior to data processing to prevent
78
      *  This is tested prior to data processing to prevent
79
      *  mis-interpretation as an invalid TEQ instruction.
79
      *  mis-interpretation as an invalid TEQ instruction.
80
      */
80
      */
81
-    if((instr & 0xfffffff0) == 0xe12fff10) {
82
-      uint8_t rn = instr & 0xf;
81
+    if ((instr & 0xFFFFFFF0) == 0xE12FFF10) {
82
+      uint8_t rn = instr & 0xF;
83
 
83
 
84
       UnwPrintd4("BX r%d\t ; r%d %s\n", rn, rn, M_Origin2Str(state->regData[rn].o));
84
       UnwPrintd4("BX r%d\t ; r%d %s\n", rn, rn, M_Origin2Str(state->regData[rn].o));
85
 
85
 
86
-      if(!M_IsOriginValid(state->regData[rn].o)) {
86
+      if (!M_IsOriginValid(state->regData[rn].o)) {
87
         UnwPrintd1("\nUnwind failure: BX to untracked register\n");
87
         UnwPrintd1("\nUnwind failure: BX to untracked register\n");
88
         return UNWIND_FAILURE;
88
         return UNWIND_FAILURE;
89
       }
89
       }
92
       state->regData[15].v = state->regData[rn].v;
92
       state->regData[15].v = state->regData[rn].v;
93
 
93
 
94
       /* Check if the return value is from the stack */
94
       /* Check if the return value is from the stack */
95
-      if(state->regData[rn].o == REG_VAL_FROM_STACK) {
95
+      if (state->regData[rn].o == REG_VAL_FROM_STACK) {
96
 
96
 
97
         /* Now have the return address */
97
         /* Now have the return address */
98
         UnwPrintd2(" Return PC=%x\n", state->regData[15].v & (~0x1));
98
         UnwPrintd2(" Return PC=%x\n", state->regData[15].v & (~0x1));
99
 
99
 
100
         /* Report the return address */
100
         /* Report the return address */
101
-        if(!UnwReportRetAddr(state, state->regData[rn].v)) {
102
-            return UNWIND_TRUNCATED;
103
-        }
101
+        if (!UnwReportRetAddr(state, state->regData[rn].v))
102
+          return UNWIND_TRUNCATED;
104
       }
103
       }
105
 
104
 
106
       /* Determine the return mode */
105
       /* Determine the return mode */
107
-      if(state->regData[rn].v & 0x1) {
106
+      if (state->regData[rn].v & 0x1) {
108
 
107
 
109
         /* Branching to THUMB */
108
         /* Branching to THUMB */
110
         return UnwStartThumb(state);
109
         return UnwStartThumb(state);
118
       }
117
       }
119
     }
118
     }
120
     /* Branch */
119
     /* Branch */
121
-    else if((instr & 0xff000000) == 0xea000000) {
120
+    else if ((instr & 0xFF000000) == 0xEA000000) {
122
 
121
 
123
-      int32_t offset = (instr & 0x00ffffff);
122
+      int32_t offset = (instr & 0x00FFFFFF);
124
 
123
 
125
       /* Shift value */
124
       /* Shift value */
126
       offset = offset << 2;
125
       offset = offset << 2;
127
 
126
 
128
       /* Sign extend if needed */
127
       /* Sign extend if needed */
129
-      if(offset & 0x02000000) {
130
-        offset |= 0xfc000000;
128
+      if (offset & 0x02000000) {
129
+        offset |= 0xFC000000;
131
       }
130
       }
132
 
131
 
133
       UnwPrintd2("B %d\n", offset);
132
       UnwPrintd2("B %d\n", offset);
142
     }
141
     }
143
 
142
 
144
     /* MRS */
143
     /* MRS */
145
-    else if((instr & 0xffbf0fff) == 0xe10f0000) {
144
+    else if ((instr & 0xFFBF0FFF) == 0xE10F0000) {
146
 #if defined(UNW_DEBUG)
145
 #if defined(UNW_DEBUG)
147
       bool R     = (instr & 0x00400000) ? true : false;
146
       bool R     = (instr & 0x00400000) ? true : false;
148
 #endif
147
 #endif
149
-      uint8_t rd = (instr & 0x0000f000) >> 12;
148
+      uint8_t rd = (instr & 0x0000F000) >> 12;
150
 
149
 
151
       UnwPrintd4("MRS r%d,%s\t; r%d invalidated", rd, R ? "SPSR" : "CPSR", rd);
150
       UnwPrintd4("MRS r%d,%s\t; r%d invalidated", rd, R ? "SPSR" : "CPSR", rd);
152
 
151
 
154
       state->regData[rd].o = REG_VAL_INVALID;
153
       state->regData[rd].o = REG_VAL_INVALID;
155
     }
154
     }
156
     /* MSR */
155
     /* MSR */
157
-    else if((instr & 0xffb0f000) == 0xe120f000) {
156
+    else if ((instr & 0xFFB0F000) == 0xE120F000) {
158
 #if defined(UNW_DEBUG)
157
 #if defined(UNW_DEBUG)
159
       bool R = (instr & 0x00400000) ? true : false;
158
       bool R = (instr & 0x00400000) ? true : false;
160
 
159
 
170
        */
169
        */
171
     }
170
     }
172
     /* Data processing */
171
     /* Data processing */
173
-    else if(isDataProc(instr)) {
172
+    else if (isDataProc(instr)) {
174
       bool            I = (instr & 0x02000000) ? true : false;
173
       bool            I = (instr & 0x02000000) ? true : false;
175
-      uint8_t    opcode = (instr & 0x01e00000) >> 21;
174
+      uint8_t    opcode = (instr & 0x01E00000) >> 21;
176
 #if defined(UNW_DEBUG)
175
 #if defined(UNW_DEBUG)
177
       bool            S = (instr & 0x00100000) ? true : false;
176
       bool            S = (instr & 0x00100000) ? true : false;
178
 #endif
177
 #endif
179
-      uint8_t        rn = (instr & 0x000f0000) >> 16;
180
-      uint8_t        rd = (instr & 0x0000f000) >> 12;
181
-      uint16_t operand2 = (instr & 0x00000fff);
178
+      uint8_t        rn = (instr & 0x000F0000) >> 16;
179
+      uint8_t        rd = (instr & 0x0000F000) >> 12;
180
+      uint16_t operand2 = (instr & 0x00000FFF);
182
       uint32_t        op2val;
181
       uint32_t        op2val;
183
       int             op2origin;
182
       int             op2origin;
184
 
183
 
203
 
202
 
204
       /* Decode operand 2 */
203
       /* Decode operand 2 */
205
       if (I) {
204
       if (I) {
206
-        uint8_t shiftDist  = (operand2 & 0x0f00) >> 8;
207
-        uint8_t shiftConst = (operand2 & 0x00ff);
205
+        uint8_t shiftDist  = (operand2 & 0x0F00) >> 8;
206
+        uint8_t shiftConst = (operand2 & 0x00FF);
208
 
207
 
209
         /* rotate const right by 2 * shiftDist */
208
         /* rotate const right by 2 * shiftDist */
210
         shiftDist *= 2;
209
         shiftDist *= 2;
217
       else {
216
       else {
218
 
217
 
219
         /* Register and shift */
218
         /* Register and shift */
220
-        uint8_t  rm        = (operand2 & 0x000f);
219
+        uint8_t  rm        = (operand2 & 0x000F);
221
         uint8_t  regShift  = (operand2 & 0x0010) ? true : false;
220
         uint8_t  regShift  = (operand2 & 0x0010) ? true : false;
222
         uint8_t  shiftType = (operand2 & 0x0060) >> 5;
221
         uint8_t  shiftType = (operand2 & 0x0060) >> 5;
223
         uint32_t shiftDist;
222
         uint32_t shiftDist;
227
         UnwPrintd2("r%d ", rm);
226
         UnwPrintd2("r%d ", rm);
228
 
227
 
229
         /* Get the shift distance */
228
         /* Get the shift distance */
230
-        if(regShift) {
229
+        if (regShift) {
231
 
230
 
232
-          uint8_t rs = (operand2 & 0x0f00) >> 8;
231
+          uint8_t rs = (operand2 & 0x0F00) >> 8;
233
 
232
 
234
-          if(operand2 & 0x00800) {
233
+          if (operand2 & 0x00800) {
235
 
234
 
236
             UnwPrintd1("\nError: Bit should be zero\n");
235
             UnwPrintd1("\nError: Bit should be zero\n");
237
             return UNWIND_ILLEGAL_INSTR;
236
             return UNWIND_ILLEGAL_INSTR;
238
           }
237
           }
239
-          else if(rs == 15) {
238
+          else if (rs == 15) {
240
 
239
 
241
             UnwPrintd1("\nError: Cannot use R15 with register shift\n");
240
             UnwPrintd1("\nError: Cannot use R15 with register shift\n");
242
             return UNWIND_ILLEGAL_INSTR;
241
             return UNWIND_ILLEGAL_INSTR;
249
           UnwPrintd7("%s r%d\t; r%d %s r%d %s", shiftMnu[shiftType], rs, rm, M_Origin2Str(state->regData[rm].o), rs, M_Origin2Str(state->regData[rs].o));
248
           UnwPrintd7("%s r%d\t; r%d %s r%d %s", shiftMnu[shiftType], rs, rm, M_Origin2Str(state->regData[rm].o), rs, M_Origin2Str(state->regData[rs].o));
250
         }
249
         }
251
         else {
250
         else {
252
-          shiftDist = (operand2 & 0x0f80) >> 7;
251
+          shiftDist = (operand2 & 0x0F80) >> 7;
253
           op2origin = REG_VAL_FROM_CONST;
252
           op2origin = REG_VAL_FROM_CONST;
254
 
253
 
255
-          if(shiftDist) {
254
+          if (shiftDist) {
256
             UnwPrintd3("%s #%d", shiftMnu[shiftType], shiftDist);
255
             UnwPrintd3("%s #%d", shiftMnu[shiftType], shiftDist);
257
           }
256
           }
258
           UnwPrintd3("\t; r%d %s", rm, M_Origin2Str(state->regData[rm].o));
257
           UnwPrintd3("\t; r%d %s", rm, M_Origin2Str(state->regData[rm].o));
265
             break;
264
             break;
266
 
265
 
267
           case 1: /* logical right */
266
           case 1: /* logical right */
268
-            if(!regShift && shiftDist == 0) {
267
+            if (!regShift && shiftDist == 0) {
269
               shiftDist = 32;
268
               shiftDist = 32;
270
             }
269
             }
271
 
270
 
273
             break;
272
             break;
274
 
273
 
275
           case 2: /* arithmetic right */
274
           case 2: /* arithmetic right */
276
-            if(!regShift && shiftDist == 0) {
275
+            if (!regShift && shiftDist == 0) {
277
               shiftDist = 32;
276
               shiftDist = 32;
278
             }
277
             }
279
 
278
 
280
-            if(state->regData[rm].v & 0x80000000) {
279
+            if (state->regData[rm].v & 0x80000000) {
281
 
280
 
282
               /* Register shifts maybe greater than 32 */
281
               /* Register shifts maybe greater than 32 */
283
-              if(shiftDist >= 32) {
284
-                op2val = 0xffffffff;
282
+              if (shiftDist >= 32) {
283
+                op2val = 0xFFFFFFFF;
285
               }
284
               }
286
               else {
285
               else {
287
                 op2val = state->regData[rm].v >> shiftDist;
286
                 op2val = state->regData[rm].v >> shiftDist;
288
-                op2val |= 0xffffffff << (32 - shiftDist);
287
+                op2val |= 0xFFFFFFFF << (32 - shiftDist);
289
               }
288
               }
290
             }
289
             }
291
             else {
290
             else {
295
 
294
 
296
           case 3: /* rotate right */
295
           case 3: /* rotate right */
297
 
296
 
298
-            if(!regShift && shiftDist == 0) {
297
+            if (!regShift && shiftDist == 0) {
299
               /* Rotate right with extend.
298
               /* Rotate right with extend.
300
                *  This uses the carry bit and so always has an
299
                *  This uses the carry bit and so always has an
301
                *  untracked result.
300
                *  untracked result.
305
             }
304
             }
306
             else {
305
             else {
307
               /* Limit shift distance to 0-31 incase of register shift */
306
               /* Limit shift distance to 0-31 incase of register shift */
308
-              shiftDist &= 0x1f;
307
+              shiftDist &= 0x1F;
309
 
308
 
310
               op2val = (state->regData[rm].v >> shiftDist) |
309
               op2val = (state->regData[rm].v >> shiftDist) |
311
                        (state->regData[rm].v << (32 - shiftDist));
310
                        (state->regData[rm].v << (32 - shiftDist));
318
         }
317
         }
319
 
318
 
320
         /* Decide the data origin */
319
         /* Decide the data origin */
321
-        if(M_IsOriginValid(op2origin) &&
320
+        if (M_IsOriginValid(op2origin) &&
322
            M_IsOriginValid(state->regData[rm].o)) {
321
            M_IsOriginValid(state->regData[rm].o)) {
323
 
322
 
324
           op2origin = state->regData[rm].o;
323
           op2origin = state->regData[rm].o;
338
         case  4: /* ADD: Rd:= Op1 + Op2 */
337
         case  4: /* ADD: Rd:= Op1 + Op2 */
339
         case 12: /* ORR: Rd:= Op1 OR Op2 */
338
         case 12: /* ORR: Rd:= Op1 OR Op2 */
340
         case 14: /* BIC: Rd:= Op1 AND NOT Op2 */
339
         case 14: /* BIC: Rd:= Op1 AND NOT Op2 */
341
-          if(!M_IsOriginValid(state->regData[rn].o) ||
340
+          if (!M_IsOriginValid(state->regData[rn].o) ||
342
              !M_IsOriginValid(op2origin)) {
341
              !M_IsOriginValid(op2origin)) {
343
             state->regData[rd].o = REG_VAL_INVALID;
342
             state->regData[rd].o = REG_VAL_INVALID;
344
           }
343
           }
368
       }
367
       }
369
 
368
 
370
       /* Account for pre-fetch by temporarily adjusting PC */
369
       /* Account for pre-fetch by temporarily adjusting PC */
371
-      if(rn == 15) {
370
+      if (rn == 15) {
372
 
371
 
373
         /* If the shift amount is specified in the instruction,
372
         /* If the shift amount is specified in the instruction,
374
          *  the PC will be 8 bytes ahead. If a register is used
373
          *  the PC will be 8 bytes ahead. If a register is used
375
          *  to specify the shift amount the PC will be 12 bytes
374
          *  to specify the shift amount the PC will be 12 bytes
376
          *  ahead.
375
          *  ahead.
377
          */
376
          */
378
-        if(!I && (operand2 & 0x0010))
377
+        if (!I && (operand2 & 0x0010))
379
           state->regData[rn].v += 12;
378
           state->regData[rn].v += 12;
380
         else
379
         else
381
           state->regData[rn].v += 8;
380
           state->regData[rn].v += 8;
430
       }
429
       }
431
 
430
 
432
       /* Remove the prefetch offset from the PC */
431
       /* Remove the prefetch offset from the PC */
433
-      if(rd != 15 && rn == 15) {
434
-        if(!I && (operand2 & 0x0010))
432
+      if (rd != 15 && rn == 15) {
433
+        if (!I && (operand2 & 0x0010))
435
           state->regData[rn].v -= 12;
434
           state->regData[rn].v -= 12;
436
         else
435
         else
437
           state->regData[rn].v -= 8;
436
           state->regData[rn].v -= 8;
441
     /* Block Data Transfer
440
     /* Block Data Transfer
442
      *  LDM, STM
441
      *  LDM, STM
443
      */
442
      */
444
-    else if((instr & 0xfe000000) == 0xe8000000) {
443
+    else if ((instr & 0xFE000000) == 0xE8000000) {
445
 
444
 
446
       bool     P         = (instr & 0x01000000) ? true : false;
445
       bool     P         = (instr & 0x01000000) ? true : false;
447
       bool     U         = (instr & 0x00800000) ? true : false;
446
       bool     U         = (instr & 0x00800000) ? true : false;
448
       bool     S         = (instr & 0x00400000) ? true : false;
447
       bool     S         = (instr & 0x00400000) ? true : false;
449
       bool     W         = (instr & 0x00200000) ? true : false;
448
       bool     W         = (instr & 0x00200000) ? true : false;
450
       bool     L         = (instr & 0x00100000) ? true : false;
449
       bool     L         = (instr & 0x00100000) ? true : false;
451
-      uint16_t baseReg   = (instr & 0x000f0000) >> 16;
452
-      uint16_t regList   = (instr & 0x0000ffff);
450
+      uint16_t baseReg   = (instr & 0x000F0000) >> 16;
451
+      uint16_t regList   = (instr & 0x0000FFFF);
453
       uint32_t addr      = state->regData[baseReg].v;
452
       uint32_t addr      = state->regData[baseReg].v;
454
       bool     addrValid = M_IsOriginValid(state->regData[baseReg].o);
453
       bool     addrValid = M_IsOriginValid(state->regData[baseReg].o);
455
       int8_t r;
454
       int8_t r;
456
 
455
 
457
 #if defined(UNW_DEBUG)
456
 #if defined(UNW_DEBUG)
458
       /* Display the instruction */
457
       /* Display the instruction */
459
-      if(L) {
458
+      if (L) {
460
         UnwPrintd6("LDM%c%c r%d%s, {reglist}%s\n", P ? 'E' : 'F', U ? 'D' : 'A', baseReg, W ? "!" : "", S ? "^" : "");
459
         UnwPrintd6("LDM%c%c r%d%s, {reglist}%s\n", P ? 'E' : 'F', U ? 'D' : 'A', baseReg, W ? "!" : "", S ? "^" : "");
461
       }
460
       }
462
       else {
461
       else {
467
        *  this is a load including the PC when the S-bit indicates that
466
        *  this is a load including the PC when the S-bit indicates that
468
        *  that CPSR is loaded from SPSR (also untracked, but ignored).
467
        *  that CPSR is loaded from SPSR (also untracked, but ignored).
469
        */
468
        */
470
-      if(S && (!L || (regList & (0x01 << 15)) == 0)) {
469
+      if (S && (!L || (regList & (0x01 << 15)) == 0)) {
471
         UnwPrintd1("\nError:S-bit set requiring banked registers\n");
470
         UnwPrintd1("\nError:S-bit set requiring banked registers\n");
472
         return UNWIND_FAILURE;
471
         return UNWIND_FAILURE;
473
       }
472
       }
474
-      else if(baseReg == 15) {
473
+      else if (baseReg == 15) {
475
         UnwPrintd1("\nError: r15 used as base register\n");
474
         UnwPrintd1("\nError: r15 used as base register\n");
476
         return UNWIND_FAILURE;
475
         return UNWIND_FAILURE;
477
       }
476
       }
478
-      else if(regList == 0) {
477
+      else if (regList == 0) {
479
         UnwPrintd1("\nError: Register list empty\n");
478
         UnwPrintd1("\nError: Register list empty\n");
480
         return UNWIND_FAILURE;
479
         return UNWIND_FAILURE;
481
       }
480
       }
488
       do {
487
       do {
489
 
488
 
490
         /* Check if the register is to be transferred */
489
         /* Check if the register is to be transferred */
491
-        if(regList & (0x01 << r)) {
490
+        if (regList & (0x01 << r)) {
492
 
491
 
493
-          if(P)
492
+          if (P)
494
             addr += U ? 4 : -4;
493
             addr += U ? 4 : -4;
495
 
494
 
496
-          if(L) {
495
+          if (L) {
497
 
496
 
498
-            if(addrValid) {
497
+            if (addrValid) {
499
 
498
 
500
-              if(!UnwMemReadRegister(state, addr, &state->regData[r])) {
499
+              if (!UnwMemReadRegister(state, addr, &state->regData[r])) {
501
                 return UNWIND_DREAD_W_FAIL;
500
                 return UNWIND_DREAD_W_FAIL;
502
               }
501
               }
503
 
502
 
504
               /* Update the origin if read via the stack pointer */
503
               /* Update the origin if read via the stack pointer */
505
-              if(M_IsOriginValid(state->regData[r].o) && baseReg == 13) {
504
+              if (M_IsOriginValid(state->regData[r].o) && baseReg == 13) {
506
                 state->regData[r].o = REG_VAL_FROM_STACK;
505
                 state->regData[r].o = REG_VAL_FROM_STACK;
507
               }
506
               }
508
 
507
 
517
             }
516
             }
518
           }
517
           }
519
           else {
518
           else {
520
-            if(addrValid) {
521
-              if(!UnwMemWriteRegister(state, state->regData[13].v, &state->regData[r])) {
519
+            if (addrValid) {
520
+              if (!UnwMemWriteRegister(state, state->regData[13].v, &state->regData[r])) {
522
                 return UNWIND_DWRITE_W_FAIL;
521
                 return UNWIND_DWRITE_W_FAIL;
523
               }
522
               }
524
             }
523
             }
526
             UnwPrintd2(" R%d = 0x%08x\n", r);
525
             UnwPrintd2(" R%d = 0x%08x\n", r);
527
           }
526
           }
528
 
527
 
529
-          if(!P)
528
+          if (!P)
530
             addr += U ? 4 : -4;
529
             addr += U ? 4 : -4;
531
         }
530
         }
532
 
531
 
533
         /* Check the next register */
532
         /* Check the next register */
534
         r += U ? 1 : -1;
533
         r += U ? 1 : -1;
535
 
534
 
536
-      } while(r >= 0 && r <= 15);
535
+      } while (r >= 0 && r <= 15);
537
 
536
 
538
       /* Check the writeback bit */
537
       /* Check the writeback bit */
539
-      if(W)
538
+      if (W)
540
         state->regData[baseReg].v = addr;
539
         state->regData[baseReg].v = addr;
541
 
540
 
542
       /* Check if the PC was loaded */
541
       /* Check if the PC was loaded */
543
-      if(L && (regList & (0x01 << 15))) {
544
-        if(!M_IsOriginValid(state->regData[15].o)) {
542
+      if (L && (regList & (0x01 << 15))) {
543
+        if (!M_IsOriginValid(state->regData[15].o)) {
545
           /* Return address is not valid */
544
           /* Return address is not valid */
546
           UnwPrintd1("PC popped with invalid address\n");
545
           UnwPrintd1("PC popped with invalid address\n");
547
           return UNWIND_FAILURE;
546
           return UNWIND_FAILURE;
548
         }
547
         }
549
         else {
548
         else {
550
           /* Store the return address */
549
           /* Store the return address */
551
-          if(!UnwReportRetAddr(state, state->regData[15].v)) {
550
+          if (!UnwReportRetAddr(state, state->regData[15].v)) {
552
             return UNWIND_TRUNCATED;
551
             return UNWIND_TRUNCATED;
553
           }
552
           }
554
 
553
 
555
           UnwPrintd2("  Return PC=0x%x", state->regData[15].v);
554
           UnwPrintd2("  Return PC=0x%x", state->regData[15].v);
556
 
555
 
557
           /* Determine the return mode */
556
           /* Determine the return mode */
558
-          if(state->regData[15].v & 0x1) {
557
+          if (state->regData[15].v & 0x1) {
559
             /* Branching to THUMB */
558
             /* Branching to THUMB */
560
             return UnwStartThumb(state);
559
             return UnwStartThumb(state);
561
           }
560
           }
578
     UnwPrintd1("\n");
577
     UnwPrintd1("\n");
579
 
578
 
580
     /* Should never hit the reset vector */
579
     /* Should never hit the reset vector */
581
-    if(state->regData[15].v == 0) return UNWIND_RESET;
580
+    if (state->regData[15].v == 0) return UNWIND_RESET;
582
 
581
 
583
     /* Check next address */
582
     /* Check next address */
584
     state->regData[15].v += 4;
583
     state->regData[15].v += 4;
587
     UnwMemHashGC(state);
586
     UnwMemHashGC(state);
588
 
587
 
589
     t--;
588
     t--;
590
-    if(t == 0)
589
+    if (t == 0)
591
       return UNWIND_EXHAUSTED;
590
       return UNWIND_EXHAUSTED;
592
 
591
 
593
-  } while(!found);
592
+  } while (!found);
594
 
593
 
595
   return UNWIND_UNSUPPORTED;
594
   return UNWIND_UNSUPPORTED;
596
 }
595
 }

Loading…
Cancel
Save