When debugging a source file that is full of #line
directives the debugger "switches" between those files accordingly.
Issue: only one file is intended to be debugged
Example: As an example one can use yacc/bison lex/flex which translate a grammar to C source. The result is something like this (the actual content is irrelevant to the question, this is just the first sample that I've looked at):
case 50:
#line 918 "parse.y" /* yacc.c:1652 */
{
struct my_struct *p;
p = ppp_define_add (ppp_setvar_list, (yyvsp[-3].s), (yyvsp[-1].s), (yyvsp[0].ui));
if (p) {
ppp_last_entry = p;
}
}
#line 2330 "parse.c" /* yacc.c:1652 */
break;
case 51:
#line 927 "parse.y" /* yacc.c:1652 */
{
struct my_struct *p;
size_t size;
When debugging code like this GDB shows the original source or generated and compiled source, depending on the actual position which is fine in general. The problem arises if you only want to debug one of those files (which in most cases will be the original source).
Things I've tried so far:
delete the file one doesn't want to skip through.
144 parse.c: No such file or directory.
skip file
when GDB showed the "unwanted" file. This strangely leads GDB (8.2.1) to still go back to the file, just only output that we're in there:
157 in parse.c
(gdb) s
159 in parse.c
(gdb) s
160 in parse.c
(gdb) s
161 in parse.c
Questions:
- Is there an option in GDB to only skip/next into a specific file (in this case parse.y)?
- Is there an option to strip the debugging information for only parse.c or parse.y from the binary?
Ideally the backtrace bt
and similar commands will only show parse.y.