Subversion Repositories HelenOS

Rev

Rev 2787 | Rev 4377 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 3424
Line 561... Line 561...
561
    ASSERT(uptime);
561
    ASSERT(uptime);
562
   
562
   
563
    /* This doesn't have to be very accurate */
563
    /* This doesn't have to be very accurate */
564
    unative_t sec = uptime->seconds1;
564
    unative_t sec = uptime->seconds1;
565
   
565
   
566
    printf("Up %u days, %u hours, %u minutes, %u seconds\n",
566
    printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
567
        sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
567
        sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
568
   
568
   
569
    return 1;
569
    return 1;
570
}
570
}
571
 
571
 
Line 630... Line 630...
630
    else if (symaddr == (uintptr_t) -1) {
630
    else if (symaddr == (uintptr_t) -1) {
631
        symtab_print_search((char *) argv->buffer);
631
        symtab_print_search((char *) argv->buffer);
632
        printf("Duplicate symbol, be more specific.\n");
632
        printf("Duplicate symbol, be more specific.\n");
633
    } else {
633
    } else {
634
        symbol = get_symtab_entry(symaddr);
634
        symbol = get_symtab_entry(symaddr);
635
        printf("Calling %s() (%.*p)\n", symbol, sizeof(uintptr_t) * 2, symaddr);
635
        printf("Calling %s() (%p)\n", symbol, symaddr);
636
#ifdef ia64
636
#ifdef ia64
637
        fptr.f = symaddr;
637
        fptr.f = symaddr;
638
        fptr.gp = ((unative_t *)cmd_call2)[1];
638
        fptr.gp = ((unative_t *)cmd_call2)[1];
639
        f =  (unative_t (*)(void)) &fptr;
639
        f =  (unative_t (*)(void)) &fptr;
640
#else
640
#else
641
        f =  (unative_t (*)(void)) symaddr;
641
        f =  (unative_t (*)(void)) symaddr;
642
#endif
642
#endif
643
        printf("Result: %#zx\n", f());
643
        printf("Result: %#" PRIxn "\n", f());
644
    }
644
    }
645
   
645
   
646
    return 1;
646
    return 1;
647
}
647
}
648
 
648
 
Line 684... Line 684...
684
    unative_t arg1 = argv[1].intval;
684
    unative_t arg1 = argv[1].intval;
685
#ifdef ia64
685
#ifdef ia64
686
    struct {
686
    struct {
687
        unative_t f;
687
        unative_t f;
688
        unative_t gp;
688
        unative_t gp;
689
    }fptr;
689
    } fptr;
690
#endif
690
#endif
691
 
691
 
692
    symaddr = get_symbol_addr((char *) argv->buffer);
692
    symaddr = get_symbol_addr((char *) argv->buffer);
693
    if (!symaddr)
693
    if (!symaddr)
694
        printf("Symbol %s not found.\n", argv->buffer);
694
        printf("Symbol %s not found.\n", argv->buffer);
Line 696... Line 696...
696
        symtab_print_search((char *) argv->buffer);
696
        symtab_print_search((char *) argv->buffer);
697
        printf("Duplicate symbol, be more specific.\n");
697
        printf("Duplicate symbol, be more specific.\n");
698
    } else {
698
    } else {
699
        symbol = get_symtab_entry(symaddr);
699
        symbol = get_symtab_entry(symaddr);
700
 
700
 
701
        printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol);
701
        printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
702
#ifdef ia64
702
#ifdef ia64
703
        fptr.f = symaddr;
703
        fptr.f = symaddr;
704
        fptr.gp = ((unative_t *)cmd_call2)[1];
704
        fptr.gp = ((unative_t *)cmd_call2)[1];
705
        f =  (unative_t (*)(unative_t,...)) &fptr;
705
        f =  (unative_t (*)(unative_t,...)) &fptr;
706
#else
706
#else
707
        f =  (unative_t (*)(unative_t,...)) symaddr;
707
        f =  (unative_t (*)(unative_t,...)) symaddr;
708
#endif
708
#endif
709
        printf("Result: %#zx\n", f(arg1));
709
        printf("Result: %#" PRIxn "\n", f(arg1));
710
    }
710
    }
711
   
711
   
712
    return 1;
712
    return 1;
713
}
713
}
714
 
714
 
Line 733... Line 733...
733
    else if (symaddr == (uintptr_t) -1) {
733
    else if (symaddr == (uintptr_t) -1) {
734
        symtab_print_search((char *) argv->buffer);
734
        symtab_print_search((char *) argv->buffer);
735
        printf("Duplicate symbol, be more specific.\n");
735
        printf("Duplicate symbol, be more specific.\n");
736
    } else {
736
    } else {
737
        symbol = get_symtab_entry(symaddr);
737
        symbol = get_symtab_entry(symaddr);
738
        printf("Calling f(0x%zx,0x%zx): %.*p: %s\n",
738
        printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
739
               arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol);
739
               arg1, arg2, symaddr, symbol);
740
#ifdef ia64
740
#ifdef ia64
741
        fptr.f = symaddr;
741
        fptr.f = symaddr;
742
        fptr.gp = ((unative_t *)cmd_call2)[1];
742
        fptr.gp = ((unative_t *)cmd_call2)[1];
743
        f =  (unative_t (*)(unative_t,unative_t,...)) &fptr;
743
        f =  (unative_t (*)(unative_t,unative_t,...)) &fptr;
744
#else
744
#else
745
        f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
745
        f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
746
#endif
746
#endif
747
        printf("Result: %#zx\n", f(arg1, arg2));
747
        printf("Result: %#" PRIxn "\n", f(arg1, arg2));
748
    }
