Skip to content

Commit

Permalink
Merge branch 'master' into development/awc-update
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaszm authored Oct 11, 2024
2 parents 8f90456 + 456ee8d commit 909e5ae
Show file tree
Hide file tree
Showing 29 changed files with 460 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Build Thunder on Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
Thunder:
uses: rdkcentral/Thunder/.github/workflows/Linux build template.yml@master
uses: rdkcentral/Thunder/.github/workflows/Linux build template.yml@development/actions-pep668-error # change back to master after Actions work again

ThunderInterfaces:
needs: Thunder
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/Linux build template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ jobs:
echo "deb http://archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
${{matrix.architecture == '32' && 'sudo dpkg --add-architecture i386' || ':'}}
sudo apt-get update
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev ${{matrix.architecture == '32' && 'zlib1g-dev:i386 libssl-dev:i386 libsbc-dev:i386 gcc-11-multilib g++-11-multilib' || 'zlib1g-dev libssl-dev libsbc-dev'}}
sudo pip install jsonref
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev ${{matrix.architecture == '32' && 'zlib1g-dev:i386 libssl-dev:i386 libsbc-dev:i386 gcc-13-multilib g++-13-multilib' || 'zlib1g-dev libssl-dev libsbc-dev'}}
python3 -m venv venv
source venv/bin/activate
pip install jsonref
# ----- Checkout & DependsOn regex -----
# --------- Thunder ----------
Expand Down Expand Up @@ -85,6 +87,7 @@ jobs:
# ----- Installing generators & Options regex -----
- name: Install generators
run: |
source venv/bin/activate
${{matrix.architecture == '32' && 'export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH' || 'PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH'}}
cmake -G Ninja -S ThunderTools -B ${{matrix.build_type}}/build/ThunderTools \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
Expand All @@ -104,6 +107,7 @@ jobs:
# ----- Building & uploading artifacts -----
- name: Build Thunder
run: |
source venv/bin/activate
${{matrix.architecture == '32' && 'export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH' || 'PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH'}}
cmake -G Ninja -S Thunder -B ${{matrix.build_type}}/build/Thunder \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/Test Thunder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ jobs:
sudo gem install apt-spy2
sudo apt-spy2 fix --commit --launchpad --country=US
sudo apt-get update
sudo apt install python3-pip
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev libgtest-dev
python3 -m venv venv
source venv/bin/activate
pip install jsonref
sudo apt install build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev libgtest-dev
# ----- Checkout & DependsOn Regex -----
# -------------- Thunder ---------------
Expand Down Expand Up @@ -98,12 +99,14 @@ jobs:
# ----- Building -----
- name: Install generators
run: |
source venv/bin/activate
cmake -G Ninja -S ThunderTools -B ${{matrix.build_type}}/build/ThunderTools \
-DCMAKE_INSTALL_PREFIX=${{matrix.build_type}}/install/usr
cmake --build ${{matrix.build_type}}/build/ThunderTools --target install
- name: Build Thunder
run: |
source venv/bin/activate
cmake -G Ninja -S Thunder -B ${{matrix.build_type}}/build/Thunder \
-DBINDING="127.0.0.1" \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
Expand Down
4 changes: 2 additions & 2 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Plugin {

static Core::ProxyPoolType<Web::TextBody> jsonBodyTextFactory(2);

void Controller::Callstack(const ThreadId id, Core::JSON::ArrayType<PluginHost::CallstackData>& response) const {
void Controller::Callstack(const Core::thread_id id, Core::JSON::ArrayType<PluginHost::CallstackData>& response) const {
std::list<Core::callstack_info> stackList;

::DumpCallStack(id, stackList);
Expand Down Expand Up @@ -1256,7 +1256,7 @@ namespace Plugin {

while (it.Next() == true) {
auto const& entry = it.Current();
threads.push_back({ entry.Id.Value(), entry.Job.Value(), entry.Runs.Value() });
threads.push_back({ PluginHost::Metadata::InstanceId(entry.Id.Value()), entry.Job.Value(), entry.Runs.Value() });
}

using Iterator = IMetadata::Data::IThreadsIterator;
Expand Down
2 changes: 1 addition & 1 deletion Source/Thunder/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace Plugin {
void WorkerPoolMetadata(PluginHost::Metadata::Server& data) const {
_pluginServer->WorkerPool().Snapshot(data);
}
void Callstack(const ThreadId id, Core::JSON::ArrayType<PluginHost::CallstackData>& response) const;
void Callstack(const Core::thread_id id, Core::JSON::ArrayType<PluginHost::CallstackData>& response) const;
void SubSystems();
uint32_t Clone(const string& basecallsign, const string& newcallsign);
void Proxies(Core::JSON::ArrayType<PluginHost::Metadata::COMRPC>& info) const;
Expand Down
11 changes: 4 additions & 7 deletions Source/Thunder/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,11 +889,8 @@ POP_WARNING()
printf("Pending: %d\n", static_cast<uint32_t>(metaData.Pending.size()));
printf("Poolruns:\n");
for (uint8_t index = 0; index < metaData.Slots; index++) {
#ifdef __APPLE__
printf(" Thread%02d|0x%16" PRIxPTR ": %10d", (index), reinterpret_cast<uintptr_t>(metaData.Slot[index].WorkerId), metaData.Slot[index].Runs);
#else
printf(" Thread%02d|0x%16lX: %10d", (index), metaData.Slot[index].WorkerId, metaData.Slot[index].Runs);
#endif
printf(" Thread%02d|0x%16" PRIu64 ": %10d", (index), static_cast<uint64_t>(Metadata::InstanceId(metaData.Slot[index].WorkerId)), metaData.Slot[index].Runs);

if (metaData.Slot[index].Job.IsSet() == false) {
printf("\n");
}
Expand Down Expand Up @@ -983,10 +980,10 @@ POP_WARNING()
case '7':
case '8':
case '9': {
ThreadId threadId = _dispatcher->WorkerPool().Id(keyPress - '0');
Core::thread_id threadId = _dispatcher->WorkerPool().Id(keyPress - '0');
printf("\nThreadPool thread[%c] callstack:\n", keyPress);
printf("============================================================\n");
if (threadId != (ThreadId)(~0)) {
if (threadId != (Core::thread_id)(~0)) {
uint8_t counter = 0;
std::list<Core::callstack_info> stackList;
::DumpCallStack(threadId, stackList);
Expand Down
9 changes: 3 additions & 6 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ namespace PluginHost {
};

public:
using Core::WorkerPool::Snapshot;

WorkerPoolImplementation() = delete;
WorkerPoolImplementation(WorkerPoolImplementation&&) = delete;
WorkerPoolImplementation(const WorkerPoolImplementation&) = delete;
Expand Down Expand Up @@ -4600,12 +4602,7 @@ namespace PluginHost {
while (index.Next() == true) {

std::list<Core::callstack_info> stackList;

#ifdef __APPLE__
::DumpCallStack(reinterpret_cast<ThreadId>(index.Current().Id.Value()), stackList);
#else
::DumpCallStack(static_cast<ThreadId>(index.Current().Id.Value()), stackList);
#endif
::DumpCallStack(PluginHost::Metadata::ThreadId(index.Current().Id.Value()), stackList);

PostMortemData::Callstack dump;
dump.Id = index.Current().Id.Value();
Expand Down
12 changes: 6 additions & 6 deletions Source/Thunder/PostMortem.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ namespace PluginHost {
}

public:
Core::JSON::Pointer Address;
Core::JSON::String Function;
Core::JSON::String Module;
Core::JSON::DecUInt32 Line;
Core::JSON::InstanceId Address;
Core::JSON::String Function;
Core::JSON::String Module;
Core::JSON::DecUInt32 Line;
};


Expand All @@ -123,7 +123,7 @@ namespace PluginHost {

Callstack()
: Core::JSON::Container()
, Id(0)
, Id()
, Data() {
Add(_T("id"), &Id);
Add(_T("stack"), &Data);
Expand All @@ -145,7 +145,7 @@ namespace PluginHost {
~Callstack() override = default;

public:
Core::JSON::Pointer Id;
Core::JSON::InstanceId Id;
Core::JSON::ArrayType<CallstackData> Data;
};

Expand Down
1 change: 0 additions & 1 deletion Source/core/JSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,6 @@ namespace Core {
typedef NumberType<int64_t, true, BASE_OCTAL> OctSInt64;

typedef NumberType<Core::instance_id, false, BASE_HEXADECIMAL> InstanceId;
typedef InstanceId Pointer;

template <class TYPE>
class FloatType : public IElement, public IMessagePack {
Expand Down
6 changes: 3 additions & 3 deletions Source/core/Portability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static void CallstackSignalHandler(int signr VARIABLE_IS_NOT_USED, siginfo_t* in
}
}

uint32_t GetCallStack(const ThreadId threadId, void* addresses[], const uint32_t bufferSize)
uint32_t GetCallStack(const Thunder::Core::thread_id threadId, void* addresses[], const uint32_t bufferSize)
{
uint32_t result = 0;

Expand All @@ -159,7 +159,7 @@ uint32_t GetCallStack(const ThreadId threadId, void* addresses[], const uint32_t
}
--result;
}
} else if (threadId != (::ThreadId)(~0)) {
} else if (threadId != (Thunder::Core::thread_id)(~0)) {
while (std::atomic_exchange_explicit(&g_lock, true, std::memory_order_acquire))
; // spin until acquired

Expand Down Expand Up @@ -196,7 +196,7 @@ uint32_t GetCallStack(const ThreadId threadId, void* addresses[], const uint32_t

extern "C" {

void DumpCallStack(const ThreadId threadId VARIABLE_IS_NOT_USED, std::list<Thunder::Core::callstack_info>& stackList VARIABLE_IS_NOT_USED)
void DumpCallStack(const Thunder::Core::thread_id threadId VARIABLE_IS_NOT_USED, std::list<Thunder::Core::callstack_info>& stackList VARIABLE_IS_NOT_USED)
{
#if defined(THUNDER_BACKTRACE)
void* callstack[32];
Expand Down
49 changes: 41 additions & 8 deletions Source/core/Portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
#define DISABLE_WARNING_DELETE_INCOMPLETE
#define DISABLE_WARNING_INCONSISTENT_MISSING_OVERRIDE
#define DISABLE_WARNING_MAYBE_UNINITIALIZED
#define DISABLE_WARNING_FREE_NONHEAP_OBJECT

#else
#define DISABLE_WARNING_CONDITIONAL_EXPRESSION_IS_CONSTANT
Expand Down Expand Up @@ -221,6 +222,7 @@
#define DISABLE_WARNING_DELETE_INCOMPLETE PUSH_WARNING_ARG_("-Wdelete-incomplete")
#define DISABLE_WARNING_INCONSISTENT_MISSING_OVERRIDE PUSH_WARNING_ARG_("-Winconsistent-missing-override")
#define DISABLE_WARNING_MAYBE_UNINITIALIZED PUSH_WARNING_ARG_("-Wmaybe-uninitialized")
#define DISABLE_WARNING_FREE_NONHEAP_OBJECT PUSH_WARNING_ARG_("-Wfree-nonheap-object")
#endif
#endif

Expand Down Expand Up @@ -359,6 +361,20 @@ typedef std::string string;
//const std::basic_string<char>::size_type std::basic_string<char>::npos = (std::basic_string<char>::size_type) - 1;
//#endif

// NTQuerySemaphore (undocumented) is used to retrieve current count of a semaphore
using NTSTATUS = LONG;
using _NTQuerySemaphore = NTSTATUS(NTAPI*)(
HANDLE SemaphoreHandle,
DWORD SemaphoreInformationClass,
PVOID SemaphoreInformation,
ULONG SemaphoreInformationLength,
PULONG ReturnLength OPTIONAL
);
struct SEMAPHORE_BASIC_INFORMATION {
ULONG CurrentCount;
ULONG MaximumCount;
};

#define LITTLE_ENDIAN_PLATFORM 1
#undef ERROR
#define __WINDOWS__
Expand All @@ -385,6 +401,7 @@ typedef std::string string;
#include <typeinfo>
#include <cmath>
#include <thread>
#include <limits.h>

#include <string.h>
#include <termios.h>
Expand Down Expand Up @@ -412,9 +429,24 @@ typedef std::string string;
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h> // memfd_create in Messaging/ConsoleRedirect.h
#include <sys/inotify.h>

#include <arpa/inet.h>

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#include <features.h>
#ifndef __USE_GNU
#define __MUSL__
#endif
#undef _GNU_SOURCE /* don't contaminate other includes unnecessarily */
#else
#include <features.h>
#ifndef __USE_GNU
#define __MUSL__
#endif
#endif

#ifdef __APPLE__
#include <pthread_impl.h>
#define SCHED_BATCH 99
Expand Down Expand Up @@ -679,12 +711,6 @@ typedef std::string string;
#define STRLEN(STATIC_TEXT) ((sizeof(STATIC_TEXT) / sizeof(TCHAR)) - 1)
#define EMPTY_STRING _T("")

#ifdef __LINUX__
typedef pthread_t ThreadId;
#else
typedef DWORD ThreadId;
#endif

#define QUOTE(str) #str
#define EXPAND_AND_QUOTE(str) QUOTE(str)

Expand Down Expand Up @@ -717,6 +743,12 @@ namespace Core {
#endif
#endif

#ifdef __LINUX__
typedef pthread_t thread_id;
#else
typedef DWORD thread_id;
#endif

typedef uint32_t hresult;

struct callstack_info {
Expand Down Expand Up @@ -990,8 +1022,9 @@ EXTERNAL extern int inet_aton(const char* cp, struct in_addr* inp);
EXTERNAL extern void usleep(const uint32_t value);
#endif

EXTERNAL void DumpCallStack(const ThreadId threadId, std::list<Thunder::Core::callstack_info>& stack);
EXTERNAL uint32_t GetCallStack(const ThreadId threadId, void* addresses[], const uint32_t bufferSize);
EXTERNAL void DumpCallStack(const Thunder::Core::thread_id threadId, std::list<Thunder::Core::callstack_info>& stack);
EXTERNAL uint32_t GetCallStack(const Thunder::Core::thread_id threadId, void* addresses[], const uint32_t bufferSize);

}


Expand Down
12 changes: 6 additions & 6 deletions Source/core/ProcessInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,30 +686,30 @@ namespace Core {
EnumerateChildProcesses(processInfo, _processes);
}

bool ProcessTree::ContainsProcess(ThreadId pid) const
bool ProcessTree::ContainsProcess(thread_id pid) const
{
PUSH_WARNING(DISABLE_WARNING_CONVERSION_TO_GREATERSIZE)
auto comparator = [pid](const ProcessInfo& processInfo) { return ((ThreadId)(processInfo.Id()) == pid); };
auto comparator = [pid](const ProcessInfo& processInfo) { return ((thread_id)(processInfo.Id()) == pid); };
POP_WARNING()
std::list<ProcessInfo>::const_iterator i = std::find_if(_processes.cbegin(), _processes.cend(), comparator);
return (i != _processes.cend());
}

void ProcessTree::GetProcessIds(std::list<ThreadId>& processIds) const
void ProcessTree::GetProcessIds(std::list<thread_id>& processIds) const
{
processIds.clear();

for (const ProcessInfo& process : _processes) {
PUSH_WARNING(DISABLE_WARNING_CONVERSION_TO_GREATERSIZE)
processIds.push_back((ThreadId)(process.Id()));
processIds.push_back((thread_id)(process.Id()));
POP_WARNING()
}
}

ThreadId ProcessTree::RootId() const
thread_id ProcessTree::RootId() const
{
PUSH_WARNING(DISABLE_WARNING_CONVERSION_TO_GREATERSIZE)
return (ThreadId)(_processes.front().Id());
return (thread_id)(_processes.front().Id());
POP_WARNING()
}

Expand Down
6 changes: 3 additions & 3 deletions Source/core/ProcessInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ namespace Core {
public:
explicit ProcessTree(const ProcessInfo& processInfo);

bool ContainsProcess(ThreadId pid) const;
void GetProcessIds(std::list<ThreadId>& processIds) const;
ThreadId RootId() const;
bool ContainsProcess(thread_id pid) const;
void GetProcessIds(std::list<thread_id>& processIds) const;
thread_id RootId() const;

private:
std::list<ProcessInfo> _processes;
Expand Down
6 changes: 4 additions & 2 deletions Source/core/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ namespace Thunder {
void* stAllocateBlock)
{
reinterpret_cast<ProxyObject<CONTEXT>*>(stAllocateBlock)->__Destructed();
PUSH_WARNING(DISABLE_WARNING_FREE_NONHEAP_OBJECT)
::free(stAllocateBlock);
POP_WARNING()
}

public:
Expand Down Expand Up @@ -539,11 +541,11 @@ POP_WARNING()
{
return (!operator==(a_RHS));
}
inline bool operator==(const nullptr_t&) const
inline bool operator==(const std::nullptr_t&) const
{
return (_refCount == nullptr);
}
inline bool operator!=(const nullptr_t&) const
inline bool operator!=(const std::nullptr_t&) const
{
return (_refCount != nullptr);
}
Expand Down
Loading

0 comments on commit 909e5ae

Please sign in to comment.