Skip to content

raddbg UI running in some frankenstein state in X11 and opengl after a weekend of prompts with gemini 2.5 pro exp #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if [ -v debug ]; then echo "[debug mode]"; fi
if [ -v release ]; then echo "[release mode]"; fi
if [ -v clang ]; then compiler="${CC:-clang}"; echo "[clang compile]"; fi
if [ -v gcc ]; then compiler="${CC:-gcc}"; echo "[gcc compile]"; fi
if [ -v asan ]; then echo "[AddressSanitizer enabled]"; fi


# --- Unpack Command Line Build Arguments -------------------------------------
auto_compile_flags=''
Expand All @@ -19,24 +21,35 @@ git_hash=$(git rev-parse HEAD)
git_hash_full=$(git rev-parse HEAD)

# --- Compile/Link Line Definitions -------------------------------------------
clang_common="-I../src/ -I../local/ -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf"
# AddressSanitizer flags
asan_flags=""
if [ -v asan ]; then
asan_flags="-fsanitize=address -fno-omit-frame-pointer"
fi

clang_common="-I../src/ -I../local/ -I/usr/include/freetype2 -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -ferror-limit=1000000 $asan_flags"
clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}"
clang_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${clang_common} ${auto_compile_flags}"
clang_link="-lpthread -lm -lrt -ldl"
clang_link="-lpthread -lm -lrt -ldl -lfreetype"
clang_out="-o"
gcc_common="-I../src/ -I../local/ -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf"
gcc_common="-I../src/ -I../local/ -I/usr/include/freetype2 -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf $asan_flags"
gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common} ${auto_compile_flags}"
gcc_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${gcc_common} ${auto_compile_flags}"
gcc_link="-lpthread -lm -lrt -ldl"
gcc_link="-lpthread -lm -lrt -ldl -lfreetype"
gcc_out="-o"

# Version without ASan for metagen
clang_common_no_asan="-I../src/ -I../local/ -I/usr/include/freetype2 -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -ferror-limit=1000000"
gcc_common_no_asan="-I../src/ -I../local/ -I/usr/include/freetype2 -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf"

# --- Per-Build Settings ------------------------------------------------------
link_dll="-fPIC"
link_os_gfx="-lX11 -lXext"
link_os_gfx="-lX11 -lXext -lXrandr -lGL -lGLEW"
link_agent="-lcurl"

# --- Choose Compile/Link Lines -----------------------------------------------
if [ -v gcc ]; then compile_debug="$gcc_debug"; fi
if [ -v gcc ]; then compile_release="$gcc_release"; fi
if [ -v gcc ]; then compile_debug="$gcc_debug -I/usr/local/include"; fi
if [ -v gcc ]; then compile_release="$gcc_release -I/usr/local/include"; fi
if [ -v gcc ]; then compile_link="$gcc_link"; fi
if [ -v gcc ]; then out="$gcc_out"; fi
if [ -v clang ]; then compile_debug="$clang_debug"; fi
Expand All @@ -46,6 +59,10 @@ if [ -v clang ]; then out="$clang_out"; fi
if [ -v debug ]; then compile="$compile_debug"; fi
if [ -v release ]; then compile="$compile_release"; fi

# Define special compiler flags for metagen (without ASan)
if [ -v gcc ]; then compile_metagen="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common_no_asan} ${auto_compile_flags} -I/usr/local/include"; fi
if [ -v clang ]; then compile_metagen="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common_no_asan} ${auto_compile_flags}"; fi

# --- Prep Directories --------------------------------------------------------
mkdir -p build
mkdir -p local
Expand All @@ -69,6 +86,16 @@ if [ -v rdi_from_dwarf ]; then didbuild=1 && $compile ../src/rdi_from_dwa
if [ -v rdi_dump ]; then didbuild=1 && $compile ../src/rdi_dump/rdi_dump_main.c $compile_link $out rdi_dump; fi
if [ -v rdi_breakpad_from_pdb ]; then didbuild=1 && $compile ../src/rdi_breakpad_from_pdb/rdi_breakpad_from_pdb_main.c $compile_link $out rdi_breakpad_from_pdb; fi
if [ -v ryan_scratch ]; then didbuild=1 && $compile ../src/scratch/ryan_scratch.c $compile_link $link_os_gfx $out ryan_scratch; fi
if [ -v whatsapp ]; then didbuild=1 && $compile ../src/whatsapp/whatsapp.c $compile_link $out whatsapp; fi
if [ -v agent ]; then didbuild=1 && $compile ../src/agent/agent.c $compile_link $link_agent $out agent; fi
if [ -v browser ]; then didbuild=1 && $compile ../src/browser/browser.c $compile_link $out browser; fi
if [ -v cad ]; then didbuild=1 && $compile ../src/cad/cad.c $compile_link $out cad; fi
if [ -v daw ]; then didbuild=1 && $compile ../src/daw/daw.c $compile_link $out daw; fi
if [ -v editor ]; then didbuild=1 && $compile ../src/editor/editor.c $compile_link $out editor; fi
if [ -v mail ]; then didbuild=1 && $compile ../src/mail/mail.c $compile_link $out mail; fi
if [ -v paint ]; then didbuild=1 && $compile ../src/paint/paint.c $compile_link $out paint; fi
if [ -v stockitup ]; then didbuild=1 && $compile ../src/stockitup/stockitup.c $compile_link $out stockitup; fi
if [ -v terminal ]; then didbuild=1 && $compile ../src/terminal/terminal.c $compile_link $out terminal; fi
cd ..

