2014年2月24日 星期一

lldb to gdb command

官方連結: LLDB to GDB Command Map

在這備忘自己常用的指令:

  • return EXPR -> thread return EXPR

顯示 step out 後的傳回值

出處:

#/usr/bin/env python
 
import lldb
 
# Put _this_ file into ~/Library/lldb/thread_return.py
# Put the following line into ~/.lldbinit
#     command script import ~/Library/lldb/thread_return.py
 
def __lldb_init_module(debugger, internal_dict):
    debugger.HandleCommand('command script add -f thread_return.thread_return thread_return')
 
def thread_return(debugger, command, result, internal_dict):
    '''Prints the return value of the last function you stepped out from.
    
    This is very useful if the return was a complex expression. This lldb command
    prevents you from needing to create a temporary variable just to inspect the return value'''
 
    # If anyone knows a way of doing this without using needing to script lldb in python...
    target = debugger.GetSelectedTarget()
    process = target.GetProcess()
    thread = process.GetSelectedThread()
    print >> result, str(thread.return_value)
    return lldb.thread.return_value

沒有留言:

張貼留言

在 Fedora 下裝 id-utils

Fedora 似乎因為執行檔撞名,而沒有提供 id-utils 的套件 ,但這是使用 gj 的必要套件,只好自己編。從官網抓好 tarball ,解開來編譯 (./configure && make)就是了。 但編譯後會遇到錯誤: ./stdio.h:10...