From patchwork Thu Apr 6 14:28:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preud'homme X-Patchwork-Id: 19881 Received: (qmail 77751 invoked by alias); 6 Apr 2017 14:28:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 76735 invoked by uid 89); 6 Apr 2017 14:28:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Apr 2017 14:28:28 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6728E80D for ; Thu, 6 Apr 2017 07:28:28 -0700 (PDT) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 178C03F3E1 for ; Thu, 6 Apr 2017 07:28:27 -0700 (PDT) To: gdb-patches@sourceware.org From: Thomas Preudhomme Subject: [PATCH, GDB] Fix Windows gdb build failure with python support Message-ID: Date: Thu, 6 Apr 2017 15:28:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-IsSubscribed: yes 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 * 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 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 ();