pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

edb-debugger-git: Add more files from Linux in netbsd/



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Feb 19 00:35:31 2017 +0100
Changeset:	c9d8dc5ee7260c8ed5cd20e9ca995f5e3e31c99a

Modified Files:
	edb-debugger-git/distinfo
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h
Added Files:
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.h
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.cpp
	edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.h

Log Message:
edb-debugger-git: Add more files from Linux in netbsd/

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=c9d8dc5ee7260c8ed5cd20e9ca995f5e3e31c99a

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 edb-debugger-git/distinfo                          |  30 +-
 ...ugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp |   2 +-
 ...plugins_DebuggerCore_unix_netbsd_DebuggerCore.h |   2 +-
 ...DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp |  43 ++
 ...s_DebuggerCore_unix_netbsd_DialogMemoryAccess.h |  49 +++
 ...gins_DebuggerCore_unix_netbsd_FeatureDetect.cpp | 179 ++++++++
 ...lugins_DebuggerCore_unix_netbsd_FeatureDetect.h |  35 ++
 ...ins_DebuggerCore_unix_netbsd_PlatformCommon.cpp |   2 +-
 ...ugins_DebuggerCore_unix_netbsd_PlatformCommon.h |   2 +-
 ...gins_DebuggerCore_unix_netbsd_PlatformEvent.cpp |   2 +-
 ...lugins_DebuggerCore_unix_netbsd_PlatformEvent.h |   2 +-
 ...ns_DebuggerCore_unix_netbsd_PlatformProcess.cpp |   2 +-
 ...gins_DebuggerCore_unix_netbsd_PlatformProcess.h |   2 +-
 ...ins_DebuggerCore_unix_netbsd_PlatformRegion.cpp |   2 +-
 ...ugins_DebuggerCore_unix_netbsd_PlatformRegion.h |   2 +-
 ...gins_DebuggerCore_unix_netbsd_PlatformState.cpp |   2 +-
 ...lugins_DebuggerCore_unix_netbsd_PlatformState.h |   2 +-
 ...ins_DebuggerCore_unix_netbsd_PlatformThread.cpp | 449 +++++++++++++++++++++
 ...ugins_DebuggerCore_unix_netbsd_PlatformThread.h |  94 +++++
 19 files changed, 879 insertions(+), 24 deletions(-)

diffs:
diff --git a/edb-debugger-git/distinfo b/edb-debugger-git/distinfo
index 6899b1a2c5..e41ef7051d 100644
--- a/edb-debugger-git/distinfo
+++ b/edb-debugger-git/distinfo
@@ -6,18 +6,24 @@ SHA512 (edb-debugger-0.9.21.tar.gz) = 88a04cafb2c27a3af6bcfc48c841c795fb5bba348f
 Size (edb-debugger-0.9.21.tar.gz) = 996932 bytes
 SHA1 (patch-plugins_Assembler_DialogAssembler.cpp) = 2bd6418dc078aae0c84c6092f15619e202e43b31
 SHA1 (patch-plugins_DebuggerCore_CMakeLists.txt) = 18b3f0bd7c7c7ec4eaa6526c81b7c4299c7ee3f4
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp) = 9806aea3878a64acf4112e2807c66c2ed0d15be9
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h) = 3a8135a25b022e8172c540c6d86112c3cefaf2b3
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp) = 68c1ad8612bb8d4f27db36dbb7d6d9608265570d
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h) = 28e5d625328c73330259c422fd9131aca4dabbd5
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp) = 392bd0c69ff2e4be7e0ba86548320cbf42362aa8
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h) = 53e40c6b0a7674a1e5e857633626a72afce5e930
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp) = 857d141c1819f8996465b77aeabd579e55007a00
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h) = a0ff2035ad1cf4990908feb8324b0d52ee0f621d
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp) = 5c8726af17343204ddc37eb19f5dc3f5588ff6dd
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h) = f7e567f4466074275d24852919b3cd9a8e3296a8
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp) = f7ae4ef00b6db91849044efd3ea56ebab4751400
-SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h) = 201f22f11b23c09de52ad3fab1a1c66938d04c89
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp) = e830e332a9e9b66284218f73860396b9d9968c76
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h) = a9335e0c89c040a18c7427af539537de945c2767
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp) = aa5ca12636f69a1d193f6dafc40fdd93b0cfb045
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.h) = 80f4753c93f8e609dfd12ced203d24e1460650d3
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.cpp) = 0df2f31b58ed6133b4d6c382aa5cba53086620ca
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.h) = da3f18057d40e5935bc7fbc06896f85df66bcb5a
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp) = aa42edff67624a067d88bdd90efd911830be29a1
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h) = 4dcceae321182040c63bd2ca269cee82cfa2776b
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp) = 1b61df3c94c197f60fe27a717023fd4f7a352d41
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h) = bb10f94a9f8a420d3bf713df5e81a76fa9d87fe1
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp) = a14e97b2c386fc066ff009bee737932830b7689d
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h) = 20e89f333a7866210ed61d22c760810f8769056c
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp) = 19143c32097ee266a842ca8d539cf99cb0a94b85
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h) = 699ddd411c8bde17dc2125f0f60b4dd64cff57c3
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp) = bb9c0db3303f514e13376ffb7b2d086a0cb818a3
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h) = 19e2935407feeb12d8b80fe2cbd7762a5946ef58
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.cpp) = acbe9c562de7fe2c039eb8b74635a1008a0056a3
+SHA1 (patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.h) = 57432f5c91546f1dff7b1bfc874216fefe931a99
 SHA1 (patch-plugins_HeapAnalyzer_DialogHeap.cpp) = a11c5aeb91168f4bf2f58fa35137fec2d5107ea4
 SHA1 (patch-plugins_ProcessProperties_DialogProcessProperties.cpp) = 31d9915e63a963fdd597dc141e3424fa8f05e81b
 SHA1 (patch-src_Debugger.cpp) = 6e680dfecf7fe690c3d557002515f21313b85ca7
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp
index 37afcc7762..32b302a4ef 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.cpp
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/DebuggerCore.cpp.orig	2017-02-18 23:29:40.659788563 +0000
+--- plugins/DebuggerCore/unix/netbsd/DebuggerCore.cpp.orig	2017-02-18 23:32:09.424899250 +0000
 +++ plugins/DebuggerCore/unix/netbsd/DebuggerCore.cpp
 @@ -0,0 +1,596 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h