748
    }
749
   
749
   
750
    return 1;
750
    return 1;
751
}
751
}
752
 
752
 
Line 772... Line 772...
772
    else if (symaddr == (uintptr_t) -1) {
772
    else if (symaddr == (uintptr_t) -1) {
773
        symtab_print_search((char *) argv->buffer);
773
        symtab_print_search((char *) argv->buffer);
774
        printf("Duplicate symbol, be more specific.\n");
774
        printf("Duplicate symbol, be more specific.\n");
775
    } else {
775
    } else {
776
        symbol = get_symtab_entry(symaddr);
776
        symbol = get_symtab_entry(symaddr);
777
        printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n",
777
        printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
778
               arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol);
778
               arg1, arg2, arg3, symaddr, symbol);
779
#ifdef ia64
779
#ifdef ia64
780
        fptr.f = symaddr;
780
        fptr.f = symaddr;
781
        fptr.gp = ((unative_t *)cmd_call2)[1];
781
        fptr.gp = ((unative_t *)cmd_call2)[1];
782
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
782
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
783
#else
783
#else
784
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
784
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
785
#endif
785
#endif
786
        printf("Result: %#zx\n", f(arg1, arg2, arg3));
786
        printf("Result: %#" PRIxn "\n", f(arg1, arg2, arg3));
787
    }
787
    }
788
   
788
   
789
    return 1;
789
    return 1;
790
}
790
}
791
 
791
 
Line 854... Line 854...
854
        symtab_print_search((char *) argv->buffer);
854
        symtab_print_search((char *) argv->buffer);
855
        printf("Duplicate symbol, be more specific.\n");
855
        printf("Duplicate symbol, be more specific.\n");
856
    } else {
856
    } else {
857
        if (pointer)
857
        if (pointer)
858
            addr = (uint32_t *)(*(unative_t *)addr);
858
            addr = (uint32_t *)(*(unative_t *)addr);
859
        printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr);
859
        printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
860
        *addr = arg1;
860
        *addr = arg1;
861
       
861
       
862
    }
862
    }
863
   
863
   
864
    return 1;
864
    return 1;
Line 1023... Line 1023...
1023
   
1023
   
1024
    uint64_t cycles;
1024
    uint64_t cycles;
1025
    char suffix;
1025
    char suffix;
1026
    order(dt, &cycles, &suffix);
1026
    order(dt, &cycles, &suffix);
1027
       
1027
       
1028
    printf("Time: %llu%c cycles\n", cycles, suffix);
1028
    printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix);
1029
   
1029
   
1030
    if (ret == NULL) {
1030
    if (ret == NULL) {
1031
        printf("Test passed\n");
1031
        printf("Test passed\n");
1032
        return true;
1032
        return true;
1033
    }
1033
    }
Line 1051... Line 1051...
1051
        printf("Error allocating memory for statistics\n");
1051
        printf("Error allocating memory for statistics\n");
1052
        return false;
1052
        return false;
1053
    }
1053
    }
1054
   
1054
   
1055
    for (i = 0; i < cnt; i++) {
1055
    for (i = 0; i < cnt; i++) {
1056
        printf("%s (%d/%d) ... ", test->name, i + 1, cnt);
1056
        printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
1057
       
1057
       
1058
        /* Update and read thread accounting
1058
        /* Update and read thread accounting
1059
           for benchmarking */
1059
           for benchmarking */
1060
        ipl_t ipl = interrupts_disable();
1060
        ipl_t ipl = interrupts_disable();
1061
        spinlock_lock(&TASK->lock);
1061
        spinlock_lock(&TASK->lock);
Line 1079... Line 1079...
1079
            break;
1079
            break;
1080
        }
1080
        }
1081
       
1081
       
1082
        data[i] = dt;
1082
        data[i] = dt;
1083
        order(dt, &cycles, &suffix);
1083
        order(dt, &cycles, &suffix);
1084
        printf("OK (%llu%c cycles)\n", cycles, suffix);
1084
        printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix);
1085
    }
1085
    }
1086
   
1086
   
1087
    if (ret) {
1087
    if (ret) {
1088
        printf("\n");
1088
        printf("\n");
1089
       
1089
       
Line 1092... Line 1092...
1092
        for (i = 0; i < cnt; i++) {
1092
        for (i = 0; i < cnt; i++) {
1093
            sum += data[i];
1093
            sum += data[i];
1094
        }
1094
        }
1095
       
1095
       
1096
        order(sum / (uint64_t) cnt, &cycles, &suffix);
1096
        order(sum / (uint64_t) cnt, &cycles, &suffix);
1097
        printf("Average\t\t%llu%c\n", cycles, suffix);
1097
        printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);
1098
    }
1098
    }
1099
   
1099
   
1100
    free(data);
1100
    free(data);
1101
   
1101
   
1102
    return ret;
1102
    return ret;