aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-01-20 13:07:30 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-26 14:55:10 -0600
commit09b9418c6d085a0728372aa760ebd10128a020b1 (patch)
treec1aa0a74eb6c3caadd86186ed1e11bd977e18773 /monitor.c
parentff06ea219763559bec2aab26dde1cec8608405e9 (diff)
monitor: Don't check for mon_get_cpu() failure
mon_get_cpu() can't return null pointer, because it passes its return value to cpu_synchronize_state() first, which crashes if its argument is null. Remove the (pretty cheesy) handling of this non-existing error. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c39
1 files changed, 3 insertions, 36 deletions
diff --git a/monitor.c b/monitor.c
index cadf422e3f..0595f0db95 100644
--- a/monitor.c
+++ b/monitor.c
@@ -692,8 +692,6 @@ static void do_info_registers(Monitor *mon)
{
CPUState *env;
env = mon_get_cpu();
- if (!env)
- return;
#ifdef TARGET_I386
cpu_dump_state(env, (FILE *)mon, monitor_fprintf,
X86_DUMP_FPU);
@@ -1127,7 +1125,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
int flags;
flags = 0;
env = mon_get_cpu();
- if (!env && !is_physical)
+ if (!is_physical)
return;
#ifdef TARGET_I386
if (wsize == 2) {
@@ -1189,8 +1187,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
cpu_physical_memory_rw(addr, buf, l, 0);
} else {
env = mon_get_cpu();
- if (!env)
- break;
if (cpu_memory_rw_debug(env, addr, buf, l, 0) < 0) {
monitor_printf(mon, " Cannot access memory\n");
break;
@@ -1317,8 +1313,6 @@ static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
uint8_t buf[1024];
env = mon_get_cpu();
- if (!env)
- return;
f = fopen(filename, "wb");
if (!f) {
@@ -1753,8 +1747,6 @@ static void tlb_info(Monitor *mon)
uint32_t pgd, pde, pte;
env = mon_get_cpu();
- if (!env)
- return;
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(mon, "PG disabled\n");
@@ -1811,8 +1803,6 @@ static void mem_info(Monitor *mon)
uint32_t pgd, pde, pte, start, end;
env = mon_get_cpu();
- if (!env)
- return;
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(mon, "PG disabled\n");
@@ -2658,8 +2648,6 @@ typedef struct MonitorDef {
static target_long monitor_get_pc (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return env->eip + env->segs[R_CS].base;
}
#endif
@@ -2671,9 +2659,6 @@ static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
unsigned int u;
int i;
- if (!env)
- return 0;
-
u = 0;
for (i = 0; i < 8; i++)
u |= env->crf[i] << (32 - (4 * i));
@@ -2684,40 +2669,30 @@ static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
static target_long monitor_get_msr (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return env->msr;
}
static target_long monitor_get_xer (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return env->xer;
}
static target_long monitor_get_decr (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return cpu_ppc_load_decr(env);
}
static target_long monitor_get_tbu (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return cpu_ppc_load_tbu(env);
}
static target_long monitor_get_tbl (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return cpu_ppc_load_tbl(env);
}
#endif
@@ -2727,8 +2702,6 @@ static target_long monitor_get_tbl (const struct MonitorDef *md, int val)
static target_long monitor_get_psr (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return GET_PSR(env);
}
#endif
@@ -2736,8 +2709,6 @@ static target_long monitor_get_psr (const struct MonitorDef *md, int val)
static target_long monitor_get_reg(const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
- if (!env)
- return 0;
return env->regwptr[val];
}
#endif
@@ -2989,7 +2960,7 @@ static void expr_error(Monitor *mon, const char *msg)
longjmp(expr_env, 1);
}
-/* return 0 if OK, -1 if not found, -2 if no CPU defined */
+/* return 0 if OK, -1 if not found */
static int get_monitor_def(target_long *pval, const char *name)
{
const MonitorDef *md;
@@ -3001,8 +2972,6 @@ static int get_monitor_def(target_long *pval, const char *name)
*pval = md->get_value(md, md->offset);
} else {
CPUState *env = mon_get_cpu();
- if (!env)
- return -2;
ptr = (uint8_t *)env + md->offset;
switch(md->type) {
case MD_I32:
@@ -3089,10 +3058,8 @@ static int64_t expr_unary(Monitor *mon)
pch++;
*q = 0;
ret = get_monitor_def(&reg, buf);
- if (ret == -1)
+ if (ret < 0)
expr_error(mon, "unknown register");
- else if (ret == -2)
- expr_error(mon, "no cpu defined");
n = reg;
}
break;