index e15639366d..8512973304 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DebuggerCore.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/DebuggerCore.h.orig	2017-02-18 23:29:40.665189223 +0000
+--- plugins/DebuggerCore/unix/netbsd/DebuggerCore.h.orig	2017-02-18 23:32:09.430404238 +0000
 +++ plugins/DebuggerCore/unix/netbsd/DebuggerCore.h
 @@ -0,0 +1,110 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp
new file mode 100644
index 0000000000..c82b9480bf
--- /dev/null
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.cpp
@@ -0,0 +1,43 @@
+$NetBSD$
+
+--- plugins/DebuggerCore/unix/netbsd/DialogMemoryAccess.cpp.orig	2017-02-18 23:34:06.650717163 +0000
++++ plugins/DebuggerCore/unix/netbsd/DialogMemoryAccess.cpp
+@@ -0,0 +1,38 @@
++/*
++Copyright (C) 2006 - 2015 Evan Teran
++                          evan.teran%gmail.com@localhost
++
++This program is free software: you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation, either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#include "DialogMemoryAccess.h"
++#include "ui_DialogMemoryAccess.h"
++
++namespace DebuggerCorePlugin {
++
++DialogMemoryAccess::DialogMemoryAccess(QWidget *parent) : QDialog(parent), ui(new Ui::DialogMemoryAccess) {
++	ui->setupUi(this);
++	adjustSize();
++	setFixedSize(width(), height());
++}
++
++DialogMemoryAccess::~DialogMemoryAccess() {
++	delete ui;
++}
++
++bool DialogMemoryAccess::warnNextTime() const {
++	return !ui->checkNeverShowAgain->isChecked();
++}
++
++}
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.h
new file mode 100644
index 0000000000..0c56640008
--- /dev/null
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_DialogMemoryAccess.h
@@ -0,0 +1,49 @@
+$NetBSD$
+
+--- plugins/DebuggerCore/unix/netbsd/DialogMemoryAccess.h.orig	2017-02-18 23:34:04.145523175 +0000
++++ plugins/DebuggerCore/unix/netbsd/DialogMemoryAccess.h
+@@ -0,0 +1,44 @@
++/*
++Copyright (C) 2016 - 2016 Evan Teran
++                          evan.teran%gmail.com@localhost
++
++This program is free software: you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation, either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#ifndef DIALOG_MEMORY_ACCESS_20160930_H_
++#define DIALOG_MEMORY_ACCESS_20160930_H_
++
++#include <QDialog>
++
++namespace DebuggerCorePlugin {
++
++namespace Ui { class DialogMemoryAccess; }
++
++class DialogMemoryAccess : public QDialog {
++	Q_OBJECT
++
++public:
++	DialogMemoryAccess(QWidget *parent = 0);
++	virtual ~DialogMemoryAccess();
++
++public:
++	bool warnNextTime() const;
++
++private:
++	 Ui::DialogMemoryAccess *const ui;
++};
++
++}
++
++#endif
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.cpp
new file mode 100644
index 0000000000..8aceb44f89
--- /dev/null
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.cpp
@@ -0,0 +1,179 @@
+$NetBSD$
+
+--- plugins/DebuggerCore/unix/netbsd/FeatureDetect.cpp.orig	2017-02-18 23:33:31.196464884 +0000
++++ plugins/DebuggerCore/unix/netbsd/FeatureDetect.cpp
+@@ -0,0 +1,174 @@
++/*
++Copyright (C) 2016 - 2016 Evan Teran
++                          evan.teran%gmail.com@localhost
++
++This program is free software: you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation, either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#include "FeatureDetect.h"
++#include "version.h"
++
++#include <iostream>
++#include <iomanip>
++#include <string>
++#include <sys/wait.h>
++#include <sys/ptrace.h>
++#include <sys/types.h>
++#include <fcntl.h>
++#include <unistd.h>
++
++namespace DebuggerCorePlugin {
++namespace feature {
++namespace {
++
++// Custom class to work with files, since various wrappers
++// appear to be unreliable to check whether writes succeeded
++class File {
++	int fd;
++	bool success;
++
++public:
++	File(const std::string &filename) {
++		fd = ::open(filename.c_str(), O_RDWR);
++		success = fd != -1;
++	}
++
++	ssize_t write(const void *buf, size_t count) {
++		const auto result = ::write(fd, buf, count);
++		success = result != -1;
++		return result;
++	}
++
++	ssize_t read(void *buf, size_t count) {
++		const auto result = ::read(fd, buf, count);
++		success = result != -1;
++		return result;
++	}
++
++	size_t seekp(size_t offset) {
++		const auto result = ::lseek(fd, offset, SEEK_SET);
++		success = result != -1;
++		return result;
++	}
++
++	~File() {
++		close(fd);
++	}
++
++	explicit operator bool() {
++		return success;
++	}
++};
++
++void kill_child(int pid) {
++	if (kill(pid, SIGKILL) == -1) {
++		perror("failed to kill child");
++	}
++}
++
++}
++
++//------------------------------------------------------------------------------
++// Name: detect_proc_access
++// Desc: detects whether or not reads/writes through /proc/<pid>/mem work
++//       correctly
++//------------------------------------------------------------------------------
++bool detect_proc_access(bool *read_broken, bool *write_broken) {
++
++	switch (pid_t pid = fork()) {
++	case 0:
++		if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) {
++			perror("child: PTRACE_TRACEME failed");
++			abort();
++		}
++
++		// force a signal
++		raise(SIGCONT);
++
++		for (;;) {
++			sleep(10);
++		}
++		abort();
++
++	case -1:
++		perror("fork");
++		return false;
++
++	default: {
++		int status;
++		if (waitpid(pid, &status, __WALL) == -1) {
++			perror("parent: waitpid failed");
++			kill_child(pid);
++			return false;
++		}
++
++		if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGCONT) {
++			std::cerr << "unexpected status returned by waitpid: 0x" << std::hex << status << "\n";
++			kill_child(pid);
++			return false;
++		}
++
++		File file("/proc/" + std::to_string(pid) + "/mem");
++		if (!file) {
++			perror("failed to open memory file");
++			kill_child(pid);
++			return false;
++		}
++
++		const auto pageAlignMask = ~(sysconf(_SC_PAGESIZE) - 1);
++		const auto addr = reinterpret_cast<uintptr_t>(&edb::version) & pageAlignMask;
++		file.seekp(addr);
++		if (!file) {
++			perror("failed to seek to address to read");
++			kill_child(pid);
++			return false;
++		}
++
++		int buf = 0x12345678;
++		{
++			file.read(&buf, sizeof(buf));
++			if (!file) {
++				*read_broken  = true;
++				*write_broken = true;
++				kill_child(pid);
++				return false;
++			}
++		}
++
++		file.seekp(addr);
++		if (!file) {
++			perror("failed to seek to address to write");
++			kill_child(pid);
++			return false;
++		}
++
++		{
++			file.write(&buf, sizeof(buf));
++			if (!file) {
++				*read_broken  = false;
++				*write_broken = true;
++			} else {
++				*read_broken  = false;
++				*write_broken = false;
++			}
++		}
++		kill_child(pid);
++		return true;
++	}
++	}
++
++}
++
++}
++}
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.h
new file mode 100644
index 0000000000..610cfacfda
--- /dev/null
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_FeatureDetect.h
@@ -0,0 +1,35 @@
+$NetBSD$
+
+--- plugins/DebuggerCore/unix/netbsd/FeatureDetect.h.orig	2017-02-18 23:33:33.499776061 +0000
++++ plugins/DebuggerCore/unix/netbsd/FeatureDetect.h
+@@ -0,0 +1,30 @@
++/*
++Copyright (C) 2016 - 2016 Evan Teran
++                          evan.teran%gmail.com@localhost
++
++This program is free software: you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation, either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#ifndef FEATURE_DETECT_H_
++#define FEATURE_DETECT_H_
++
++namespace DebuggerCorePlugin {
++namespace feature {
++
++bool detect_proc_access(bool *read_broken, bool *write_broken);
++
++}
++}
++
++#endif
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp
index ebd1a22faf..54127c6790 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.cpp
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformCommon.cpp.orig	2017-02-18 23:31:07.331573062 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformCommon.cpp.orig	2017-02-18 23:32:09.435914446 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformCommon.cpp
 @@ -0,0 +1,189 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h
index cbb6620555..610a4694ea 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformCommon.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformCommon.h.orig	2017-02-18 23:31:00.955171803 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformCommon.h.orig	2017-02-18 23:32:09.441357375 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformCommon.h
 @@ -0,0 +1,97 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp
index 4237035c2b..7e03137175 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.cpp
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformEvent.cpp.orig	2017-02-18 23:29:40.670536255 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformEvent.cpp.orig	2017-02-18 23:32:09.446839987 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformEvent.cpp
 @@ -0,0 +1,258 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h
index 45ed033e86..fb8c466098 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformEvent.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformEvent.h.orig	2017-02-18 23:29:40.675855400 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformEvent.h.orig	2017-02-18 23:32:09.452234186 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformEvent.h
 @@ -0,0 +1,62 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp
index 3d1f9efc74..7a0a0484e0 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.cpp
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformProcess.cpp.orig	2017-02-18 23:29:40.681119972 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformProcess.cpp.orig	2017-02-18 23:32:09.457680759 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformProcess.cpp
 @@ -0,0 +1,19 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h
index de9327a7fc..46ebc2a94d 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformProcess.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformProcess.h.orig	2017-02-18 23:29:40.686362060 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformProcess.h.orig	2017-02-18 23:32:09.463008446 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformProcess.h
 @@ -0,0 +1,27 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp
index 146e526102..9b24f7ec2a 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.cpp
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformRegion.cpp.orig	2017-02-18 23:29:40.691589984 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformRegion.cpp.orig	2017-02-18 23:32:09.468423823 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformRegion.cpp
 @@ -0,0 +1,96 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h
index 24ca97402e..9a3a579adb 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformRegion.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformRegion.h.orig	2017-02-18 23:29:40.696877164 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformRegion.h.orig	2017-02-18 23:32:09.473752076 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformRegion.h
 @@ -0,0 +1,67 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp
index 43427d79bd..d885e9d6af 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.cpp
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformState.cpp.orig	2017-02-18 23:29:40.702326185 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformState.cpp.orig	2017-02-18 23:32:09.479331154 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformState.cpp
 @@ -0,0 +1,392 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h
index f7c705f238..676307c7a9 100644
--- a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformState.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- plugins/DebuggerCore/unix/netbsd/PlatformState.h.orig	2017-02-18 23:29:40.707634975 +0000
+--- plugins/DebuggerCore/unix/netbsd/PlatformState.h.orig	2017-02-18 23:32:09.484809635 +0000
 +++ plugins/DebuggerCore/unix/netbsd/PlatformState.h
 @@ -0,0 +1,68 @@
 +/*
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.cpp b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.cpp
new file mode 100644
index 0000000000..84125fa1ea
--- /dev/null
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.cpp
@@ -0,0 +1,449 @@
+$NetBSD$
+
+--- plugins/DebuggerCore/unix/netbsd/PlatformThread.cpp.orig	2017-02-18 23:33:06.436692657 +0000
++++ plugins/DebuggerCore/unix/netbsd/PlatformThread.cpp
+@@ -0,0 +1,444 @@
++/*
++Copyright (C) 2015 - 2015 Evan Teran
++                          evan.teran%gmail.com@localhost
++
++This program is free software: you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation, either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#include "PlatformThread.h"
++#include "PlatformState.h"
++#include "PlatformCommon.h"
++#include "IProcess.h"
++#include "DebuggerCore.h"
++#include "State.h"
++#include <QtDebug>
++
++#ifndef _GNU_SOURCE
++#define _GNU_SOURCE        /* or _BSD_SOURCE or _SVID_SOURCE */
++#endif
++
++#include <asm/ldt.h>
++#include <elf.h>
++#include <linux/uio.h>
++#include <sys/ptrace.h>
++#include <sys/user.h>
++
++// doesn't always seem to be defined in the headers
++#ifndef PTRACE_GET_THREAD_AREA
++#define PTRACE_GET_THREAD_AREA static_cast<__ptrace_request>(25)
++#endif
++
++#ifndef PTRACE_SET_THREAD_AREA
++#define PTRACE_SET_THREAD_AREA static_cast<__ptrace_request>(26)
++#endif
++
++#ifndef PTRACE_GETSIGINFO
++#define PTRACE_GETSIGINFO static_cast<__ptrace_request>(0x4202)
++#endif
++
++#ifndef PTRACE_GETREGSET
++#define PTRACE_GETREGSET static_cast<__ptrace_request>(0x4204)
++#endif
++
++#ifndef PTRACE_SETREGSET
++#define PTRACE_SETREGSET static_cast<__ptrace_request>(0x4205)
++#endif
++
++namespace DebuggerCorePlugin {
++
++//------------------------------------------------------------------------------
++// Name: fillSegmentBases
++// Desc:
++//------------------------------------------------------------------------------
++void PlatformThread::fillSegmentBases(PlatformState* state) {
++
++	struct user_desc desc;
++	std::memset(&desc, 0, sizeof(desc));
++
++	for(size_t sregIndex=0;sregIndex<state->seg_reg_count();++sregIndex) {
++		const edb::seg_reg_t reg=state->x86.segRegs[sregIndex];
++		if(!reg) continue;
++		bool fromGDT=!(reg&0x04); // otherwise the selector picks descriptor from LDT
++		if(!fromGDT) continue;
++		if(ptrace(PTRACE_GET_THREAD_AREA, tid_, reg / LDT_ENTRY_SIZE, &desc) != -1) {
++			state->x86.segRegBases[sregIndex] = desc.base_addr;
++			state->x86.segRegBasesFilled[sregIndex]=true;
++		}
++	}
++	for(size_t sregIndex=0;sregIndex<state->seg_reg_count();++sregIndex) {
++		const edb::seg_reg_t sreg=state->x86.segRegs[sregIndex];
++		if(sreg==core_->USER_CS_32||sreg==core_->USER_CS_64||sreg==core_->USER_SS ||
++				(state->is64Bit() && sregIndex<PlatformState::X86::FS)) {
++			state->x86.segRegBases[sregIndex] = 0;
++			state->x86.segRegBasesFilled[sregIndex]=true;
++		}
++	}
++}
++
++//------------------------------------------------------------------------------
++// Name: fillStateFromPrStatus
++// Desc:
++//------------------------------------------------------------------------------
++bool PlatformThread::fillStateFromPrStatus(PlatformState* state) {
++
++	static bool prStatusSupported=true;
++	if(!prStatusSupported)
++		return false;
++
++
++	PrStatus_X86_64 prstat64;
++
++	iovec prstat_iov = {&prstat64, sizeof(prstat64)};
++
++	if(ptrace(PTRACE_GETREGSET, tid_, NT_PRSTATUS, &prstat_iov) != -1) {
++		if(prstat_iov.iov_len==sizeof(prstat64)) {
++			state->fillFrom(prstat64);
++		} else if(prstat_iov.iov_len==sizeof(PrStatus_X86)) {
++			// In this case the actual structure returned is PrStatus_X86,
++			// so copy it to the correct container (reinterpret_cast would
++			// cause UB in any case). Good compiler should be able to optimize this out.
++			PrStatus_X86 prstat32;
++			std::memcpy(&prstat32,&prstat64,sizeof(prstat32));
++			state->fillFrom(prstat32);
++		} else {
++			prStatusSupported=false;
++			qWarning() << "PTRACE_GETREGSET(NT_PRSTATUS) returned unexpected length " << prstat_iov.iov_len;
++			return false;
++		}
++	}
++	else {
++		prStatusSupported=false;
++		perror("PTRACE_GETREGSET(NT_PRSTATUS) failed");
++		return false;
++	}
++	fillSegmentBases(state);
++	return true;
++}
++
++//------------------------------------------------------------------------------
++// Name: fillStateFromSimpleRegs
++// Desc:
++//------------------------------------------------------------------------------
++bool PlatformThread::fillStateFromSimpleRegs(PlatformState* state) {
++
++	user_regs_struct regs;
++	if(ptrace(PTRACE_GETREGS, tid_, 0, &regs) != -1) {
++
++		state->fillFrom(regs);
++		fillSegmentBases(state);
++		return true;
++	}
++	else {
++		perror("PTRACE_GETREGS failed");
++		return false;
++	}
++}
++
++
++//------------------------------------------------------------------------------
++// Name: PlatformThread
++// Desc:
++//------------------------------------------------------------------------------
++PlatformThread::PlatformThread(DebuggerCore *core, IProcess *process, edb::tid_t tid) : core_(core), process_(process), tid_(tid) {
++	assert(process);
++	assert(core);
++}
++
++//------------------------------------------------------------------------------
++// Name:
++// Desc:
++//------------------------------------------------------------------------------
++PlatformThread::~PlatformThread() {
++}
++
++//------------------------------------------------------------------------------
++// Name:
++// Desc:
++//------------------------------------------------------------------------------
++edb::tid_t PlatformThread::tid() const {
++	return tid_;
++}
++
++//------------------------------------------------------------------------------
++// Name:
++// Desc:
++//------------------------------------------------------------------------------
++QString PlatformThread::name() const  {
++	struct user_stat thread_stat;
++	int n = get_user_stat(QString("/proc/%1/task/%2/stat").arg(process_->pid()).arg(tid_), &thread_stat);
++	if(n >= 2) {
++		return thread_stat.comm;
++	}
++
++	return QString();
++}
++
++//------------------------------------------------------------------------------
++// Name:
++// Desc:
++//------------------------------------------------------------------------------
++int PlatformThread::priority() const  {
++	struct user_stat thread_stat;
++	int n = get_user_stat(QString("/proc/%1/task/%2/stat").arg(process_->pid()).arg(tid_), &thread_stat);
++	if(n >= 30) {
++		return thread_stat.priority;
++	}
++
++	return 0;
++}
++
++//------------------------------------------------------------------------------
++// Name:
++// Desc:
++//------------------------------------------------------------------------------
++edb::address_t PlatformThread::instruction_pointer() const  {
++	struct user_stat thread_stat;
++	int n = get_user_stat(QString("/proc/%1/task/%2/stat").arg(process_->pid()).arg(tid_), &thread_stat);
++	if(n >= 18) {
++		return thread_stat.kstkeip;
++	}
++
++	return 0;
++}
++
++//------------------------------------------------------------------------------
++// Name:
++// Desc:
++//------------------------------------------------------------------------------
++QString PlatformThread::runState() const  {
++	struct user_stat thread_stat;
++	int n = get_user_stat(QString("/proc/%1/task/%2/stat").arg(process_->pid()).arg(tid_), &thread_stat);
++	if(n >= 3) {
++		switch(thread_stat.state) {           // 03
++		case 'R':
++			return tr("%1 (Running)").arg(thread_stat.state);
++			break;
++		case 'S':
++			return tr("%1 (Sleeping)").arg(thread_stat.state);
++			break;
++		case 'D':
++			return tr("%1 (Disk Sleep)").arg(thread_stat.state);
++			break;
++		case 'T':
++			return tr("%1 (Stopped)").arg(thread_stat.state);
++			break;
++		case 't':
++			return tr("%1 (Tracing Stop)").arg(thread_stat.state);
++			break;
++		case 'Z':
++			return tr("%1 (Zombie)").arg(thread_stat.state);
++			break;
++		case 'X':
++		case 'x':
++			return tr("%1 (Dead)").arg(thread_stat.state);
++			break;
++		case 'W':
++			return tr("%1 (Waking/Paging)").arg(thread_stat.state);
++			break;
++		case 'K':
++			return tr("%1 (Wakekill)").arg(thread_stat.state);
++			break;
++		case 'P':
++			return tr("%1 (Parked)").arg(thread_stat.state);
++			break;
++		default:
++			return tr("%1").arg(thread_stat.state);
++			break;
++		}
++	}
++
++	return tr("Unknown");
++}
++
++//------------------------------------------------------------------------------
++// Name: step
++// Desc: steps this thread one instruction, passing the signal that stopped it
++//       (unless the signal was SIGSTOP)
++//------------------------------------------------------------------------------
++void PlatformThread::step() {
++	core_->ptrace_step(tid_, resume_code(status_));
++}
++
++//------------------------------------------------------------------------------
++// Name: step
++// Desc: steps this thread one instruction, passing the signal that stopped it
++//       (unless the signal was SIGSTOP, or the passed status != DEBUG_EXCEPTION_NOT_HANDLED)
++//------------------------------------------------------------------------------
++void PlatformThread::step(edb::EVENT_STATUS status) {
++	const int code = (status == edb::DEBUG_EXCEPTION_NOT_HANDLED) ? resume_code(status_) : 0;
++	core_->ptrace_step(tid_, code);
++}
++
++//------------------------------------------------------------------------------
++// Name: resume
++// Desc: resumes this thread, passing the signal that stopped it
++//       (unless the signal was SIGSTOP)
++//------------------------------------------------------------------------------
++void PlatformThread::resume() {
++	core_->ptrace_continue(tid_, resume_code(status_));
++}
++
++//------------------------------------------------------------------------------
++// Name: resume
++// Desc: resumes this thread , passing the signal that stopped it
++//       (unless the signal was SIGSTOP, or the passed status != DEBUG_EXCEPTION_NOT_HANDLED)
++//------------------------------------------------------------------------------
++void PlatformThread::resume(edb::EVENT_STATUS status) {
++	const int code = (status == edb::DEBUG_EXCEPTION_NOT_HANDLED) ? resume_code(status_) : 0;
++	core_->ptrace_continue(tid_, code);
++}
++
++//------------------------------------------------------------------------------
++// Name: get_state
++// Desc:
++//------------------------------------------------------------------------------
++void PlatformThread::get_state(State *state) {
++	// TODO: assert that we are paused
++
++	core_->detectDebuggeeBitness();
++
++	if(auto state_impl = static_cast<PlatformState *>(state->impl_)) {
++		// State must be cleared before filling to zero all presence flags, otherwise something
++		// may remain not updated. Also, this way we'll mark all the unfilled values.
++		state_impl->clear();
++
++			if(EDB_IS_64_BIT)
++				fillStateFromSimpleRegs(state_impl); // 64-bit GETREGS call always returns 64-bit state, so use it
++			else if(!fillStateFromPrStatus(state_impl)) // if EDB is 32 bit, use GETREGSET so that we get 64-bit state for 64-bit debuggee
++				fillStateFromSimpleRegs(state_impl); // failing that, try to just get what we can
++
++			long ptraceStatus=0;
++
++			// First try to get full XSTATE
++			X86XState xstate;
++			iovec iov={&xstate,sizeof(xstate)};
++			ptraceStatus=ptrace(PTRACE_GETREGSET, tid_, NT_X86_XSTATE, &iov);
++			if(ptraceStatus==-1 || !state_impl->fillFrom(xstate,iov.iov_len)) {
++
++				// No XSTATE available, get just floating point and SSE registers
++				static bool getFPXRegsSupported=(EDB_IS_32_BIT ? true : false);
++				UserFPXRegsStructX86 fpxregs;
++				// This should be automatically optimized out on amd64. If not, not a big deal.
++				// Avoiding conditional compilation to facilitate syntax error checking
++				if(getFPXRegsSupported)
++					getFPXRegsSupported=(ptrace(PTRACE_GETFPXREGS, tid_, 0, &fpxregs)!=-1);
++
++				if(getFPXRegsSupported) {
++					state_impl->fillFrom(fpxregs);
++				} else {
++					// No GETFPXREGS: on x86 this means SSE is not supported
++					//                on x86_64 FPREGS already contain SSE state
++					user_fpregs_struct fpregs;
++					if((ptraceStatus=ptrace(PTRACE_GETFPREGS, tid_, 0, &fpregs))!=-1)
++						state_impl->fillFrom(fpregs);
++					else
++						perror("PTRACE_GETFPREGS failed");
++				}
++			}
++
++			// debug registers
++			for(std::size_t i=0;i<8;++i)
++				state_impl->x86.dbgRegs[i] = get_debug_register(i);
++	}
++}
++
++//------------------------------------------------------------------------------
++// Name: set_state
++// Desc:
++//------------------------------------------------------------------------------
++void PlatformThread::set_state(const State &state) {
++
++	// TODO: assert that we are paused
++
++	if(auto state_impl = static_cast<PlatformState *>(state.impl_)) {
++		bool setPrStatusDone=false;
++		if(EDB_IS_32_BIT && state_impl->is64Bit()) {
++			// Try to set 64-bit state
++			PrStatus_X86_64 prstat64;
++			state_impl->fillStruct(prstat64);
++			iovec prstat_iov = {&prstat64, sizeof(prstat64)};
++			if(ptrace(PTRACE_SETREGSET, tid_, NT_PRSTATUS, &prstat_iov) != -1)
++				setPrStatusDone=true;
++			else
++				perror("PTRACE_SETREGSET failed");
++		}
++		// Fallback to setting 32-bit set
++		if(!setPrStatusDone) {
++			user_regs_struct regs;
++			state_impl->fillStruct(regs);
++			ptrace(PTRACE_SETREGS, tid_, 0, &regs);
++		}
++
++		// debug registers
++		for(std::size_t i=0;i<8;++i)
++			set_debug_register(i,state_impl->x86.dbgRegs[i]);
++
++		static bool xsaveSupported=true; // hope for the best, adjust for reality
++		if(xsaveSupported) {
++			X86XState xstate;
++			const auto size=state_impl->fillStruct(xstate);
++			iovec iov={&xstate,size};
++			if(ptrace(PTRACE_SETREGSET, tid_, NT_X86_XSTATE, &iov)==-1)
++				xsaveSupported=false;
++		}
++		// If xsave/xrstor appears unsupported, fallback to fxrstor
++		// NOTE: it's not "else", it's an independent check for possibly modified flag
++		if(!xsaveSupported) {
++			static bool setFPXRegsSupported=EDB_IS_32_BIT;
++			if(setFPXRegsSupported) {
++				UserFPXRegsStructX86 fpxregs;
++				state_impl->fillStruct(fpxregs);
++				setFPXRegsSupported=(ptrace(PTRACE_SETFPXREGS, tid_, 0, &fpxregs)!=-1);
++			}
++			if(!setFPXRegsSupported) {
++				// No SETFPXREGS: on x86 this means SSE is not supported
++				//                on x86_64 FPREGS already contain SSE state
++				// Just set fpregs then
++				user_fpregs_struct fpregs;
++				state_impl->fillStruct(fpregs);
++				if(ptrace(PTRACE_SETFPREGS, tid_, 0, &fpregs)==-1)
++					perror("PTRACE_SETFPREGS failed");
++			}
++		}
++	}
++}
++
++//------------------------------------------------------------------------------
++// Name: get_debug_register
++// Desc:
++//------------------------------------------------------------------------------
++unsigned long PlatformThread::get_debug_register(std::size_t n) {
++	return ptrace(PTRACE_PEEKUSER, tid_, offsetof(struct user, u_debugreg[n]), 0);
++}
++
++//------------------------------------------------------------------------------
++// Name: set_debug_register
++// Desc:
++//------------------------------------------------------------------------------
++long PlatformThread::set_debug_register(std::size_t n, long value) {
++	return ptrace(PTRACE_POKEUSER, tid_, offsetof(struct user, u_debugreg[n]), value);
++}
++
++//------------------------------------------------------------------------------
++// Name: stop
++// Desc:
++//------------------------------------------------------------------------------
++void PlatformThread::stop() {
++	syscall(SYS_tgkill, process_->pid(), tid_, SIGSTOP);
++	// TODO(eteran): should this just be this?
++	//::kill(tid_, SIGSTOP);
++}
++
++
++}
diff --git a/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.h b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.h
new file mode 100644
index 0000000000..76f4dc779f
--- /dev/null
+++ b/edb-debugger-git/patches/patch-plugins_DebuggerCore_unix_netbsd_PlatformThread.h
@@ -0,0 +1,94 @@
+$NetBSD$
+
+--- plugins/DebuggerCore/unix/netbsd/PlatformThread.h.orig	2017-02-18 23:33:04.164504158 +0000
++++ plugins/DebuggerCore/unix/netbsd/PlatformThread.h
+@@ -0,0 +1,89 @@
++/*
++Copyright (C) 2015 - 2015 Evan Teran
++                          evan.teran%gmail.com@localhost
++
++This program is free software: you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation, either version 2 of the License, or
++(at your option) any later version.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#ifndef PLATFORM_THREAD_20151013_H_
++#define PLATFORM_THREAD_20151013_H_
++
++#include "IThread.h"
++#include <QCoreApplication>
++
++class IProcess;
++
++namespace DebuggerCorePlugin {
++
++class DebuggerCore;
++class PlatformState;
++
++class PlatformThread : public IThread {
++	Q_DECLARE_TR_FUNCTIONS(PlatformThread)
++	friend class DebuggerCore;
++public:
++	typedef std::shared_ptr<PlatformThread> pointer;
++
++public:
++	enum SignalStatus {
++		Stopped,
++		Signaled
++	};
++
++public:
++	PlatformThread(DebuggerCore *core, IProcess *process, edb::tid_t tid);
++	virtual ~PlatformThread() override;
++
++private:
++	PlatformThread(const PlatformThread &) = delete;
++	PlatformThread& operator=(const PlatformThread &) = delete;
++
++public:
++	virtual edb::tid_t tid() const override;
++	virtual QString name() const override;
++	virtual int priority() const override;
++	virtual edb::address_t instruction_pointer() const override;
++	virtual QString runState() const override;
++
++public:
++	virtual void get_state(State *state) override;
++	virtual void set_state(const State &state) override;
++
++public:
++	virtual void step() override;
++	virtual void step(edb::EVENT_STATUS status) override;
++	virtual void resume() override;
++	virtual void resume(edb::EVENT_STATUS status) override;
++	virtual void stop() override;
++
++private:
++	void fillSegmentBases(PlatformState* state);
++	bool fillStateFromPrStatus(PlatformState* state);
++	bool fillStateFromSimpleRegs(PlatformState* state);
++
++private:
++	unsigned long get_debug_register(std::size_t n);
++	long set_debug_register(std::size_t n, long value);
++
++private:
++	DebuggerCore *const core_;
++	IProcess *const     process_;
++	edb::tid_t          tid_;
++	int                 status_;
++	SignalStatus        signal_status_;
++};
++
++}
++
++#endif



Home | Main Index | Thread Index | Old Index