mirror of
https://github.com/diamante0018/MonitorRam.git
synced 2025-05-09 05:54:54 +00:00
feat: ultimate dev container
This commit is contained in:
parent
81c509081f
commit
1f63f81979
55
.devcontainer/Dockerfile
Normal file
55
.devcontainer/Dockerfile
Normal file
@ -0,0 +1,55 @@
|
||||
FROM ubuntu:noble
|
||||
|
||||
# Official workaround for "groupadd: GID '1000' already exists"
|
||||
RUN userdel -r ubuntu
|
||||
|
||||
# Set non-interactive mode for apt-get
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install basic dependencies for compilation
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
gcc \
|
||||
gcc-multilib \
|
||||
g++-multilib \
|
||||
make \
|
||||
wget \
|
||||
unzip \
|
||||
git \
|
||||
gdb \
|
||||
libc6-dbg \
|
||||
valgrind \
|
||||
strace \
|
||||
clang-format \
|
||||
python3 python3-pip python3-venv \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a virtual environment and install colour-valgrind
|
||||
RUN python3 -m venv /opt/venv && \
|
||||
/opt/venv/bin/pip install colour-valgrind
|
||||
|
||||
# Add the virtual environment to PATH for all users
|
||||
ENV PATH="/opt/venv/bin:$PATH"
|
||||
|
||||
# Download and install Premake5
|
||||
RUN wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-linux.tar.gz \
|
||||
&& tar -xvf premake-5.0.0-beta5-linux.tar.gz \
|
||||
&& mv premake5 /usr/local/bin/ \
|
||||
&& chmod +x /usr/local/bin/premake5 \
|
||||
&& rm premake-5.0.0-beta5-linux.tar.gz
|
||||
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
|
||||
# Create the user
|
||||
RUN groupadd --gid $USER_GID $USERNAME \
|
||||
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
||||
#
|
||||
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
|
||||
&& apt-get update \
|
||||
&& apt-get install -y sudo \
|
||||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
||||
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
||||
|
||||
USER $USERNAME
|
32
.devcontainer/devcontainer.json
Normal file
32
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "MonitorRam Dev Container",
|
||||
"build": {
|
||||
"context": "..",
|
||||
"dockerfile": "./Dockerfile"
|
||||
},
|
||||
"capAdd": [
|
||||
"SYS_PTRACE"
|
||||
],
|
||||
"securityOpt": [
|
||||
"seccomp=unconfined"
|
||||
],
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
],
|
||||
"settings": {
|
||||
"C_Cpp.clang_format_style": "file",
|
||||
"C_Cpp.formatting": "clangFormat",
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"runArgs": [
|
||||
"--network=host"
|
||||
],
|
||||
"forwardPorts": [
|
||||
3000
|
||||
],
|
||||
"remoteUser": "vscode"
|
||||
}
|
51
.vscode/launch.json
vendored
Normal file
51
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "GDB Debug (Debug Build)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/bin/x64/Debug/MonitorRam",
|
||||
"args": [
|
||||
""
|
||||
], // Arguments to pass to your program
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "/usr/bin/gdb", // Path to gdb inside the container
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "build-debug" // Task to build the Debug version
|
||||
},
|
||||
{
|
||||
"name": "GDB Debug (Release Build)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/bin/x64/Release/MonitorRam",
|
||||
"args": [
|
||||
""
|
||||
], // Arguments to pass to your program
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "/usr/bin/gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "build-release" // Task to build the Release version
|
||||
}
|
||||
]
|
||||
}
|
54
.vscode/tasks.json
vendored
Normal file
54
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "generate-makefiles",
|
||||
"type": "shell",
|
||||
"command": "premake5",
|
||||
"args": [
|
||||
"gmake"
|
||||
], // Generate Makefiles
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "build-debug",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"args": [
|
||||
"-C",
|
||||
"build",
|
||||
"config=debug_x64"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"dependsOn": "generate-makefiles"
|
||||
},
|
||||
{
|
||||
"label": "build-release",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"args": [
|
||||
"-C",
|
||||
"build",
|
||||
"config=release_x64"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"dependsOn": "generate-makefiles"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common.h"
|
||||
@ -19,7 +20,12 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(act));
|
||||
|
||||
act.sa_handler = sigint_handler;
|
||||
sigemptyset(&act.sa_mask); // Initialize the signal mask to empty
|
||||
act.sa_flags = 0; // Set flags to 0
|
||||
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
|
||||
int result = setup(argv[1]);
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@ -108,6 +109,13 @@ static int is_process_wild(int curr_real_mem, int peak_real_mem,
|
||||
}
|
||||
|
||||
int setup(const char* pid) {
|
||||
assert(pid);
|
||||
|
||||
if (*pid == '\0') {
|
||||
printf("Invalid PID\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(&processes, 0, sizeof(processes));
|
||||
|
||||
char* command = va("pgrep %s", pid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user