| 1 | // |
| 2 | // Copyright (c) Microsoft. All rights reserved. |
| 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | |
| 6 | #include "standardpch.h" |
| 7 | #include "simpletimer.h" |
| 8 | #include "methodcontext.h" |
| 9 | #include "methodcontextiterator.h" |
| 10 | #include "verbdumpmap.h" |
| 11 | #include "verbildump.h" |
| 12 | |
| 13 | // Dump the CSV format header for all the columns we're going to dump. |
| 14 | void () |
| 15 | { |
| 16 | printf("index," ); |
| 17 | // printf("process name,"); |
| 18 | printf("method name," ); |
| 19 | printf("full signature\n" ); |
| 20 | } |
| 21 | |
| 22 | void DumpMap(int index, MethodContext* mc) |
| 23 | { |
| 24 | CORINFO_METHOD_INFO cmi; |
| 25 | unsigned int flags = 0; |
| 26 | |
| 27 | mc->repCompileMethod(&cmi, &flags); |
| 28 | |
| 29 | const char* moduleName = nullptr; |
| 30 | const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); |
| 31 | const char* className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); |
| 32 | |
| 33 | printf("%d," , index); |
| 34 | // printf("\"%s\",", mc->cr->repProcessName()); |
| 35 | printf("%s:%s," , className, methodName); |
| 36 | |
| 37 | // Also, dump the full method signature |
| 38 | printf("\"" ); |
| 39 | DumpAttributeToConsoleBare(mc->repGetMethodAttribs(cmi.ftn)); |
| 40 | DumpPrimToConsoleBare(mc, cmi.args.retType, (DWORDLONG)cmi.args.retTypeClass); |
| 41 | printf(" %s(" , methodName); |
| 42 | DumpSigToConsoleBare(mc, &cmi.args); |
| 43 | printf(")\"\n" ); |
| 44 | } |
| 45 | |
| 46 | int verbDumpMap::DoWork(const char* nameOfInput) |
| 47 | { |
| 48 | MethodContextIterator mci; |
| 49 | if (!mci.Initialize(nameOfInput)) |
| 50 | return -1; |
| 51 | |
| 52 | DumpMapHeader(); |
| 53 | |
| 54 | while (mci.MoveNext()) |
| 55 | { |
| 56 | MethodContext* mc = mci.Current(); |
| 57 | DumpMap(mci.MethodContextNumber(), mc); |
| 58 | } |
| 59 | |
| 60 | if (!mci.Destroy()) |
| 61 | return -1; |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |