I am building a .Net Profiler for some custom requirement where I need to capture the exception details even though it got handled properly in the code.
To do so-
I have implemented ICorProfilerCallback
SetEventsMask for COR_PRF_MONITOR_EXCEPTIONS
Implemented the ExceptionThrown callback
So far so good, I am getting callback for every exception being thrown. However, it gives OjbectID that is a pointer to the actual exception object. I want more details like the message, call stack, etc. about the exception.
How do I get object details from ObjectID?
As #HansPassant mentioned, what you are doing smells like a debugger feature more than a profiler. However, you can do what you want using the profiler if that is a hard requirement - I believe IL re-writing is possible via the ICorDebug interfaces, but I am a profiler dev and haven't used the debugger interfaces as much.
David Broman's blog has a great description of taking a managed stack walk using the ICorProfilerInfo2 interface. In order to get the native parts you need to do a lot more work.
Navigating the object instance is also done via the ICorProfilerInfo2 interface.
Get the class ID of the object using ICorProfilerInfo::GetClassFromObject()
Using the class ID get the class layout via ICorProfilerInfo2::GetClassLayout()
You will need to parse the object metadata to determine which field you want.
Index into the object to grab the desired data.
Related
I should create in Apex a code for the mass creation of Leads and use as caller of the Workbeanch class. Unfortunately I was able to create the code for the creation of one lead at a time, I saw that you have to use the Wrapper class how is it used?
I'm trying to create a node interface for a c++ media player. Upon decoding of a frame, there is an event which allows me to access the frame data, which I'm trying to funnel into node. But I can't seem to figure out how to get that kind of functionality to work with the functions available in the node api. My approach, for the time being, is to figure out a push mechanism to get the data from c++ to javascript where all i need is to initialize a callback in javascript, since it seems more elegant. If that fails I could create a polling loop in js to check if there is new frame data, but it seems less efficient.
I've tried with napi_create_async_work, by creating a lambda function in the execute parameter function, which would allow me to call napi_make_callback for every frame callback, but then I get the following error :
Fatal error in HandleScope::HandleScope
Entering the V8 API without proper locking in place
I'm likely approaching this incorrectly, its the first time I use n-api.
Any help is welcome, thank you!
The issue is mainly pertaining to the fact you can’t access V8 (JavaScript) memory outside the event-loop’s main thread. If you're creating an async thread, by default you're also creating a new memory stack.
Fortunately, a fix is on the way which should allow thread safe access with
napi_create_threadsafe_function (example here)
Until then
There is a header only C++ package which integrates great with the C++ N-API wrapper
Napi-addon-api is update. These is a good way that use the Napi::ThreadSafeFunction.
Doc and example.
I'm building a Browser application using the QtWebkit and QtNetwork modules.
Let's say that it's a requirement that each webpage only be able to access resources from only a specific folder, set aside specifically for it. In this scenario, each webpage would have some kind of ID to identify it which could be used to verify that it's accessing the correct folder.
The problem is that it's not clear how exactly the createRequest() method gets invoked. If it's a signal that's emitted or something then I would be able to intercept it and add a few parameters indicating webpage ID.
As such now the only option open to me is to create a separate QNetworkAccessManager for each QWebPage and overload the createRequest() function whereas I would really like to be able to share the QNetworkAccessManager across QWebPages.
Alternate solutions would be appreciated but generally I'm also really confused about how the createRequest() method is reached.
Reference :
QNetworkAccessManager::createRequest
It's not a big deal to have a separate access manager for each web page. You don't have any measurements to show it to be a problem, so in a true Don Quixote fashion, you're fighting windmills and imaginary enemies :)
The createRequest virtual method is called by the various non-virtual request methods: get, post and put. It's a good example of the non virtual interface (NVI) pattern.
I am making an application in C++ that runs a simulation for a health club. The user simply enters the simulation data at the beginning (3 integer values) and presses run. After that there is no user input - so very simple.
After starting the simulation a lot of the logic is deep down in lower classes but a lot of them need to print simple output messages to the UI. Returning a message is not possible as objects need to print to the UI but keep working.
I was going to pass a reference to the UI object to all classes that need it but I end up passing it around quite a lot - there must be a better way.
What I really need is something that can make calling the UI's printOutput(string) function as easy (or not much more difficult) than cout << string;
The UI also has a displayConnectionStatus(bool[] connections) method.
Bear in mind the UI inherits an abstract 'UserInterface' class so simple console UIs and GUIs can be changed in and out easily.
How do you suggest I implement this link to the UI?
If I were to use a global function, how can I redirect it to call methods of the UserInterface implementation that I selected to use?
Don't be afraid of globals.
Global objects hurt encapsulation, but for a targeted solution with no concern for immediate reusability, globals are just fine.
Expose a global object that processes events from your simulation. You can then choose to print the events, send them by e-mail, render them with OpenGL or whatever you fancy. Make a uniform interface that catches what happens inside the simulation via report callbacks, and then you can subclass this global object to suit your needs.
If the object wasn't global, you'd be passing a pointer around all the codebase.
I would suggest to go for logging framework i.e. your own class LogMessages, which got functions which get data and log the data, it can be to a UI, file, over network or anything.
And each class which needs logging, can use your logging class.
This way you can avoid globals and a generic solution , also have a look at http://www.pantheios.org/ which is open source C/C++ Diagnostic Logging API library, you may use that also...
I'm trying to walk a callstack that contains both managed and native frames on a x64 process using StackWalk64. Everything works fine until the first or second managed frame, after which StackWalk64 can't figure out the return address of the frame and fails.
I'm using SymFunctionTableAccess64 for the function table access callback and the symbol handler has been initialized with SymInitialize(). Is there some magic I need to do in dbghelp to get it to walk over managed frames correctly?
Example callstack that fails:
UnmanagedFrame1
UnmanagedFrame2
UnmanagedFrame3
ManagedFrame1 <----- (StackWalk64 fails after this frame)
ManagedFrame2
UnmanagedFrame4
UnmanagedFrame5
ntdll!RtlUserThreadStart
Note: this question IS NOT about how to resolve the managed frames to symbols/method names/etc, I simply want to walk the full stack with no regard to symbol resolution/etc.
Also, IDebugControl4::GetContextStackTrace works correctly, but DbgEng uses a custom function table callback, and doesn't simply delegate to SymFunctionTableAccess64. I suspect the issue is that the CLR uses RtlInstallFunctionTableCallback to install a callback function table (which points to mscordacwks), and SymFunctionTableAccess64 isn't smart enough to follow that.
I spent some time trying to write a custom function table access callback to traverse the function table chain and call the callback in mscordacwks, but it got pretty sketchy and didn't really work anyways.
Does the SOS debugger extension help at all? It provides the ability, from windbg and Visual Studio to walk the stack exactly the way you wish.
Alternatively Profiler Stack Walking in the .NET Framework 2.0: Basics and Beyond might be of some use.