-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 964f696
Showing
8 changed files
with
501 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated from CLion C/C++ Code Style settings | ||
BasedOnStyle: LLVM | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: Consecutive | ||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments | ||
AlignOperands: Align | ||
AllowAllArgumentsOnNextLine: false | ||
AllowAllConstructorInitializersOnNextLine: false | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: Always | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Always | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterUnion: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: false | ||
SplitEmptyRecord: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakInheritanceList: BeforeColon | ||
ColumnLimit: 0 | ||
CompactNamespaces: false | ||
ContinuationIndentWidth: 8 | ||
IndentCaseLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MaxEmptyLinesToKeep: 2 | ||
NamespaceIndentation: All | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PointerAlignment: Right | ||
ReflowComments: false | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
TabWidth: 4 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/ | ||
*.elf | ||
*.wps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM ghcr.io/wiiu-env/devkitppc:20230218 | ||
|
||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230215 /artifacts $DEVKITPRO | ||
|
||
WORKDIR project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#------------------------------------------------------------------------------- | ||
|
||
ifeq ($(strip $(DEVKITPRO)),) | ||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") | ||
endif | ||
|
||
TOPDIR ?= $(CURDIR) | ||
|
||
include $(DEVKITPRO)/wups/share/wups_rules | ||
|
||
WUT_ROOT := $(DEVKITPRO)/wut | ||
#------------------------------------------------------------------------------- | ||
# TARGET is the name of the output | ||
# BUILD is the directory where object files & intermediate files will be placed | ||
# SOURCES is a list of directories containing source code | ||
# DATA is a list of directories containing data files | ||
# INCLUDES is a list of directories containing header files | ||
#------------------------------------------------------------------------------- | ||
TARGET := ThreadsViewer | ||
BUILD := build | ||
SOURCES := src src/utils | ||
DATA := data | ||
INCLUDES := src | ||
|
||
#------------------------------------------------------------------------------- | ||
# options for code generation | ||
#------------------------------------------------------------------------------- | ||
CFLAGS := -g -Wall -O2 -ffunction-sections \ | ||
$(MACHDEP) | ||
|
||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__ | ||
|
||
CXXFLAGS := $(CFLAGS) | ||
|
||
ASFLAGS := -g $(ARCH) | ||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUPSSPECS) | ||
|
||
ifeq ($(DEBUG),1) | ||
CXXFLAGS += -DDEBUG -g | ||
CFLAGS += -DDEBUG -g | ||
endif | ||
|
||
ifeq ($(DEBUG),VERBOSE) | ||
CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g | ||
CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g | ||
endif | ||
|
||
LIBS := -lwups -lwut | ||
|
||
#------------------------------------------------------------------------------- | ||
# list of directories containing libraries, this must be the top level | ||
# containing include and lib | ||
#------------------------------------------------------------------------------- | ||
LIBDIRS := $(PORTLIBS) $(WUPS_ROOT) $(WUT_ROOT) | ||
|
||
#------------------------------------------------------------------------------- | ||
# no real need to edit anything past this point unless you need to add additional | ||
# rules for different file extensions | ||
#------------------------------------------------------------------------------- | ||
ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
#------------------------------------------------------------------------------- | ||
|
||
export OUTPUT := $(CURDIR)/$(TARGET) | ||
export TOPDIR := $(CURDIR) | ||
|
||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) | ||
|
||
export DEPSDIR := $(CURDIR)/$(BUILD) | ||
|
||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | ||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) | ||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) | ||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) | ||
|
||
#------------------------------------------------------------------------------- | ||
# use CXX for linking C++ projects, CC for standard C | ||
#------------------------------------------------------------------------------- | ||
ifeq ($(strip $(CPPFILES)),) | ||
#------------------------------------------------------------------------------- | ||
export LD := $(CC) | ||
#------------------------------------------------------------------------------- | ||
else | ||
#------------------------------------------------------------------------------- | ||
export LD := $(CXX) | ||
#------------------------------------------------------------------------------- | ||
endif | ||
#------------------------------------------------------------------------------- | ||
|
||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) | ||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) | ||
export OFILES := $(OFILES_BIN) $(OFILES_SRC) | ||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) | ||
|
||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
-I$(CURDIR)/$(BUILD) | ||
|
||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
|
||
.PHONY: $(BUILD) clean all | ||
|
||
#------------------------------------------------------------------------------- | ||
all: $(BUILD) | ||
|
||
$(BUILD): | ||
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD)) | ||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
|
||
#------------------------------------------------------------------------------- | ||
clean: | ||
@echo clean ... | ||
@rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf | ||
|
||
#------------------------------------------------------------------------------- | ||
else | ||
.PHONY: all | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
#------------------------------------------------------------------------------- | ||
# main targets | ||
#------------------------------------------------------------------------------- | ||
all : $(OUTPUT).wps | ||
|
||
$(OUTPUT).wps : $(OUTPUT).elf | ||
$(OUTPUT).elf : $(OFILES) | ||
|
||
$(OFILES_SRC) : $(HFILES_BIN) | ||
|
||
#------------------------------------------------------------------------------- | ||
# you need a rule like this for each extension you use as binary data | ||
#------------------------------------------------------------------------------- | ||
%.bin.o %_bin.h : %.bin | ||
#------------------------------------------------------------------------------- | ||
@echo $(notdir $<) | ||
@$(bin2o) | ||
|
||
-include $(DEPENDS) | ||
|
||
#------------------------------------------------------------------------------- | ||
endif | ||
#------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Threads Viewer | ||
|
||
This is a plugin for [Aroma](https://github.com/wiiu-env/Aroma) that shows a list of active threads in the plugin menu. | ||
|
||
**Note: This code is new and likely to break and have problems. It is a bit messy with excessive NULL checks. It will be cleaned up soon.** | ||
|
||
## Installation | ||
|
||
1. Copy the file `ThreadsViewer.wps` into `sd:/wiiu/environments/aroma/plugins`. | ||
2. Requires the [WiiUPluginLoaderBackend](https://github.com/wiiu-env/WiiUPluginLoaderBackend) in `sd:/wiiu/environments/aroma/modules`. | ||
|
||
Start Aroma and the backend should load the plugin. | ||
|
||
## Building | ||
|
||
For building you need: | ||
|
||
- [wups](https://github.com/Maschell/WiiUPluginSystem) | ||
- [wut](https://github.com/devkitpro/wut) | ||
|
||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself. | ||
|
||
Then you should be able to compile via `make` (with no logging) or `make DEBUG=1` (with logging). | ||
|
||
## Buildflags | ||
|
||
### Logging | ||
|
||
Building via `make` only logs errors (via OSReport). To enable logging via the [LoggingModule](https://github.com/wiiu-env/LoggingModule) set `DEBUG` to `1` or `VERBOSE`. | ||
|
||
`make` Logs errors only (via OSReport). | ||
`make DEBUG=1` Enables information and error logging via [LoggingModule](https://github.com/wiiu-env/LoggingModule). | ||
`make DEBUG=VERBOSE` Enables verbose information and error logging via [LoggingModule](https://github.com/wiiu-env/LoggingModule). | ||
|
||
If the [LoggingModule](https://github.com/wiiu-env/LoggingModule) is not present, it'll fallback to UDP (Port 4405) and [CafeOS](https://github.com/wiiu-env/USBSerialLoggingModule) logging. | ||
|
||
## Building using the Dockerfile | ||
|
||
It's possible to use a docker image for building. This way you don't need anything installed on your host system. | ||
|
||
``` | ||
# Build docker image (only needed once) | ||
docker build . -t example-plugin-builder | ||
# make | ||
docker run -it --rm -v ${PWD}:/project example-plugin-builder make DEBUG=1 | ||
# make clean | ||
docker run -it --rm -v ${PWD}:/project example-plugin-builder make clean | ||
``` | ||
|
||
## Format the code via docker | ||
|
||
`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src -i` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#include "utils/logger.h" | ||
#include <coreinit/interrupts.h> | ||
#include <coreinit/scheduler.h> | ||
#include <coreinit/thread.h> | ||
#include <wups.h> | ||
#include <wups/config/WUPSConfigItemStub.h> | ||
|
||
/** | ||
Mandatory plugin information. | ||
If not set correctly, the loader will refuse to use the plugin. | ||
**/ | ||
WUPS_PLUGIN_NAME("Threads Viewer"); | ||
WUPS_PLUGIN_DESCRIPTION("Displays a list of active threads"); | ||
WUPS_PLUGIN_VERSION("v1.0"); | ||
WUPS_PLUGIN_AUTHOR("ItzSwirlz, Maschell"); | ||
WUPS_PLUGIN_LICENSE("BSD"); | ||
|
||
WUPS_USE_WUT_DEVOPTAB(); // Use the wut devoptabs | ||
WUPS_USE_STORAGE("threads_viewer"); // Unique id for the storage api | ||
|
||
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle root) { | ||
{ | ||
OSThread *curThread = OSGetCurrentThread(); | ||
int state = OSDisableInterrupts(); | ||
__OSLockScheduler(curThread); | ||
OSThread *t = *((OSThread **) 0x100567F8); // active threadlist address | ||
if(t == NULL) { | ||
DEBUG_FUNCTION_LINE_ERR("The first thread obtained was NULL. This should never happen."); | ||
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; | ||
} | ||
|
||
OSThread *threads[30]; // lets hope we dont have more than 100 | ||
int i = 0; | ||
|
||
// threads are handled by a linked list. | ||
// Since the scheduler is locked and interrupts are disabled, to save time, | ||
// have a local array pointing to these threads instead of making new ones | ||
// and holding up the system | ||
while (t->activeLink.next != NULL && t != NULL && i < 30) { | ||
threads[i] = t; | ||
if(t->activeLink.next == NULL) break; | ||
t = t->activeLink.next; | ||
i++; | ||
} | ||
__OSUnlockScheduler(curThread); | ||
OSRestoreInterrupts(state); | ||
|
||
if(threads[0] == NULL) { | ||
DEBUG_FUNCTION_LINE_ERR("The first thread obtained was NULL. This should never happen."); | ||
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; | ||
} | ||
for (int i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) { | ||
if (threads[i]) { | ||
if(threads[i]->name != NULL) { | ||
if (WUPSConfigItemStub_AddToCategory(root, threads[i]->name) != WUPSCONFIG_API_RESULT_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to add thread %d to the list", threads[i]->name); | ||
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS; | ||
} | ||
|
||
void ConfigMenuClosedCallback() { | ||
WUPSStorageAPI_SaveStorage(false); | ||
} | ||
|
||
/** | ||
Gets called ONCE when the plugin was loaded. | ||
**/ | ||
INITIALIZE_PLUGIN() { | ||
// Logging only works when compiled with `make DEBUG=1`. See the README for more information. | ||
initLogging(); | ||
DEBUG_FUNCTION_LINE("INITIALIZE_PLUGIN of threads_viewer!"); | ||
|
||
WUPSConfigAPIOptionsV1 configOptions = {.name = "Threads Viewer"}; | ||
if (WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback) != WUPSCONFIG_API_RESULT_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to init config api"); | ||
} | ||
|
||
WUPSStorageAPI_SaveStorage(false); | ||
|
||
deinitLogging(); | ||
} | ||
|
||
/** | ||
Gets called when the plugin will be unloaded. | ||
**/ | ||
DEINITIALIZE_PLUGIN() { | ||
DEBUG_FUNCTION_LINE("DEINITIALIZE_PLUGIN of threads_viewer!"); | ||
} | ||
|
||
/** | ||
Gets called when an application starts. | ||
**/ | ||
ON_APPLICATION_START() { | ||
initLogging(); | ||
|
||
DEBUG_FUNCTION_LINE("ON_APPLICATION_START of threads_viewer!"); | ||
} | ||
|
||
/** | ||
* Gets called when an application actually ends | ||
*/ | ||
ON_APPLICATION_ENDS() { | ||
deinitLogging(); | ||
} | ||
|
||
/** | ||
Gets called when an application request to exit. | ||
**/ | ||
ON_APPLICATION_REQUESTS_EXIT() { | ||
DEBUG_FUNCTION_LINE_INFO("ON_APPLICATION_REQUESTS_EXIT of threads_viewer!"); | ||
} |
Oops, something went wrong.