binutils-gdb-2.32.patch 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. --- readline/Makefile.in 2019-04-16 20:10:40.000000000 +0300
  2. +++ readline/Makefile-patched.in 2019-04-16 20:20:11.000000000 +0300
  3. @@ -219,6 +219,7 @@
  4. ## readline along with GDB. GDB links statically against readline,
  5. ## so it doesn't depend on us installing it on the system.
  6. +install-strip:
  7. install:
  8. #install: $(INSTALL_TARGETS)
  9. --- gdb/configure 2020-06-14 20:40:38.430076716 +0300
  10. +++ gdb/configure-patched 2020-06-14 20:40:29.175000000 +0300
  11. @@ -9039,7 +9039,7 @@
  12. ac_res=-l$ac_lib
  13. LIBS="-l$ac_lib $ac_func_search_save_LIBS"
  14. fi
  15. - if ac_fn_c_try_link "$LINENO"; then :
  16. + if ac_fn_c_try_run "$LINENO"; then :
  17. ac_cv_search_tgetent=$ac_res
  18. fi
  19. rm -f core conftest.err conftest.$ac_objext \
  20. diff --git bfd/Makefile.am bfd/Makefile.am
  21. index a9191555..e0c24d5e 100644
  22. --- bfd/Makefile.am
  23. +++ bfd/Makefile.am
  24. @@ -965,7 +965,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
  25. fi ;\
  26. $(SED) -e "s,@bfd_version@,$$bfd_version," \
  27. -e "s,@bfd_version_string@,$$bfd_version_string," \
  28. - -e "s,@bfd_version_package@,$$bfd_version_package," \
  29. + -e "s|@bfd_version_package@|$$bfd_version_package|" \
  30. -e "s,@report_bugs_to@,$$report_bugs_to," \
  31. < $(srcdir)/version.h > $@; \
  32. echo "$${bfd_soversion}" > libtool-soversion
  33. diff --git bfd/Makefile.in bfd/Makefile.in
  34. index 896df520..8e184d3e 100644
  35. --- bfd/Makefile.in
  36. +++ bfd/Makefile.in
  37. @@ -2080,7 +2080,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
  38. fi ;\
  39. $(SED) -e "s,@bfd_version@,$$bfd_version," \
  40. -e "s,@bfd_version_string@,$$bfd_version_string," \
  41. - -e "s,@bfd_version_package@,$$bfd_version_package," \
  42. + -e "s|@bfd_version_package@|$$bfd_version_package|" \
  43. -e "s,@report_bugs_to@,$$report_bugs_to," \
  44. < $(srcdir)/version.h > $@; \
  45. echo "$${bfd_soversion}" > libtool-soversion
  46. diff --git gdb/python/lib/gdb/__init__.py gdb/python/lib/gdb/__init__.py
  47. index af74df80..afe5b08f 100644
  48. --- gdb/python/lib/gdb/__init__.py
  49. +++ gdb/python/lib/gdb/__init__.py
  50. @@ -106,6 +106,32 @@ def execute_unwinders(pending_frame):
  51. return None
  52. +def _execute_file(filepath):
  53. + """This function is used to replace Python 2's PyRun_SimpleFile.
  54. +
  55. + Loads and executes the given file.
  56. +
  57. + We could use the runpy module, but its documentation says:
  58. + "Furthermore, any functions and classes defined by the executed code are
  59. + not guaranteed to work correctly after a runpy function has returned."
  60. + """
  61. + globals = sys.modules['__main__'].__dict__
  62. + set_file = False
  63. + # Set file (if not set) so that the imported file can use it (e.g. to
  64. + # access file-relative paths). This matches what PyRun_SimpleFile does.
  65. + if not hasattr(globals, '__file__'):
  66. + globals['__file__'] = filepath
  67. + set_file = True
  68. + try:
  69. + with open(filepath, 'rb') as file:
  70. + # We pass globals also as locals to match what Python does
  71. + # in PyRun_SimpleFile.
  72. + compiled = compile(file.read(), filepath, 'exec')
  73. + exec(compiled, globals, globals)
  74. + finally:
  75. + if set_file:
  76. + del globals['__file__']
  77. +
  78. # Convenience variable to GDB's python directory
  79. PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
  80. diff --git gdb/python/python-config.py gdb/python/python-config.py
  81. index 3e60b86a..1e04f6cf 100644
  82. --- gdb/python/python-config.py
  83. +++ gdb/python/python-config.py
  84. @@ -3,6 +3,7 @@
  85. import sys
  86. import os
  87. +import platform
  88. import getopt
  89. from distutils import sysconfig
  90. @@ -45,16 +46,29 @@ def to_unix_path(path):
  91. for opt in opt_flags:
  92. if opt == '--prefix':
  93. - print (to_unix_path(sysconfig.PREFIX))
  94. + prefix=os.environ.get('CONFIG_PYTHON_PREFIX')
  95. + if prefix and prefix.strip():
  96. + sys.stderr.write ("%s -> [%s]\n" % (opt, prefix.strip()))
  97. + print (prefix.strip())
  98. + else:
  99. + sys.stderr.write ("%s -> [%s]\n" % (opt, to_unix_path(sysconfig.PREFIX)))
  100. + print (to_unix_path(sysconfig.PREFIX))
  101. elif opt == '--exec-prefix':
  102. - print (to_unix_path(sysconfig.EXEC_PREFIX))
  103. + prefix=os.environ.get('CONFIG_PYTHON_PREFIX')
  104. + if prefix and prefix.strip():
  105. + sys.stderr.write ("%s -> [%s]\n" % (opt, prefix.strip()))
  106. + print (prefix.strip())
  107. + else:
  108. + sys.stderr.write ("%s -> [%s]\n" % (opt, to_unix_path(sysconfig.EXEC_PREFIX)))
  109. + print (to_unix_path(sysconfig.EXEC_PREFIX))
  110. elif opt in ('--includes', '--cflags'):
  111. flags = ['-I' + sysconfig.get_python_inc(),
  112. '-I' + sysconfig.get_python_inc(plat_specific=True)]
  113. if opt == '--cflags':
  114. flags.extend(getvar('CFLAGS').split())
  115. + sys.stderr.write ("%s -> [%s]\n" % (opt, to_unix_path(' '.join(flags))))
  116. print (to_unix_path(' '.join(flags)))
  117. elif opt in ('--libs', '--ldflags'):
  118. @@ -73,5 +87,7 @@ for opt in opt_flags:
  119. libs.insert(0, '-L' + sysconfig.PREFIX + '/libs')
  120. if getvar('LINKFORSHARED') is not None:
  121. libs.extend(getvar('LINKFORSHARED').split())
  122. - print (to_unix_path(' '.join(libs)))
  123. + tmp = to_unix_path(' '.join(libs))
  124. + sys.stderr.write ("%s -> [%s]\n" % (opt, tmp))
  125. + print (tmp)
  126. diff --git gdb/python/python.c gdb/python/python.c
  127. index c23db2c1..fe1da107 100644
  128. --- gdb/python/python.c
  129. +++ gdb/python/python.c
  130. @@ -323,9 +323,8 @@ python_interactive_command (const char *arg, int from_tty)
  131. A FILE * from one runtime does not necessarily operate correctly in
  132. the other runtime.
  133. - To work around this potential issue, we create on Windows hosts the
  134. - FILE object using Python routines, thus making sure that it is
  135. - compatible with the Python library. */
  136. + To work around this potential issue, we run code in Python to load
  137. + the script. */
  138. static void
  139. python_run_simple_file (FILE *file, const char *filename)
  140. @@ -339,15 +338,21 @@ python_run_simple_file (FILE *file, const char *filename)
  141. /* Because we have a string for a filename, and are using Python to
  142. open the file, we need to expand any tilde in the path first. */
  143. gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
  144. - gdbpy_ref<> python_file (PyFile_FromString (full_path.get (), (char *) "r"));
  145. - if (python_file == NULL)
  146. +
  147. + if (gdb_python_module == nullptr
  148. + || ! PyObject_HasAttrString (gdb_python_module, "_execute_file"))
  149. + error (_("Installation error: gdb._execute_file function is missing"));
  150. +
  151. + gdbpy_ref<> return_value
  152. + (PyObject_CallMethod (gdb_python_module, "_execute_file", "s",
  153. + full_path.get ()));
  154. + if (return_value == nullptr)
  155. {
  156. - gdbpy_print_stack ();
  157. - error (_("Error while opening file: %s"), full_path.get ());
  158. + /* Use PyErr_PrintEx instead of gdbpy_print_stack to better match the
  159. + behavior of the non-Windows codepath. */
  160. + PyErr_PrintEx(0);
  161. }
  162. - PyRun_SimpleFile (PyFile_AsFile (python_file.get ()), filename);
  163. -
  164. #endif /* _WIN32 */
  165. }