From patchwork Wed Dec 3 09:48:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 4049 Received: (qmail 24018 invoked by alias); 3 Dec 2014 09:48:42 -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 24006 invoked by uid 89); 3 Dec 2014 09:48:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 03 Dec 2014 09:48:39 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C68D0116893; Wed, 3 Dec 2014 04:48:37 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id n5qkQ+Q6K3Nh; Wed, 3 Dec 2014 04:48:37 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 59E2A116890; Wed, 3 Dec 2014 04:48:37 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 1BC9A46B66; Wed, 3 Dec 2014 13:48:34 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Yao Qi Subject: [pushed] callback.h:struct host_callback_struct compilation error on Windows hosts. Date: Wed, 3 Dec 2014 13:48:28 +0400 Message-Id: <1417600108-7999-1-git-send-email-brobecker@adacore.com> In-Reply-To: <20141202170144.GA9407@adacore.com> References: <20141202170144.GA9407@adacore.com> On Windows, a recent gnulib update imported the lstat module, and this caused a remote-sim.c build failure in struct host_callback_struct: In file included from /[...]/gdb/remote-sim.c:34:0: /[...]/gdb/../include/gdb/callback.h:93:9: error: duplicate member '_stati64' int (*lstat) (host_callback *, const char *, struct stat *); ^ What happens it that gnulib's stat.h makes the following defines: /* Large File Support on native Windows. */ #if 1 # define stat _stati64 #endif and then: #if 1 # if ! 0 /* mingw does not support symlinks, therefore it does not have lstat. But without links, stat does just fine. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define lstat stat # endif So, the following fields in struct host_callback_struct... int (*stat) (host_callback *, const char *, struct stat *); int (*fstat) (host_callback *, int, struct stat *); int (*lstat) (host_callback *, const char *, struct stat *); ... get translated to... int (*_stati64) (host_callback *, const char *, struct _stati64 *); int (*_fstati64) (host_callback *, int, struct _stati64 *); int (*_stati64) (host_callback *, const char *, struct _stati64 *); ... which causes two fields to have the same name. This patch fixes the issue by renaming the stat-related fields by adding a "to_" prefix, similar to what is done in GDB's target_ops vector. include/gdb/ChangeLog: * callback.h (struct host_callback_struct) : Renamed from "stat". : Renamed from "fstat". : Renamed from "lstat". sim/common/ChangeLog: * sim-io.c (sim_io_stat, sim_io_fstat): Adjust calls to "stat" and "fstat" callbacks by calls to "to_stat" and "to_fstat" (resp) callbacks following renaming in callback.h. * syscall.c (cb_syscall): Likewise. Adjust calls to "lstat" callback by call to "to_lstat" callback sim/cris/ChangeLog: * traps.c (cris_break_13_handler): Adjust call to "fstat" callback by call to "to_fstat" following renaming in callback.h. sim/h8300/ChangeLog: * compile.c (sim_resume): Adjust calls to "stat" and "fstat" callbacks by calls to "to_stat" and "to_fstat" (resp) callbacks following renaming in callback.h. Tested by rebuilding each and every simulator on x86_64-linux. Since the builds are currently broken on Windows, I decided to go ahead and push, but it is of course extra easy to revert the patch, now that we're using git, so that would be no problem if people wanted to implement another solution. Just let me know. Thank you, diff --git a/include/gdb/ChangeLog b/include/gdb/ChangeLog index 135391d..7ec304c 100644 --- a/include/gdb/ChangeLog +++ b/include/gdb/ChangeLog @@ -1,3 +1,10 @@ +2014-12-03 Joel Brobecker + + * callback.h (struct host_callback_struct) : Renamed + from "stat". + : Renamed from "fstat". + : Renamed from "lstat". + 2014-03-10 Mike Frysinger * remote-sim.h (sim_do_command): Add const to cmd. diff --git a/include/gdb/callback.h b/include/gdb/callback.h index bb1edac..d9ac263 100644 --- a/include/gdb/callback.h +++ b/include/gdb/callback.h @@ -88,9 +88,9 @@ struct host_callback_struct void (*flush_stdout) (host_callback *); int (*write_stderr) (host_callback *, const char *, int); void (*flush_stderr) (host_callback *); - int (*stat) (host_callback *, const char *, struct stat *); - int (*fstat) (host_callback *, int, struct stat *); - int (*lstat) (host_callback *, const char *, struct stat *); + int (*to_stat) (host_callback *, const char *, struct stat *); + int (*to_fstat) (host_callback *, int, struct stat *); + int (*to_lstat) (host_callback *, const char *, struct stat *); int (*ftruncate) (host_callback *, int, long); int (*truncate) (host_callback *, const char *, long); int (*pipe) (host_callback *, int *); diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 64f2081..3c85626 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,11 @@ +2014-12-03 Joel Brobecker + + * sim-io.c (sim_io_stat, sim_io_fstat): Adjust calls to "stat" + and "fstat" callbacks by calls to "to_stat" and "to_fstat" (resp) + callbacks following renaming in callback.h. + * syscall.c (cb_syscall): Likewise. Adjust calls to "lstat" + callback by call to "to_lstat" callback + 2014-08-28 Gary Benson * sim-trace.h (debug_printf): New define. diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c index 918137b..1114ec6 100644 --- a/sim/common/sim-io.c +++ b/sim/common/sim-io.c @@ -391,11 +391,11 @@ sim_io_poll_read (SIM_DESC sd, int sim_io_stat (SIM_DESC sd, const char *path, struct stat *buf) { - return STATE_CALLBACK (sd)->stat (STATE_CALLBACK (sd), path, buf); + return STATE_CALLBACK (sd)->to_stat (STATE_CALLBACK (sd), path, buf); } int sim_io_fstat (SIM_DESC sd, int fd, struct stat *buf) { - return STATE_CALLBACK (sd)->fstat (STATE_CALLBACK (sd), fd, buf); + return STATE_CALLBACK (sd)->to_fstat (STATE_CALLBACK (sd), fd, buf); } diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 397cd80..b5cb1ca 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -455,7 +455,7 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) result = -1; goto FinishSyscall; } - result = (*cb->stat) (cb, path, &statbuf); + result = (*cb->to_stat) (cb, path, &statbuf); free (path); if (result < 0) goto ErrorFinish; @@ -488,7 +488,7 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) struct stat statbuf; TADDR addr = sc->arg2; - result = (*cb->fstat) (cb, sc->arg1, &statbuf); + result = (*cb->to_fstat) (cb, sc->arg1, &statbuf); if (result < 0) goto ErrorFinish; buflen = cb_host_to_target_stat (cb, NULL, NULL); @@ -526,7 +526,7 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) result = -1; goto FinishSyscall; } - result = (*cb->lstat) (cb, path, &statbuf); + result = (*cb->to_lstat) (cb, path, &statbuf); free (path); if (result < 0) goto ErrorFinish; diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index 4801f14..ad903fb 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,8 @@ +2014-12-03 Joel Brobecker + + * traps.c (cris_break_13_handler): Adjust call to "fstat" callback + by call to "to_fstat" following renaming in callback.h. + 2014-08-19 Alan Modra * configure: Regenerate. diff --git a/sim/cris/traps.c b/sim/cris/traps.c index 35dce3c..c50f04f 100644 --- a/sim/cris/traps.c +++ b/sim/cris/traps.c @@ -2204,7 +2204,7 @@ cris_break_13_handler (SIM_CPU *current_cpu, USI callnum, USI arg1, || ((events = sim_core_read_unaligned_2 (current_cpu, pc, 0, ufds + 4)) != TARGET_POLLIN) - || ((cb->fstat) (cb, fd, &buf) != 0 + || ((cb->to_fstat) (cb, fd, &buf) != 0 || (buf.st_mode & S_IFIFO) == 0) || current_cpu->thread_data == NULL) { diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog index 62ef367..16489e6 100644 --- a/sim/h8300/ChangeLog +++ b/sim/h8300/ChangeLog @@ -1,3 +1,9 @@ +2014-12-03 Joel Brobecker + + * compile.c (sim_resume): Adjust calls to "stat" and "fstat" + callbacks by calls to "to_stat" and "to_fstat" (resp) callbacks + following renaming in callback.h. + 2014-08-19 Alan Modra * configure: Regenerate. diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c index 348cdbb..4deba82 100644 --- a/sim/h8300/compile.c +++ b/sim/h8300/compile.c @@ -3062,7 +3062,8 @@ sim_resume (SIM_DESC sd, int step, int siggnal) stat_ptr = (h8300hmode && !h8300_normal_mode) ? GET_L_REG (1) : GET_W_REG (1); /* Callback stat and return. */ - fstat_return = sim_callback->fstat (sim_callback, fd, &stat_rec); + fstat_return = sim_callback->to_fstat (sim_callback, fd, + &stat_rec); /* Have stat_ptr point to starting of stat_rec. */ temp_stat_ptr = (char *) (&stat_rec); @@ -3136,7 +3137,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal) /* Callback stat and return. */ stat_return = - sim_callback->stat (sim_callback, filename, &stat_rec); + sim_callback->to_stat (sim_callback, filename, &stat_rec); /* Have stat_ptr point to starting of stat_rec. */ temp_stat_ptr = (char *) (&stat_rec);