Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a command line parameter: --small-log, output log to a limited size FILE, but log is always up to date #135

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f5e0587
add h extention
pxk27 Jan 8, 2023
ab7bb33
correct csr r/w
pxk27 Jan 12, 2023
6087c0e
Merge branch 'OpenXiangShan:master' into master
pxk27 Jan 12, 2023
4c0755b
add the difftest with spike
pxk27 Jan 12, 2023
935ea3b
difftest bug
pxk27 Jan 14, 2023
704ae3e
merge the last master 2023.1.14
pxk27 Jan 14, 2023
a764079
correct some bugs about initializing csr, virtual memory and interrupt
pxk27 Feb 3, 2023
ffa08ef
correct some bugs about privilege and some exception
pxk27 Feb 3, 2023
98754cf
correct some bugs about two stage translation
pxk27 Feb 7, 2023
5b351fc
correct some bugs about interrupt delegation and pc synchronizes when…
pxk27 Feb 8, 2023
41a0d94
fix the read/write bugs of mip sip vsip hip hvip
pxk27 Feb 9, 2023
19d88e7
fix the bugs about h ld/st instruction access and load/store when pri…
pxk27 Feb 10, 2023
eb30cc0
fix some bugs about two stage translation
pxk27 Feb 11, 2023
b07fddb
delete some print
pxk27 Feb 11, 2023
e06ed34
modify difftest ref
pxk27 Mar 10, 2023
13618c6
modify default paddrbits
pxk27 Mar 17, 2023
2df15c9
add hpm to run opensbi and difftest with spike
pxk27 Mar 24, 2023
f81f16d
modify the r/w of xatp csr
pxk27 Mar 29, 2023
a50dc56
fix some bugs
pxk27 Apr 1, 2023
30845e5
fix bug when close opt
pxk27 May 11, 2023
30c8870
fix a bug about A extension: if execute sc faild, we should clear lr_…
pxk27 May 17, 2023
cac155d
modify ad of pte by soft; add hcounteren
pxk27 May 18, 2023
b83d28b
modify hcounteren mask
pxk27 May 18, 2023
1d52554
fix a bug about difference between NEMU and spike when guest page fau…
pxk27 May 18, 2023
ff82069
fix bugs about two stage translation and htval
pxk27 May 18, 2023
40bfa42
fix a bug about difftest pc
pxk27 Jun 6, 2023
366eb82
improve log function of NEMU
pxk27 Jun 9, 2023
8bba64c
fix some bugs about log function
pxk27 Jun 12, 2023
ef2c690
fix a bug about log function
pxk27 Jun 12, 2023
28408d5
fix a bug about tcache
pxk27 Jun 13, 2023
7f91061
nemu can run over the guest linux
pxk27 Jun 14, 2023
23ca5c7
nemu:update vsstatus sd
pxk27 Jun 19, 2023
01c3221
modify the usage of vsstatus
pxk27 Jun 27, 2023
727d02a
delete unnecessary
pxk27 Jun 28, 2023
233f656
fix status sd
pxk27 Jun 30, 2023
5485aea
run kvm when opening difftest with Spike
pxk27 Jul 2, 2023
cad65d8
merge remote master
pxk27 Jul 4, 2023
cdf4c64
compile NEMU without H extention
pxk27 Jul 4, 2023
7e4a151
change some code according to review from pr
pxk27 Jul 12, 2023
fdedb02
change some code according to review from pr
pxk27 Jul 12, 2023
eeebc1e
Merge branch 'OpenXiangShan:master' into master
pxk27 Jul 19, 2023
bf931f8
add a command line parameter: --small-log, output log to a limited si…
pxk27 Aug 25, 2023
4ef0c1b
Merge branch 'OpenXiangShan:master' into master
pxk27 Aug 25, 2023
21dc61e
fix a bug when compiling nemu as reference
pxk27 Aug 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ uint64_t get_time();
)*/
#define log_write(...) \
do { \
extern bool enable_small_log; \
extern FILE* log_fp; \
extern char *log_filebuf; \
extern uint64_t record_row_number; \
extern bool log_enable(); \
extern void log_flush(); \
if (log_fp != NULL) { \
snprintf(log_filebuf + record_row_number * 300, 300, __VA_ARGS__);\
log_flush(); \
if (enable_small_log) { \
snprintf(log_filebuf + record_row_number * 300, 300, __VA_ARGS__);\
log_flush(); \
} else if (log_enable()){ \
fprintf(log_fp, __VA_ARGS__); \
fflush(log_fp); \
} \
}else{ \
printf(__VA_ARGS__); \
} \
Expand Down
1 change: 1 addition & 0 deletions src/checkpoint/simpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern void log_flush();
extern char *log_filebuf;
extern uint64_t record_row_number;
extern FILE *log_fp;
extern bool enable_small_log;
}

