एक्सकोड में, जीडीबी आपको डिबगिंग के दौरान स्थानीय चर बदलने की अनुमति देता है (how to change NSString value while debugging in XCode? देखें)। क्या एलएलडीबी एक समान कार्यक्षमता प्रदान करता है? यदि हां, तो हम इसका उपयोग कैसे कर सकते हैं?एक्सकोड में एलएलवीएम के साथ डीबगिंग करते समय वैरिएबल वैल्यू कैसे बदलें?
उत्तर
expr myString = @"Foo"
(lldb) help expr
Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope. This command takes 'raw' input (no need to quote stuff).Syntax: expression --
Command Options Usage: expression [-f ] [-G ] [-d ] [-u ] -- expression [-o] [-d ] [-u ] -- expression
-G <gdb-format> (--gdb-format <gdb-format>) Specify a format using a GDB format specifier string. -d <boolean> (--dynamic-value <boolean>) Upcast the value resulting from the expression to its dynamic type if available. -f <format> (--format <format>) Specify a format to be used for display. -o (--object-description) Print the object description of the value resulting from the expression. -u <boolean> (--unwind-on-error <boolean>) Clean up program state if the expression causes a crash, breakpoint hit or signal.
Examples:
expr my_struct->a = my_array[3]
expr -f bin -- (index * 8) + 5
expr char c[] = "foo"; c[0]IMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options you must use ' -- ' between the end of the command options and the beginning of the raw input.
'expr' is an abbreviation for 'expression'
निम्नलिखित सामान मेरे लिए काम करता है। मैं एक्सकोड 8.
यदि आप कुछ चर सेट करना चाहते हैं (उदाहरण के लिए "dict") को शून्य पर सेट करना चाहते हैं और फिर कोड प्रवाह का परीक्षण करना चाहते हैं, तो आप निम्न को आजमा सकते हैं।
- वांछित मूल्य के आरंभ में ब्रेकपॉइंट ठीक से रखें।
- फिर इसे बदलने के लिए lldb कमांड लाइन में "अभिव्यक्ति dict = nil" निष्पादित करें। (उदाहरण के लिए "शून्य")
- ब्रेक पॉइंट पर कदम।
- अगली पंक्ति में परिवर्तनीय "dict" की जांच करें। यह शून्य होगा।
यह कंसोल में कुछ दिखाई देगा।
(lldb) expression dict = nil
(NSDictionary *) $5 = nil
दरअसल, धन्यवाद! एक और छोटा सवाल: मैं इसे UILabel के पाठ को बदलने की कोशिश करने के लिए कर रहा हूं: '' expr myLabel.text = @ "हैलो!" 'लेकिन मुझे एक त्रुटि मिली: संपत्ति 'टेक्स्ट' प्रकार की वस्तु पर नहीं मिला 'उइलाबेल *' '... कोई विचार? – Eric
'expr (शून्य) [लेबल सेटटेक्स्ट: @" फू "] 'इसे करना चाहिए। डॉट-सिंटेक्स आमतौर पर डीबगर में काम नहीं करेगा। एलएलडीबी शायद इसे समझता है क्योंकि आप सी-स्ट्रक्चर के सदस्य तक पहुंचना चाहते हैं, लेकिन मुझे यकीन नहीं है कि यही कारण है कि यह काम नहीं करेगा। डॉट-सिंटेक्स या तो 'पीओ' के लिए काम नहीं करता है। 'po label.text' के बजाय आपको' po [लेबल टेक्स्ट] ' –
कूल का उपयोग करना होगा। बहुत बहुत धन्यवाद Matthias! – Eric