获取异常的堆栈跟踪效率如何?我知道这是昂贵的,但成本如何?它们绝对不能用于生产环境吗?
人们说除了没有尾调用优化的限制之外,clojure实现是优秀的 - 限制jvm而不是clojure实现.
http://lambda-the-ultimate.org/node/2547
有人说,将Python实现TCO会牺牲
是否必须为实施TCO的jvm做出同样的牺牲?还有什么需要牺牲的吗?
我是iphone开发的新手,我一直在努力解决几天前发生的EXC_BAD_ACCESS错误.我基本上独立地使用斯坦福iphone类,我试图将一个NSManagedObjects数组传递给一个应该显示它们的TableViewController.应用程序在模拟器中启动并在tableView中显示数据,但它会立即出现EXC_BAD_ACCESS错误.
我按照这里和其他地方的说明如何使用NSZombieEnabled来识别过早释放的对象,但即使使用NSZombieEnabled也没有任何有用的消息.我的猜测是它必须是由于试图访问未通过发布/自动释放释放的未分配内存而导致的.否则它会被视为僵尸对象,就像我能够修复的其他错误一样.我不是专家,但如果我要声明一个对象并在没有实例化的情况下发送消息,那么这意味着会发生这样的事情吗?我查看了我的代码,看看我是否有类似的东西,我空了.
我在调试器中有堆栈跟踪,但我不知道如何使用它.我有点沮丧,因为我不能在代码中使用断点来进一步缩小问题,因为它似乎发生在应用程序加载完成后.如果没有可能的用户交互,我认为该应用程序将保持闲置状态.它是否在负载的尾端失败,我不能轻易看到它或者在完成加载后突然在后台做东西.我非常感谢有关如何阅读堆栈跟踪的任何提示.
我在下面键入了我的堆栈跟踪(无法弄清楚如何从调试器中复制它)
0 objc_msgSend
1 ??
2 -[NSManagedObject dealloc]
3 -[_PFManagedObjectReferenceQueue _processReferenceQue:]
4 _performRunLoopAction
5 ___CFRunLoopDoObservers
6 CFRunLoopRunSpecific
7 CFRunLoopRunInMode
8 GSEventRunModal
9 GSEventRun
10 UIApplicationMain
11 main
我的程序中的两个主要类是顶级委托类和它调用的ViewTableController.
` - (void)applicationDidFinishLaunching:(UIApplication*)application {
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
UINavigationController *contactsNavigationController = [[self createContactsNavigationController] retain];
//UINavigationController *recentsNavigationController = [[self createRecentsNavigationController:photos] retain];
tabBarController.viewControllers = [[NSArray alloc] initWithObjects: contactsNavigationController, nil];
[contactsNavigationController release];
//[recentsNavigationController release];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)
}
- (UINavigationController*)createContactsNavigationController {
UINavigationController *contactsNavigationController = [[UINavigationController alloc] init];
UITabBarItem *contactsTabBarItem …Run Code Online (Sandbox Code Playgroud) 我从我的应用程序收到崩溃报告.我真的不明白问题是什么.它永远不会跟我崩溃......可能是什么问题?从应用程序集线器错误消息:
0 coredll.dll xxx_RaiseException 19
1 mscoree3_7.dll 436488
2 mscoree3_7.dll 386545
3 mscoree3_7.dll 540936
4 TransitionStub 0
5 System.ThrowHelper.ThrowKeyNotFoundException 52
6 System.Collections.Generic.Dictionary 2.get_Item 136
7 System.IO.IsolatedStorage.IsolatedStorageSettings.get_Item 80
8 ScheduledTaskAgent1.ScheduledAgent.OnInvoke 660
9 Microsoft.Phone.Scheduler.ScheduledTaskAgent.Invoke 856
10 .AgentRequest.Invoke 764
11 Microsoft.Phone.BackgroundAgentDispatcher.InvocationThread 196
12 System.Threading.ThreadHelper.ThreadStartHelper 132
13 System.Threading.ThreadHelper.ThreadStart_Context 80
14 System.Threading.ExecutionContext.Run 324
15 System.Threading.ThreadHelper.ThreadStartHelper 168
16 mscoree3_7.dll 429164
17 mscoree3_7.dll 310125
18 mscoree3_7.dll 310319
19 mscoree3_7.dll 305995"
我非常喜欢Flame Graph的概念,因为它有助于消除不必要的函数调用.然而,有一个问题是它需要分析器在每次收集样本时执行完整的堆栈转储.这可以通过DTrace或SystemTap轻松完成,但我需要能够在运行ubuntu的ARM设备上执行此操作(这会消除DTrace).我还想在不重新编译内核的情况下执行此操作(这会消除SystemTap).
是否有可能获得Valgrind/Callgrind或OProfile(或其他可以在Ubuntu中的ARM设备上运行的分析工具)输出类似于:
dtrace -n 'profile-1001 /pid == 12345 && arg1/ { @[ustack()] = count(); }
我的最终目标是转储用户空间堆栈。
我尝试将以下cpp文件构建为android平台上的可执行文件。因此,通过调用tryToGetStack(),可以在运行时获取可执行文件的调用堆栈。
#include <utils/CallStack.h>
namespace android
{
extern "C" void tryToGetStack()
{
CallStack stack;
stack.update();
stack.dump("");
}
}
Run Code Online (Sandbox Code Playgroud)
并将lib设置添加到Android.mak,因为CallStack.tpp在libutils中
LOCAL_SHARED_LIBRARIES + = libutils
但是我总是收到错误消息:
错误:未定义对“ android :: CallStack :: CallStack()”的引用
错误:未定义对“ android :: CallStack :: update(int,int)”的引用
...
似乎可执行文件在链接时解析符号,而不是在运行时加载.so文件?我会丢失某些东西还是Android构建系统存在某些限制吗?
我知道这是一个简单的问题,但我确实需要帮助...
更新1
我尝试将代码添加到另一个可执行文件中。结果是一样的...有人知道android构建系统的规则吗?
更新2
我的控制台中有一些关键字“ target StaticExecutable:...”,我认为这就是答案。
如何打印每个函数/方法调用?我尝试使用:,python -m trace --trace但它还会打印函数内部代码...我只想要被调用的函数名称。在代码中使用traceback会打印调用命令本身之前调用的最后一个函数,并且该代码包含许多类。
I know we can get the full stacktrace using __STACKTRACE__ in a catch/rescue block in elixir, but what's the correct way of printing it? In my case, I rescue from an error but I still want to log it to console. This is what I'm doing right now:
def unreliable_method(item) do
# Do something with `item`
:ok
rescue
_err ->
Logger.error("Failed for item: #{inspect(item)}")
Logger.error(inspect(__STACKTRACE__))
{:error, :processing_failed}
end
Run Code Online (Sandbox Code Playgroud) 每天有几次在我的Phoenix应用程序中浏览错误的堆栈跟踪时,我注意到某些绝对在执行的文件没有显示在堆栈跟踪中。
这是一个涉及format_date从我的模板调用的助手的示例。代码:
# The template, `...web/templates/home/index.html.eex`:
<h1>My Super Old Company</h1>
<p>We've been operating since <%= format_date(Timex.now()) %>!!</p>
# The `format_date` helper lives in the corresponding View module:
def format_date(date) do
template = "%b %d, %Y"
method = :strftime
# Whoops, it looks like I passed a bad value to Timex here
Timex.format!(nil, template, method)
end
Run Code Online (Sandbox Code Playgroud)
尝试呈现此页面会产生异常:
Request: GET /
** (exit) an exception was raised:
** (ArgumentError) invalid_date
(timex) lib/format/datetime/formatter.ex:60: Timex.Format.DateTime.Formatter.lformat!/4
(rtl) lib/rtl_web/templates/home/index.html.eex:3: RTLWeb.HomeView."index.html"/1
(rtl) lib/rtl_web/templates/layout/app.html.eex:27: RTLWeb.LayoutView."app.html"/1 …Run Code Online (Sandbox Code Playgroud)