tls-so_extern.exp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright 2003-2022 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. # tls-so_extern.exp -- Expect script to test thread local storage in gdb, with
  15. # a variable defined in a shared library.
  16. standard_testfile tls-so_extern_main.c
  17. set libfile tls-so_extern
  18. set srcfile_lib ${libfile}.c
  19. set binfile_lib [standard_output_file ${libfile}.so]
  20. # get the value of gcc_compiled
  21. if [get_compiler_info] {
  22. return -1
  23. }
  24. if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != ""
  25. || [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable [list debug shlib=${binfile_lib}]] != ""} {
  26. return -1
  27. }
  28. clean_restart ${binfile}
  29. gdb_load_shlib ${binfile_lib}
  30. if ![runto_main] then {
  31. return 0
  32. }
  33. gdb_test "print so_extern" "0x0" "print thread local storage variable"
  34. gdb_test "ptype so_extern" "void \\*" "ptype of thread local storage variable"
  35. gdb_test "info address so_extern" \
  36. "Symbol \\\"so_extern\\\" is a thread-local variable at offset 0x0 in the thread-local storage for .*tls-so_extern.*" \
  37. "print storage info for thread local storage variable"
  38. set line_number [gdb_get_line_number "break here to check result"]
  39. gdb_test "break $line_number" \
  40. "Breakpoint.*at.*file.*tls-so_extern_main.c.*line ${line_number}." \
  41. "break in thread function"
  42. gdb_test "continue" \
  43. "tls_ptr .* at .*:.*break here to check result.*" \
  44. "continue to break in tls_ptr called by main"
  45. gdb_test "print so_extern == &so_extern" \
  46. " = 1" \
  47. "check so_extern address in main"
  48. gdb_test "continue" \
  49. "tls_ptr .* at .*:.*break here to check result.*" \
  50. "continue to break in a thread"
  51. gdb_test "print so_extern == &so_extern" \
  52. " = 1" \
  53. "check so_extern address"
  54. gdb_test "continue" \
  55. "tls_ptr .* at .*:.*break here to check result.*" \
  56. "continue to break in the other thread"
  57. gdb_test "print so_extern == &so_extern" \
  58. " = 1" \
  59. "check so_extern address in other thread"
  60. gdb_test "continue" \
  61. "tls_ptr .* at .*:.*break here to check result.*" \
  62. "continue to break in tls_ptr called at end of main"
  63. gdb_test "print so_extern == &so_extern" \
  64. " = 1" \
  65. "check so_extern address at end of main"