Rev 1582 | Rev 1695 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1582 | Rev 1666 | ||
|---|---|---|---|
| Line 475... | Line 475... | ||
| 475 | int cmd_call0(cmd_arg_t *argv) |
475 | int cmd_call0(cmd_arg_t *argv) |
| 476 | { |
476 | { |
| 477 | __address symaddr; |
477 | __address symaddr; |
| 478 | char *symbol; |
478 | char *symbol; |
| 479 | __native (*f)(void); |
479 | __native (*f)(void); |
| - | 480 | #ifdef ia64 |
|
| - | 481 | struct { |
|
| - | 482 | __native f; |
|
| - | 483 | __native gp; |
|
| - | 484 | }fptr; |
|
| - | 485 | #endif |
|
| 480 | 486 | ||
| 481 | symaddr = get_symbol_addr(argv->buffer); |
487 | symaddr = get_symbol_addr(argv->buffer); |
| 482 | if (!symaddr) |
488 | if (!symaddr) |
| 483 | printf("Symbol %s not found.\n", argv->buffer); |
489 | printf("Symbol %s not found.\n", argv->buffer); |
| 484 | else if (symaddr == (__address) -1) { |
490 | else if (symaddr == (__address) -1) { |
| 485 | symtab_print_search(argv->buffer); |
491 | symtab_print_search(argv->buffer); |
| 486 | printf("Duplicate symbol, be more specific.\n"); |
492 | printf("Duplicate symbol, be more specific.\n"); |
| 487 | } else { |
493 | } else { |
| 488 | symbol = get_symtab_entry(symaddr); |
494 | symbol = get_symtab_entry(symaddr); |
| 489 | printf("Calling f(): %.*p: %s\n", sizeof(__address) * 2, symaddr, symbol); |
495 | printf("Calling f(): %.*p: %s\n", sizeof(__address) * 2, symaddr, symbol); |
| - | 496 | #ifdef ia64 |
|
| - | 497 | fptr.f = symaddr; |
|
| - | 498 | fptr.gp = ((__native *)cmd_call2)[1]; |
|
| - | 499 | f = (__native (*)(void)) &fptr; |
|
| - | 500 | #else |
|
| 490 | f = (__native (*)(void)) symaddr; |
501 | f = (__native (*)(void)) symaddr; |
| - | 502 | #endif |
|
| 491 | printf("Result: %#zx\n", f()); |
503 | printf("Result: %#zx\n", f()); |
| 492 | } |
504 | } |
| 493 | 505 | ||
| 494 | return 1; |
506 | return 1; |
| 495 | } |
507 | } |
| Line 499... | Line 511... | ||
| 499 | { |
511 | { |
| 500 | __address symaddr; |
512 | __address symaddr; |
| 501 | char *symbol; |
513 | char *symbol; |
| 502 | __native (*f)(__native,...); |
514 | __native (*f)(__native,...); |
| 503 | __native arg1 = argv[1].intval; |
515 | __native arg1 = argv[1].intval; |
| - | 516 | #ifdef ia64 |
|
| - | 517 | struct { |
|
| - | 518 | __native f; |
|
| - | 519 | __native gp; |
|
| - | 520 | }fptr; |
|
| - | 521 | #endif |
|
| 504 | 522 | ||
| 505 | symaddr = get_symbol_addr(argv->buffer); |
523 | symaddr = get_symbol_addr(argv->buffer); |
| 506 | if (!symaddr) |
524 | if (!symaddr) |
| 507 | printf("Symbol %s not found.\n", argv->buffer); |
525 | printf("Symbol %s not found.\n", argv->buffer); |
| 508 | else if (symaddr == (__address) -1) { |
526 | else if (symaddr == (__address) -1) { |
| 509 | symtab_print_search(argv->buffer); |
527 | symtab_print_search(argv->buffer); |
| 510 | printf("Duplicate symbol, be more specific.\n"); |
528 | printf("Duplicate symbol, be more specific.\n"); |
| 511 | } else { |
529 | } else { |
| 512 | symbol = get_symtab_entry(symaddr); |
530 | symbol = get_symtab_entry(symaddr); |
| - | 531 | ||
| 513 | printf("Calling f(0x%zX): %.*p: %s\n", arg1, sizeof(__address) * 2, symaddr, symbol); |
532 | printf("Calling f(0x%zX): %.*p: %s\n", arg1, sizeof(__address) * 2, symaddr, symbol); |
| - | 533 | #ifdef ia64 |
|
| - | 534 | fptr.f = symaddr; |
|
| - | 535 | fptr.gp = ((__native *)cmd_call2)[1]; |
|
| - | 536 | f = (__native (*)(__native,...)) &fptr; |
|
| - | 537 | #else |
|
| 514 | f = (__native (*)(__native,...)) symaddr; |
538 | f = (__native (*)(__native,...)) symaddr; |
| - | 539 | #endif |
|
| 515 | printf("Result: %#zx\n", f(arg1)); |
540 | printf("Result: %#zx\n", f(arg1)); |
| 516 | } |
541 | } |
| 517 | 542 | ||
| 518 | return 1; |
543 | return 1; |
| 519 | } |
544 | } |
| Line 524... | Line 549... | ||
| 524 | __address symaddr; |
549 | __address symaddr; |
| 525 | char *symbol; |
550 | char *symbol; |
| 526 | __native (*f)(__native,__native,...); |
551 | __native (*f)(__native,__native,...); |
| 527 | __native arg1 = argv[1].intval; |
552 | __native arg1 = argv[1].intval; |
| 528 | __native arg2 = argv[2].intval; |
553 | __native arg2 = argv[2].intval; |
| - | 554 | #ifdef ia64 |
|
| - | 555 | struct { |
|
| - | 556 | __native f; |
|
| - | 557 | __native gp; |
|
| - | 558 | }fptr; |
|
| - | 559 | #endif |
|
| 529 | 560 | ||
| 530 | symaddr = get_symbol_addr(argv->buffer); |
561 | symaddr = get_symbol_addr(argv->buffer); |
| 531 | if (!symaddr) |
562 | if (!symaddr) |
| 532 | printf("Symbol %s not found.\n", argv->buffer); |
563 | printf("Symbol %s not found.\n", argv->buffer); |
| 533 | else if (symaddr == (__address) -1) { |
564 | else if (symaddr == (__address) -1) { |
| Line 535... | Line 566... | ||
| 535 | printf("Duplicate symbol, be more specific.\n"); |
566 | printf("Duplicate symbol, be more specific.\n"); |
| 536 | } else { |
567 | } else { |
| 537 | symbol = get_symtab_entry(symaddr); |
568 | symbol = get_symtab_entry(symaddr); |
| 538 | printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", |
569 | printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", |
| 539 | arg1, arg2, sizeof(__address) * 2, symaddr, symbol); |
570 | arg1, arg2, sizeof(__address) * 2, symaddr, symbol); |
| - | 571 | #ifdef ia64 |
|
| - | 572 | fptr.f = symaddr; |
|
| - | 573 | fptr.gp = ((__native *)cmd_call2)[1]; |
|
| - | 574 | f = (__native (*)(__native,__native,...)) &fptr; |
|
| - | 575 | #else |
|
| 540 | f = (__native (*)(__native,__native,...)) symaddr; |
576 | f = (__native (*)(__native,__native,...)) symaddr; |
| - | 577 | #endif |
|
| 541 | printf("Result: %#zx\n", f(arg1, arg2)); |
578 | printf("Result: %#zx\n", f(arg1, arg2)); |
| 542 | } |
579 | } |
| 543 | 580 | ||
| 544 | return 1; |
581 | return 1; |
| 545 | } |
582 | } |
| Line 551... | Line 588... | ||
| 551 | char *symbol; |
588 | char *symbol; |
| 552 | __native (*f)(__native,__native,__native,...); |
589 | __native (*f)(__native,__native,__native,...); |
| 553 | __native arg1 = argv[1].intval; |
590 | __native arg1 = argv[1].intval; |
| 554 | __native arg2 = argv[2].intval; |
591 | __native arg2 = argv[2].intval; |
| 555 | __native arg3 = argv[3].intval; |
592 | __native arg3 = argv[3].intval; |
| - | 593 | #ifdef ia64 |
|
| - | 594 | struct { |
|
| - | 595 | __native f; |
|
| - | 596 | __native gp; |
|
| - | 597 | }fptr; |
|
| - | 598 | #endif |
|
| 556 | 599 | ||
| 557 | symaddr = get_symbol_addr(argv->buffer); |
600 | symaddr = get_symbol_addr(argv->buffer); |
| 558 | if (!symaddr) |
601 | if (!symaddr) |
| 559 | printf("Symbol %s not found.\n", argv->buffer); |
602 | printf("Symbol %s not found.\n", argv->buffer); |
| 560 | else if (symaddr == (__address) -1) { |
603 | else if (symaddr == (__address) -1) { |
| Line 562... | Line 605... | ||
| 562 | printf("Duplicate symbol, be more specific.\n"); |
605 | printf("Duplicate symbol, be more specific.\n"); |
| 563 | } else { |
606 | } else { |
| 564 | symbol = get_symtab_entry(symaddr); |
607 | symbol = get_symtab_entry(symaddr); |
| 565 | printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", |
608 | printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", |
| 566 | arg1, arg2, arg3, sizeof(__address) * 2, symaddr, symbol); |
609 | arg1, arg2, arg3, sizeof(__address) * 2, symaddr, symbol); |
| - | 610 | #ifdef ia64 |
|
| - | 611 | fptr.f = symaddr; |
|
| - | 612 | fptr.gp = ((__native *)cmd_call2)[1]; |
|
| - | 613 | f = (__native (*)(__native,__native,__native,...)) &fptr; |
|
| - | 614 | #else |
|
| 567 | f = (__native (*)(__native,__native,__native,...)) symaddr; |
615 | f = (__native (*)(__native,__native,__native,...)) symaddr; |
| - | 616 | #endif |
|
| 568 | printf("Result: %#zx\n", f(arg1, arg2, arg3)); |
617 | printf("Result: %#zx\n", f(arg1, arg2, arg3)); |
| 569 | } |
618 | } |
| 570 | 619 | ||
| 571 | return 1; |
620 | return 1; |
| 572 | } |
621 | } |