From patchwork Thu Jan 5 16:42:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 639306 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp335303pvb; Thu, 5 Jan 2023 09:15:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXsKXwXbtPWZ7kkgY4te3TOTkIsrwo5pS6Rx1JFk69Ml/SirgTfE5DRiC8vvzLQDs/+0JSyS X-Received: by 2002:a05:6214:3c09:b0:52d:e201:c3d2 with SMTP id nt9-20020a0562143c0900b0052de201c3d2mr81973862qvb.33.1672938916551; Thu, 05 Jan 2023 09:15:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672938916; cv=none; d=google.com; s=arc-20160816; b=CmJFUMIP2hy7E1W3e5APvd7hjSDZTB10kXu24vynJqrFKrWXmXf6fpYmvqAAbGlD3u xq/uKoNUkVelqULDVPWuVHmb4hJwAv1ytfXegkAmAJTrJ5ztjIXTHehXk9pwCLgDEHZI CYNG2k8cJPhjvA+tDPNtnznaXpO4ewZRIz2a0zgIqJcAjTwyDhraqn16NBdy+C5K6dCR 9nNkok5Mcacr4611ZsRczJHidBquQQHx+zXJ2fXR/qyJXWZIR4ecvwv0Rt2AwbD8ccNP /OCpO3Fh1SFsE2hLvoIwHAZD26xtCSpoPhYzLLmYy8CokMqE1puQgtpSiwwBDCAdPDlZ FJWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=andOexte/qTAbZAFNvqdK8ze6FjZMbbXg1AFTficNCU=; b=law62XH9B3Ivp945OVAVlo32awt/Fs0nkVWLVArA04OV3G5Z37x0vu4LF9A0najgCJ 5co9mXjZ2ThwOgXFWM5t8AgSx4QBHuAUbygipAUVCaDqbhtSCas0JsOXg4sZ+5wfk4c4 +0N5Vh2LhCva9n5jfQ5NCBuyizpH9BYee4gV09u1XssPBo68eYRQZ8IhxX1cLnEZepb1 N+yWBIfrpuZt5G6CTbxx00fjR3uFRsk5ob/Z98MKY+D0e5sSDHUtY4JrdgY6Cvi98mWB wjvEbHRSKRXm731lbaUJwKWtVUxH9VEykAwn8JWAglbr/O2aqLhZHFlO/eULhneeBFPu jH1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nAnw6qgJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kd18-20020a056214401200b004bba970dbc4si18528097qvb.381.2023.01.05.09.15.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 09:15:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nAnw6qgJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDTKy-0006rx-Iq; Thu, 05 Jan 2023 11:43:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDTKw-0006qr-Sm for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:26 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTKt-0006wA-8e for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:26 -0500 Received: by mail-wm1-x336.google.com with SMTP id ay40so28484730wmb.2 for ; Thu, 05 Jan 2023 08:43:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=andOexte/qTAbZAFNvqdK8ze6FjZMbbXg1AFTficNCU=; b=nAnw6qgJhq8wku70jVM9IaApWWFFDlQZYqXxbY7RN7xpas6S/MGksQWeGOqXcuXej6 dXrNL0zkyQwiSGVv8cXH6ctjB0NteeVMf0OCa2sqmaO54YSe9OFn3j9/uN/SlaugzI3L lvN8y+53zz2Dg6+Ve00TWR2Cgl9judNjlSxjMiuLnim/8wD3ONyxGprrGKBYXYq71JHD /YZZBWVd8xMToRgwt968Sa497PzIfN9rdZuFVu8ZeIj9VgdxK17ne8BcPuGLn0lHMb6E vDfhwXQKMkbXP9gtQ+m/GXXFbI8IaCuwpQVNw5v72tAH4jo3j3nOkfrWX/2QEj/auBcV J6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=andOexte/qTAbZAFNvqdK8ze6FjZMbbXg1AFTficNCU=; b=5/b/hxV3xNRo0BsMYkJJEVQ0L7IJwC/LmKzRrF4vt81N3KgGCF9yeCZyKO603+h+MR ziggBuAcovGBXjKpb72jcFk7bhO6OTLej13yKPaBWNv7l3INd3Cktlyt4dTblah043s1 hPYZGRrgaNumMVBqgrQz/RW5Emfozs4vyDubpYM6L73dvTv9GMdj3i8DTCY2RJY5nIf8 1emFbyI90kCOHXEPobajLUCWR0Cs0N6/1/5mPPQscl+mVfuGJomLuGXB5jVULBS/il50 TZYatbNb0BgAuhjyr6caWWPNd5ZtJhhlrSbM8qKm03V8nmBUGIHKKZWUKQlWYThtY1ka 4HmA== X-Gm-Message-State: AFqh2kpOJpdoLuMGyK/hNyv7dLFLDE9EONZUZZNytg7Wz671m4rV8AVm W+iDx7P/n7IJWj1JEWotJDdxuQ== X-Received: by 2002:a05:600c:1c85:b0:3d3:4b18:27c6 with SMTP id k5-20020a05600c1c8500b003d34b1827c6mr36137319wms.11.1672937001511; Thu, 05 Jan 2023 08:43:21 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id he11-20020a05600c540b00b003d359aa353csm2851006wmb.45.2023.01.05.08.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 08:43:20 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5D4E91FFB7; Thu, 5 Jan 2023 16:43:20 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org, alex.bennee@gmail.com Cc: David Hildenbrand , Sunil Muthuswamy , Aurelien Jarno , Michael Rolnik , Aleksandar Rikalo , Greg Kurz , Ilya Leoshkevich , Thomas Huth , qemu-ppc@nongnu.org, Laurent Vivier , Max Filippov , Yanan Wang , Marek Vasut , Stafford Horne , Peter Maydell , Daniel Henrique Barboza , Palmer Dabbelt , =?utf-8?q?Alex_Benn=C3=A9e?= , Taylor Simpson , Marcel Apfelbaum , Alexandre Iooss , Chris Wulff , Richard Henderson , Eduardo Habkost , Song Gao , Mark Cave-Ayland , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , Artyom Tarasenko , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Alistair Francis , "Edgar E. Iglesias" , Bastian Koppelmann , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Bin Meng , Mahmoud Mandour , David Gibson , Yoshinori Sato , Xiaojuan Yang , qemu-arm@nongnu.org Subject: [PATCH v2 00/21] gdbstub: re-organise to for better compilation behaviour Date: Thu, 5 Jan 2023 16:42:59 +0000 Message-Id: <20230105164320.2164095-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org I was motivated to sort this out while working on my register API which is target agnostic but ran into the weeds when trying to link up with the gdbstub. This was due to us building gdbstub for every single target we support due to a few ABI sensitive bits that require CPU specific information. This series does a bunch of surgery to break the monolithic file apart into its constituent parts as well as simplify the headers to users can avoid bringing in more dependencies than they need. While the final result does increase the number of object files we reduce the total size of them all. We could go even further if we manage to build just 2 ABI binaries and sort out the magic to link them in meson. I think this requires us to removing TARGET_LONG_BITS from cpu-defs.h and exposing it to the build machinery. Before: 🕙16:36:31 alex.bennee@hackbox2:qemu.git/builds/reference on  gdbstub/next [$?⇕] took 2s ➜ find . -iname "gdbstub*.o" -exec echo -n -e {}"\0" \; | du -hc --files0-from=- | tail -n 1 12M total 🕙16:36:42 alex.bennee@hackbox2:qemu.git/builds/reference on  gdbstub/next [$?⇕] ➜ find . -iname "gdbstub*.o" | wc -l 68 After: ➜ find . -iname "gdbstub*.o" -exec echo -n -e {}"\0" \; | du -hc --files0-from=- | tail -n 1 4.0M total 🕙16:41:42 alex.bennee@hackbox2:qemu.git/builds/all on  gdbstub/next [$?⇕] took 2s ➜ find . -iname "gdbstub*.o" | wc -l 105 The following patches need review: gdbstub: only compile gdbstub twice for whole build gdbstub: move syscall handling to new file gdbstub: move register helpers into standalone include gdbstub: don't use target_ulong while handling registers gdbstub: fix address type of gdb_set_cpu_pc gdbstub: specialise stub_can_reverse gdbstub: introduce gdb_get_max_cpus gdbstub: specialise target_memory_rw_debug gdbstub: specialise handle_query_attached gdbstub: abstract target specific details from gdb_put_packet_binary gdbstub: make various helpers visible to the rest of the module gdbstub: move fromhex/tohex routines to internals gdbstub: define separate user/system structures target/arm: fix handling of HLT semihosting in system mode Alex Bennée (20): gdbstub/internals.h: clean up include guard target/arm: fix handling of HLT semihosting in system mode gdbstub: fix-up copyright and license files gdbstub: define separate user/system structures gdbstub: move GDBState to shared internals header includes: move tb_flush into its own header gdbstub: move fromhex/tohex routines to internals gdbstub: make various helpers visible to the rest of the module gdbstub: move chunk of softmmu functionality to own file gdbstub: move chunks of user code into own files gdbstub: abstract target specific details from gdb_put_packet_binary gdbstub: specialise handle_query_attached gdbstub: specialise target_memory_rw_debug gdbstub: introduce gdb_get_max_cpus gdbstub: specialise stub_can_reverse gdbstub: fix address type of gdb_set_cpu_pc gdbstub: don't use target_ulong while handling registers gdbstub: move register helpers into standalone include gdbstub: move syscall handling to new file gdbstub: only compile gdbstub twice for whole build Philippe Mathieu-Daudé (1): gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs gdbstub/internals.h | 207 ++- include/exec/exec-all.h | 1 - include/exec/gdbstub.h | 208 --- include/exec/tb-flush.h | 26 + include/gdbstub/helpers.h | 103 ++ include/gdbstub/syscalls.h | 124 ++ include/gdbstub/user.h | 43 + linux-user/user-internals.h | 1 + accel/stubs/tcg-stub.c | 1 + accel/tcg/tb-maint.c | 1 + accel/tcg/translate-all.c | 1 + cpu.c | 1 + gdbstub/gdbstub.c | 1654 ++---------------------- gdbstub/softmmu.c | 589 ++++++++- gdbstub/syscalls.c | 230 ++++ gdbstub/user-target.c | 283 ++++ gdbstub/user.c | 406 +++++- hw/ppc/spapr_hcall.c | 1 + linux-user/exit.c | 2 +- linux-user/main.c | 1 + linux-user/signal.c | 2 +- plugins/core.c | 1 + plugins/loader.c | 2 +- semihosting/arm-compat-semi.c | 1 + semihosting/guestfd.c | 2 +- semihosting/syscalls.c | 3 +- softmmu/runstate.c | 2 +- target/alpha/gdbstub.c | 2 +- target/alpha/sys_helper.c | 1 + target/arm/gdbstub.c | 1 + target/arm/gdbstub64.c | 2 +- target/arm/helper-a64.c | 2 +- target/arm/m_helper.c | 2 +- target/arm/translate.c | 2 +- target/avr/gdbstub.c | 2 +- target/cris/gdbstub.c | 2 +- target/hexagon/gdbstub.c | 2 +- target/hppa/gdbstub.c | 2 +- target/i386/gdbstub.c | 2 +- target/i386/whpx/whpx-all.c | 2 +- target/loongarch/gdbstub.c | 1 + target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 1 + target/m68k/m68k-semi.c | 3 +- target/microblaze/gdbstub.c | 2 +- target/mips/gdbstub.c | 2 +- target/mips/tcg/sysemu/mips-semi.c | 3 +- target/nios2/cpu.c | 2 +- target/nios2/nios2-semi.c | 3 +- target/openrisc/gdbstub.c | 2 +- target/openrisc/interrupt.c | 2 +- target/openrisc/mmu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/ppc/gdbstub.c | 1 + target/riscv/csr.c | 1 + target/riscv/gdbstub.c | 1 + target/rx/gdbstub.c | 2 +- target/s390x/gdbstub.c | 1 + target/s390x/helper.c | 2 +- target/sh4/gdbstub.c | 2 +- target/sparc/gdbstub.c | 2 +- target/tricore/gdbstub.c | 2 +- target/xtensa/core-dc232b.c | 2 +- target/xtensa/core-dc233c.c | 2 +- target/xtensa/core-de212.c | 2 +- target/xtensa/core-de233_fpu.c | 2 +- target/xtensa/core-dsp3400.c | 2 +- target/xtensa/core-fsf.c | 2 +- target/xtensa/core-lx106.c | 2 +- target/xtensa/core-sample_controller.c | 2 +- target/xtensa/core-test_kc705_be.c | 2 +- target/xtensa/core-test_mmuhifi_c3.c | 2 +- target/xtensa/gdbstub.c | 2 +- target/xtensa/helper.c | 2 +- MAINTAINERS | 1 + gdbstub/meson.build | 35 +- gdbstub/trace-events | 4 +- 77 files changed, 2250 insertions(+), 1775 deletions(-) create mode 100644 include/exec/tb-flush.h create mode 100644 include/gdbstub/helpers.h create mode 100644 include/gdbstub/syscalls.h create mode 100644 include/gdbstub/user.h create mode 100644 gdbstub/syscalls.c create mode 100644 gdbstub/user-target.c Reviewed-by: Philippe Mathieu-Daudé