# --- Warn On No Builds -------------------------------------------------------
Expand Down
130 changes: 65 additions & 65 deletions src/base/base_log.h
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_LOG_H
#define BASE_LOG_H
////////////////////////////////
//~ rjf: Log Types
typedef enum LogMsgKind
{
LogMsgKind_Info,
LogMsgKind_UserError,
LogMsgKind_COUNT
}
LogMsgKind;
typedef struct LogScope LogScope;
struct LogScope
{
LogScope *next;
U64 pos;
String8List strings[LogMsgKind_COUNT];
};
typedef struct LogScopeResult LogScopeResult;
struct LogScopeResult
{
String8 strings[LogMsgKind_COUNT];
};
typedef struct Log Log;
struct Log
{
Arena *arena;
LogScope *top_scope;
};
////////////////////////////////
//~ rjf: Log Creation/Selection
internal Log *log_alloc(void);
internal void log_release(Log *log);
internal void log_select(Log *log);
////////////////////////////////
//~ rjf: Log Building
internal void log_msg(LogMsgKind kind, String8 string);
internal void log_msgf(LogMsgKind kind, char *fmt, ...);
#define log_info(s) log_msg(LogMsgKind_Info, (s))
#define log_infof(fmt, ...) log_msgf(LogMsgKind_Info, (fmt), __VA_ARGS__)
#define log_user_error(s) log_msg(LogMsgKind_UserError, (s))
#define log_user_errorf(fmt, ...) log_msgf(LogMsgKind_UserError, (fmt), __VA_ARGS__)
#define LogInfoNamedBlock(s) DeferLoop(log_infof("%S:\n{\n", (s)), log_infof("}\n"))
#define LogInfoNamedBlockF(fmt, ...) DeferLoop((log_infof(fmt, __VA_ARGS__), log_infof(":\n{\n")), log_infof("}\n"))
////////////////////////////////
//~ rjf: Log Scopes
internal void log_scope_begin(void);
internal LogScopeResult log_scope_end(Arena *arena);
#endif // BASE_LOG_H
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)

#ifndef BASE_LOG_H
#define BASE_LOG_H

////////////////////////////////
//~ rjf: Log Types

typedef enum LogMsgKind
{
LogMsgKind_Info,
LogMsgKind_UserError,
LogMsgKind_COUNT
}
LogMsgKind;

typedef struct LogScope LogScope;
struct LogScope
{
LogScope *next;
U64 pos;
String8List strings[LogMsgKind_COUNT];
};

typedef struct LogScopeResult LogScopeResult;
struct LogScopeResult
{
String8 strings[LogMsgKind_COUNT];
};

typedef struct Log Log;
struct Log
{
Arena *arena;
LogScope *top_scope;
};

////////////////////////////////
//~ rjf: Log Creation/Selection

internal Log *log_alloc(void);
internal void log_release(Log *log);
internal void log_select(Log *log);

////////////////////////////////
//~ rjf: Log Building

internal void log_msg(LogMsgKind kind, String8 string);
internal void log_msgf(LogMsgKind kind, char *fmt, ...);
#define log_info(s) log_msg(LogMsgKind_Info, (s))
#define log_infof(fmt, ...) log_msgf(LogMsgKind_Info, (fmt), ##__VA_ARGS__)
#define log_user_error(s) log_msg(LogMsgKind_UserError, (s))
#define log_user_errorf(fmt, ...) log_msgf(LogMsgKind_UserError, (fmt), ##__VA_ARGS__)

#define LogInfoNamedBlock(s) DeferLoop(log_infof("%S:\n{\n", (s)), log_infof("}\n"))
#define LogInfoNamedBlockF(fmt, ...) DeferLoop((log_infof(fmt, ##__VA_ARGS__), log_infof(":\n{\n")), log_infof("}\n"))

////////////////////////////////
//~ rjf: Log Scopes

internal void log_scope_begin(void);
internal LogScopeResult log_scope_end(Arena *arena);

#endif // BASE_LOG_H
14 changes: 14 additions & 0 deletions src/base/base_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ mul_4x4f32(Mat4x4F32 a, Mat4x4F32 b)
return c;
}

internal Mat4x4F32
transpose_4x4f32(Mat4x4F32 m)
{
Mat4x4F32 result;
for(int j = 0; j < 4; j += 1)
{
for(int i = 0; i < 4; i += 1)
{
result.v[i][j] = m.v[j][i];
}
}
return result;
}

internal Mat4x4F32
scale_4x4f32(Mat4x4F32 m, F32 scale)
{
Expand Down
1 change: 1 addition & 0 deletions src/base/base_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ internal Mat4x4F32 make_orthographic_4x4f32(F32 left, F32 right, F32 bottom, F32
internal Mat4x4F32 make_look_at_4x4f32(Vec3F32 eye, Vec3F32 center, Vec3F32 up);
internal Mat4x4F32 make_rotate_4x4f32(Vec3F32 axis, F32 turns);
internal Mat4x4F32 mul_4x4f32(Mat4x4F32 a, Mat4x4F32 b);
internal Mat4x4F32 transpose_4x4f32(Mat4x4F32 m);
internal Mat4x4F32 scale_4x4f32(Mat4x4F32 m, F32 scale);
internal Mat4x4F32 inverse_4x4f32(Mat4x4F32 m);
internal Mat4x4F32 derotate_4x4f32(Mat4x4F32 mat);
Expand Down
Loading