MCPcopy Create free account
hub / github.com/F-Stack/f-stack / unwind_exec_insn

Function unwind_exec_insn

freebsd/arm/arm/unwind.c:370–492  ·  view source on GitHub ↗

Executes the next instruction on the list */

Source from the content-addressed store, hash-verified

368
369/* Executes the next instruction on the list */
370static int
371unwind_exec_insn(struct unwind_state *state)
372{
373 unsigned int insn;
374 uint32_t *vsp = (uint32_t *)state->registers[SP];
375 int update_vsp = 0;
376
377 /* This should never happen */
378 if (state->entries == 0)
379 return 1;
380
381 /* Read the next instruction */
382 insn = unwind_exec_read_byte(state);
383
384 if ((insn & INSN_VSP_MASK) == INSN_VSP_INC) {
385 state->registers[SP] += ((insn & INSN_VSP_SIZE_MASK) << 2) + 4;
386
387 } else if ((insn & INSN_VSP_MASK) == INSN_VSP_DEC) {
388 state->registers[SP] -= ((insn & INSN_VSP_SIZE_MASK) << 2) + 4;
389
390 } else if ((insn & INSN_STD_MASK) == INSN_POP_MASKED) {
391 unsigned int mask, reg;
392
393 /* Load the mask */
394 mask = unwind_exec_read_byte(state);
395 mask |= (insn & INSN_STD_DATA_MASK) << 8;
396
397 /* We have a refuse to unwind instruction */
398 if (mask == 0)
399 return 1;
400
401 /* Update SP */
402 update_vsp = 1;
403
404 /* Load the registers */
405 for (reg = 4; mask && reg < 16; mask >>= 1, reg++) {
406 if (mask & 1) {
407 state->registers[reg] = *vsp++;
408 state->update_mask |= 1 << reg;
409
410 /* If we have updated SP kep its value */
411 if (reg == SP)
412 update_vsp = 0;
413 }
414 }
415
416 } else if ((insn & INSN_STD_MASK) == INSN_VSP_REG &&
417 ((insn & INSN_STD_DATA_MASK) != 13) &&
418 ((insn & INSN_STD_DATA_MASK) != 15)) {
419 /* sp = register */
420 state->registers[SP] =
421 state->registers[insn & INSN_STD_DATA_MASK];
422
423 } else if ((insn & INSN_STD_MASK) == INSN_POP_COUNT) {
424 unsigned int count, reg;
425
426 /* Read how many registers to load */
427 count = insn & INSN_POP_COUNT_MASK;

Callers 1

unwind_tabFunction · 0.85

Calls 2

unwind_exec_read_byteFunction · 0.85
db_printfFunction · 0.85

Tested by

no test coverage detected