[00/58] Turn gdbserver's process_stratum_target into a class

Message ID cover.1581410932.git.tankut.baris.aktemur@intel.com
Headers show
Series
  • Turn gdbserver's process_stratum_target into a class
Related show

Message

Tankut Baris Aktemur Feb. 11, 2020, 9:01 a.m.
Hi All,

This is a C++'ification series that aims to convert the target ops
vector in gdbserver into a class.  Currently, the target ops is a
struct of function pointers.  At the end of the series, it becomes a
class with methods, and the existing low target definitions become
subclasses.  That is, we end up with the following class hierarchy:

process_stratum_target
^
├── linux-low
├── lynx-low
├── nto-low
└── win32-low

process_stratum_target either defines the default behavior for the
target ops or leaves them as pure virtual for the subclasses to
override.

PATCH 1's commit message gives more details about the approach in this
transformation.

If and when this series is accepted, the next step is to C++'ify linux
low targets, giving a hierarchy that looks like below.  (This second
phase is not included in this series.)

process_stratum_target
^
├── linux-low
│   ^
│   ├── linux-arm-low
│   ├── linux-ppc-low
│   ├── linux-x86-low
│   └── ...
├── lynx-low
├── nto-low
└── win32-low

My goal in this series was to make gdbserver buildable after each
patch.  I could test this for linux-low, but not for other targets --
in particular, for lynx-low, nto-low, and win32-low.  I verified their
code manually to my best; however, I may have made typos or some
oversights that break build on these systems.  Can builbot be used to
test?

The patches are also available at

https://github.com/barisaktemur/gdb/commits/gdbserver-cppify-target-v1

Thanks.
Baris

Tankut Baris Aktemur (58):
  gdbserver: start turning the target ops vector into a class
  gdbserver: turn target op 'create_inferior' into a method
  gdbserver: turn target op 'post_create_inferior' into a method
  gdbserver: turn target op 'attach' into a method
  gdbserver: turn target op 'kill' into a method
  gdbserver: turn target op 'detach' into a method
  gdbserver: turn target op 'mourn' into a method
  gdbserver: turn target op 'join' into a method
  gdbserver: turn target op 'thread_alive' into a method
  gdbserver: turn target op 'resume' into a method
  gdbserver: turn target op 'wait' into a method
  gdbserver: turn target ops 'fetch_registers' and 'store_registers'
    into methods
  gdbserver: turn prepare_to_access_memory & done_accessing_memory into
    methods
  gdbserver: turn target ops 'read_memory' and 'write_memory' into
    methods
  gdbserver: turn target op 'look_up_symbols' into a method
  gdbserver: turn target op 'request_interrupt' into a method
  gdbserver: turn target op 'read_auxv' into a method
  gdbserver: turn target op 'supports_z_point_type' into a method
  gdbserver: turn target ops 'insert_point' and 'remove_point' into
    methods
  gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' into a
    method
  gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a
    method
  gdbserver: turn target op 'supports_hardware_single_step' into a
    method
  gdbserver: turn target ops 'stopped_by_watchpoint' and
    'stopped_data_address' into methods
  gdbserver: turn target op 'read_offsets' into a method
  gdbserver: turn target op 'get_tls_address' into a method
  gdbserver: turn target op 'hostio_last_error' into a method
  gdbserver: turn target op 'qxfer_osdata' into a method
  gdbserver: turn target op 'qxfer_siginfo' into a method
  gdbserver: turn non-stop and async target ops into methods
  gdbserver: turn target op 'supports_multi_process' into a method
  gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into
    methods
  gdbserver: turn target op 'handle_new_gdb_connection' into a method
  gdbserver: turn target op 'handle_monitor_command' into a method
  gdbserver: turn target op 'core_of_thread' into a method
  gdbserver: turn target op 'read_loadmap' into a method
  gdbserver: turn target op 'process_qsupported' into a method
  gdbserver: turn target op 'supports_tracepoints' into a method
  gdbserver: turn target ops 'read_pc' and 'write_pc' into methods
  gdbserver: turn target op 'thread_stopped' into a method
  gdbserver: turn target op 'get_tib_address' into a method
  gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods
  gdbserver: turn target op 'stabilize_threads' into a method
  gdbserver: turn fast tracepoint target ops into methods
  gdbserver: turn target op 'emit_ops' into a method
  gdbserver: turn target op 'supports_disable_randomization' into a
    method
  gdbserver: turn target op 'qxfer_libraries_svr4' into a method
  gdbserver: turn target op 'supports_agent' into a method
  gdbserver: turn btrace-related target ops into methods
  gdbserver: turn target op 'supports_range_stepping' into a method
  gdbserver: turn target op 'pid_to_exec_file' into a method
  gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into
    methods
  gdbserver: turn breakpoint kind-related target ops into methods
  gdbserver: turn target ops 'thread_name' and 'thread_handle' into
    methods
  gdbserver: turn target op 'supports_software_single_step' into a
    method
  gdbserver: turn target op 'supports_catch_syscall' into a method
  gdbserver: turn target op 'get_ipa_tdesc_idx' into a method
  gdbserver: use unique_ptr for 'the_target'
  gdbserver: finish turning the target ops vector into a class

 gdbserver/fork-child.c        |   2 +-
 gdbserver/hostio.c            |  13 +-
 gdbserver/linux-aarch32-low.c |   6 +-
 gdbserver/linux-aarch64-low.c |   4 +-
 gdbserver/linux-arm-low.c     |   8 +-
 gdbserver/linux-cris-low.c    |   4 +-
 gdbserver/linux-crisv32-low.c |   4 +-
 gdbserver/linux-low.c         | 635 ++++++++++++++++++----------------
 gdbserver/linux-low.h         | 222 ++++++++++++
 gdbserver/linux-m32r-low.c    |   4 +-
 gdbserver/linux-mips-low.c    |   2 +-
 gdbserver/linux-nios2-low.c   |   4 +-
 gdbserver/linux-ppc-low.c     |   2 +-
 gdbserver/linux-sh-low.c      |   2 +-
 gdbserver/linux-sparc-low.c   |   6 +-
 gdbserver/linux-tic6x-low.c   |   2 +-
 gdbserver/linux-tile-low.c    |   2 +-
 gdbserver/linux-x86-low.c     |   2 +-
 gdbserver/linux-xtensa-low.c  |   4 +-
 gdbserver/lynx-low.c          | 128 +++----
 gdbserver/lynx-low.h          |  42 +++
 gdbserver/mem-break.c         |  11 +-
 gdbserver/nto-low.c           | 208 ++++-------
 gdbserver/nto-low.h           |  59 ++++
 gdbserver/regcache.c          |  16 +-
 gdbserver/remote-utils.c      |  15 +-
 gdbserver/server.c            |  77 +++--
 gdbserver/target.c            | 578 +++++++++++++++++++++++++++----
 gdbserver/target.h            | 555 ++++++++++++++---------------
 gdbserver/tracepoint.c        |  54 ++-
 gdbserver/win32-low.c         | 214 +++++-------
 gdbserver/win32-low.h         |  68 ++++
 32 files changed, 1803 insertions(+), 1150 deletions(-)

-- 
2.17.1

Comments

Hannes Domani via Gdb-patches Feb. 11, 2020, 5:40 p.m. | #1
On Tue, Feb 11, 2020 at 3:03 AM Tankut Baris Aktemur
<tankut.baris.aktemur@intel.com> wrote:
>

> Hi All,

>

> This is a C++'ification series that aims to convert the target ops

> vector in gdbserver into a class.  Currently, the target ops is a

> struct of function pointers.  At the end of the series, it becomes a

> class with methods, and the existing low target definitions become

> subclasses.  That is, we end up with the following class hierarchy:

>

> process_stratum_target

> ^

> ├── linux-low

> ├── lynx-low

> ├── nto-low

> └── win32-low

>

> process_stratum_target either defines the default behavior for the

> target ops or leaves them as pure virtual for the subclasses to

> override.

>

> PATCH 1's commit message gives more details about the approach in this

> transformation.

>

> If and when this series is accepted, the next step is to C++'ify linux

> low targets, giving a hierarchy that looks like below.  (This second

> phase is not included in this series.)

>

> process_stratum_target

> ^

> ├── linux-low

> │   ^

> │   ├── linux-arm-low

> │   ├── linux-ppc-low

> │   ├── linux-x86-low

> │   └── ...

> ├── lynx-low

> ├── nto-low

> └── win32-low

>

> My goal in this series was to make gdbserver buildable after each

> patch.  I could test this for linux-low, but not for other targets --

> in particular, for lynx-low, nto-low, and win32-low.  I verified their

> code manually to my best; however, I may have made typos or some

> oversights that break build on these systems.  Can builbot be used to

> test?


I'm not a patch approver (and I only skimmed most of the patches), but
I really like this work!

You can use buildbot to test win32 (the Fedora-x86_64-w64-mingw32 bot
tests it by crosscompiling from linux to windows). Testing lynx and
nto may be harder, you may have to track down a cross compiler and/or
a qemu image...


Christian

>

> The patches are also available at

>

> https://github.com/barisaktemur/gdb/commits/gdbserver-cppify-target-v1

>

> Thanks.

> Baris

>

> Tankut Baris Aktemur (58):

>   gdbserver: start turning the target ops vector into a class

>   gdbserver: turn target op 'create_inferior' into a method

>   gdbserver: turn target op 'post_create_inferior' into a method

>   gdbserver: turn target op 'attach' into a method

>   gdbserver: turn target op 'kill' into a method

>   gdbserver: turn target op 'detach' into a method

>   gdbserver: turn target op 'mourn' into a method

>   gdbserver: turn target op 'join' into a method

>   gdbserver: turn target op 'thread_alive' into a method

>   gdbserver: turn target op 'resume' into a method

>   gdbserver: turn target op 'wait' into a method

>   gdbserver: turn target ops 'fetch_registers' and 'store_registers'

>     into methods

>   gdbserver: turn prepare_to_access_memory & done_accessing_memory into

>     methods

>   gdbserver: turn target ops 'read_memory' and 'write_memory' into

>     methods

>   gdbserver: turn target op 'look_up_symbols' into a method

>   gdbserver: turn target op 'request_interrupt' into a method

>   gdbserver: turn target op 'read_auxv' into a method

>   gdbserver: turn target op 'supports_z_point_type' into a method

>   gdbserver: turn target ops 'insert_point' and 'remove_point' into

>     methods

>   gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' into a

>     method

>   gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a

>     method

>   gdbserver: turn target op 'supports_hardware_single_step' into a

>     method

>   gdbserver: turn target ops 'stopped_by_watchpoint' and

>     'stopped_data_address' into methods

>   gdbserver: turn target op 'read_offsets' into a method

>   gdbserver: turn target op 'get_tls_address' into a method

>   gdbserver: turn target op 'hostio_last_error' into a method

>   gdbserver: turn target op 'qxfer_osdata' into a method

>   gdbserver: turn target op 'qxfer_siginfo' into a method

>   gdbserver: turn non-stop and async target ops into methods

>   gdbserver: turn target op 'supports_multi_process' into a method

>   gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into

>     methods

>   gdbserver: turn target op 'handle_new_gdb_connection' into a method

>   gdbserver: turn target op 'handle_monitor_command' into a method

>   gdbserver: turn target op 'core_of_thread' into a method

>   gdbserver: turn target op 'read_loadmap' into a method

>   gdbserver: turn target op 'process_qsupported' into a method

>   gdbserver: turn target op 'supports_tracepoints' into a method

>   gdbserver: turn target ops 'read_pc' and 'write_pc' into methods

>   gdbserver: turn target op 'thread_stopped' into a method

>   gdbserver: turn target op 'get_tib_address' into a method

>   gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods

>   gdbserver: turn target op 'stabilize_threads' into a method

>   gdbserver: turn fast tracepoint target ops into methods

>   gdbserver: turn target op 'emit_ops' into a method

>   gdbserver: turn target op 'supports_disable_randomization' into a

>     method

>   gdbserver: turn target op 'qxfer_libraries_svr4' into a method

>   gdbserver: turn target op 'supports_agent' into a method

>   gdbserver: turn btrace-related target ops into methods

>   gdbserver: turn target op 'supports_range_stepping' into a method

>   gdbserver: turn target op 'pid_to_exec_file' into a method

>   gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into

>     methods

>   gdbserver: turn breakpoint kind-related target ops into methods

>   gdbserver: turn target ops 'thread_name' and 'thread_handle' into

>     methods

>   gdbserver: turn target op 'supports_software_single_step' into a

>     method

>   gdbserver: turn target op 'supports_catch_syscall' into a method

>   gdbserver: turn target op 'get_ipa_tdesc_idx' into a method

>   gdbserver: use unique_ptr for 'the_target'

>   gdbserver: finish turning the target ops vector into a class

>

>  gdbserver/fork-child.c        |   2 +-

>  gdbserver/hostio.c            |  13 +-

>  gdbserver/linux-aarch32-low.c |   6 +-

>  gdbserver/linux-aarch64-low.c |   4 +-

>  gdbserver/linux-arm-low.c     |   8 +-

>  gdbserver/linux-cris-low.c    |   4 +-

>  gdbserver/linux-crisv32-low.c |   4 +-

>  gdbserver/linux-low.c         | 635 ++++++++++++++++++----------------

>  gdbserver/linux-low.h         | 222 ++++++++++++

>  gdbserver/linux-m32r-low.c    |   4 +-

>  gdbserver/linux-mips-low.c    |   2 +-

>  gdbserver/linux-nios2-low.c   |   4 +-

>  gdbserver/linux-ppc-low.c     |   2 +-

>  gdbserver/linux-sh-low.c      |   2 +-

>  gdbserver/linux-sparc-low.c   |   6 +-

>  gdbserver/linux-tic6x-low.c   |   2 +-

>  gdbserver/linux-tile-low.c    |   2 +-

>  gdbserver/linux-x86-low.c     |   2 +-

>  gdbserver/linux-xtensa-low.c  |   4 +-

>  gdbserver/lynx-low.c          | 128 +++----

>  gdbserver/lynx-low.h          |  42 +++

>  gdbserver/mem-break.c         |  11 +-

>  gdbserver/nto-low.c           | 208 ++++-------

>  gdbserver/nto-low.h           |  59 ++++

>  gdbserver/regcache.c          |  16 +-

>  gdbserver/remote-utils.c      |  15 +-

>  gdbserver/server.c            |  77 +++--

>  gdbserver/target.c            | 578 +++++++++++++++++++++++++++----

>  gdbserver/target.h            | 555 ++++++++++++++---------------

>  gdbserver/tracepoint.c        |  54 ++-

>  gdbserver/win32-low.c         | 214 +++++-------

>  gdbserver/win32-low.h         |  68 ++++

>  32 files changed, 1803 insertions(+), 1150 deletions(-)

>

> --

> 2.17.1

>
Tankut Baris Aktemur Feb. 12, 2020, 8:17 a.m. | #2
On Tuesday, February 11, 2020 6:41 PM, Christian Biesinger wrote:
> On Tue, Feb 11, 2020 at 3:03 AM Tankut Baris Aktemur

> <tankut.baris.aktemur@intel.com> wrote:

> >

> > Hi All,

> >

> > This is a C++'ification series that aims to convert the target ops

> > vector in gdbserver into a class.  Currently, the target ops is a

> > struct of function pointers.  At the end of the series, it becomes a

> > class with methods, and the existing low target definitions become

> > subclasses.  That is, we end up with the following class hierarchy:

> >

> > process_stratum_target

> > ^

> > ├── linux-low

> > ├── lynx-low

> > ├── nto-low

> > └── win32-low

> >

> > process_stratum_target either defines the default behavior for the

> > target ops or leaves them as pure virtual for the subclasses to

> > override.

> >

> > PATCH 1's commit message gives more details about the approach in this

> > transformation.

> >

> > If and when this series is accepted, the next step is to C++'ify linux

> > low targets, giving a hierarchy that looks like below.  (This second

> > phase is not included in this series.)

> >

> > process_stratum_target

> > ^

> > ├── linux-low

> > │   ^

> > │   ├── linux-arm-low

> > │   ├── linux-ppc-low

> > │   ├── linux-x86-low

> > │   └── ...

> > ├── lynx-low

> > ├── nto-low

> > └── win32-low

> >

> > My goal in this series was to make gdbserver buildable after each

> > patch.  I could test this for linux-low, but not for other targets --

> > in particular, for lynx-low, nto-low, and win32-low.  I verified their

> > code manually to my best; however, I may have made typos or some

> > oversights that break build on these systems.  Can builbot be used to

> > test?

> 

> I'm not a patch approver (and I only skimmed most of the patches), but

> I really like this work!


Thank you!

> You can use buildbot to test win32 (the Fedora-x86_64-w64-mingw32 bot

> tests it by crosscompiling from linux to windows). Testing lynx and

> nto may be harder, you may have to track down a cross compiler and/or

> a qemu image...

> 

> 

> Christian


As far as I understand, I need to contact Sergio to ask for access:
https://sourceware.org/gdb/wiki/BuildBot

The builbot page at https://gdb-buildbot.osci.io does not contain much
instructions.  If there are other pointers one needs to know, please let me know!

Thanks.
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Hannes Domani via Gdb-patches Feb. 12, 2020, 4:42 p.m. | #3
On Wed, Feb 12, 2020 at 2:18 AM Aktemur, Tankut Baris
<tankut.baris.aktemur@intel.com> wrote:
>

> On Tuesday, February 11, 2020 6:41 PM, Christian Biesinger wrote:

> > On Tue, Feb 11, 2020 at 3:03 AM Tankut Baris Aktemur

> > <tankut.baris.aktemur@intel.com> wrote:

> > >

> > > Hi All,

> > >

> > > This is a C++'ification series that aims to convert the target ops

> > > vector in gdbserver into a class.  Currently, the target ops is a

> > > struct of function pointers.  At the end of the series, it becomes a

> > > class with methods, and the existing low target definitions become

> > > subclasses.  That is, we end up with the following class hierarchy:

> > >

> > > process_stratum_target

> > > ^

> > > ├── linux-low

> > > ├── lynx-low

> > > ├── nto-low

> > > └── win32-low

> > >

> > > process_stratum_target either defines the default behavior for the

> > > target ops or leaves them as pure virtual for the subclasses to

> > > override.

> > >

> > > PATCH 1's commit message gives more details about the approach in this

> > > transformation.

> > >

> > > If and when this series is accepted, the next step is to C++'ify linux

> > > low targets, giving a hierarchy that looks like below.  (This second

> > > phase is not included in this series.)

> > >

> > > process_stratum_target

> > > ^

> > > ├── linux-low

> > > │   ^

> > > │   ├── linux-arm-low

> > > │   ├── linux-ppc-low

> > > │   ├── linux-x86-low

> > > │   └── ...

> > > ├── lynx-low

> > > ├── nto-low

> > > └── win32-low

> > >

> > > My goal in this series was to make gdbserver buildable after each

> > > patch.  I could test this for linux-low, but not for other targets --

> > > in particular, for lynx-low, nto-low, and win32-low.  I verified their

> > > code manually to my best; however, I may have made typos or some

> > > oversights that break build on these systems.  Can builbot be used to

> > > test?

> >

> > I'm not a patch approver (and I only skimmed most of the patches), but

> > I really like this work!

>

> Thank you!

>

> > You can use buildbot to test win32 (the Fedora-x86_64-w64-mingw32 bot

> > tests it by crosscompiling from linux to windows). Testing lynx and

> > nto may be harder, you may have to track down a cross compiler and/or

> > a qemu image...

> >

> >

> > Christian

>

> As far as I understand, I need to contact Sergio to ask for access:

> https://sourceware.org/gdb/wiki/BuildBot

>

> The builbot page at https://gdb-buildbot.osci.io does not contain much

> instructions.  If there are other pointers one needs to know, please let me know!


Yes, https://sourceware.org/gdb/wiki/BuildBot#TL.3BDR is the process
(email gdb@ and cc sergio)

https://sourceware.org/gdb/wiki/BuildBot#Installing_buildbot has the
instructions for how to set it up. At the time, I had to use vpython
and buildbot from their git repository, hopefully that is not
necessary anymore.

It occurs to me that buildbot has a maximum patch size. Hopefully,
your patch series fits under that!

Otherwise, you can install the mingw crosscompiler yourself and test
the build locally; Debian has a g++-mingw-w64 package for that. I'm
sure Fedora has a package too but I don't know what it's called. Then
you can just build GDB with configure --build=x86_64-pc-linux-gnu
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --without-python
--disable-nls --without-nls --disable-source-highlight.

Christian
Pedro Alves Feb. 13, 2020, 8:26 p.m. | #4
On 2/11/20 9:01 AM, Tankut Baris Aktemur wrote:
> Hi All,

> 

> This is a C++'ification series that aims to convert the target ops

> vector in gdbserver into a class.  Currently, the target ops is a

> struct of function pointers.  At the end of the series, it becomes a

> class with methods, and the existing low target definitions become

> subclasses.  That is, we end up with the following class hierarchy:


Pretty cool!

I'm sending comments to some of the individual patches.

Thanks,
Pedro Alves