diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-objfile.c | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-objfile.exp | 14 |
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" |