Changeset 20800 in vbox for trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
- Timestamp:
- Jun 22, 2009 11:47:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r20799 r20800 399 399 * 400 400 * @returns Image mapped size. 401 * UINTPTR_MAX is returned if the handle is invalid.401 * RTUINTPTR_MAX is returned if the handle is invalid. 402 402 * 403 403 * @param hDbgMod The module handle. … … 406 406 { 407 407 PRTDBGMODINT pDbgMod = hDbgMod; 408 RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINTPTR_MAX);408 RTDBGMOD_VALID_RETURN_RC(pDbgMod, RTUINTPTR_MAX); 409 409 RTDBGMOD_LOCK(pDbgMod); 410 410 … … 535 535 * 536 536 * @returns The segment size. 537 * UINTPTR_MAX is returned if either the handle and segment index are537 * RTUINTPTR_MAX is returned if either the handle and segment index are 538 538 * invalid. 539 539 * … … 559 559 * 560 560 * @returns The segment relative address. 561 * UINTPTR_MAX is returned if either the handle and segment index are561 * RTUINTPTR_MAX is returned if either the handle and segment index are 562 562 * invalid. 563 563 * … … 574 574 575 575 576 577 578 576 /** 579 577 * Adds a line number to the module. 580 578 * 581 579 * @returns IPRT status code. 580 * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding 581 * custom symbols. This is a common place occurance. 582 582 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid. 583 * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding 584 * custom symbols. 585 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE 586 * @retval VERR_DBG_INVALID_RVA 587 * @retval VERR_DBG_INVALID_SEGMENT_INDEX 588 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET 589 * @retval VERR_INVALID_PARAMETER 583 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or 584 * short. 585 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and 586 * it's not inside any of the segments defined by the module. 587 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid. 588 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the 589 * end of the segment. 590 * @retval VERR_DBG_ADDRESS_WRAP if off+cb wraps around. 591 * @retval VERR_INVALID_PARAMETER if the symbol flags sets undefined bits. 590 592 * 591 593 * @param hDbgMod The module handle. … … 593 595 * @param iSeg The segment index. 594 596 * @param off The segment offset. 595 * @param cb The size of the symbol. 596 * @param fFlags Symbol flags. 597 * @param cb The size of the symbol. Can be zero, although this 598 * may depend somewhat on the debug interpreter. 599 * @param fFlags Symbol flags. Reserved for the future, MBZ. 597 600 * @param piOrdinal Where to return the symbol ordinal on success. If 598 601 * the interpreter doesn't do ordinals, this will be set to 599 * UINT32_MAX. Optional 600 */ 601 RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal) 602 * UINT32_MAX. Optional. 603 */ 604 RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, 605 RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal) 602 606 { 603 607 /* … … 615 619 ("%#x\n", iSeg), 616 620 VERR_DBG_INVALID_SEGMENT_INDEX); 621 AssertMsgReturn(off + cb >= off, ("off=%RTptr cb=%RTptr\n", off, cb), VERR_DBG_ADDRESS_WRAP); 617 622 AssertReturn(!fFlags, VERR_INVALID_PARAMETER); /* currently reserved. */ 618 623 … … 642 647 643 648 644 RTDECL(uint32_t) RTDbgModSymbolCount(RTDBGMOD hDbgMod) 645 { 646 return 1; 647 } 648 649 RTDECL(int) RTDbgModSymbolByIndex(RTDBGMOD hDbgMod, uint32_t iSymbol, PRTDBGSYMBOL pSymbol) 650 { 651 return VERR_NOT_IMPLEMENTED; 652 } 653 654 RTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol) 655 { 656 return VERR_NOT_IMPLEMENTED; 657 } 658 659 RTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol) 660 { 661 return VERR_NOT_IMPLEMENTED; 662 } 663 664 RTDECL(int) RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol) 665 { 666 return VERR_NOT_IMPLEMENTED; 667 } 668 669 RTDECL(int) RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol) 670 { 671 return VERR_NOT_IMPLEMENTED; 649 /** 650 * Gets the symbol count. 651 * 652 * This can be used together wtih RTDbgModSymbolByOrdinal or 653 * RTDbgModSymbolByOrdinalA to enumerate all the symbols. 654 * 655 * @returns The number of symbols in the module. 656 * UINT32_MAX is returned if the module handle is invalid or some other 657 * error occurs. 658 * 659 * @param hDbgMod The module handle. 660 */ 661 RTDECL(uint32_t) RTDbgModSymbolCount(RTDBGMOD hDbgMod) 662 { 663 PRTDBGMODINT pDbgMod = hDbgMod; 664 RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX); 665 RTDBGMOD_LOCK(pDbgMod); 666 667 uint32_t cSymbols = pDbgMod->pDbgVt->pfnSymbolCount(pDbgMod); 668 669 RTDBGMOD_UNLOCK(pDbgMod); 670 return cSymbols; 671 } 672 673 674 /** 675 * Queries symbol information by ordinal number. 676 * 677 * @returns IPRT status code. 678 * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number. 679 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols. 680 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid. 681 * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported. 682 * 683 * @param hDbgMod The module handle. 684 * @param iOrdinal The symbol ordinal number. 0-based. The highest 685 * number is RTDbgModSymbolCount() - 1. 686 * @param pSymInfo Where to store the symbol information. 687 */ 688 RTDECL(int) RTDbgModSymbolByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo) 689 { 690 PRTDBGMODINT pDbgMod = hDbgMod; 691 RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE); 692 RTDBGMOD_LOCK(pDbgMod); 693 694 int rc = pDbgMod->pDbgVt->pfnSymbolByOrdinal(pDbgMod, iOrdinal, pSymInfo); 695 696 RTDBGMOD_UNLOCK(pDbgMod); 697 return rc; 698 } 699 700 701 /** 702 * Queries symbol information by ordinal number. 703 * 704 * @returns IPRT status code. 705 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols. 706 * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported. 707 * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number. 708 * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails. 709 * 710 * @param hDbgMod The module handle. 711 * @param iOrdinal The symbol ordinal number. 0-based. The highest 712 * number is RTDbgModSymbolCount() - 1. 713 * @param ppSymInfo Where to store the pointer to the returned 714 * symbol information. Always set. Free with 715 * RTDbgSymbolFree. 716 */ 717 RTDECL(int) RTDbgModSymbolByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL *ppSymInfo) 718 { 719 AssertPtr(ppSymInfo); 720 *ppSymInfo = NULL; 721 722 PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc(); 723 if (!pSymInfo) 724 return VERR_NO_MEMORY; 725 726 int rc = RTDbgModSymbolByOrdinal(hDbgMod, iOrdinal, pSymInfo); 727 728 if (RT_SUCCESS(rc)) 729 *ppSymInfo = pSymInfo; 730 else 731 RTDbgSymbolFree(pSymInfo); 732 return rc; 733 } 734 735 736 /** 737 * Queries symbol information by address. 738 * 739 * The returned symbol is what the debug info interpreter consideres the symbol 740 * most applicable to the specified address. This usually means a symbol with an 741 * address equal or lower than the requested. 742 * 743 * @returns IPRT status code. 744 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found. 745 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols. 746 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid. 747 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and 748 * it's not inside any of the segments defined by the module. 749 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid. 750 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the 751 * end of the segment. 752 * 753 * @param pMod Pointer to the module structure. 754 * @param iSeg The segment number (0-based) or RTDBGSEGIDX_ABS. 755 * @param off The offset into the segment. 756 * @param poffDisp Where to store the distance between the specified address 757 * and the returned symbol. Optional. 758 * @param pSymInfo Where to store the symbol information. 759 */ 760 RTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo) 761 { 762 /* 763 * Validate input. 764 */ 765 PRTDBGMODINT pDbgMod = hDbgMod; 766 RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX); 767 AssertPtrNull(poffDisp); 768 AssertPtr(pSymInfo); 769 770 RTDBGMOD_LOCK(pDbgMod); 771 772 /* 773 * Convert RVAs. 774 */ 775 if (iSeg == RTDBGSEGIDX_RVA) 776 { 777 iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, off, &off); 778 if (iSeg == NIL_RTDBGSEGIDX) 779 { 780 RTDBGMOD_UNLOCK(pDbgMod); 781 return VERR_DBG_INVALID_RVA; 782 } 783 } 784 785 /* 786 * Get down to business. 787 */ 788 int rc = pDbgMod->pDbgVt->pfnSymbolByAddr(pDbgMod, iSeg, off, poffDisp, pSymInfo); 789 790 RTDBGMOD_UNLOCK(pDbgMod); 791 return rc; 792 } 793 794 795 /** 796 * Queries symbol information by address. 797 * 798 * The returned symbol is what the debug info interpreter consideres the symbol 799 * most applicable to the specified address. This usually means a symbol with an 800 * address equal or lower than the requested. 801 * 802 * @returns IPRT status code. 803 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found. 804 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols. 805 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid. 806 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and 807 * it's not inside any of the segments defined by the module. 808 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid. 809 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the 810 * end of the segment. 811 * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails. 812 * 813 * @param hDbgMod The module handle. 814 * @param iSeg The segment index. 815 * @param off The offset into the segment. 816 * @param poffDisp Where to store the distance between the 817 * specified address and the returned symbol. Optional. 818 * @param ppSymInfo Where to store the pointer to the returned 819 * symbol information. Always set. Free with 820 * RTDbgSymbolFree. 821 */ 822 RTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo) 823 { 824 AssertPtr(ppSymInfo); 825 *ppSymInfo = NULL; 826 827 PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc(); 828 if (!pSymInfo) 829 return VERR_NO_MEMORY; 830 831 int rc = RTDbgModSymbolByAddr(hDbgMod, iSeg, off, poffDisp, pSymInfo); 832 833 if (RT_SUCCESS(rc)) 834 *ppSymInfo = pSymInfo; 835 else 836 RTDbgSymbolFree(pSymInfo); 837 return rc; 838 } 839 840 841 /** 842 * Queries symbol information by symbol name. 843 * 844 * @returns IPRT status code. 845 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols. 846 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found. 847 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or 848 * short. 849 * 850 * @param hDbgMod The module handle. 851 * @param pszSymbol The symbol name. 852 * @param pSymInfo Where to store the symbol information. 853 */ 854 RTDECL(int) RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymInfo) 855 { 856 /* 857 * Validate input. 858 */ 859 PRTDBGMODINT pDbgMod = hDbgMod; 860 RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX); 861 AssertPtr(pszSymbol); 862 size_t cchSymbol = strlen(pszSymbol); 863 AssertReturn(cchSymbol, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE); 864 AssertReturn(cchSymbol < RTDBG_SYMBOL_NAME_LENGTH, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE); 865 AssertPtr(pSymInfo); 866 867 /* 868 * Make the query. 869 */ 870 RTDBGMOD_LOCK(pDbgMod); 871 int rc = pDbgMod->pDbgVt->pfnSymbolByName(pDbgMod, pszSymbol, cchSymbol, pSymInfo); 872 RTDBGMOD_UNLOCK(pDbgMod); 873 874 return rc; 875 } 876 877 878 /** 879 * Queries symbol information by symbol name. 880 * 881 * @returns IPRT status code. 882 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols. 883 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found. 884 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or 885 * short. 886 * 887 * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails. 888 * @param hDbgMod The module handle. 889 * @param pszSymbol The symbol name. 890 * @param ppSymInfo Where to store the pointer to the returned 891 * symbol information. Always set. Free with 892 * RTDbgSymbolFree. 893 */ 894 RTDECL(int) RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo) 895 { 896 AssertPtr(ppSymInfo); 897 *ppSymInfo = NULL; 898 899 PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc(); 900 if (!pSymInfo) 901 return VERR_NO_MEMORY; 902 903 int rc = RTDbgModSymbolByName(hDbgMod, pszSymbol, pSymInfo); 904 905 if (RT_SUCCESS(rc)) 906 *ppSymInfo = pSymInfo; 907 else 908 RTDbgSymbolFree(pSymInfo); 909 return rc; 672 910 } 673 911
Note:
See TracChangeset
for help on using the changeset viewer.