Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Alan Hayward <Alan.Hayward@arm.com>
To: Simon Marchi <simon.marchi@ericsson.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH 8/8] Ptrace support for Aarch64 SVE
Date: Mon, 04 Jun 2018 15:49:00 -0000	[thread overview]
Message-ID: <626E6E07-4A7B-4E1D-A86B-6C4C74EF96E1@arm.com> (raw)
In-Reply-To: <0ff06fe2-396d-a9da-d95b-130f6bef2d2c@ericsson.com>


>>>> diff --git a/gdb/nat/aarch64-sve-linux-ptrace.c b/gdb/nat/aarch64-sve-linux-ptrace.c
>>>> index 9381786fda..84c7a41f40 100644
>>>> --- a/gdb/nat/aarch64-sve-linux-ptrace.c
>>>> +++ b/gdb/nat/aarch64-sve-linux-ptrace.c
>>>> @@ -25,6 +25,13 @@
>>>> #include "aarch64-sve-linux-ptrace.h"
>>>> #include "arch/aarch64.h"
>>>> 
>>>> +#ifndef GDBSERVER
>>>> +#include "defs.h"
>>>> +#endif
>>>> +#include "regcache.h"
>>> 
>>> Hmm we try not add any more "#ifdef GDBSERVER" in the common code.
>>> 
>>> https://sourceware.org/gdb/wiki/Common#Header_files_in_common_code_.28defs.h_vs_server.h.2C_etc..29
>>> 
>>> Instead, we should try defining a common interface (probably in common/common-regcache.h?) that the
>>> common code will use, and that regcaches from GDB and GDBserver will implement.
>> 
>> I tried using common-defs.h, but gdb/regcache.h requires defines from
>> defs.h - RequireLongest and maybe others.
>> Putting defs.h at the top of gdb/regcache.h then broke in a weird way.
>> A lot of fiddling later, and I hadn’t found a way to make it work.
>> 
>> Creating common/common-regcache.h gets a bit odd because, the functions
>> I need for gdbserver (raw_supply, raw_collect and get_register_status)
>> on gdb come from:
>> 
>> 
>> class reg_buffer
>> ...
>>  enum register_status get_register_status (int regnum) const;
>> ...
>> 
>> 
>> class readable_regcache : public reg_buffer
>> ...
>> 
>> 
>> class detached_regcache : public readable_regcache
>> ...
>>  void raw_supply (int regnum, const void *buf);
>> ...
>> 
>> 
>> class regcache : public detached_regcache
>> ...
>>  void raw_collect (int regnum, void *buf) const;
>> ...
>> 
>> 
>> I don’t think that this would work:
>> class regcache : public detached_regcache, common_regcache
> 
> I did some quick hacking and it seems to work to have this in common/common-regcache.h
> 
> struct reg_buffer_common
> {
>  virtual ~reg_buffer_common () = default;
>  virtual void raw_supply (int regnum, const void *buf) = 0;
>  virtual void raw_collect (int regnum, void *buf) const = 0;
>  virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
>  virtual register_status get_register_status (int regnum) const = 0;
> };
> 
> and make your code in nat/ take a pointer to reg_buffer_common.  gdb's reg_buffer
> and gdbserver's regcache should inherit from reg_buffer_common.  I  built
> it on other regcache refactor patches I have in the pipeline, so maybe some other
> changes in there are needed, maybe not.  I pushed the result on this branch, it's
> a bit raw but it should be enough to show the idea.
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/simark/regcache-for-alan

Thanks for trying this out, however I tried adding your changes
into my build, but that results in the following:

../../src/binutils-gdb/gdb/linux-fork.c: In function ‘void fork_save_infrun_state(fork_info*, int)’:
../../src/binutils-gdb/gdb/linux-fork.c:298:75: error: invalid new-expression of abstract class type ‘readonly_detached_regcache’
   fp->savedregs = new readonly_detached_regcache (*get_current_regcache ());
                                                                           ^
In file included from ../../src/binutils-gdb/gdb/gdbarch.h:70:0,
                 from ../../src/binutils-gdb/gdb/defs.h:531,
                 from ../../src/binutils-gdb/gdb/linux-fork.c:20:
../../src/binutils-gdb/gdb/regcache.h:367:7: note:   because the following virtual functions are pure within ‘readonly_detached_regcache’:
 class readonly_detached_regcache : public readable_regcache
       ^
