This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, GDB] Fix Windows gdb build failure with python support


Hi,

GDB fails to build for Windows host with python support enabled due to
python_file's second argument being of type char * and being passed a
string litteral. This patch takes the conservative assumptions that the
function might indeed modify the character string and use a local char
array to pass the mode instead.

ChangeLog entry is as follows:

*** gdb/ChangeLog ***

2017-04-06  Thomas Preud'homme  <thomas.preudhomme@arm.com>

        * python/python.c (python_run_simple_file): Pass mode as a char
        pointer using local char array.

Testing: build for Windows with python support succeed with this patch and fails without.

Is this ok to commit to master?

Best regards,

Thomas
diff --git a/gdb/python/python.c b/gdb/python/python.c
index cc58267b9557a9d6893f03b99d7912b5a3affdbb..590af7311ea6a43db4983a936d5f85f18f7debe0 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -348,11 +348,12 @@ python_run_simple_file (FILE *file, const char *filename)
   PyRun_SimpleFile (file, filename);
 
 #else /* _WIN32 */
+  char mode[] = "r";
 
   /* Because we have a string for a filename, and are using Python to
      open the file, we need to expand any tilde in the path first.  */
   gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
-  gdbpy_ref<> python_file (PyFile_FromString (full_path.get (), "r"));
+  gdbpy_ref<> python_file (PyFile_FromString (full_path.get (), mode));
   if (python_file == NULL)
     {
       gdbpy_print_stack ();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]