Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/dev/dtrace/riscv/dtrace_isa.c
| Context not available. | |||||
| ulong_t | ulong_t | ||||
| dtrace_getreg(struct trapframe *rp, uint_t reg) | dtrace_getreg(struct trapframe *rp, uint_t reg) | ||||
| { | { | ||||
| switch (reg) { | |||||
| printf("IMPLEMENT ME: %s\n", __func__); | case REG_ZERO: | ||||
| return (0); | |||||
| case REG_RA: | |||||
| return (rp->tf_ra); | |||||
| case REG_SP: | |||||
| return (rp->tf_sp); | |||||
| case REG_GP: | |||||
| return (rp->tf_gp); | |||||
| case REG_TP: | |||||
| return (rp->tf_tp); | |||||
| case REG_T0 ... REG_T2: | |||||
mhorne: I think specifying a range in this way is a GNU extension, not standard C syntax, and it should… | |||||
Done Inline ActionsThere are other code pieces that use this as well, I don't think that's too much of an issue, christos: There are other code pieces that use this as well, I don't think that's too much of an issue… | |||||
Done Inline ActionsIt is a GNU extension, but we do use it a fair bit already[*], especially in bhyve. I'd vote for keeping it since it makes the code easier to follow. [*]$ git grep 'case.*\.\.\..*:' markj: It is a GNU extension, but we do use it a fair bit already[*], especially in bhyve. I'd vote… | |||||
Done Inline ActionsI'll leave it as is. christos: I'll leave it as is. | |||||
Done Inline ActionsSounds great. mhorne: Sounds great. | |||||
| return (rp->tf_t[reg - REG_T0]); | |||||
| case REG_S0 ... REG_S1: | |||||
| return (rp->tf_s[reg - REG_S0]); | |||||
| case REG_A0 ... REG_A7: | |||||
| return (rp->tf_a[reg - REG_A0]); | |||||
| case REG_S2 ... REG_S11: | |||||
| return (rp->tf_s[reg - REG_S2 + 2]); | |||||
| case REG_T3 ... REG_T6: | |||||
| return (rp->tf_t[reg - REG_T3 + 3]); | |||||
| case REG_PC: | |||||
| return (rp->tf_sepc); | |||||
| default: | |||||
| DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP); | |||||
| return (0); | |||||
| } | |||||
| return (0); | return (0); | ||||
Done Inline ActionsNit: the final return statement will never execute due to the default case. You can use __assert_unreachable() instead. mhorne: Nit: the final return statement will never execute due to the default case. You can use… | |||||
Done Inline ActionsWon't a /* NOTREACHED */ comment suffice? christos: Won't a `/* NOTREACHED */` comment suffice? | |||||
| } | } | ||||
| Context not available. | |||||
I think specifying a range in this way is a GNU extension, not standard C syntax, and it should be avoided. Unfortunately that makes this code a lot uglier :(