mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
os: add working stack logic for macOS
This commit is contained in:
parent
a3865e721a
commit
7456a77ba9
2 changed files with 41 additions and 13 deletions
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope 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 <stratosphere.hpp>
|
||||
#include "diag_symbol_impl.hpp"
|
||||
|
||||
namespace ams::diag::impl {
|
||||
|
||||
uintptr_t GetSymbolNameImpl(char *dst, size_t dst_size, uintptr_t address) {
|
||||
/* TODO: How should we do this on macOS? */
|
||||
AMS_UNUSED(dst, dst_size, address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t GetSymbolSizeImpl(uintptr_t address) {
|
||||
/* TODO: How should we do this on macOS? */
|
||||
AMS_UNUSED(address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,22 +25,17 @@ namespace ams::os::impl {
|
|||
AMS_ASSERT(out_stack != nullptr);
|
||||
AMS_ASSERT(out_size != nullptr);
|
||||
|
||||
/* Get the current stack by pthread */
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(std::addressof(attr));
|
||||
ON_SCOPE_EXIT { pthread_attr_destroy(std::addressof(attr)); };
|
||||
/* Get the current pthread. */
|
||||
const auto self = pthread_self();
|
||||
|
||||
const auto getattr_res = pthread_getattr_np(pthread_self(), std::addressof(attr));
|
||||
AMS_ABORT_UNLESS(getattr_res == 0);
|
||||
/* Get the thread stack. */
|
||||
uintptr_t stack_bottom = reinterpret_cast<uintptr_t>(pthread_get_stackaddr_np(self));
|
||||
size_t stack_size = pthread_get_stacksize_np(self);
|
||||
|
||||
/* Get the thread satck. */
|
||||
void *base = nullptr;
|
||||
size_t size = 0;
|
||||
const auto getstack_res = pthread_getattr_np(pthread_self(), std::addressof(attr));
|
||||
AMS_ABORT_UNLESS(getstack_res == 0);
|
||||
uintptr_t stack_top = stack_bottom - stack_size;
|
||||
|
||||
*out_stack = reinterpret_cast<uintptr_t>(base);
|
||||
*out_size = size;
|
||||
*out_stack = stack_top;
|
||||
*out_size = stack_size;
|
||||
}
|
||||
|
||||
static void QueryMemoryInfo(os::MemoryInfo *out) {
|
||||
|
|
Loading…
Reference in a new issue