मेरे पास एक तरीका है कि मैंने हमेशा ऐसा किया है, लेकिन आपके प्रश्न को देखकर मुझे यह देखने के लिए उत्सुक बना दिया गया कि कोई बेहतर तंत्र है या नहीं। मुझे कुछ नहीं मिला।
तुम हमेशा समारोह आप में कदम कर रहे हैं अंदर एक ब्रेकपाइंट सेट कर सकते हैं, लेकिन इससे पहले कि आप चरण करते हैं, के आदेशों का 'आदेश का उपयोग gdb है कि आप इसे कुछ भी मुद्रित करने के लिए नहीं करना चाहते हैं बताने के लिए जब यह हिट वह ब्रेकपॉइंट। एक उदाहरण चीजों को स्पष्ट कर देगा ...
आप देखेंगे कि जब मैं प्रोग्राम चलाता हूं, तो मैं लाइन 10 (कॉल टू फू) पर ब्रेकपॉइंट पर रुक जाता हूं और यह मेरे वर्तमान संदर्भ को प्रिंट करता है। 'कमांड 2' कमांड जारी करने और जीडीबी को उस ब्रेकपॉइंट पर चुप रहने के बाद, जब भी मैं इसे दबाता हूं तो कुछ भी मुद्रित नहीं होता है। मैंने बैकट्रैक (बीटी) सिर्फ यह दिखाने के लिए किया था कि मैं वहीं था जहां मैं बनना चाहता था।
आशा इस मदद करता है:
> cat tmp.cpp
#include <stdio.h>
void foo(int a)
{
printf ("%d\n", a);
}
int main()
{
foo(0);
return 0;
}
> g++ -g tmp.cpp
> gdb a.out
GNU gdb Fedora (6.8-27.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) break 10
Breakpoint 1 at 0x8048491: file tmp.cpp, line 10.
(gdb) break 5
Breakpoint 2 at 0x804846a: file tmp.cpp, line 5.
(gdb) run
Starting program: /home/ronb/software/a.out
Breakpoint 1, main() at tmp.cpp:10
10 foo(0);
(gdb) commands 2
Type commands for when breakpoint 2 is hit, one per line.
End with a line saying just "end".
>silent
>end
(gdb) c
Continuing.
(gdb) bt
#0 foo (a=0) at tmp.cpp:5
#1 0x0804849d in main() at tmp.cpp:10
(gdb)