From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 612C53858C50 for ; Mon, 28 Mar 2022 17:28:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 612C53858C50 Received: by mail-il1-x130.google.com with SMTP id u13so1571558ilv.6 for ; Mon, 28 Mar 2022 10:28:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YiWXOIUDLQRAZiLJANrVs+QzvpU0CyuCx+gS0PVTMhw=; b=7lMxX8uwT6S3P8QVaYwyB2XamTZJTD3R57cU7eW9jXrfvvp3xoe4vpx0UP4R8GfqC7 R9b4P2khqTZVJiSMDDIPbK0B5rl9teh/jAN35DCu3QoGu+Hy8A5DvM6Ds6PrjhF2t1Ws xywHM66NEhp5EFKWuFLGpLg7TyYCsfi1K5/MvF3K6t71FDK32gnqIf9yROAEU/l0vT0u Xk/n2UVvkd6bZ5a4QE7kP6PGn/cGs6RRBnSDpvp1IVtKJT4G9NyvgljjEjaWeevVvVXd eKJyUWM2ICDIJsurj+/FZjApRU6tDR2wCtDT942CLxxEksJF3JvlxI8zl3Myo0b2scNH QQDw== X-Gm-Message-State: AOAM5307m82Cr4r7SD3dyYcv72BzP7UJxUFfCEkyjz7I4HG0tFnNDH1C Y4vvoVxO/nu5odDrOXzSzsHrrb0mirU1Nw== X-Google-Smtp-Source: ABdhPJwfrEuC4RJ6m93bTE3YezWUkGfLMNm0MD1aPGBVCCtIaM3rte1Lpz3F8vUn3YHp/SOtwl7Kgw== X-Received: by 2002:a92:ca47:0:b0:2c7:f738:3953 with SMTP id q7-20020a92ca47000000b002c7f7383953mr6698937ilo.42.1648488507515; Mon, 28 Mar 2022 10:28:27 -0700 (PDT) Received: from murgatroyd.Home (71-211-175-224.hlrn.qwest.net. [71.211.175.224]) by smtp.gmail.com with ESMTPSA id k2-20020a92b702000000b002c9b14968c6sm2417929ili.52.2022.03.28.10.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 10:28:27 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Consolidate definition of current_directory Date: Mon, 28 Mar 2022 11:28:25 -0600 Message-Id: <20220328172825.266004-1-tromey@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2022 17:28:30 -0000 I noticed that both gdbserver and gdb define current_directory. However, as it is referenced by gdbsupport, it seemed better to define it there as well. This patch also moves the declaration to pathstuff.h. Tested by rebuilding. --- gdb/top.c | 4 ---- gdbserver/server.cc | 4 ---- gdbsupport/common-defs.h | 3 --- gdbsupport/pathstuff.cc | 4 ++++ gdbsupport/pathstuff.h | 3 +++ 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/gdb/top.c b/gdb/top.c index 7831b4f96ca..787706ef10b 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -140,10 +140,6 @@ show_confirm (struct ui_file *file, int from_tty, value); } -/* Current working directory. */ - -char *current_directory; - /* The last command line executed on the console. Used for command repetitions when the user enters an empty line. */ diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 8e53f226d3c..9f52d6e63fe 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -65,10 +65,6 @@ break; \ } -/* String containing the current directory (what getwd would return). */ - -char *current_directory; - /* The environment to pass to the inferior when creating it. */ static gdb_environ our_environ; diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h index e263d948ee1..eed364a48ce 100644 --- a/gdbsupport/common-defs.h +++ b/gdbsupport/common-defs.h @@ -213,9 +213,6 @@ /* Pull in gdb::unique_xmalloc_ptr. */ #include "gdbsupport/gdb_unique_ptr.h" -/* String containing the current directory (what getwd would return). */ -extern char *current_directory; - /* sbrk on macOS is not useful for our purposes, since sbrk(0) always returns the same value. brk/sbrk on macOS is just an emulation that always returns a pointer to a 4MB section reserved for diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc index cb2dd4f5782..a347123cf2b 100644 --- a/gdbsupport/pathstuff.cc +++ b/gdbsupport/pathstuff.cc @@ -29,6 +29,10 @@ /* See gdbsupport/pathstuff.h. */ +char *current_directory; + +/* See gdbsupport/pathstuff.h. */ + gdb::unique_xmalloc_ptr gdb_realpath (const char *filename) { diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h index 38828b7c4a3..50e388aad04 100644 --- a/gdbsupport/pathstuff.h +++ b/gdbsupport/pathstuff.h @@ -136,4 +136,7 @@ extern const char *get_shell (); extern gdb::char_vector make_temp_filename (const std::string &f); +/* String containing the current directory (what getwd would return). */ +extern char *current_directory; + #endif /* COMMON_PATHSTUFF_H */ -- 2.34.1