[02/10] Include elf_64_file_p in the netbsd_process_target class

Message ID 20201002021804.2814-3-n54@gmx.com
State New
Headers show
Series
  • Refactor the NetBSD gdbserver support
Related show

Commit Message

Kamil Rytarowski Oct. 2, 2020, 2:17 a.m.
gdbserver/ChangeLog:

        * netbsd-low.cc (elf_64_file_p): Turn into...
        (netbsd_process_target::elf_64_file_p): ...this.
        * netbsd-low.h (netbsd_process_target::elf_64_file_p): Add.
---
 gdbserver/ChangeLog     | 6 ++++++
 gdbserver/netbsd-low.cc | 8 +++-----
 gdbserver/netbsd-low.h  | 8 ++++++++
 3 files changed, 17 insertions(+), 5 deletions(-)

--
2.28.0

Comments

Simon Marchi Oct. 7, 2020, 2:45 a.m. | #1
On 2020-10-01 10:17 p.m., Kamil Rytarowski wrote:
> gdbserver/ChangeLog:

>

>         * netbsd-low.cc (elf_64_file_p): Turn into...

>         (netbsd_process_target::elf_64_file_p): ...this.

>         * netbsd-low.h (netbsd_process_target::elf_64_file_p): Add.


I don't see the point in making this a member function.  It doesn't
interact with netbsd_process_target class in any way, so low cohesion.
So the net result is that if you need to use this quite generic function
from outside the netbsd_process_target in the future, you can't.

I'm not strongly opposing, since this is not a particularly important
matter, I just find it odd.

Simon

Patch

diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 94fb3409f23..47714e8f85a 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,9 @@ 
+2020-10-01  Kamil Rytarowski  <n54@gmx.com>
+
+	* netbsd-low.cc (elf_64_file_p): Turn into...
+	(netbsd_process_target::elf_64_file_p): ...this.
+	* netbsd-low.h (netbsd_process_target::elf_64_file_p): Add.
+
 2020-10-01  Kamil Rytarowski  <n54@gmx.com>

 	* netbsd-low.cc (netbsd_ptrace_fun): Turn into...
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index 8a7ca5294f0..b1f2454f755 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -1197,12 +1197,10 @@  netbsd_qxfer_libraries_svr4 (netbsd_process_target *target,
   return len;
 }

-/* Return true if FILE is a 64-bit ELF file,
-   false if the file is not a 64-bit ELF file,
-   and error if the file is not accessible or doesn't exist.  */
+/* See netbsd-low.h.  */

-static bool
-elf_64_file_p (const char *file)
+bool
+netbsd_process_target::elf_64_file_p (const char *file)
 {
   int fd = gdb::handle_eintr<int> (-1, ::open, file, O_RDONLY);
   if (fd < 0)
diff --git a/gdbserver/netbsd-low.h b/gdbserver/netbsd-low.h
index c229a0f9f61..0d18e329b59 100644
--- a/gdbserver/netbsd-low.h
+++ b/gdbserver/netbsd-low.h
@@ -127,6 +127,14 @@  class netbsd_process_target : public process_stratum_target

   bool supports_catch_syscall () override;

+protected:
+  /* The architecture-independent NetBSD specific methods are listed below.  */
+
+  /* Return true if FILE is a 64-bit ELF file,
+     false if the file is not a 64-bit ELF file,
+     and error if the file is not accessible or doesn't exist.  */
+  bool elf_64_file_p (const char *file);
+
 protected:
   /* The architecture-specific "low" methods are listed below.  */