edb-debugger-git: DebuggerCore initial port to NetBSD

Pity that the original FreeBSD code was long dead and irrelevant.
This commit is contained in:
Kamil Rytarowski 2017-02-19 03:05:29 +01:00
parent 4c67150cb8
commit 6f915ca9cf
6 changed files with 671 additions and 402 deletions

View File

@ -5,21 +5,22 @@ RMD160 (edb-debugger-0.9.21.tar.gz) = d7821e07b607667090b1158b559053856ef077de
SHA512 (edb-debugger-0.9.21.tar.gz) = 88a04cafb2c27a3af6bcfc48c841c795fb5bba348f64fe52957716c2c03e4cd056d045b241135c5be7fd7174d2c5a35fa5c95dc2b6aad4fb5c04f4fe36ab4f0d
Size (edb-debugger-0.9.21.tar.gz) = 996932 bytes
SHA1 (patch-CMakeLists.txt) = d714177643b1f8b3a37c8d6bd51953c5fb296239
SHA1 (patch-include_os_unix_OSTypes.h) = bc7d3f584c7e8e40ad029e83141a186629b4c1eb
SHA1 (patch-include_os_unix_OSTypes.h) = 8209e8cd487b4b93532847df9166c0abecb00c48
SHA1 (patch-include_os_unix_netbsd_linker.h) = d09a31187b4e7c0d4a20db6c32806cc8fd710538
SHA1 (patch-plugins_Analyzer_Analyzer.cpp) = 511efa03a82a96612d64fd43b9e6631e4d6aeb76
SHA1 (patch-plugins_Assembler_DialogAssembler.cpp) = 2bd6418dc078aae0c84c6092f15619e202e43b31
SHA1 (patch-plugins_DebuggerCore_CMakeLists.txt) = 18b3f0bd7c7c7ec4eaa6526c81b7c4299c7ee3f4
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp) = e48d60ec404717b0822ddd75bb69ea7b2360230e
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h) = 9ae7087401a657750ceda08e4fafd064ffd8a021
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp) = 716e48cbe859d12cd31a50040fc556e4f26fd659
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h) = 6dc06aa1d0d05741cce3f8cffbee5d0c3c377be3
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp) = 5096c5fc7b1812545faf70194b1d02985fc1546f
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.h) = 390ce937f71b3b4c5c63dd668dc42115d2e0622c
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.ui) = fb6689928090b65e3cb6f6e69886199a447c2fa6
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.cpp) = d7a577e879e30447122985e09609cc195670157f
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.h) = 4e5a8906e904d76f4fa85a5e1919a37f57083d1e
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp) = b1b07940d1a717ffd24ccd4bb028c098e5a6a8b6
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h) = 7431b033535e272689814eb7647043aa5c9282c1
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp) = 62e99fc234d072fa4ba82435216349eb76af2076
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h) = ef2b3d1e4106a137c8474aabbec7f30ee0524eb0
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h) = 1781ca113c68b2e88051c7bf49bf388f61169ece
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp) = 06bc435f25546ef3f27cf60ba815f7dc9d8f9706
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h) = a4ddbd5c6f486695d4de27954ed65de4ec8bb288
SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp) = dc5b3caa442e041658da7aac8e59d51ccfe0c130

View File

