Message ID | 20221025162946.727169-1-ivan.tetyushkin@syntacore.com |
---|---|
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E45B38561A8 for <patchwork@sourceware.org>; Tue, 25 Oct 2022 16:32:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:107]) by sourceware.org (Postfix) with ESMTPS id BEEA4385703E for <gdb-patches@sourceware.org>; Tue, 25 Oct 2022 16:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BEEA4385703E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=syntacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=syntacore.com Received: from sas1-71299a9d5a62.qloud-c.yandex.net (sas1-71299a9d5a62.qloud-c.yandex.net [IPv6:2a02:6b8:c08:210e:0:640:7129:9a9d]) by forward104p.mail.yandex.net (Yandex) with ESMTP id A21EC3C21247 for <gdb-patches@sourceware.org>; Tue, 25 Oct 2022 19:32:05 +0300 (MSK) Received: by sas1-71299a9d5a62.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id vYrOVqEYP6-W5g0SMKt; Tue, 25 Oct 2022 19:32:05 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mail; t=1666715525; bh=i3I/eIlEVwhHiH6qxbQjx8La9VlTRQbnvO/DRwYoE1g=; h=Message-Id:Date:Cc:Subject:To:From; b=dmSImocckYtltPwW4QQaDMdNnKr9qK2lhAtSg+lqem4w8BiGcLWoQKDhIvV/bLbrs 5G8uhL9Gf6oKsxDTIXFuEsDUN4GnqS1rLOOrOIuz9cbL8mDZaJUDsQE855g4L83XwE 3GreVwKrZuz78KHkU0fqSWWKvF4cDVScewUBzYbY= Authentication-Results: sas1-71299a9d5a62.qloud-c.yandex.net; dkim=pass header.i=@syntacore.com From: Ivan Tetyushkin <ivan.tetyushkin@syntacore.com> To: gdb-patches@sourceware.org Subject: [PATCH 0/7] introduce get_runtime_path Date: Tue, 25 Oct 2022 19:29:40 +0300 Message-Id: <20221025162946.727169-1-ivan.tetyushkin@syntacore.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
introduce get_runtime_path
|
|
Message
Ivan Tetyushkin
Oct. 25, 2022, 4:29 p.m. UTC
Hi. I tried to run a testsuite using a remote host test setup on QEMU (RISC-V) with Linux. Some tests that passed on local machine are failed due to hardcoded pathes in tests. For example, see gdb.base/print-file-var.exp. This test has SHLIB_NAME that is an absolute path on local machine, and of course this file does not exist on remote machine. To fix this, a function get_runtime_path was created. These patches introduce this function and some tests that could be fixed by changing an absolute path on local machine to a runtime path. Ivan Tetyushkin (7): [gdb/testsuite] Adding function to find runtime path to support remote execution for testsuite [gdb/testsuite] fix test gdb.base/print-file-var.exp for remote execution [gdb/testsuite] fix test gdb.base/jit-reader-exec.exp for remote execution [gdb/testsuite] fix test gdb.base/solib-vanish.exp for remote execution [gdb/testsuite] fix test gdb.base/infcall-exec.exp for remote execution [gdb/testsuite] fix test gdb.base/info-shared.exp for remote execution [gdb/testsuite] fix test gdb.base/jit-elf-so.exp for remote execution gdb/testsuite/gdb.base/infcall-exec.exp | 7 +++++-- gdb/testsuite/gdb.base/info-shared.exp | 9 +++++++-- gdb/testsuite/gdb.base/jit-elf-so.exp | 6 ++++-- gdb/testsuite/gdb.base/jit-reader-exec.exp | 5 ++++- gdb/testsuite/gdb.base/print-file-var.exp | 4 +++- gdb/testsuite/gdb.base/solib-vanish.exp | 7 ++++++- gdb/testsuite/lib/gdb.exp | 12 ++++++++++++ 7 files changed, 41 insertions(+), 9 deletions(-)
Comments
Ivan Tetyushkin <ivan.tetyushkin@syntacore.com> writes: > Hi. I tried to run a testsuite using a remote host test setup on QEMU > (RISC-V) with Linux. Thanks for looking at these problems. I suspect the setup you are using is not one that is used very often. Could you give more details about your setup so that others might be able to reproduce the issues you are seeing, and validate your fixes? Thanks, Andrew > Some tests that passed on local machine are failed due to hardcoded pathes in tests. > For example, see gdb.base/print-file-var.exp. This test has SHLIB_NAME > that is an absolute path on local machine, and of course this file does not > exist on remote machine. To fix this, a function get_runtime_path was created. > > These patches introduce this function and some tests that could be fixed > by changing an absolute path on local machine to a runtime path. > > Ivan Tetyushkin (7): > [gdb/testsuite] Adding function to find runtime path to support remote > execution for testsuite > [gdb/testsuite] fix test gdb.base/print-file-var.exp for remote > execution > [gdb/testsuite] fix test gdb.base/jit-reader-exec.exp for remote > execution > [gdb/testsuite] fix test gdb.base/solib-vanish.exp for remote > execution > [gdb/testsuite] fix test gdb.base/infcall-exec.exp for remote > execution > [gdb/testsuite] fix test gdb.base/info-shared.exp for remote execution > [gdb/testsuite] fix test gdb.base/jit-elf-so.exp for remote execution > > gdb/testsuite/gdb.base/infcall-exec.exp | 7 +++++-- > gdb/testsuite/gdb.base/info-shared.exp | 9 +++++++-- > gdb/testsuite/gdb.base/jit-elf-so.exp | 6 ++++-- > gdb/testsuite/gdb.base/jit-reader-exec.exp | 5 ++++- > gdb/testsuite/gdb.base/print-file-var.exp | 4 +++- > gdb/testsuite/gdb.base/solib-vanish.exp | 7 ++++++- > gdb/testsuite/lib/gdb.exp | 12 ++++++++++++ > 7 files changed, 41 insertions(+), 9 deletions(-) > > -- > 2.38.1
Hi > Could you give more details about your setup so that others might be > able to reproduce the issues you are seeing, and validate your fixes? To reproduce my setup please: 0) Setup environment 0.1) Determine QEMU-related variables: # QEMU_SSH_PORT - port is used for no-password access with ssh. # QEMU_WORK_PORT - port used by gdb to send commands to gdbserver. export QEMU_WORK_PORT=1111 export QEMU_SSH_PORT=2222 # HOSTNAME - name, used for connection with ssh. export HOSTNAME=debian # QEMU_ROOT_USER, QEMU_ROOT_PASS, QEMU_USER, QEMU_PASS - name and password for use in QEMU # In suggested to download image: export QEMU_ROOT_USER=root export QEMU_ROOT_PASS=root export QEMU_USER=debian export QEMU_PASS=debian 0.2) Determine paths: # for easier setup, you may want to use: # BASEDIR - default parent directory for all paths here export BASEDIR=~/BASEDIR # QEMU_DIR - full path to folder where you want to have QEMU-related files. export QEMU_DIR=$BASEDIR/qemu_dir # BUILDDIR - full path to place where you want configure & build to be done export BUILDDIR=$BASEDIR/gdb-build # INSTALL_DIR - full path to install gdb export INSTALL_DIR=$BASEDIR/gdb-install # gdb_source - full path to binutils-gdb repo with configure export gdb_source=$BASEDIR/binutils-gdb # Optional # dejagnu_dir - full path where you want to have dejagnu, if you do not have it already export dejagnu_dir=$BASEDIR 0.3) Make sure that all directories exist. mkdir --parents $BASEDIR mkdir --parents $QEMU_DIR mkdir --parents $BUILDDIR 0.4) Make sure you have required apps in your path. apt update apt-get install -y gcc-riscv64-linux-gnu apt-get install -y g++-riscv64-linux-gnu apt-get install -y qemu-system-riscv64 apt-get install -y u-boot-qemu opensbi 1) Prepare QEMU with Linux. 1.1) Download Debian-based image for RISCV QEMU: url: https://gitlab.com/api/v4/projects/giomasce%2Fdqib/jobs/artifacts/master/download?job=convert_riscv64-virt wget "https://gitlab.com/api/v4/projects/giomasce%2Fdqib/jobs/artifacts/master/download?job=convert_riscv64-virt" -O "$QEMU_DIR/debian-rv64.zip" 1.2) Unpack & prepare QEMU files for work: unzip "$QEMU_DIR/debian-rv64.zip" -d "$QEMU_DIR/debian_tmp" mv "$QEMU_DIR/debian_tmp/artifacts" "$QEMU_DIR/debian-rv64" 1.3) Create image overlay file (overlay.qcow2) for QEMU: qemu-img create -o backing_file="$QEMU_DIR/debian-rv64/image.qcow2",backing_fmt=qcow2 -f qcow2 "$QEMU_DIR/overlay.qcow2" 1.4) Run QEMU: qemu-system-riscv64 \ -machine virt \ -smp 8 \ -cpu rv64 \ -m 8G \ -device virtio-blk-device,drive=hd \ -drive file=$QEMU_DIR/overlay.qcow2,if=none,id=hd \ -device virtio-net-device,netdev=net \ -netdev user,id=net,hostfwd=tcp::$QEMU_SSH_PORT-:22,hostfwd=tcp::$QEMU_WORK_PORT-:1111 \ -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \ -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \ -object rng-random,filename=/dev/urandom,id=rng \ -device virtio-rng-device,rng=rng \ -daemonize 1.5) Add ssh config to be able to connect without password: To your .ssh/config write (if you changed earlier environment variables, please, change there too): Host debian HostName 127.0.0.1 User debian Port 2222 check that ssh connection works: # adding to the list of known hosts (may need to be done twice due to reset of connection). ssh $HOSTNAME If you do not have ssh keys, you need to generate them: ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa <<< y; Copy you ssh public keys to QEMU: sshpass -p $QEMU_PASS ssh $HOSTNAME "mkdir --parents /home/$QEMU_USER/.ssh" sshpass -p $QEMU_PASS scp ~/.ssh/id_rsa.pub $HOSTNAME:/home/$QEMU_USER/.ssh/authorized_keys Now you should be able to connect to QEMU without password: ssh $HOSTNAME 1.6) Install gdbserver on QEMU: # adding to the list of known hosts. No need to put password ssh $QEMU_ROOT_USER@localhost -p $QEMU_SSH_PORT sshpass -p $QEMU_ROOT_PASS ssh $QEMU_ROOT_USER@localhost -p $QEMU_SSH_PORT # in QEMU apt update apt install gdbserver exit 2) Prepare binutils-gdb 2.0) If you want clean repo and used $BASEDIR structure, you may want to clone it from the sourceware repo to $BASEDIR. cd $BASEDIR; git clone https://sourceware.org/git/binutils-gdb.git 2.1) Create board settings file. Setup usage riscv64-linux-gnu-gcc and remote execution. Create new file NEW_BOARD.exp in $gdb_source/gdb/testsuite/boards (if you changed HOSTNAME or QEMU_PORT, change here as well): load_generic_config "gdbserver" load_board_description "gdbserver-base" process_multilib_options "" set_board_info compiler riscv64-linux-gnu-gcc set_board_info c++compiler riscv64-linux-gnu-g++ set GDBSERVER "/usr/bin/gdbserver" set_board_info gdb_server_prog "/usr/bin/gdbserver" set_board_info hostname debian set_board_info gdb,socketport 1111 set_board_info portnum 1111 set_board_info rsh_prog /usr/bin/ssh set_board_info rcp_prog /usr/bin/scp set_board_info file_transfer ftp set_board_info protocol standard set_board_info gdb_protocol "remote" set_board_info use_gdb_stub 1 set_board_info gdb,do_reload_on_run 1 set_board_info noargs 1 set_board_info gdb,noinferiorio 1 set_board_info gdb,no_hardware_watchpoints 1 2.2) call binutils-gdb configure cd $BUILDDIR; $gdb_source/configure \ --prefix=$INSTALL_DIR \ --with-expat=yes \ --target=riscv64-linux-gnu 2.3) build gdb cd $BUILDDIR; make all-gdb 3) Download and run tests to reproduce the problem. 3.1) If you do not have dejagnu in the path, you need to download it and add to the path: cd $dejagnu_dir git clone https://git.savannah.gnu.org/git/dejagnu.git export PATH=$PATH:$(realpath ./)/dejagnu 3.2) Run test and observe failure without my patches cd $BUILDDIR/gdb make check RUNTESTFLAGS="--target_board=NEW_BOARD gdb.base/print-file-var.exp" -- Ivan
On 10/29/22 11:20, Andrew Burgess via Gdb-patches wrote: > Ivan Tetyushkin <ivan.tetyushkin@syntacore.com> writes: > >> Hi. I tried to run a testsuite using a remote host test setup on QEMU >> (RISC-V) with Linux. > > Thanks for looking at these problems. I suspect the setup you are using > is not one that is used very often. > > Could you give more details about your setup so that others might be > able to reproduce the issues you are seeing, and validate your fixes? > Hi, I found a fairly easy way to reproduce this (after reading the response to Andrews question and realizing that given the use of --target_board rather than --host_board, from the point of view of dejagnu, this is not a remote host, but a remote target setup). Add a local test account remote-target, and put a remote-target entry in the .ssh/config: ... Host remote-target HostName 127.0.0.1 User remote-target IdentityFile <some rsa file> IdentitiesOnly yes PreferredAuthentications publickey ... such that we can access it without password: ... $ ssh remote-target Last login: Sat Nov 5 15:12:34 2022 from 127.0.0.1 Have a lot of fun... remote-target@127.0.0.1:~> ... and likewise for remote-target@remote-target. Edit remote-gdbserver-on-localhost.exp to use the remote-target account: ... set_board_info rcp_prog "/usr/bin/scp" set_board_info rsh_prog "/usr/bin/ssh" set_board_info protocol standard -set_board_info username $env(USER) -set_board_info hostname localhost +set_board_info username remote-target +set_board_info hostname remote-target proc ${board}_spawn { board cmd } { global board_info ... Run test-case gdb.base/print-file-var.exp with target board remote-gdbserver-on-localhost.exp, and watch it pass. Now make sure the remote-target account cannot access files from the $USER account (well, as far as the testsuite output dir is concerned): ... $ chmod go-rx build/gdb/testsuite/outputs/ ... mimicking an actual remote target machine not being able to access the files on the build/host machine. Run the test again, and watch it fail. Now apply the patch series, and watch it pass again. Thanks, - Tom