{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/docs/issues/6728","repository_url":"https://api.github.com/repos/dotnet/docs","labels_url":"https://api.github.com/repos/dotnet/docs/issues/6728/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/docs/issues/6728/comments","events_url":"https://api.github.com/repos/dotnet/docs/issues/6728/events","html_url":"https://github.com/dotnet/docs/issues/6728","id":345708114,"node_id":"MDU6SXNzdWUzNDU3MDgxMTQ=","number":6728,"title":"How to extract function argument and return value??","user":{"login":"Ashutosh-K-Singh","id":23715492,"node_id":"MDQ6VXNlcjIzNzE1NDky","avatar_url":"https://avatars3.githubusercontent.com/u/23715492?v=4","gravatar_id":"","url":"https://api.github.com/users/Ashutosh-K-Singh","html_url":"https://github.com/Ashutosh-K-Singh","followers_url":"https://api.github.com/users/Ashutosh-K-Singh/followers","following_url":"https://api.github.com/users/Ashutosh-K-Singh/following{/other_user}","gists_url":"https://api.github.com/users/Ashutosh-K-Singh/gists{/gist_id}","starred_url":"https://api.github.com/users/Ashutosh-K-Singh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ashutosh-K-Singh/subscriptions","organizations_url":"https://api.github.com/users/Ashutosh-K-Singh/orgs","repos_url":"https://api.github.com/users/Ashutosh-K-Singh/repos","events_url":"https://api.github.com/users/Ashutosh-K-Singh/events{/privacy}","received_events_url":"https://api.github.com/users/Ashutosh-K-Singh/received_events","type":"User","site_admin":false},"labels":[{"id":633282030,"node_id":"MDU6TGFiZWw2MzMyODIwMzA=","url":"https://api.github.com/repos/dotnet/docs/labels/Area%20-%20.NET%20Framework%20Guide","name":"Area - .NET Framework Guide","color":"3d5c8e","default":false},{"id":918839682,"node_id":"MDU6TGFiZWw5MTg4Mzk2ODI=","url":"https://api.github.com/repos/dotnet/docs/labels/forum","name":"forum","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-30T10:54:00Z","updated_at":"2018-07-31T22:56:33Z","closed_at":null,"author_association":"NONE","body":"It is a very helpful article for understanding. I would like to know, how we can extract function parameter name, value and also function return value.\n\n---\n#### Document Details\n\n⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*\n\n* ID: ebb4f9b7-d848-6548-76a1-3a2da84380e6\n* Version Independent ID: 59c8856d-a5ad-a91a-bdea-76eed7dffc00\n* Content: [FunctionLeave2 Function](https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/profiling/functionleave2-function)\n* Content Source: [docs/framework/unmanaged-api/profiling/functionleave2-function.md](https://github.com/dotnet/docs/blob/master/docs/framework/unmanaged-api/profiling/functionleave2-function.md)\n* Product: **dotnet-framework**\n* GitHub Login: @mairaw\n* Microsoft Alias: **mairaw**"},"comment":{"url":"https://api.github.com/repos/dotnet/docs/issues/comments/409394385","html_url":"https://github.com/dotnet/docs/issues/6728#issuecomment-409394385","issue_url":"https://api.github.com/repos/dotnet/docs/issues/6728","id":409394385,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTM5NDM4NQ==","user":{"login":"noahfalk","id":6243776,"node_id":"MDQ6VXNlcjYyNDM3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/6243776?v=4","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false},"created_at":"2018-07-31T22:56:32Z","updated_at":"2018-07-31T22:56:32Z","author_association":"MEMBER","body":"My team owns it. \r\n\r\n1) To get parameter names you would want to use metadata...\r\n   a) ICorProfilerInfo::GetFunctionInfo() converts from FunctionID -> ModuleID and mdToken (MethodDef token)\r\n   b) ICorProfilerInfo::GetModuleMetaData() get an IMetadataImport interface for the ModuleID\r\n   c) IMetadataImport::GetParamForMethodInfex() gets a ParamDef token for the n'th parameter given the MethodDef token for the method\r\n   d) IMetaDataImport::GetParamProps() gets the name of the parameter given the ParamDef token\r\n\r\n2) To get values you need to inspect the memory that is pointed to by the argument info\r\n   a) FunctionEnter2 has an argumentInfo structure passed to you as an argument\r\n   b) COR_PRF_FUNCTION_ARGUMENT_INFO describes a set of memory ranges where are all the arguments are stored in left to right order\r\n   c) You can use metadata to understand the types of the arguments (IMetadataImport::GetMethodProps to get the signature blob, which then can be parsed according to ECMA CLI specification for a LocalVarSignature)\r\n   d) Once you know the types of the arguments, you can infer their sizes and how to interpret the bytes you are reading from memory. For example an int is going to be 4 bytes of the memory range or any reference type is going to be a pointer sized piece of memory that points at the object contents. Methods such as ICorProfilerInfo2::GetClassLayout, ICorProfiler2::GetArrayObjectInfo, and ICorProfiler2::GetBoxClassLayout can assist in understanding the layout of complex types that might appear in these arguments\r\n\r\n3) Return value is similar to arguments, except use the retvalRange parameter in FunctionLeave2.\r\n\r\nSorry this is just a quick overview as the full details can get fairly involved. I hunted around to see if I could find a sample but unforetunately I didn't locate one. Hope this helps though.\r\n"}}
{"actor":{"display_login":"noahfalk"}}