write byte arrays from param_data in save/restore in JSON style format (using [] instead of {}). fixes in save/restore.

This commit is contained in:
Stanislav Shwartsman 2018-01-26 20:02:28 +00:00
parent 3dd83448eb
commit 7310d9edae
2 changed files with 9 additions and 7 deletions

View File

@ -2310,8 +2310,10 @@ static int parse_line_formatted(const char *context, int num_params, char *param
pname = strtok(param, "=");
val = strtok(NULL, "");
if (val != NULL) {
if (isdigit(val[0])) {
SIM->opt_plugin_ctrl(pname, atoi(val));
if (!strcmp(val, "0") || !stricmp(val, "false")) {
SIM->opt_plugin_ctrl(pname, 0);
} else if (!strcmp(val, "1") || !stricmp(val, "true")) {
SIM->opt_plugin_ctrl(pname, 1);
} else {
PARSE_ERR(("%s: plugin_ctrl directive malformed", context));
}

View File

@ -1275,13 +1275,13 @@ bx_bool bx_real_sim_c::restore_bochs_param(bx_list_c *root, const char *sr_path,
fread(dparam->getptr(), 1, dparam->get_size(), fp2);
fclose(fp2);
}
} else if (!strcmp(ptr, "{")) {
} else if (!strcmp(ptr, "[")) {
i = 0;
do {
bx_restore_getline(fp, buf, BX_PATHNAME_LEN);
ptr = strtok(buf, " ");
while (ptr) {
if (!strcmp(ptr, "}")) {
if (!strcmp(ptr, "]")) {
i = 0;
break;
} else {
@ -1373,7 +1373,7 @@ bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_
case BXT_PARAM_DATA:
{
bx_shadow_data_c *dparam = (bx_shadow_data_c*)node;
if (!dparam->get_format()) {
if (!dparam->is_text_format()) {
node->get_param_path(pname, BX_PATHNAME_LEN);
if (!strncmp(pname, "bochs.", 6)) {
strcpy(pname, pname+6);
@ -1389,7 +1389,7 @@ bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_
fclose(fp2);
}
} else {
fprintf(fp, "{\n");
fprintf(fp, "[\n");
for (i=0; i < (int)dparam->get_size(); i++) {
if ((i % 16) == 0) {
for (j=0; j<(level+1); j++)
@ -1406,7 +1406,7 @@ bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_
}
for (i=0; i<level; i++)
fprintf(fp, " ");
fprintf(fp, "}\n");
fprintf(fp, "]\n");
}
}
break;