binutils-gdb/gdb/testsuite/gdb.base/cached-source-file.c
Sergio Durigan Junior f6be87130b New testcase for PR tui/25126 (staled source cache)
I'm dealing with a Fedora GDB bug that is related to PR tui/25126, and
I thought I'd write a specific testcase for it because I couldn't find
one.

The idea is to get the simple reproducer from the bug and tweak the
testcase around it.  This one was a bit hard because, since we need to
modify the source file and recompile it, it involved a bit of TCL-foo
to do things.  Also for this reason, I'm only enabling the test for
native boards.

I tested this with an upstream GDB and made sure everything is
passing.  I also tested with a faulty GDB and made sure the test
failed.

gdb/testsuite/ChangeLog:
2020-02-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR tui/25126
	https://bugzilla.redhat.com/show_bug.cgi?id=1784210
	* gdb.base/cached-source-file.c: New file.
	* gdb.base/cached-source-file.exp: New file.

Change-Id: Ib1b074342ebe8613c6d1dfde631691ebdf6d81c6
2020-02-11 11:36:17 -05:00

44 lines
1.2 KiB
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Test for PR tui/25126.
The bug is about a regression that makes GDB not reload its source
code cache when the inferior's symbols are reloaded, which leads to
wrong backtraces/listings.
This bug is reproducible even without using the TUI.
The .exp testcase depends on the line numbers and contents from
this file If you change this file, make sure to double-check the
testcase. */
#include <stdio.h>
void
foo (void)
{
printf ("hello\n"); /* break-here */
}
int
main ()
{
foo ();
return 0;
}