aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-06-25 15:45:41 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-07-29 20:44:08 -0500
commitc620ed8866cc90ccfa363daf98ce7061d076d598 (patch)
treeb66b50a551c9a7b2ef9b8e14469000b858ca5783 /gdb/testsuite
parente48de49be52cb6e0fe3edbcdc3e63bbc2465d930 (diff)
downloadgdb-c620ed8866cc90ccfa363daf98ce7061d076d598.zip
gdb-c620ed8866cc90ccfa363daf98ce7061d076d598.tar.gz
gdb-c620ed8866cc90ccfa363daf98ce7061d076d598.tar.bz2
Add Objfile.lookup_{global,static}_symbol functions
This is essentially the inverse of Symbol.objfile. This allows handling different symbols with the same name (but from different objfiles) and can also be faster if the objfile is known. gdb/ChangeLog: 2019-07-29 Christian Biesinger <cbiesinger@google.com> * NEWS: Mention new functions Objfile.lookup_{global,static}_symbol. * python/py-objfile.c (objfpy_lookup_global_symbol): New function. (objfpy_lookup_static_symbol): New function. (objfile_object_methods): Add new functions. gdb/doc/ChangeLog: 2019-07-29 Christian Biesinger <cbiesinger@google.com> * python.texi (Objfiles In Python): Document new functions Objfile.lookup_{global,static}_symbol. gdb/testsuite/ChangeLog: 2019-07-29 Christian Biesinger <cbiesinger@google.com> * gdb.python/py-objfile.c: Add global and static vars. * gdb.python/py-objfile.exp: Test new functions Objfile. lookup_global_symbol and lookup_static_symbol.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.c3
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.exp14
3 files changed, 23 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a0b5862..b255106 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-29 Christian Biesinger <cbiesinger@google.com>
+
+ * gdb.python/py-objfile.c: Add global and static vars.
+ * gdb.python/py-objfile.exp: Test new functions Objfile.
+ lookup_global_symbol and lookup_static_symbol.
+
2019-07-29 Tom Tromey <tom@tromey.com>
* lib/tuiterm.exp (Term::_csi_@): New proc.
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491..6d751bd 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e..261f605 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,20 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\") is None)" \
+ "True" "lookup_global_symbol does not find static symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"static_var\").name)" \
+ "static_var" "lookup_static_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\") is None)" \
+ "True" "lookup_static_symbol does not find global symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"nonexistant\"))" \
+ "None" "lookup_static_symbol can handle nonexistant symbol"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"