run_avr: Add -v argument to raise verbosity level
authorJakob Gruber <jakob.gruber@gmail.com>
Thu, 2 Aug 2012 07:41:05 +0000 (09:41 +0200)
committerJakob Gruber <jakob.gruber@gmail.com>
Sun, 5 Aug 2012 11:00:53 +0000 (13:00 +0200)
Pass it more than once to raise it further. This works better with the
standard conventions, which would allow passing -vvv (instead of -v -v
-v). Unfortunately, this does not work here.

The type of avr->log has been altered to accomodate values up to 3.

simavr/sim/run_avr.c
simavr/sim/sim_avr.h

index f1f04c3..e18f1cd 100644 (file)
 
 void display_usage(char * app)
 {
-       printf("usage: %s [-t] [-g] [-m <device>] [-f <frequency>] firmware\n", app);
-       printf("       -t: run full scale decoder trace\n"
-                  "       -g: listen for gdb connection on port 1234\n"
-                  "       -ff: Loads next .hex file as flash\n"
-                  "       -ee: Loads next .hex file as eeprom\n"
+       printf("Usage: %s [-t] [-g] [-v] [-m <device>] [-f <frequency>] firmware\n", app);
+       printf("       -t: Run full scale decoder trace\n"
+                  "       -g: Listen for gdb connection on port 1234\n"
+                  "       -ff: Load next .hex file as flash\n"
+                  "       -ee: Load next .hex file as eeprom\n"
+                  "       -v: Raise verbosity level (can be passed more than once)\n"
                   "   Supported AVR cores:\n");
        for (int i = 0; avr_kind[i]; i++) {
                printf("       ");
@@ -67,6 +68,7 @@ int main(int argc, char *argv[])
        long f_cpu = 0;
        int trace = 0;
        int gdb = 0;
+       int log = 1;
        char name[16] = "";
        uint32_t loadBase = AVR_SEGMENT_OFFSET_FLASH;
        int trace_vectors[8] = {0};
@@ -95,6 +97,8 @@ int main(int argc, char *argv[])
                                trace_vectors[trace_vectors_count++] = atoi(argv[++pi]);
                } else if (!strcmp(argv[pi], "-g") || !strcmp(argv[pi], "-gdb")) {
                        gdb++;
+               } else if (!strcmp(argv[pi], "-v")) {
+                       log++;
                } else if (!strcmp(argv[pi], "-ee")) {
                        loadBase = AVR_SEGMENT_OFFSET_EEPROM;
                } else if (!strcmp(argv[pi], "-ff")) {
@@ -155,6 +159,7 @@ int main(int argc, char *argv[])
                printf("Attempted to load a bootloader at %04x\n", f.flashbase);
                avr->pc = f.flashbase;
        }
+       avr->log = (log > LOG_TRACE ? LOG_TRACE : log);
        avr->trace = trace;
        for (int ti = 0; ti < trace_vectors_count; ti++)
                if (avr->interrupts.vector[trace_vectors[ti]])
index 6f6cc34..737b3ce 100644 (file)
@@ -245,7 +245,7 @@ typedef struct avr_t {
        avr_int_table_t interrupts;
 
        // DEBUG ONLY -- value ignored if CONFIG_SIMAVR_TRACE = 0
-       int             trace : 1,
+       uint8_t trace : 1,
                        log : 2; // log level, default to 1
 
        // Only used if CONFIG_SIMAVR_TRACE is defined