I'm really stumped by this one!
The StackFrame object (MSDN Link) has a GetFileName method that returns the original path of the source file that compiled the executing method (provided symbols were generated and included with the executing assemblies). It looks like this information is used to generate full exception text.
I'm trying to find a way to get at this information if the method isn't currently executing. I've been poking around the reflection API and haven't seen a way to get at this information. I assume it must be in there somewhere.
Does anyone else know of a reflection based method (or indeed any other method) that can get me the code file name?
Any ideas, comments or abuse gratefully accepted.
Many thanks!
At the same time, it can also retrieve the source code of your Python objects. Please note dill is not a standard library, so you must install it separately. Its API is quite similar to inspect 's.
I go into this in detail in RTVCLSRC makes a comeback. If it is RPG or RPGLE then there is no IBM command to retrieve the source code. I need to be a bit creative in my thinking.
If it is RPG or RPGLE then there is no IBM command to retrieve the source code. I need to be a bit creative in my thinking. When I compile a RPG/RPGLE object I have choices in the debug views and these are included in the compiled object. I wrote about the debug views and the advantages of them for RPGLE in Debug views finding your favorite.
If the program was compiled with the "Source listing options" parameter, OPTION, of *SRCDBG or *LSTDBG then the source was included in the program object.
Reflection can only provide type information from the assembly metadata. Getting the address requires the .pdb debugging file and the address of the function in memory, as compiled by the JIT compiler. You can't get the address without the StackFrame.GetNativeOffset() method or the debugger interfaces, assuming the method is even compiled. The latter approach can't work in-process, a program cannot debug itself.
The CLR doesn't have any trouble because it can retrieve the method address from the stack frames when it processes the exception. That's still an imperfect art, it cannot see addresses of methods that were inlined. Having those stack frames is the required first step.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With