@ -2,11 +2,12 @@ $NetBSD$
--- include/os/unix/OSTypes.h.orig 2017-02-18 21:21:09.000000000 +0000
+++ include/os/unix/OSTypes.h
@@ -24,7 +24,11 @@ along with this program. If not, see <h
@@ -24,7 +24,12 @@ along with this program. If not, see <h
namespace edb {
using ::pid_t;
using ::uid_t;
+#if defined(__NetBSD__)
+ typedef ::pid_t pid_t;
+ typedef ::lwpid_t tid_t;
+#else
typedef ::pid_t tid_t;

View File

@ -2,7 +2,7 @@ $NetBSD$
--- plugins/DebuggerCore/unix/netbsd/DebuggerCore.h.orig 2017-02-19 00:51:04.563698490 +0000
+++ plugins/DebuggerCore/unix/netbsd/DebuggerCore.h
@@ -0,0 +1,110 @@
@@ -0,0 +1,119 @@
+/*
+Copyright (C) 2006 - 2015 Evan Teran
+ evan.teran@gmail.com
@ -25,89 +25,98 @@ $NetBSD$
+#define DEBUGGERCORE_20090529_H_
+
+#include "DebuggerCoreUNIX.h"
+#include "PlatformState.h"
+#include "PlatformThread.h"
+#include <QHash>
+#include <QSet>
+#include <csignal>
+#include <sys/syscall.h> /* For SYS_xxx definitions */
+#include <unistd.h>
+#include <sys/ptrace.h>
+
+namespace DebuggerCore {
+class IBinary;
+
+namespace DebuggerCorePlugin {
+
+class DebuggerCore : public DebuggerCoreUNIX {
+ Q_OBJECT
+#if QT_VERSION >= 0x050000
+ Q_PLUGIN_METADATA(IID "edb.IDebugger/1.0")
+#endif
+ Q_INTERFACES(IDebugger)
+ Q_CLASSINFO("author", "Evan Teran")
+ Q_CLASSINFO("url", "http://www.codef00.com")
+ friend class PlatformProcess;
+ friend class PlatformThread;
+
+public:
+ DebuggerCore();
+ virtual ~DebuggerCore();
+ virtual ~DebuggerCore() override;
+
+public:
+ virtual edb::address_t page_size() const;
+ virtual bool has_extension(quint64 ext) const;
+ virtual IDebugEvent::const_pointer wait_debug_event(int msecs);
+ virtual bool attach(edb::pid_t pid);
+ virtual void detach();
+ virtual void kill();
+ virtual void pause();
+ virtual void resume(edb::EVENT_STATUS status);
+ virtual void step(edb::EVENT_STATUS status);
+ virtual void get_state(State *state);
+ virtual void set_state(const State &state);
+ virtual bool open(const QString &path, const QString &cwd, const QList<QByteArray> &args, const QString &tty);
+ virtual std::size_t pointer_size() const override;
+ virtual edb::address_t page_size() const override;
+ virtual bool has_extension(quint64 ext) const override;
+ virtual IDebugEvent::const_pointer wait_debug_event(int msecs) override;
+ virtual QString attach(edb::pid_t pid) override;
+ virtual void detach() override;
+ virtual void kill() override;
+ virtual void get_state(State *state) override;
+ virtual void set_state(const State &state) override;
+ virtual QString open(const QString &path, const QString &cwd, const QList<QByteArray> &args, const QString &tty) override;
+ virtual MeansOfCapture last_means_of_capture() override;
+
+public:
+ // thread support stuff (optional)
+ virtual QList<edb::tid_t> thread_ids() const { return threads_.keys(); }
+ virtual edb::tid_t active_thread() const { return active_thread_; }
+ virtual void set_active_thread(edb::tid_t);
+ virtual edb::pid_t parent_pid(edb::pid_t pid) const override;
+
+public:
+ virtual QList<IRegion::pointer> memory_regions() const;
+ virtual edb::address_t process_code_address() const;
+ virtual edb::address_t process_data_address() const;
+ virtual IState *create_state() const override;
+
+public:
+ virtual IState *create_state() const;
+
+public:
+ // process properties
+ virtual QList<QByteArray> process_args(edb::pid_t pid) const;
+ virtual QString process_exe(edb::pid_t pid) const;
+ virtual QString process_cwd(edb::pid_t pid) const;
+ virtual edb::pid_t parent_pid(edb::pid_t pid) const;
+ virtual QDateTime process_start(edb::pid_t pid) const;
+ virtual quint64 cpu_type() const;
+
+public:
+ virtual QMap<edb::pid_t, ProcessInfo> enumerate_processes() const;
+ virtual QList<Module> loaded_modules() const;
+
+public:
+ virtual QString stack_pointer() const;
+ virtual QString frame_pointer() const;
+ virtual QString instruction_pointer() const;
+
+public:
+ virtual QString format_pointer(edb::address_t address) const;
+ virtual quint64 cpu_type() const override;
+
+private:
+ virtual long read_data(edb::address_t address, bool *ok);
+ virtual bool write_data(edb::address_t address, long value);
+ virtual QMap<edb::pid_t, IProcess::pointer> enumerate_processes() const override;
+
+public:
+ virtual QString stack_pointer() const override;
+ virtual QString frame_pointer() const override;
+ virtual QString instruction_pointer() const override;
+ virtual QString flag_register() const override;
+
+public:
+ virtual QString format_pointer(edb::address_t address) const override;
+
+public:
+ virtual IProcess *process() const override;
+
+private:
+ struct thread_info {
+ public:
+ thread_info() : status(0) {
+ }
+ long ptrace_getsiginfo(edb::pid_t tid, ptrace_siginfo_t *siginfo);
+ long ptrace_continue(edb::pid_t tid, long status);
+ long ptrace_step(edb::pid_t tid, long status);
+ long ptrace_traceme();
+
+ thread_info(int s) : status(s) {
+ }
+private:
+ void reset();
+ void stop_threads();
+ IDebugEvent::const_pointer handle_event(edb::tid_t tid, int status);
+ int attach_thread(edb::tid_t tid);
+ void detectDebuggeeBitness();
+
+ int status;
+ };
+private:
+ typedef QHash<edb::tid_t, PlatformThread::pointer> threadmap_t;
+
+ typedef QHash<edb::tid_t, thread_info> threadmap_t;
+
+ edb::address_t page_size_;
+ threadmap_t threads_;
+private:
+ threadmap_t threads_;
+ std::unique_ptr<IBinary> binary_info_;
+ IProcess *process_;
+ std::size_t pointer_size_;
+ const bool edbIsIn64BitSegment;
+ const bool osIs64Bit;
+ const edb::seg_reg_t USER_CS_32;
+ const edb::seg_reg_t USER_CS_64;
+ const edb::seg_reg_t USER_SS;
+ MeansOfCapture lastMeansOfCapture = MeansOfCapture::NeverCaptured;
+};
+
+}

View File

@ -0,0 +1,95 @@
$NetBSD$
--- plugins/DebuggerCore/unix/netbsd/DialogMemoryAccess.ui.orig 2017-02-19 01:11:03.492521515 +0000
+++ plugins/DebuggerCore/unix/netbsd/DialogMemoryAccess.ui
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DebuggerCorePlugin::DialogMemoryAccess</class>
+ <widget class="QDialog" name="DialogMemoryAccess">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>360</width>
+ <height>276</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Memory Access Error</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;EDB has detected that on this kernel, access to debugee memory &lt;br/&gt;does not work through &lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;/proc/&amp;lt;pid&amp;gt;/mem&lt;/span&gt;. &lt;/p&gt;&lt;p&gt;Possible causes include: &lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;EDB's feature detection has a bug&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The kernel is older and restricts writes to &lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;/proc/&amp;lt;pid&amp;gt;/mem&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The kernel has &lt;span style=&quot; font-weight:600;&quot;&gt;grsecurity&lt;/span&gt; enabled&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;EDB has a fallback method of accessing debugee memory, &lt;br/&gt;but it may have a negative impact on performance. &lt;br/&gt;If you experience poor performance, please file a bug report at:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://github.com/eteran/edb-debugger/issues&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#2980b9;&quot;&gt;http://github.com/eteran/edb-debugger/issues&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="openExternalLinks">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkNeverShowAgain">
+ <property name="text">
+ <string>Never show this message again</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>DialogMemoryAccess</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>DialogMemoryAccess</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>

View File

@ -2,7 +2,7 @@ $NetBSD$
--- plugins/DebuggerCore/unix/netbsd/PlatformEvent.h.orig 2017-02-19 00:51:04.612693828 +0000
+++ plugins/DebuggerCore/unix/netbsd/PlatformEvent.h
@@ -0,0 +1,62 @@
@@ -0,0 +1,61 @@
+/*
+Copyright (C) 2006 - 2015 Evan Teran
+ evan.teran@gmail.com
@ -55,11 +55,10 @@ $NetBSD$
+ virtual int code() const;
+
+private:
+ int status;
+ edb::pid_t pid;
+ edb::tid_t tid;
+ void * fault_address_;
+ long fault_code_;
+ ptrace_siginfo_t siginfo_;
+ edb::pid_t pid_;
+ edb::tid_t tid_;
+ int status_;
+};
+
+}