Rev 1735 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1735 | Rev 1780 | ||
---|---|---|---|
Line 477... | Line 477... | ||
477 | } |
477 | } |
478 | 478 | ||
479 | /** Call function with zero parameters */ |
479 | /** Call function with zero parameters */ |
480 | int cmd_call0(cmd_arg_t *argv) |
480 | int cmd_call0(cmd_arg_t *argv) |
481 | { |
481 | { |
482 | __address symaddr; |
482 | uintptr_t symaddr; |
483 | char *symbol; |
483 | char *symbol; |
484 | __native (*f)(void); |
484 | unative_t (*f)(void); |
485 | #ifdef ia64 |
485 | #ifdef ia64 |
486 | struct { |
486 | struct { |
487 | __native f; |
487 | unative_t f; |
488 | __native gp; |
488 | unative_t gp; |
489 | }fptr; |
489 | }fptr; |
490 | #endif |
490 | #endif |
491 | 491 | ||
492 | symaddr = get_symbol_addr(argv->buffer); |
492 | symaddr = get_symbol_addr(argv->buffer); |
493 | if (!symaddr) |
493 | if (!symaddr) |
494 | printf("Symbol %s not found.\n", argv->buffer); |
494 | printf("Symbol %s not found.\n", argv->buffer); |
495 | else if (symaddr == (__address) -1) { |
495 | else if (symaddr == (uintptr_t) -1) { |
496 | symtab_print_search(argv->buffer); |
496 | symtab_print_search(argv->buffer); |
497 | printf("Duplicate symbol, be more specific.\n"); |
497 | printf("Duplicate symbol, be more specific.\n"); |
498 | } else { |
498 | } else { |
499 | symbol = get_symtab_entry(symaddr); |
499 | symbol = get_symtab_entry(symaddr); |
500 | printf("Calling f(): %.*p: %s\n", sizeof(__address) * 2, symaddr, symbol); |
500 | printf("Calling f(): %.*p: %s\n", sizeof(uintptr_t) * 2, symaddr, symbol); |
501 | #ifdef ia64 |
501 | #ifdef ia64 |
502 | fptr.f = symaddr; |
502 | fptr.f = symaddr; |
503 | fptr.gp = ((__native *)cmd_call2)[1]; |
503 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
504 | f = (__native (*)(void)) &fptr; |
504 | f = (unative_t (*)(void)) &fptr; |
505 | #else |
505 | #else |
506 | f = (__native (*)(void)) symaddr; |
506 | f = (unative_t (*)(void)) symaddr; |
507 | #endif |
507 | #endif |
508 | printf("Result: %#zx\n", f()); |
508 | printf("Result: %#zx\n", f()); |
509 | } |
509 | } |
510 | 510 | ||
511 | return 1; |
511 | return 1; |
512 | } |
512 | } |
513 | 513 | ||
514 | /** Call function with one parameter */ |
514 | /** Call function with one parameter */ |
515 | int cmd_call1(cmd_arg_t *argv) |
515 | int cmd_call1(cmd_arg_t *argv) |
516 | { |
516 | { |
517 | __address symaddr; |
517 | uintptr_t symaddr; |
518 | char *symbol; |
518 | char *symbol; |
519 | __native (*f)(__native,...); |
519 | unative_t (*f)(unative_t,...); |
520 | __native arg1 = argv[1].intval; |
520 | unative_t arg1 = argv[1].intval; |
521 | #ifdef ia64 |
521 | #ifdef ia64 |
522 | struct { |
522 | struct { |
523 | __native f; |
523 | unative_t f; |
524 | __native gp; |
524 | unative_t gp; |
525 | }fptr; |
525 | }fptr; |
526 | #endif |
526 | #endif |
527 | 527 | ||
528 | symaddr = get_symbol_addr(argv->buffer); |
528 | symaddr = get_symbol_addr(argv->buffer); |
529 | if (!symaddr) |
529 | if (!symaddr) |
530 | printf("Symbol %s not found.\n", argv->buffer); |
530 | printf("Symbol %s not found.\n", argv->buffer); |
531 | else if (symaddr == (__address) -1) { |
531 | else if (symaddr == (uintptr_t) -1) { |
532 | symtab_print_search(argv->buffer); |
532 | symtab_print_search(argv->buffer); |
533 | printf("Duplicate symbol, be more specific.\n"); |
533 | printf("Duplicate symbol, be more specific.\n"); |
534 | } else { |
534 | } else { |
535 | symbol = get_symtab_entry(symaddr); |
535 | symbol = get_symtab_entry(symaddr); |
536 | 536 | ||
537 | printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(__address) * 2, symaddr, symbol); |
537 | printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol); |
538 | #ifdef ia64 |
538 | #ifdef ia64 |
539 | fptr.f = symaddr; |
539 | fptr.f = symaddr; |
540 | fptr.gp = ((__native *)cmd_call2)[1]; |
540 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
541 | f = (__native (*)(__native,...)) &fptr; |
541 | f = (unative_t (*)(unative_t,...)) &fptr; |
542 | #else |
542 | #else |
543 | f = (__native (*)(__native,...)) symaddr; |
543 | f = (unative_t (*)(unative_t,...)) symaddr; |
544 | #endif |
544 | #endif |
545 | printf("Result: %#zx\n", f(arg1)); |
545 | printf("Result: %#zx\n", f(arg1)); |
546 | } |
546 | } |
547 | 547 | ||
548 | return 1; |
548 | return 1; |
549 | } |
549 | } |
550 | 550 | ||
551 | /** Call function with two parameters */ |
551 | /** Call function with two parameters */ |
552 | int cmd_call2(cmd_arg_t *argv) |
552 | int cmd_call2(cmd_arg_t *argv) |
553 | { |
553 | { |
554 | __address symaddr; |
554 | uintptr_t symaddr; |
555 | char *symbol; |
555 | char *symbol; |
556 | __native (*f)(__native,__native,...); |
556 | unative_t (*f)(unative_t,unative_t,...); |
557 | __native arg1 = argv[1].intval; |
557 | unative_t arg1 = argv[1].intval; |
558 | __native arg2 = argv[2].intval; |
558 | unative_t arg2 = argv[2].intval; |
559 | #ifdef ia64 |
559 | #ifdef ia64 |
560 | struct { |
560 | struct { |
561 | __native f; |
561 | unative_t f; |
562 | __native gp; |
562 | unative_t gp; |
563 | }fptr; |
563 | }fptr; |
564 | #endif |
564 | #endif |
565 | 565 | ||
566 | symaddr = get_symbol_addr(argv->buffer); |
566 | symaddr = get_symbol_addr(argv->buffer); |
567 | if (!symaddr) |
567 | if (!symaddr) |
568 | printf("Symbol %s not found.\n", argv->buffer); |
568 | printf("Symbol %s not found.\n", argv->buffer); |
569 | else if (symaddr == (__address) -1) { |
569 | else if (symaddr == (uintptr_t) -1) { |
570 | symtab_print_search(argv->buffer); |
570 | symtab_print_search(argv->buffer); |
571 | printf("Duplicate symbol, be more specific.\n"); |
571 | printf("Duplicate symbol, be more specific.\n"); |
572 | } else { |
572 | } else { |
573 | symbol = get_symtab_entry(symaddr); |
573 | symbol = get_symtab_entry(symaddr); |
574 | printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", |
574 | printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", |
575 | arg1, arg2, sizeof(__address) * 2, symaddr, symbol); |
575 | arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol); |
576 | #ifdef ia64 |
576 | #ifdef ia64 |
577 | fptr.f = symaddr; |
577 | fptr.f = symaddr; |
578 | fptr.gp = ((__native *)cmd_call2)[1]; |
578 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
579 | f = (__native (*)(__native,__native,...)) &fptr; |
579 | f = (unative_t (*)(unative_t,unative_t,...)) &fptr; |
580 | #else |
580 | #else |
581 | f = (__native (*)(__native,__native,...)) symaddr; |
581 | f = (unative_t (*)(unative_t,unative_t,...)) symaddr; |
582 | #endif |
582 | #endif |
583 | printf("Result: %#zx\n", f(arg1, arg2)); |
583 | printf("Result: %#zx\n", f(arg1, arg2)); |
584 | } |
584 | } |
585 | 585 | ||
586 | return 1; |
586 | return 1; |
587 | } |
587 | } |
588 | 588 | ||
589 | /** Call function with three parameters */ |
589 | /** Call function with three parameters */ |
590 | int cmd_call3(cmd_arg_t *argv) |
590 | int cmd_call3(cmd_arg_t *argv) |
591 | { |
591 | { |
592 | __address symaddr; |
592 | uintptr_t symaddr; |
593 | char *symbol; |
593 | char *symbol; |
594 | __native (*f)(__native,__native,__native,...); |
594 | unative_t (*f)(unative_t,unative_t,unative_t,...); |
595 | __native arg1 = argv[1].intval; |
595 | unative_t arg1 = argv[1].intval; |
596 | __native arg2 = argv[2].intval; |
596 | unative_t arg2 = argv[2].intval; |
597 | __native arg3 = argv[3].intval; |
597 | unative_t arg3 = argv[3].intval; |
598 | #ifdef ia64 |
598 | #ifdef ia64 |
599 | struct { |
599 | struct { |
600 | __native f; |
600 | unative_t f; |
601 | __native gp; |
601 | unative_t gp; |
602 | }fptr; |
602 | }fptr; |
603 | #endif |
603 | #endif |
604 | 604 | ||
605 | symaddr = get_symbol_addr(argv->buffer); |
605 | symaddr = get_symbol_addr(argv->buffer); |
606 | if (!symaddr) |
606 | if (!symaddr) |
607 | printf("Symbol %s not found.\n", argv->buffer); |
607 | printf("Symbol %s not found.\n", argv->buffer); |
608 | else if (symaddr == (__address) -1) { |
608 | else if (symaddr == (uintptr_t) -1) { |
609 | symtab_print_search(argv->buffer); |
609 | symtab_print_search(argv->buffer); |
610 | printf("Duplicate symbol, be more specific.\n"); |
610 | printf("Duplicate symbol, be more specific.\n"); |
611 | } else { |
611 | } else { |
612 | symbol = get_symtab_entry(symaddr); |
612 | symbol = get_symtab_entry(symaddr); |
613 | printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", |
613 | printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", |
614 | arg1, arg2, arg3, sizeof(__address) * 2, symaddr, symbol); |
614 | arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol); |
615 | #ifdef ia64 |
615 | #ifdef ia64 |
616 | fptr.f = symaddr; |
616 | fptr.f = symaddr; |
617 | fptr.gp = ((__native *)cmd_call2)[1]; |
617 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
618 | f = (__native (*)(__native,__native,__native,...)) &fptr; |
618 | f = (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr; |
619 | #else |
619 | #else |
620 | f = (__native (*)(__native,__native,__native,...)) symaddr; |
620 | f = (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr; |
621 | #endif |
621 | #endif |
622 | printf("Result: %#zx\n", f(arg1, arg2, arg3)); |
622 | printf("Result: %#zx\n", f(arg1, arg2, arg3)); |
623 | } |
623 | } |
624 | 624 | ||
625 | return 1; |
625 | return 1; |
Line 657... | Line 657... | ||
657 | } |
657 | } |
658 | 658 | ||
659 | /** Write 4 byte value to address */ |
659 | /** Write 4 byte value to address */ |
660 | int cmd_set4(cmd_arg_t *argv) |
660 | int cmd_set4(cmd_arg_t *argv) |
661 | { |
661 | { |
662 | __u32 *addr ; |
662 | uint32_t *addr ; |
663 | __u32 arg1 = argv[1].intval; |
663 | uint32_t arg1 = argv[1].intval; |
664 | bool pointer = false; |
664 | bool pointer = false; |
665 | 665 | ||
666 | if (((char *)argv->buffer)[0] == '*') { |
666 | if (((char *)argv->buffer)[0] == '*') { |
667 | addr = (__u32 *) get_symbol_addr(argv->buffer+1); |
667 | addr = (uint32_t *) get_symbol_addr(argv->buffer+1); |
668 | pointer = true; |
668 | pointer = true; |
669 | } else if (((char *)argv->buffer)[0] >= '0' && |
669 | } else if (((char *)argv->buffer)[0] >= '0' && |
670 | ((char *)argv->buffer)[0] <= '9') |
670 | ((char *)argv->buffer)[0] <= '9') |
671 | addr = (__u32 *)atoi((char *)argv->buffer); |
671 | addr = (uint32_t *)atoi((char *)argv->buffer); |
672 | else |
672 | else |
673 | addr = (__u32 *)get_symbol_addr(argv->buffer); |
673 | addr = (uint32_t *)get_symbol_addr(argv->buffer); |
674 | 674 | ||
675 | if (!addr) |
675 | if (!addr) |
676 | printf("Symbol %s not found.\n", argv->buffer); |
676 | printf("Symbol %s not found.\n", argv->buffer); |
677 | else if (addr == (__u32 *) -1) { |
677 | else if (addr == (uint32_t *) -1) { |
678 | symtab_print_search(argv->buffer); |
678 | symtab_print_search(argv->buffer); |
679 | printf("Duplicate symbol, be more specific.\n"); |
679 | printf("Duplicate symbol, be more specific.\n"); |
680 | } else { |
680 | } else { |
681 | if (pointer) |
681 | if (pointer) |
682 | addr = (__u32 *)(*(__native *)addr); |
682 | addr = (uint32_t *)(*(unative_t *)addr); |
683 | printf("Writing 0x%x -> %.*p\n", arg1, sizeof(__address) * 2, addr); |
683 | printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr); |
684 | *addr = arg1; |
684 | *addr = arg1; |
685 | 685 | ||
686 | } |
686 | } |
687 | 687 | ||
688 | return 1; |
688 | return 1; |