stack-trace

Print current call stack from a method in Python code

走远了吗. 提交于 2020-01-18 04:46:46
问题 In Python, how can I print the current call stack from within a method (for debugging purposes). 回答1: Here's an example of getting the stack via the traceback module, and printing it: import traceback def f(): g() def g(): for line in traceback.format_stack(): print(line.strip()) f() # Prints: # File "so-stack.py", line 10, in <module> # f() # File "so-stack.py", line 4, in f # g() # File "so-stack.py", line 7, in g # for line in traceback.format_stack(): If you really only want to print the

How to see complete traceback?

旧城冷巷雨未停 提交于 2020-01-17 03:35:13
问题 I have added an assert(0) in a function to understand the sequence of function calls to this function. Ex: def my_func(): ...lines of code... assert(0) ...more lines of code... The logs show only this: Traceback (most recent call last): File "/var/www/folder/file.py", line 273, in my_func assert(0) AssertionError I want to see the complete call trace - Example: first_func -> second_func -> my_func I tried traceback library but it is showing me the same stacktrace. Please let me know what I am

Mule - accessing the exception stack and logging a particular part

旧巷老猫 提交于 2020-01-17 02:53:10
问题 I have a Mule flow that evaluates a payload an depending on the value, may throw an exception using Groovy. My flow looks as follows: <flow name="test-flow" doc:name="test-flow"> <vm:inbound-endpoint path="testexception.in" exchange-pattern="request-response" doc:name="VM"/> <choice doc:name="Choice"> <when expression="#[payload == 'Goodbye']"> <logger message="**************** #[payload] ****************" level="INFO" doc:name="Logger"/> </when> <otherwise> <scripting:component doc:name=

Stack Backtrace for ARM core using GCC compiler (when there is a MSP to PSP switch)

為{幸葍}努か 提交于 2020-01-16 17:20:30
问题 Core - ARM Cortex-M4 Compiler - GCC 5.3.0 ARM EABI OS - Free RTOS I am doing stack backtrace using gcc library function _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn,void*); In our project, MSP stack is used for exception handling. In other cases, PSP stack is used. When I call _Unwind_Backtrace() inside the exception handler, I am able to back trace properly up to the first function which is called inside exception. Until this the stack is MSP. But before exception, we were not able

VC++ stack trace does not resolve function names on production

瘦欲@ 提交于 2020-01-14 12:35:11
问题 I recently implemented stack trace logging using boost's new stacktrace library: int debugErrorCallback(int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata) { boost::stacktrace::stacktrace stacktrace(4, 10); //skipped 4 frames include cv::error, this function and 2 in boost::stacktrace ctor std::cout << boost::stacktrace::detail::to_string(stacktrace.as_vector().data(), stacktrace.size()) << std::endl; } Having tested it on my development

Get stack trace of C# async calls using the API that the visual studio debugger uses

痴心易碎 提交于 2020-01-14 03:28:31
问题 Is it possible to get an equivalent stack trace that is provided by the visual studio 2019 debugger. Eg if I breakpoint in my async code inside of visual studio I see the following stack trace within the "Call Stack" window company.Common.dll!company.Common.Api.ResourcesDatabase.Lock() Line 58 C# company.Common.dll!company.Common.Api.ResourcesDatabase.ResourcesDatabase(bool openAndCreateDB) Line 29 C# company.Api.dll!company.Api.GlobalsDownloader.DownloadNewGlobals_UnderLock(System.Func

HOWTO get the correct Frame Pointer of an arbitrary thread in iOS?

只谈情不闲聊 提交于 2020-01-13 04:44:30
问题 Way to get the Frame Pointer On a Demo App running on iPhone 5s Device / Xcode 7, I tried to get the frame pointer of an arbitrary thread using thread_get_state , but always result in an incorrect one : - (BOOL)fillThreadState:(thread_t)thread intoMachineContext:(_STRUCT_MCONTEXT *)machineContext { mach_msg_type_number_t state_count = MACHINE_THREAD_STATE_COUNT; kern_return_t kr = thread_get_state(thread, MACHINE_THREAD_STATE, (thread_state_t)&machineContext->__ss, &state_count); if (kr !=

Fetch only first N lines of a Stack Trace

大兔子大兔子 提交于 2020-01-12 18:45:29
问题 I have a Factory method that returns an object from a ID call. Mock code: public static Object getById(String id) { Object o = CRUD.doRecovery(Class, id); if(o == null) { printLogMessage("recovery by ID returned Null: " + id); // would really like to show only a few lines of stack trace. } return o; } How can I show only the first N lines of the stack trace (so I know the caller of the method) without dumping the whole stack trace on the log or having to rely on external libs? 回答1: I'm

Mysterious line in stack trace

喜夏-厌秋 提交于 2020-01-12 14:31:11
问题 While investigating a stack trace discrepancy when composing another answer, I came across a behavior I do not understand. Consider the following test program (this is as far down as I could narrow it): interface TestInterface <U> { void test (U u); } static class Test <T extends Test<T>> implements TestInterface<T> { // line 11 @Override public void test (T t) { throw new RuntimeException("My exception"); // line 13 } } static class TestA extends Test<TestA> { } static class TestB extends

How can I rethrow an Inner Exception while maintaining the stack trace generated so far?

人走茶凉 提交于 2020-01-11 15:22:31
问题 Duplicate of: In C#, how can I rethrow InnerException without losing stack trace? I have some operations that I invoke asynchronously on a background thread. Sometimes, things go bad. When this happens, I tend to get a TargetInvocationException, which, while appropriate, is quite useless. What I really need is the TargetInvocationException's InnerException, like this: try { ReturnValue = myFunctionCall.Invoke(Target, Parameters); } catch (TargetInvocationException err) { throw err