panic() cleanup.
this change
- makes panic() variadic, doing full printf() formatting -
no more NO_NUM, and no more separate printf() statements
needed to print extra info (or something in hex) before panicing
- unifies panic() - same panic() name and usage for everyone -
vm, kernel and rest have different names/syntax currently
in order to implement their own luxuries, but no longer
- throws out the 1st argument, to make source less noisy.
the panic() in syslib retrieves the server name from the kernel
so it should be clear enough who is panicing; e.g.
panic("sigaction failed: %d", errno);
looks like:
at_wini(73130): panic: sigaction failed: 0
syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
- throws out report() - printf() is more convenient and powerful
- harmonizes/fixes the use of panic() - there were a few places
that used printf-style formatting (didn't work) and newlines
(messes up the formatting) in panic()
- throws out a few per-server panic() functions
- cleans up a tie-in of tty with panic()
merging printf() and panic() statements to be done incrementally.
This commit is contained in:
@@ -61,7 +61,7 @@ static int driver_open(int which)
|
||||
gid = cpf_grant_direct(driver[which].endpt,
|
||||
(vir_bytes) &part, sizeof(part), CPF_WRITE);
|
||||
if(!GRANT_VALID(gid))
|
||||
panic(__FILE__, "invalid grant", gid);
|
||||
panic("invalid grant: %d", gid);
|
||||
|
||||
msg.m_type = DEV_IOCTL_S;
|
||||
msg.REQUEST = DIOCGETP;
|
||||
@@ -165,7 +165,7 @@ void driver_init(void)
|
||||
check_driver(DRIVER_MAIN);
|
||||
}
|
||||
else if (driver_open(DRIVER_MAIN) != OK) {
|
||||
panic(__FILE__, "unhandled driver_open failure", NO_NUM);
|
||||
panic("unhandled driver_open failure");
|
||||
}
|
||||
|
||||
if(USE_MIRROR) {
|
||||
@@ -174,7 +174,7 @@ void driver_init(void)
|
||||
|
||||
if(!strcmp(driver[DRIVER_MAIN].label,
|
||||
driver[DRIVER_BACKUP].label)) {
|
||||
panic(__FILE__, "same driver: not tested", NO_NUM);
|
||||
panic("same driver: not tested");
|
||||
}
|
||||
|
||||
r = ds_retrieve_label_num(driver[DRIVER_BACKUP].label,
|
||||
@@ -186,8 +186,7 @@ void driver_init(void)
|
||||
check_driver(DRIVER_BACKUP);
|
||||
}
|
||||
else if (driver_open(DRIVER_BACKUP) != OK) {
|
||||
panic(__FILE__, "unhandled driver_open failure",
|
||||
NO_NUM);
|
||||
panic("unhandled driver_open failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -377,7 +376,7 @@ static int check_problem(int which, int problem, int retries, int *tell_rs)
|
||||
break;
|
||||
|
||||
default:
|
||||
panic(__FILE__, "invalid problem", problem);
|
||||
panic("invalid problem: %d", problem);
|
||||
}
|
||||
|
||||
/* At this point, the driver will be restarted. */
|
||||
@@ -441,7 +440,7 @@ static void restart_driver(int which, int tell_rs)
|
||||
r = sendrec(RS_PROC_NR, &msg);
|
||||
|
||||
if (r != OK || msg.m_type != OK)
|
||||
panic(__FILE__, "RS request failed", r);
|
||||
panic("RS request failed: %d", r);
|
||||
|
||||
#if DEBUG
|
||||
printf("Filter: RS call succeeded\n");
|
||||
@@ -545,7 +544,7 @@ static int flt_senda(message *mess, int which)
|
||||
r = senda(amsgtable, 2);
|
||||
|
||||
if(r != OK)
|
||||
panic(__FILE__, "senda returned error", r);
|
||||
panic("senda returned error: %d", r);
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -585,7 +584,7 @@ static int flt_receive(message *mess, int which)
|
||||
for (;;) {
|
||||
r = sef_receive(ANY, mess);
|
||||
if(r != OK)
|
||||
panic(__FILE__, "sef_receive returned error", r);
|
||||
panic("sef_receive returned error: %d", r);
|
||||
|
||||
if(mess->m_source == CLOCK && is_notify(mess->m_type)) {
|
||||
if (mess->NOTIFY_TIMESTAMP < flt_alarm(-1)) {
|
||||
@@ -727,7 +726,7 @@ static int do_sendrec_both(message *m1, message *m2)
|
||||
} else if (ma.m_source == driver[DRIVER_BACKUP].endpt) {
|
||||
which = DRIVER_MAIN;
|
||||
} else {
|
||||
panic(__FILE__, "message from unexpected source",
|
||||
panic("message from unexpected source: %d",
|
||||
ma.m_source);
|
||||
}
|
||||
|
||||
@@ -822,7 +821,7 @@ static int single_grant(endpoint_t endpt, vir_bytes buf, int access,
|
||||
|
||||
grant = cpf_grant_direct(endpt, buf, chunk, access);
|
||||
if (!GRANT_VALID(grant))
|
||||
panic(__FILE__, "invalid grant", grant);
|
||||
panic("invalid grant: %d", grant);
|
||||
|
||||
vector[count].iov_grant = grant;
|
||||
vector[count].iov_size = chunk;
|
||||
@@ -836,7 +835,7 @@ static int single_grant(endpoint_t endpt, vir_bytes buf, int access,
|
||||
sizeof(vector[0]) * count, CPF_READ | CPF_WRITE);
|
||||
|
||||
if (!GRANT_VALID(*gid))
|
||||
panic(__FILE__, "invalid grant", *gid);
|
||||
panic("invalid grant: %d", *gid);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ static int do_vrdwt(int flag_rw)
|
||||
grants = m_in.COUNT;
|
||||
if((r = sys_safecopyfrom(who_e, grant_id, 0, (vir_bytes) iov_proc,
|
||||
grants * sizeof(iovec_t), D)) != OK) {
|
||||
panic(__FILE__, "copying in grant vector failed", r);
|
||||
panic("copying in grant vector failed: %d", r);
|
||||
}
|
||||
|
||||
pos = make64(m_in.POSITION, m_in.HIGHPOS);
|
||||
@@ -240,7 +240,7 @@ static int do_vrdwt(int flag_rw)
|
||||
/* Copy the caller's grant-table back. */
|
||||
if((r = sys_safecopyto(who_e, grant_id, 0, (vir_bytes) iov_proc,
|
||||
grants * sizeof(iovec_t), D)) != OK) {
|
||||
panic(__FILE__, "copying out grant vector failed", r);
|
||||
panic("copying out grant vector failed: %d", r);
|
||||
}
|
||||
|
||||
flt_free(buffer, size, buf_array);
|
||||
@@ -405,7 +405,7 @@ int main(int argc, char *argv[])
|
||||
for (;;) {
|
||||
/* Wait for request. */
|
||||
if(sef_receive(ANY, &m_in) != OK) {
|
||||
panic(__FILE__, "sef_receive failed", NO_NUM);
|
||||
panic("sef_receive failed");
|
||||
}
|
||||
|
||||
#if DEBUG2
|
||||
@@ -480,7 +480,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
|
||||
}
|
||||
|
||||
if ((buf_array = flt_malloc(BUF_SIZE, NULL, 0)) == NULL)
|
||||
panic(__FILE__, "no memory available", NO_NUM);
|
||||
panic("no memory available");
|
||||
|
||||
sum_init();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ void sum_init(void)
|
||||
rb1_array = flt_malloc(SBUF_SIZE, NULL, 0);
|
||||
|
||||
if (ext_array == NULL || rb0_array == NULL || rb1_array == NULL)
|
||||
panic(__FILE__, "no memory available", NO_NUM);
|
||||
panic("no memory available");
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -92,7 +92,7 @@ static void calc_sum(unsigned sector, char *data, char *sum)
|
||||
break;
|
||||
|
||||
default:
|
||||
panic(__FILE__, "invalid checksum type", SUM_TYPE);
|
||||
panic("invalid checksum type: %d", SUM_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,12 +252,12 @@ static int make_sum(sector_t current_sector, sector_t sectors_left)
|
||||
size = sectors_left * SECTOR_SIZE;
|
||||
|
||||
if (group_left != NR_SUM_SEC - sector_in_group)
|
||||
panic(__FILE__, "group_left assertion", 0);
|
||||
panic("group_left assertion: %d", 0);
|
||||
|
||||
gap = group_left - sectors_left;
|
||||
|
||||
if (gap <= 0)
|
||||
panic(__FILE__, "gap assertion", 0);
|
||||
panic("gap assertion: %d", 0);
|
||||
|
||||
if ((r = read_sectors(extp + size,
|
||||
LOG2PHYS(current_sector) + sectors_left,
|
||||
|
||||
@@ -21,7 +21,7 @@ char *flt_malloc(size_t size, char *sbuf, size_t ssize)
|
||||
return sbuf;
|
||||
|
||||
if(!(p = alloc_contig(size, 0, NULL)))
|
||||
panic(__FILE__, "out of memory", size);
|
||||
panic("out of memory: %d", size);
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -66,17 +66,17 @@ clock_t flt_alarm(clock_t dt)
|
||||
r = sys_setalarm(dt, 0);
|
||||
|
||||
if(r != OK)
|
||||
panic(__FILE__, "sys_setalarm failed", r);
|
||||
panic("sys_setalarm failed: %d", r);
|
||||
|
||||
if(dt == 0) {
|
||||
if(!next_alarm)
|
||||
panic(__FILE__, "clearing unset alarm", r);
|
||||
panic("clearing unset alarm: %d", r);
|
||||
next_alarm = 0;
|
||||
} else {
|
||||
if(next_alarm)
|
||||
panic(__FILE__, "overwriting alarm", r);
|
||||
panic("overwriting alarm: %d", r);
|
||||
if ((r = getuptime(&next_alarm)) != OK)
|
||||
panic(__FILE__, "getuptime failed", r);
|
||||
panic("getuptime failed: %d", r);
|
||||
next_alarm += dt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user