由于无限递归,我正在调试堆栈溢出.当堆栈深度为700次调用时,程序将失败.
我想跳转到最初调用该函数的框架.但是,gdb一次向我显示堆栈顶部的堆栈跟踪大约20个条目,我想知道我是否能以某种方式直接跳到调用函数而不查看堆栈跟踪来查找它的编号.
为此,我希望能够根据其名称而不是其编号跳转到堆栈帧.
这可以在gdb中完成吗?
使用:
traceback.print_stack()
Run Code Online (Sandbox Code Playgroud)
我可以得到:
File "x.py", line 20, in <module>
y(x)
File "x.py", line 11, in y
fun(x)
File "x.py", line 8, in fun
traceback.print_stack()
Run Code Online (Sandbox Code Playgroud)
我有办法得到这样的东西:
File "x.py", line 20, in <module>
y(x) WHERE x == 1
File "x.py", line 11, in y
fun(x) WHERE x == 'str'
File "x.py", line 8, in fun
traceback.print_stack()
Run Code Online (Sandbox Code Playgroud)
我只是想看看哪些参数传递给函数.
我正在使用一个对我来说不熟悉的遗留Java应用程序,因此有一种方法可以找出它是如何工作的并且更容易找到事情,我认为在执行操作后能够获得完整的堆栈跟踪,以便能够根据特定的UI动作查看正在使用的类.我原以为这在调试器中是可能的,但似乎只有在我插入一个断点时它才有效,在这种情况下,部分目的是为了让我不必知道被调用的是什么才能插入断点第一(因为这有助于告诉我).
如果这是一个基本问题我很抱歉,我已经搜索了这个,但我找不到正确的答案.
我有一个用C语言编写的程序,可以在Linux,MacOS和Windows上运行.有没有办法可以调用函数并生成堆栈跟踪?这对我来说非常有用.理想情况下,我想在所有三个平台上都这样做,但Linux是最重要的.(Windows正在通过mingw编译.)
谢谢.
e.printStackTrace()工作正常(即将我的堆栈跟踪打印到stderr)但Log.X根本无法打印堆栈跟踪.
例如:
} catch (IOException e) {
Log.e("Network", "Exception", e);
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
输出:
08-31 03:46:21.992: W/Network(13238): Exception
08-31 03:46:22.092: W/System.err(13238): java.net.UnknownHostException: Unable to resolve host "...": No address associated with hostname
08-31 03:46:22.204: W/System.err(13238): at java.net.InetAddress.lookupHostByName(InetAddress.java:394)
08-31 03:46:22.222: W/System.err(13238): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
08-31 03:46:22.222: W/System.err(13238): at java.net.InetAddress.getAllByName(InetAddress.java:214)
Run Code Online (Sandbox Code Playgroud) React Native移动应用程序在每次点击时都非常慢.我正在使用react本机v0.40.0,以下是我的项目的依赖项.
{
"analytics-react-native": "^1.1.0",
"apisauce": "^0.7.0",
"babel-preset-es2015": "^6.18.0",
"es6-promise": "^4.0.5",
"flow-bin": "^0.36.0",
"geolib": "^2.0.22",
"immutable": "^3.8.1",
"intl": "^1.2.5",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"lodash.range": "^3.2.0",
"prop-types": "^15.5.10",
"raven-js": "^3.13.1",
"react": "^15.4.2",
"react-native": "^0.40.0",
"react-native-apple-healthkit-rn0.40": "^0.3.2",
"react-native-blur": "^2.0.0",
"react-native-button": "^1.7.1",
"react-native-checkbox": "^2.0.0",
"react-native-code-push": "^1.17.3-beta",
"react-native-datepicker": "^1.4.4",
"react-native-device-info": "^0.10.1",
"react-native-easy-toast": "^1.0.6",
"react-native-fbsdk": "^0.5.0",
"react-native-geocoder": "^0.4.5",
"react-native-gifted-chat": "^0.1.3",
"react-native-global-props": "^1.1.1",
"react-native-image-crop-picker": "^0.15.1",
"react-native-image-picker": "^0.25.1",
"react-native-image-slider": "^1.1.5",
"react-native-keyboard-aware-scroll-view": "^0.2.7",
"react-native-maps": "0.15.2",
"react-native-modal-dropdown": "^0.4.4",
"react-native-popup-menu": "^0.7.2",
"react-native-push-notification": "^2.2.1",
"react-native-radio-buttons": "^0.14.0",
"react-native-router-flux": …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个函数,该函数将在引发对象常量时重新引入堆栈跟踪。(请参阅此相关问题)。
我注意到的是,如果将异步函数作为回调传递给另一个异步调用者函数,则如果调用者函数具有try / catch并捕获任何错误并抛出新的Error,则堆栈跟踪会丢失。
我已经尝试了几种方法:
function alpha() {
throw Error("I am an error!");
}
function alphaObectLiberal() {
throw "I am an object literal!"; //Ordinarily this will cause the stack trace to be lost.
}
function syncFunctionCaller(fn) {
return fn();
}
function syncFunctionCaller2(fn) { //This wrapper wraps it in a proper error and subsequently preserves the stack trace.
try {
return fn();
} catch (err) {
throw new Error(err); //Stack trace is preserved when it is synchronous.
}
} …Run Code Online (Sandbox Code Playgroud) 我正在写一个我想要移植的库.因此,它不应该依赖于glibc或Microsoft扩展或标准中没有的任何其他内容.我有一个很好的从std :: exception派生的类层次结构,我用它来处理逻辑和输入中的错误.知道在特定文件和行号处抛出特定类型的异常是有用的,但是知道执行的执行方式可能会更有价值,所以我一直在寻找获取堆栈跟踪的方法.
我知道,使用execinfo.h功能(见的是glibc建造时这个数据是可用的质疑76822),并通过微软的C++实现的StackWalk接口(见问题126450),但我非常希望避免任何的不便携.
我正在考虑以这种形式自己实现这个功能:
class myException : public std::exception
{
public:
...
void AddCall( std::string s )
{ m_vCallStack.push_back( s ); }
std::string ToStr() const
{
std::string l_sRet = "";
...
l_sRet += "Call stack:\n";
for( int i = 0; i < m_vCallStack.size(); i++ )
l_sRet += " " + m_vCallStack[i] + "\n";
...
return l_sRet;
}
private:
...
std::vector< std::string > m_vCallStack;
};
ret_type some_function( param_1, param_2, param_3 )
{
try
{
...
} …Run Code Online (Sandbox Code Playgroud) 有没有办法表示不是完整崩溃报告的堆栈跟踪?
我正在将[NSThread callStackSymbols]的字符串结果记录到我们的服务器.这不会提供完全格式化的崩溃报告,而只是非符号化的堆栈跟踪(下面的示例).
我试图象征这一点.我也尝试从同一个构建中替换实际崩溃报告的线程0堆栈跟踪.都没有奏效.我确实在app存档中有构建的dSYM.有没有办法在分发版本中不留下符号的情况下这样做?
0 domino free 0x00072891 domino free + 465041
1 domino free 0x000ea205 domino free + 954885
2 domino free 0x000ea033 domino free + 954419
3 domino free 0x0007fe55 domino free + 519765
4 domino free 0x0006f6d5 domino free + 452309
5 domino free 0x0006f7a3 domino free + 452515
6 domino free 0x0006fb9b domino free + 453531
7 Foundation 0x30558c29 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 16
8 Foundation 0x304b06d9 -[NSURLConnectionInternalConnection invokeForDelegate:] + 28
9 Foundation 0x304b06a3 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + …Run Code Online (Sandbox Code Playgroud) 我的应用程序的作用是显示通过windowManager.addView()和WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY标记附加的系统覆盖视图.这是通过服务完成的,该服务管理视图可见性和其他一些事情.
但是,我收到崩溃报告,无法重现它们.崩溃堆栈跟踪也与我的应用程序包无关,所以我真的无法解决这个问题的根源.以下是来自不同来源的两个堆栈跟踪,但似乎是相关的:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.measure(int, int)' on a null object reference
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2388)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2101)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1297)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7011)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Run Code Online (Sandbox Code Playgroud)
.
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getMeasuredWidth()' on a null object reference
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2484)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2181)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1293)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6599)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:800)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at …Run Code Online (Sandbox Code Playgroud) stack-trace ×10
android ×3
async-await ×1
c ×1
c++ ×1
debugging ×1
eclipse ×1
exception ×1
gdb ×1
ios ×1
java ×1
javascript ×1
logging ×1
performance ×1
portability ×1
python ×1
react-native ×1
redux ×1
service ×1
symbolicate ×1
traceback ×1
try-catch ×1
view ×1
xcode ×1