[08/23] sim/erc32: added -v and -vv command line switches for verbose output

Message ID 1424159099-5148-9-git-send-email-jiri@gaisler.se
State Superseded
Headers

Commit Message

Jiri Gaisler Feb. 17, 2015, 7:44 a.m. UTC
  * help.c (usage) update usage help print-out

	* sis.c (run_sim) increase debug level with -v and -vv. Also print
	simulation time in long long format.
---
 sim/erc32/help.c |  2 +-
 sim/erc32/sis.c  | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
  

Comments

Mike Frysinger Feb. 17, 2015, 9:13 a.m. UTC | #1
On 17 Feb 2015 08:44, Jiri Gaisler wrote:
> --- a/sim/erc32/sis.c
> +++ b/sim/erc32/sis.c
>
> -			    printf(" %8u ", ebase.simtime);
> +			    printf(" %8llu ", ebase.simtime);

if i'm reading things correctly, simtime is a uint64, which means you should 
include inttypes.h and use PRIu64 here instead of hardcoding llu.

same goes for the other changes you're making like this below.

> @@ -214,6 +214,10 @@ main(argc, argv)
>  #endif
>              } else if (strcmp(argv[stat], "-dumbio") == 0) {
>  		dumbio = 1;
> +            } else if (strcmp(argv[stat], "-v") == 0) {
> +		sis_verbose = 1;
> +            } else if (strcmp(argv[stat], "-vv") == 0) {
> +		sis_verbose = 2;

what about -v -v ?  maybe the -v handler should increment sim_verbose instead
-mike
  

Patch

diff --git a/sim/erc32/help.c b/sim/erc32/help.c
index 21c2a77..6d74e79 100644
--- a/sim/erc32/help.c
+++ b/sim/erc32/help.c
@@ -7,8 +7,8 @@  usage()
 {
 
     printf("usage: sis [-uart1 uart_device1] [-uart2 uart_device2]\n");
+    printf("[-sparclite] [-dumbio] [-v] [-vv]\n");
     printf("[-nfp] [-freq frequency] [-c batch_file] [files]\n");
-    printf("[-sparclite] [-dumbio]\n");
 }
 
 void
diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
index 39050d7..97f1b31 100644
--- a/sim/erc32/sis.c
+++ b/sim/erc32/sis.c
@@ -122,7 +122,7 @@  run_sim(sregs, icount, dis)
 			        sregs->histind = 0;
 		        }
 		        if (dis) {
-			    printf(" %8u ", ebase.simtime);
+			    printf(" %8llu ", ebase.simtime);
 			    dis_mem(sregs->pc, 1, &dinfo);
 		        }
 		    }
@@ -214,6 +214,10 @@  main(argc, argv)
 #endif
             } else if (strcmp(argv[stat], "-dumbio") == 0) {
 		dumbio = 1;
+            } else if (strcmp(argv[stat], "-v") == 0) {
+		sis_verbose = 1;
+            } else if (strcmp(argv[stat], "-vv") == 0) {
+		sis_verbose = 2;
 	    } else {
 		printf("unknown option %s\n", argv[stat]);
 		usage();
@@ -279,7 +283,7 @@  main(argc, argv)
 	case CTRL_C:
 	    printf("\b\bInterrupt!\n");
 	case TIME_OUT:
-	    printf(" Stopped at time %d (%.3f ms)\n", ebase.simtime, 
+	    printf(" Stopped at time %llu (%.3f ms)\n", ebase.simtime,
 	      ((double) ebase.simtime / (double) sregs.freq) / 1000.0);
 	    break;
 	case BPT_HIT:
@@ -289,7 +293,7 @@  main(argc, argv)
 	case ERROR:
 	    printf("IU in error mode (%d)\n", sregs.trap);
 	    stat = 0;
-	    printf(" %8d ", ebase.simtime);
+	    printf(" %8llu ", ebase.simtime);
 	    dis_mem(sregs.pc, 1, &dinfo);
 	    break;
 	default: