2010-03-05 15 views
11

मैं कुछ प्रोग्राम डीबग करना चाहता हूं। मुझे सभी कार्यों से कुछ फ़ंक्शन पर बैकट्रैक चाहिए, उदा। डालता है।स्वचालित जीडीबी: फ़ंक्शन पर प्रत्येक कॉल पर बैकट्रैक दिखाएं

अब मैं इस तरह के gdb script का उपयोग करें:

Function "puts" not defined. 
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal] 
/root/script:5: Error in sourced command file: 
No breakpoint number 1. 

मैं कैसे पुस्तकालय कॉल के लिए स्क्रिप्ट में ब्रेकपाइंट सेट कर सकते हैं:

set width 0 
set height 0 
set verbose off 
break puts 
commands 1 
backtrace 
continue 
end 

लेकिन

gdb --batch --command=script --args ./some_program arguments 

के साथ शुरू करने के लिए एक त्रुटि देता है ?

उत्तर

18

ऐसा करें:

set width 0 
set height 0 
set verbose off 
start # runs to main, so shared libraries are loaded 
     # after you reach main, GDB should have libc symbols, "puts" among them 
break puts 
commands 1 
backtrace 
continue 
end 

अगर यह काम नहीं करता है, सिस्टम संस्करण ऑपरेटिंग राज्य कृपया।

संपादित करें: के रूप में osgx सही ढंग से बताते हैं, अन्य वैकल्पिक जोड़ने के लिए

set breakpoint pending on 

break puts

+1

और क्या बारे में पहले "ब्रेकप्वाइंट लंबित" सेटिंग है? А еще - спасибо। – osgx

+6

आप ब्रेक मुख्य के बजाय 'स्टार्ट' का उपयोग कर सकते हैं; रन ' –

+0

हां,' स्टार्ट 'बेहतर है। उत्तर तय, धन्यवाद! –

संबंधित मुद्दे