In file included from ../../src/binutils-gdb/gdb/regcache.h:23:0,
                 from ../../src/binutils-gdb/gdb/gdbarch.h:70,
                 from ../../src/binutils-gdb/gdb/defs.h:531,
                 from ../../src/binutils-gdb/gdb/linux-fork.c:20:
../../src/binutils-gdb/gdb/common/common-regcache.h:68:16: note: 	virtual void reg_buffer_common::raw_supply(int, const void*)
   virtual void raw_supply (int regnum, const void *buf) = 0;
                ^
../../src/binutils-gdb/gdb/common/common-regcache.h:69:16: note: 	virtual void reg_buffer_common::raw_collect(int, void*) const
   virtual void raw_collect (int regnum, void *buf) const = 0;


And then similar errors trying to create a register_dump_reg_buffer.


I could then add the following to readonly_detached_regcache:

  void raw_supply (int regnum, const void *buf) override
  { gdb_assert(false); }

  void raw_collect (int regnum, void *buf) const override
  { gdb_assert(false); }

...Or even make the methods in reg_buffer_common have a
{ gdb_assert(false); } body.

But that feels wrong, as it’s breaking the nice regcache abstractions.

Any thoughts?

Alan.

  reply	other threads:[~2018-06-04 15:49 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11 10:53 [PATCH 0/8] Add SVE support for Aarch64 GDB Alan Hayward
2018-05-11 10:53 ` [PATCH 7/8] Add methods to gdbserver regcache and raw_compare Alan Hayward
2018-05-11 10:53 ` [PATCH 1/8] Add Aarch64 SVE target description Alan Hayward
2018-05-11 14:56   ` Eli Zaretskii
2018-05-11 16:46     ` Alan Hayward
2018-05-31 11:56   ` Simon Marchi
2018-05-31 14:12     ` Alan Hayward
2018-05-11 10:53 ` [PATCH 8/8] Ptrace support for Aarch64 SVE Alan Hayward
2018-05-31 13:40   ` Simon Marchi
2018-05-31 14:56     ` Alan Hayward
2018-06-01 15:17       ` Simon Marchi
2018-06-04 15:49         ` Alan Hayward [this message]
2018-05-31 20:17   ` Simon Marchi
2018-05-11 10:53 ` [PATCH 2/8] Function for reading the Aarch64 SVE vector length Alan Hayward
2018-05-31 12:06   ` Simon Marchi
2018-05-31 14:57   ` Pedro Alves
2018-06-05 20:01   ` Sergio Durigan Junior
2018-06-05 22:06     ` [PATCH] Guard declarations of 'sve_*_from_*' macros on Aarch64 (and unbreak build) Sergio Durigan Junior
2018-06-05 23:37       ` Sergio Durigan Junior
2018-06-06  7:34       ` Alan Hayward
2018-06-06 21:19         ` Simon Marchi
2018-06-06 21:36         ` Sergio Durigan Junior
2018-05-11 10:53 ` [PATCH 4/8] Enable SVE for GDB Alan Hayward
2018-05-31 12:22   ` Simon Marchi
2018-05-31 14:58   ` Pedro Alves
2018-05-31 16:13   ` Pedro Alves
2018-05-31 16:20     ` Alan Hayward
     [not found]       ` <2c87cd8d-c608-4ccf-b16a-635168dbb250@redhat.com>
2018-05-31 18:06         ` Alan Hayward
2018-05-11 10:53 ` [PATCH 6/8] Aarch64 SVE pseudo register support Alan Hayward
2018-05-31 13:26   ` Simon Marchi
2018-05-31 14:59   ` Pedro Alves
2018-05-11 11:52 ` [PATCH 5/8] Add aarch64 psuedo help functions Alan Hayward
2018-05-31 13:22   ` Simon Marchi
2018-05-31 15:20     ` Pedro Alves
2018-06-04 13:13     ` Alan Hayward
2018-05-11 12:12 ` [PATCH 3/8] Add SVE register defines Alan Hayward
2018-06-01  8:33   ` Alan Hayward
2018-06-01 15:18     ` Simon Marchi
2018-05-22 11:00 ` [PATCH 0/8] Add SVE support for Aarch64 GDB Alan Hayward
2018-05-29 12:09   ` [PING 2][PATCH " Alan Hayward
2018-05-29 14:35     ` Omair Javaid
2018-05-29 14:59       ` Alan Hayward

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=626E6E07-4A7B-4E1D-A86B-6C4C74EF96E1@arm.com \
    --to=alan.hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox