From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 899F83AAA0A1 for ; Fri, 13 Mar 2020 19:09:05 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 837B5561B5; Fri, 13 Mar 2020 15:09:05 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id BCyy08uSmRSQ; Fri, 13 Mar 2020 15:09:05 -0400 (EDT) Received: from murgatroyd.Home (184-96-250-69.hlrn.qwest.net [184.96.250.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 40DA9561B4; Fri, 13 Mar 2020 15:09:05 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 26/29] Add read_pc / write_pc support to win32-low Date: Fri, 13 Mar 2020 13:08:52 -0600 Message-Id: <20200313190855.28662-27-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200313190855.28662-1-tromey@adacore.com> References: <20200313190855.28662-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 19:09:06 -0000 This changes win32-low.c to implement the read_pc and write_pc methods. A subsequent patch will need these. Note that I have no way to test, or even compile, the win32-arm-low.c change. gdbserver/ChangeLog 2020-03-13 Tom Tromey * win32-low.h (win32_process_target::read_pc) (win32_process_target::write_pc): Declare. * win32-low.c (win32_process_target::read_pc) (win32_process_target::write_pc): New methods. * win32-i386-low.c (i386_win32_get_pc, i386_win32_set_pc): New functions. (the_low_target): Update. * win32-arm-low.c (arm_win32_get_pc, arm_win32_set_pc): New functions. (the_low_target): Update. --- gdbserver/ChangeLog | 13 +++++++++++ gdbserver/win32-arm-low.cc | 23 +++++++++++++++++++ gdbserver/win32-i386-low.cc | 46 +++++++++++++++++++++++++++++++++++++ gdbserver/win32-low.cc | 12 ++++++++++ gdbserver/win32-low.h | 9 ++++++++ 5 files changed, 103 insertions(+) diff --git a/gdbserver/win32-arm-low.cc b/gdbserver/win32-arm-low.cc index 78b7fd09ec3..77200112df1 100644 --- a/gdbserver/win32-arm-low.cc +++ b/gdbserver/win32-arm-low.cc @@ -115,6 +115,27 @@ arm_arch_setup (void) static const unsigned long arm_wince_breakpoint = 0xe6000010; #define arm_wince_breakpoint_len 4 +/* Implement win32_target_ops "get_pc" method. */ + +static CORE_ADDR +arm_win32_get_pc (struct regcache *regcache) +{ + uint32_t pc; + + collect_register_by_name (regcache, "pc", &pc); + return (CORE_ADDR) pc; +} + +/* Implement win32_target_ops "set_pc" method. */ + +static void +arm_win32_set_pc (struct regcache *regcache, CORE_ADDR pc) +{ + uint32_t newpc = pc; + + supply_register_by_name (regcache, "pc", &newpc); +} + struct win32_target_ops the_low_target = { arm_arch_setup, sizeof (mappings) / sizeof (mappings[0]), @@ -127,6 +148,8 @@ struct win32_target_ops the_low_target = { NULL, /* single_step */ (const unsigned char *) &arm_wince_breakpoint, arm_wince_breakpoint_len, + arm_win32_get_pc, + arm_win32_set_pc, /* Watchpoint related functions. See target.h for comments. */ NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc index 1c14bc70362..eac15b5694a 100644 --- a/gdbserver/win32-i386-low.cc +++ b/gdbserver/win32-i386-low.cc @@ -450,6 +450,50 @@ i386_arch_setup (void) win32_tdesc = tdesc; } +/* Implement win32_target_ops "get_pc" method. */ + +static CORE_ADDR +i386_win32_get_pc (struct regcache *regcache) +{ + bool use_64bit = register_size (regcache->tdesc, 0) == 8; + + if (use_64bit) + { + uint64_t pc; + + collect_register_by_name (regcache, "rip", &pc); + return (CORE_ADDR) pc; + } + else + { + uint32_t pc; + + collect_register_by_name (regcache, "eip", &pc); + return (CORE_ADDR) pc; + } +} + +/* Implement win32_target_ops "set_pc" method. */ + +static void +i386_win32_set_pc (struct regcache *regcache, CORE_ADDR pc) +{ + bool use_64bit = register_size (regcache->tdesc, 0) == 8; + + if (use_64bit) + { + uint64_t newpc = pc; + + supply_register_by_name (regcache, "rip", &newpc); + } + else + { + uint32_t newpc = pc; + + supply_register_by_name (regcache, "eip", &newpc); + } +} + struct win32_target_ops the_low_target = { i386_arch_setup, sizeof (mappings) / sizeof (mappings[0]), @@ -462,6 +506,8 @@ struct win32_target_ops the_low_target = { i386_single_step, &i386_win32_breakpoint, i386_win32_breakpoint_len, + i386_win32_get_pc, + i386_win32_set_pc, i386_supports_z_point_type, i386_insert_point, i386_remove_point, diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index d151505e9f8..131eacb13c4 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -1659,6 +1659,18 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size) return the_low_target.breakpoint; } +CORE_ADDR +win32_process_target::read_pc (struct regcache *regcache) +{ + return (*the_low_target.get_pc) (regcache); +} + +void +win32_process_target::write_pc (struct regcache *regcache, CORE_ADDR pc) +{ + return (*the_low_target.set_pc) (regcache, pc); +} + /* The win32 target ops object. */ static win32_process_target the_win32_target; diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index 917f7275622..56ff8a9baf2 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -63,6 +63,11 @@ struct win32_target_ops const unsigned char *breakpoint; int breakpoint_len; + /* Get the PC register from REGCACHE. */ + CORE_ADDR (*get_pc) (struct regcache *regcache); + /* Set the PC register in REGCACHE. */ + void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); + /* Breakpoint/Watchpoint related functions. See target.h for comments. */ int (*supports_z_point_type) (char z_type); int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr, @@ -142,6 +147,10 @@ class win32_process_target : public process_stratum_target int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override; const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override; + + CORE_ADDR read_pc (regcache *regcache) override; + + void write_pc (regcache *regcache, CORE_ADDR pc) override; }; /* Retrieve the context for this thread, if not already retrieved. */ -- 2.21.1