SimPoint::SimPoint()
Expand Down
6 changes: 4 additions & 2 deletions src/cpu/cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,11 @@ static int execute(int n) {
#endif // CONFIG_BR_LOG
IFDEF(CONFIG_DEBUG, debug_hook(s.pc, s.logbuf));
IFDEF(CONFIG_DIFFTEST, difftest_step(s.pc, cpu.pc));
if(isa_query_intr()){break;}
if (isa_query_intr() != INTR_EMPTY){
break;
}
if (nemu_state.state == NEMU_STOP) {
break;
break;
}
}
return n;
Expand Down
14 changes: 12 additions & 2 deletions src/monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

#ifndef CONFIG_SHARE
void init_aligncheck();
void init_log(const char *log_file);
void init_log(const char *log_file, const bool small_log);
void init_mem();
void init_regex();
void init_wp_pool();
void init_difftest(char *ref_so_file, long img_size, int port);
void init_device();

static char *log_file = NULL;
bool small_log = false;
static char *diff_so_file = NULL;
static char *img_file = NULL;
static int batch_mode = false;
Expand Down Expand Up @@ -88,6 +89,9 @@ static inline int parse_args(int argc, char *argv[]) {
{"dump-mem" , required_argument, NULL, 'M'},
{"dump-reg" , required_argument, NULL, 'R'},

// small log file
{"small-log" , required_argument, NULL, 8},

{0 , 0 , NULL, 0 },
};
int o;
Expand Down Expand Up @@ -153,11 +157,17 @@ static inline int parse_args(int argc, char *argv[]) {

case 4: sscanf(optarg, "%d", &cpt_id); break;

case 8:
log_file = optarg;
small_log = true;
break;

default:
printf("Usage: %s [OPTION...] IMAGE [args]\n\n", argv[0]);
printf("\t-b,--batch run with batch mode\n");
printf("\t-I,--max-instr max number of instructions executed\n");
printf("\t-l,--log=FILE output log to FILE\n");
printf("\t--small-log=FILE output log to a limited size FILE, but log is always up to date\n");
printf("\t-d,--diff=REF_SO run DiffTest with reference REF_SO\n");
printf("\t-p,--port=PORT run DiffTest with port PORT\n");

Expand Down Expand Up @@ -208,7 +218,7 @@ void init_monitor(int argc, char *argv[]) {
}

/* Open the log file. */
init_log(log_file);
init_log(log_file, small_log);

/* Initialize memory. */
init_mem();
Expand Down
23 changes: 13 additions & 10 deletions src/utils/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,35 @@
// control when the log is printed, unit: number of instructions
#define LOG_START (0)
// restrict the size of log file
#define LOG_END (100 * 1024)
#define LOG_ROW_NUM (LOG_END - LOG_START) // row number
#define LOG_END (1024 * 1024 * 50)
#define SMALL_LOG_ROW_NUM (100 * 1024) // row number
uint64_t record_row_number = 0;
FILE *log_fp = NULL;
char *log_filebuf;
void init_log(const char *log_file) {
bool enable_small_log = false;
void init_log(const char *log_file, const bool small_log) {
if (log_file == NULL) return;
log_fp = fopen(log_file, "w");
Assert(log_fp, "Can not open '%s'", log_file);
log_filebuf = (char *)malloc(sizeof(char) * LOG_ROW_NUM * 300);

enable_small_log = small_log;
if (enable_small_log)
log_filebuf = (char *)malloc(sizeof(char) * SMALL_LOG_ROW_NUM * 300);
}

// bool log_enable() {
// extern uint64_t g_nr_guest_instr;
// return (g_nr_guest_instr >= LOG_START) && (g_nr_guest_instr <= LOG_END);
// }
bool log_enable() {
extern uint64_t g_nr_guest_instr;
return (g_nr_guest_instr >= LOG_START) && (g_nr_guest_instr <= LOG_END);
}

void log_flush() {
record_row_number ++;
if(record_row_number > LOG_ROW_NUM){
if(record_row_number > SMALL_LOG_ROW_NUM){
// rewind(log_fp);
record_row_number = 0;
}
}
void log_close(){
if (enable_small_log == false) return;
if (log_fp == NULL) return;
// fprintf(log_fp, "%s", log_filebuf);
for (int i = 0; i < record_row_number; i++)
Expand Down
Loading