xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/x86-linux-nat.h (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1 /* Native-dependent code for GNU/Linux x86 (i386 and x86-64).
2 
3    Copyright (C) 1999-2023 Free Software Foundation, Inc.
4 
5    This file is part of GDB.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 #ifndef X86_LINUX_NAT_H
21 #define X86_LINUX_NAT_H 1
22 
23 #include "gdb_proc_service.h"  /* For ps_err_e.  */
24 #include "linux-nat.h"
25 #include "x86-nat.h"
26 #include "nat/x86-linux.h"
27 
28 struct x86_linux_nat_target : public x86_nat_target<linux_nat_target>
29 {
30   virtual ~x86_linux_nat_target () override = 0;
31 
32   /* Add the description reader.  */
33   const struct target_desc *read_description () override;
34 
35   struct btrace_target_info *enable_btrace (thread_info *tp,
36 					    const struct btrace_config *conf) override;
37   void disable_btrace (struct btrace_target_info *tinfo) override;
38   void teardown_btrace (struct btrace_target_info *tinfo) override;
39   enum btrace_error read_btrace (struct btrace_data *data,
40 				 struct btrace_target_info *btinfo,
41 				 enum btrace_read_type type) override;
42   const struct btrace_config *btrace_conf (const struct btrace_target_info *) override;
43 
44   /* These two are rewired to low_ versions.  linux-nat.c queries
45      stopped-by-watchpoint info as soon as an lwp stops (via the low_
46      methods) and caches the result, to be returned via the normal
47      non-low methods.  */
48   bool stopped_by_watchpoint () override
49   { return linux_nat_target::stopped_by_watchpoint (); }
50 
51   bool stopped_data_address (CORE_ADDR *addr_p) override
52   { return linux_nat_target::stopped_data_address (addr_p); }
53 
54   bool low_stopped_by_watchpoint () override
55   { return x86_nat_target::stopped_by_watchpoint (); }
56 
57   bool low_stopped_data_address (CORE_ADDR *addr_p) override
58   { return x86_nat_target::stopped_data_address (addr_p); }
59 
60   void low_new_fork (struct lwp_info *parent, pid_t child_pid) override;
61 
62   void low_forget_process (pid_t pid) override
63   { x86_forget_process (pid); }
64 
65   void low_prepare_to_resume (struct lwp_info *lwp) override
66   { x86_linux_prepare_to_resume (lwp); }
67 
68   void low_new_thread (struct lwp_info *lwp) override
69   { x86_linux_new_thread (lwp); }
70 
71   void low_delete_thread (struct arch_lwp_info *lwp) override
72   { x86_linux_delete_thread (lwp); }
73 
74 protected:
75   /* Override the GNU/Linux inferior startup hook.  */
76   void post_startup_inferior (ptid_t) override;
77 };
78 
79 
80 
81 /* Helper for ps_get_thread_area.  Sets BASE_ADDR to a pointer to
82    the thread local storage (or its descriptor) and returns PS_OK
83    on success.  Returns PS_ERR on failure.  */
84 
85 extern ps_err_e x86_linux_get_thread_area (pid_t pid, void *addr,
86 					   unsigned int *base_addr);
87 
88 #endif
89