From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward503p.mail.yandex.net (forward503p.mail.yandex.net [77.88.28.113]) by sourceware.org (Postfix) with ESMTPS id DD5EF3858C39 for ; Tue, 1 Nov 2022 09:19:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DD5EF3858C39 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 iva3-6d6b5ab252da.qloud-c.yandex.net (iva3-6d6b5ab252da.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:c19:0:640:6d6b:5ab2]) by forward503p.mail.yandex.net (Yandex) with ESMTP id 5D78011019BF; Tue, 1 Nov 2022 12:19:42 +0300 (MSK) Received: by iva3-6d6b5ab252da.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id wKo68Njz7a-JfgCu2gS; Tue, 01 Nov 2022 12:19:41 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mail; t=1667294381; bh=Px+feVl9rwX0lgSZoqvIjz1ZJf/D07+laLbg7a3KVj4=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID; b=RF0u2pyoTmlqtBNMWRO7ZlIXDNe8QWubHv0hdZvnQEdXYWsc1zNrKPe2CZplENnpD f9kF/gEeELqhwv/o5VrAsGQGpdt+OdDcBVSUeAOBiC/1boRSjXYdXkYUmdVBQng6aQ +YhZMpF0b1VufgbYCcNcSuYA5l6NXQXGv3ttgSJ8= Authentication-Results: iva3-6d6b5ab252da.qloud-c.yandex.net; dkim=pass header.i=@syntacore.com Message-ID: Date: Tue, 1 Nov 2022 12:19:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH 0/7] introduce get_runtime_path Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: <20221025162946.727169-1-ivan.tetyushkin@syntacore.com> <87czabc7f7.fsf@redhat.com> From: Ivan Tetyushkin In-Reply-To: <87czabc7f7.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 List-Id: 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