From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20440 invoked by alias); 7 Feb 2018 10:33:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20275 invoked by uid 89); 7 Feb 2018 10:33:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4554, misused, abused, (unknown) X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 10:32:59 +0000 Received: by mail-wm0-f45.google.com with SMTP id v123so2316892wmd.5 for ; Wed, 07 Feb 2018 02:32:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=fTgBpHpV+oXx9tJtE/cQ7GsRAazF9L2YSZRHfvVvpYM=; b=AY5Vn/shEhbqWiho7nX3X5QHUL3cAY2mUNTCqgrJzrbS38dPCkzCn7ukLLET7M9p+7 bojNewpzjhcd4tKsblU0Vc1ZEbKiX1a1OOt9wylnlq0A8Kl76IngpcETFeIw7xfwuagE j0cCyx8Gl/hmmkQMNBVzyStcLNilaxn3mMa+ftCWLOJVgzhZIhvpA02PNoPYBy3ON7qu vwPeDvylhH8UqqfstIta5H7k9x6lkSXUecpLN7mNul8UJ/LAo+rfoPlAqn4vs65KNCuz KcPo6aaVFsIyQyQZRlF9RjCAoap0Nj07E3CvFf0Yu4ZhAum80hYydm5nfwoIgCMbOxI2 OCwQ== X-Gm-Message-State: APf1xPD0Ux/jkxL04IcBhsvODxtGdW8VaRs1HlHe+c64kw3Na6M20TJI MKQMDgCaOy8eBCigBc0iuJVD2Q== X-Google-Smtp-Source: AH8x226RUmxxMXCKsy02zDtaUXE4ys8CiR+H14uqpmlbfno7hQeljGUDGM5SkcJ23vBikfcaIgjDCQ== X-Received: by 10.28.213.77 with SMTP id m74mr4564785wmg.137.1517999576971; Wed, 07 Feb 2018 02:32:56 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id x135sm1138884wmf.35.2018.02.07.02.32.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Feb 2018 02:32:56 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 00/10 v2] Remove regcache::m_readonly_p Date: Wed, 07 Feb 2018 10:33:00 -0000 Message-Id: <1517999572-14987-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00104.txt.bz2 regcache is used in many places in gdb in different ways, so regcache becomes a flat and fat object. That exposes some unnecessary APIs to different part, and some APIs are misused or abused: 1) gdbarch methods pseudo_register_read, pseudo_register_read_value, read_pc have a parameter 'regcache *', but these two gdbarch methods only need raw_read* and cooked_read* methods. So it is better to pass a class which only has raw_read* and cooked_read* methods, and other regcache methods are invisible to each gdbarch implementation. 2) target_ops methods to_fetch_registers and to_store_registers have a parameter 'regcache *', but these two target_ops methods only need raw_supply and raw_collect methods, because raw registers are from target layer, pseudo registers are "composed" or "created" by gdbarch. 3) jit.c uses regcache in an odd way, and record-full.c should use a simple version regcache instead of an array (see patch 11) Beside these api issues, one issue in regcache is that there is no type or class for readonly regcache. We use a flag field m_readonly_p to indicate the regcache is readonly or not, so some regcache apis have assert that this regcache is or is not readonly. The better way to do this is to create a new class for readonly regcache which doesn't have write methods at all. This patch series fixes all of the problems above except 2) (I had a patch to fix 2 in my tree, but still need more time to polish it.) by designing a class hierarchy about regcache, like this, reg_buffer ^ | ------+----- ^ | readable_regcache ^ | ------+------ ^ ^ | | detached_regcache readonly_detached_regcache ^ | regcache Class reg_buffer is a simple class, having register contents and status (in patch 1). readable_regcache is an abstract class only having raw_read* and cooked_read* methods (in patch 2). detached_regcache is a class which has read and write methods, but it detaches from target, IOW, the write doesn't go through. Class readonly_detached_regcache is the readonly regcache, created from regcache::save method. This is the v2 of this patch series, v1 can be found https://sourceware.org/ml/gdb-patches/2017-12/msg00014.html Some changes compared with v1, - Some of the preparatory patches in v1 are already committed, - Rename some classes, - Pass readable_regcache to gdbarch read_pc. We can pass readable_regcache to gdbarch breakpoint_kind_from_current_state as well, because this gdbarch method doesn't need to write regcache. The reason I don't that is arm_breakpoint_kind_from_current_state uses a function arm_get_next_pcs_ctor shared between GDB and GDBserver, and I don't propagate the regcache changes to GDBserver at this moment, This patch series is pushed to users/qiyao/regcache-split-4-2. Regression tested on {x86_64,aarch64}-linux. *** BLURB HERE *** Yao Qi (10): Class reg_buffer class readable_regcache and pass readable_regcache to gdbarch pseudo_register_read and pseudo_register_read_value Remove regcache_save and regcache_cpy Class readonly_detached_regcache Class detached_regcache Replace regcache::dump with class register_dump No longer create readonly regcache Remove regcache::m_readonly_p Move register_dump to regcache-dump.c Pass readable_regcache to gdbarch method read_pc gdb/Makefile.in | 1 + gdb/aarch64-tdep.c | 2 +- gdb/amd64-tdep.c | 2 +- gdb/arm-tdep.c | 6 +- gdb/avr-tdep.c | 7 +- gdb/bfin-tdep.c | 2 +- gdb/dummy-frame.c | 6 +- gdb/frame.c | 15 +- gdb/frame.h | 3 +- gdb/frv-tdep.c | 2 +- gdb/gdbarch.c | 6 +- gdb/gdbarch.h | 12 +- gdb/gdbarch.sh | 6 +- gdb/h8300-tdep.c | 4 +- gdb/hppa-tdep.c | 8 +- gdb/i386-tdep.c | 6 +- gdb/i386-tdep.h | 2 +- gdb/ia64-tdep.c | 8 +- gdb/infcmd.c | 6 +- gdb/inferior.h | 2 +- gdb/infrun.c | 8 +- gdb/jit.c | 10 +- gdb/linux-fork.c | 20 ++- gdb/m32c-tdep.c | 20 +-- gdb/m68hc11-tdep.c | 2 +- gdb/mep-tdep.c | 6 +- gdb/mi/mi-main.c | 12 +- gdb/mips-tdep.c | 6 +- gdb/msp430-tdep.c | 2 +- gdb/nds32-tdep.c | 2 +- gdb/ppc-linux-tdep.c | 10 +- gdb/record-full.c | 21 ++- gdb/regcache-dump.c | 335 ++++++++++++++++++++++++++++++++++++++ gdb/regcache.c | 445 +++++++++++++-------------------------------------- gdb/regcache.h | 244 ++++++++++++++++------------ gdb/rl78-tdep.c | 2 +- gdb/rs6000-tdep.c | 52 ++++-- gdb/s390-tdep.c | 2 +- gdb/sh-tdep.c | 4 +- gdb/sh64-tdep.c | 4 +- gdb/sparc-tdep.c | 2 +- gdb/sparc64-tdep.c | 2 +- gdb/spu-tdep.c | 15 +- gdb/xtensa-tdep.c | 4 +- 44 files changed, 757 insertions(+), 579 deletions(-) create mode 100644 gdb/regcache-dump.c -- 1.9.1