Changeset 64589 in vbox
- Timestamp:
- Nov 6, 2016 6:07:32 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/dbgf.h
r64586 r64589 2508 2508 /** Pointer to a control flow graph iterator. */ 2509 2509 typedef DBGFFLOWIT *PDBGFFLOWIT; 2510 /** A DBGF control flow graph branch table iterator. */ 2511 typedef struct DBGFFLOWBRANCHTBLITINT *DBGFFLOWBRANCHTBLIT; 2512 /** Pointer to a control flow graph branch table iterator. */ 2513 typedef DBGFFLOWBRANCHTBLIT *PDBGFFLOWBRANCHTBLIT; 2510 2514 2511 2515 /** @name DBGFFLOWBB Flags. … … 2604 2608 VMMR3DECL(int) DBGFR3FlowBbQuerySuccessors(DBGFFLOWBB hFlowBb, PDBGFFLOWBB phFlowBbFollow, 2605 2609 PDBGFFLOWBB phFlowBbTarget); 2606 2607 2610 VMMR3DECL(uint32_t) DBGFR3FlowBbGetRefBbCount(DBGFFLOWBB hFlowBb); 2608 2611 VMMR3DECL(int) DBGFR3FlowBbGetRefBb(DBGFFLOWBB hFlowBb, PDBGFFLOWBB pahFlowBbRef, uint32_t cRef); … … 2619 2622 VMMR3DECL(int) DBGFR3FlowItReset(DBGFFLOWIT hFlowIt); 2620 2623 2624 VMMR3DECL(int) DBGFR3FlowBranchTblItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWBRANCHTBLIT phFlowBranchTblIt); 2625 VMMR3DECL(void) DBGFR3FlowBranchTblItDestroy(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt); 2626 VMMR3DECL(DBGFFLOWBRANCHTBL) DBGFR3FlowBranchTblItNext(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt); 2627 VMMR3DECL(int) DBGFR3FlowBranchTblItReset(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt); 2628 2621 2629 /** @} */ 2622 2630 -
trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
r64586 r64589 511 511 return VERR_INTERNAL_ERROR; 512 512 } 513 VMMR3DECL(int) DBGFR3FlowBranchTblItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWBRANCHTBLIT phFlowBranchTblIt) 514 { 515 return VERR_INTERNAL_ERROR; 516 } 517 VMMR3DECL(void) DBGFR3FlowBranchTblItDestroy(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt) 518 { 519 } 520 VMMR3DECL(DBGFFLOWBRANCHTBL) DBGFR3FlowBranchTblItNext(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt) 521 { 522 return NULL; 523 } 524 VMMR3DECL(int) DBGFR3FlowBranchTblItReset(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt) 525 { 526 return VERR_INTERNAL_ERROR; 527 } 513 528 514 529 #include <VBox/vmm/cfgm.h> -
trunk/src/VBox/VMM/VMMR3/DBGFR3Flow.cpp
r64588 r64589 181 181 182 182 183 /** 184 * Control flow graph branch table iterator state. 185 */ 186 typedef struct DBGFFLOWBRANCHTBLITINT 187 { 188 /** Pointer to the control flow graph (holding a reference). */ 189 PDBGFFLOWINT pFlow; 190 /** Next branch table to return. */ 191 uint32_t idxTblNext; 192 /** Array of branch table pointers sorted by the specified order - variable in size. */ 193 PDBGFFLOWBRANCHTBLINT apBranchTbl[1]; 194 } DBGFFLOWBRANCHTBLITINT; 195 /** Pointer to the internal control flow graph branch table iterator state. */ 196 typedef DBGFFLOWBRANCHTBLITINT *PDBGFFLOWBRANCHTBLITINT; 197 183 198 /********************************************************************************************************************************* 184 199 * Internal Functions * … … 1964 1979 * 1965 1980 * @returns VBox status code. 1966 * @param hFlow 1981 * @param hFlow The control flow graph handle. 1967 1982 * @param enmOrder The order in which the basic blocks are enumerated. 1968 * @param phFlowIt 1983 * @param phFlowIt Where to store the handle to the iterator on success. 1969 1984 */ 1970 1985 VMMR3DECL(int) DBGFR3FlowItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWIT phFlowIt) … … 2065 2080 return VINF_SUCCESS; 2066 2081 } 2082 2083 2084 /** 2085 * @callback_method_impl{FNRTSORTCMP} 2086 */ 2087 static DECLCALLBACK(int) dbgfR3FlowBranchTblItSortCmp(void const *pvElement1, void const *pvElement2, void *pvUser) 2088 { 2089 PDBGFFLOWITORDER penmOrder = (PDBGFFLOWITORDER)pvUser; 2090 PDBGFFLOWBRANCHTBLINT pTbl1 = *(PDBGFFLOWBRANCHTBLINT *)pvElement1; 2091 PDBGFFLOWBRANCHTBLINT pTbl2 = *(PDBGFFLOWBRANCHTBLINT *)pvElement2; 2092 2093 if (dbgfR3FlowAddrEqual(&pTbl1->AddrStart, &pTbl2->AddrStart)) 2094 return 0; 2095 2096 if (*penmOrder == DBGFFLOWITORDER_BY_ADDR_LOWEST_FIRST) 2097 { 2098 if (dbgfR3FlowAddrLower(&pTbl1->AddrStart, &pTbl2->AddrStart)) 2099 return -1; 2100 else 2101 return 1; 2102 } 2103 else 2104 { 2105 if (dbgfR3FlowAddrLower(&pTbl1->AddrStart, &pTbl2->AddrStart)) 2106 return 1; 2107 else 2108 return -1; 2109 } 2110 } 2111 2112 2113 /** 2114 * Creates a new branch table iterator for the given control flow graph. 2115 * 2116 * @returns VBox status code. 2117 * @param hFlow The control flow graph handle. 2118 * @param enmOrder The order in which the basic blocks are enumerated. 2119 * @param phFlowBranchTblIt Where to store the handle to the iterator on success. 2120 */ 2121 VMMR3DECL(int) DBGFR3FlowBranchTblItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, 2122 PDBGFFLOWBRANCHTBLIT phFlowBranchTblIt) 2123 { 2124 int rc = VINF_SUCCESS; 2125 PDBGFFLOWINT pFlow = hFlow; 2126 AssertPtrReturn(pFlow, VERR_INVALID_POINTER); 2127 AssertPtrReturn(phFlowBranchTblIt, VERR_INVALID_POINTER); 2128 AssertReturn(enmOrder > DBGFFLOWITORDER_INVALID && enmOrder < DBGFFLOWITORDER_BREADTH_FIRST, 2129 VERR_INVALID_PARAMETER); 2130 AssertReturn(enmOrder < DBGFFLOWITORDER_DEPTH_FRIST, VERR_NOT_SUPPORTED); 2131 2132 PDBGFFLOWBRANCHTBLITINT pIt = (PDBGFFLOWBRANCHTBLITINT)RTMemAllocZ(RT_OFFSETOF(DBGFFLOWBRANCHTBLITINT, apBranchTbl[pFlow->cBranchTbls])); 2133 if (RT_LIKELY(pIt)) 2134 { 2135 DBGFR3FlowRetain(hFlow); 2136 pIt->pFlow = pFlow; 2137 pIt->idxTblNext = 0; 2138 /* Fill the list and then sort. */ 2139 PDBGFFLOWBRANCHTBLINT pFlowBranchTbl; 2140 uint32_t idxTbl = 0; 2141 RTListForEach(&pFlow->LstBranchTbl, pFlowBranchTbl, DBGFFLOWBRANCHTBLINT, NdBranchTbl) 2142 { 2143 DBGFR3FlowBranchTblRetain(pFlowBranchTbl); 2144 pIt->apBranchTbl[idxTbl++] = pFlowBranchTbl; 2145 } 2146 2147 /* Sort the blocks by address. */ 2148 RTSortShell(&pIt->apBranchTbl[0], pFlow->cBranchTbls, sizeof(PDBGFFLOWBRANCHTBLINT), dbgfR3FlowBranchTblItSortCmp, &enmOrder); 2149 2150 *phFlowBranchTblIt = pIt; 2151 } 2152 else 2153 rc = VERR_NO_MEMORY; 2154 2155 return rc; 2156 } 2157 2158 2159 /** 2160 * Destroys a given control flow graph branch table iterator. 2161 * 2162 * @returns nothing. 2163 * @param hFlowBranchTblIt The control flow graph branch table iterator handle. 2164 */ 2165 VMMR3DECL(void) DBGFR3FlowBranchTblItDestroy(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt) 2166 { 2167 PDBGFFLOWBRANCHTBLITINT pIt = hFlowBranchTblIt; 2168 AssertPtrReturnVoid(pIt); 2169 2170 for (unsigned i = 0; i < pIt->pFlow->cBranchTbls; i++) 2171 DBGFR3FlowBranchTblRelease(pIt->apBranchTbl[i]); 2172 2173 DBGFR3FlowRelease(pIt->pFlow); 2174 RTMemFree(pIt); 2175 } 2176 2177 2178 /** 2179 * Returns the next branch table in the iterator or NULL if there is no 2180 * branch table left. 2181 * 2182 * @returns Handle to the next basic block in the iterator or NULL if the end 2183 * was reached. 2184 * @param hFlowBranchTblIt The iterator handle. 2185 * 2186 * @note If a valid handle is returned it must be release with DBGFR3FlowBranchTblRelease() 2187 * when not required anymore. 2188 */ 2189 VMMR3DECL(DBGFFLOWBRANCHTBL) DBGFR3FlowBranchTblItNext(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt) 2190 { 2191 PDBGFFLOWBRANCHTBLITINT pIt = hFlowBranchTblIt; 2192 AssertPtrReturn(pIt, NULL); 2193 2194 PDBGFFLOWBRANCHTBLINT pTbl = NULL; 2195 if (pIt->idxTblNext < pIt->pFlow->cBranchTbls) 2196 { 2197 pTbl = pIt->apBranchTbl[pIt->idxTblNext++]; 2198 DBGFR3FlowBranchTblRetain(pTbl); 2199 } 2200 2201 return pTbl; 2202 } 2203 2204 2205 /** 2206 * Resets the given iterator to the beginning. 2207 * 2208 * @returns VBox status code. 2209 * @param hFlowBranchTblIt The iterator handle. 2210 */ 2211 VMMR3DECL(int) DBGFR3FlowBranchTblItReset(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt) 2212 { 2213 PDBGFFLOWBRANCHTBLITINT pIt = hFlowBranchTblIt; 2214 AssertPtrReturn(pIt, VERR_INVALID_HANDLE); 2215 2216 pIt->idxTblNext = 0; 2217 return VINF_SUCCESS; 2218 } -
trunk/src/VBox/VMM/VMMR3/VMMR3.def
r64586 r64589 162 162 DBGFR3FlowItNext 163 163 DBGFR3FlowItReset 164 DBGFR3FlowBranchTblItCreate 165 DBGFR3FlowBranchTblItDestroy 166 DBGFR3FlowBranchTblItNext 167 DBGFR3FlowBranchTblItReset 164 168 DBGFR3PlugInLoad 165 169 DBGFR3PlugInUnload
Note:
See TracChangeset
for help on using the changeset viewer.