Skip to content

Update for 0.15.x, update tracy to 0.12.4 #9

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
35 changes: 18 additions & 17 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pub fn build(b: *std.Build) void {
if (options.callstack > 0) {
translate_c.defineCMacro("TRACY_USE_CALLSTACK", "");
var callstack_buffer: [64]u8 = undefined;
const callstack = std.fmt.bufPrintIntToSlice(&callstack_buffer, @as(u32, options.callstack), 10, .lower, .{});
translate_c.defineCMacro("TRACY_CALLSTACK", callstack);
const callstack_str_len = std.fmt.printInt(&callstack_buffer, @as(u32, options.callstack), 10, .lower, .{});
translate_c.defineCMacro("TRACY_CALLSTACK", callstack_buffer[0..callstack_str_len]);
}

const ztracy = b.addModule("root", .{
Expand All @@ -63,30 +63,29 @@ pub fn build(b: *std.Build) void {
});
ztracy.addImport("c", translate_c.createModule());

const tracy = if (options.shared) blk: {
const lib = b.addSharedLibrary(.{
.name = "tracy",
const tracy = b.addLibrary(.{
.name = "tracy",
.linkage = if (options.shared) .dynamic else .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
});
lib.root_module.addCMacro("TRACY_EXPORTS", "");
break :blk lib;
} else b.addStaticLibrary(.{
.name = "tracy",
.target = target,
.optimize = optimize,
}),
});

if (options.shared) {
tracy.root_module.addCMacro("TRACY_EXPORTS", "");
}

tracy.addIncludePath(b.path("libs/tracy/tracy"));
tracy.addCSourceFile(.{
.file = b.path("libs/tracy/TracyClient.cpp"),
.flags = &.{
if (options.enable_ztracy) "-DTRACY_ENABLE" else "",
if (options.enable_fibers) "-DTRACY_FIBERS" else "",
"-fno-sanitize=undefined",
},
});

if (options.enable_ztracy) tracy.root_module.addCMacro("TRACY_ENABLE", "");
if (options.enable_fibers) tracy.root_module.addCMacro("TRACY_FIBERS", "");
if (options.on_demand) tracy.root_module.addCMacro("TRACY_ON_DEMAND", "");

tracy.linkLibC();
Expand Down Expand Up @@ -115,9 +114,11 @@ pub fn build(b: *std.Build) void {

const tests = b.addTest(.{
.name = "ztracy-tests",
.root_source_file = b.path("src/ztracy.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/ztracy.zig"),
.target = target,
.optimize = optimize,
}),
});
tests.linkLibrary(tracy);
b.installArtifact(tests);
Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.name = .ztracy,
.fingerprint = 0xf803f1f7ab5272cc,
.version = "0.14.0-dev",
.minimum_zig_version = "0.14.0",
.version = "0.15.0-dev",
.minimum_zig_version = "0.15.0-dev.1230+cf9db9c7b",
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
4 changes: 4 additions & 0 deletions libs/tracy/TracyClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "client/TracyOverride.cpp"
#include "client/TracyKCore.cpp"

#ifdef TRACY_ROCPROF
# include "client/TracyRocprof.cpp"
#endif

#if defined(TRACY_HAS_CALLSTACK)
# if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
# include "libbacktrace/alloc.cpp"
Expand Down
9 changes: 7 additions & 2 deletions libs/tracy/client/TracyCallstack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ extern "C"
t_SymFromInlineContext _SymFromInlineContext = 0;
t_SymGetLineFromInlineContext _SymGetLineFromInlineContext = 0;

TRACY_API ___tracy_t_RtlWalkFrameChain ___tracy_RtlWalkFrameChain = 0;
typedef unsigned long (__stdcall *___tracy_t_RtlWalkFrameChain)( void**, unsigned long, unsigned long );
___tracy_t_RtlWalkFrameChain ___tracy_RtlWalkFrameChainPtr = nullptr;
TRACY_API unsigned long ___tracy_RtlWalkFrameChain( void** callers, unsigned long count, unsigned long flags)
{
return ___tracy_RtlWalkFrameChainPtr(callers, count, flags);
}
}

struct ModuleCache
Expand All @@ -307,7 +312,7 @@ size_t s_krnlCacheCnt;

void InitCallstackCritical()
{
___tracy_RtlWalkFrameChain = (___tracy_t_RtlWalkFrameChain)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlWalkFrameChain" );
___tracy_RtlWalkFrameChainPtr = (___tracy_t_RtlWalkFrameChain)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlWalkFrameChain" );
}

void DbgHelpInit()
Expand Down
4 changes: 2 additions & 2 deletions libs/tracy/client/TracyCallstack.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# endif

# if defined _WIN32
# include "../common/TracyUwp.hpp"
# ifndef TRACY_UWP
# include "../common/TracyWinFamily.hpp"
# if !defined TRACY_WIN32_NO_DESKTOP
# define TRACY_HAS_CALLSTACK 1
# endif
# elif defined __ANDROID__
Expand Down
14 changes: 8 additions & 6 deletions libs/tracy/client/TracyCallstack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace tracy
{
static tracy_force_inline void* Callstack( int /*depth*/ ) { return nullptr; }
static constexpr bool has_callstack() { return false; }
static tracy_force_inline void* Callstack( int32_t /*depth*/ ) { return nullptr; }
}

#else
Expand Down Expand Up @@ -38,6 +39,8 @@ static tracy_force_inline void* Callstack( int /*depth*/ ) { return nullptr; }
namespace tracy
{

static constexpr bool has_callstack() { return true; }

struct CallstackSymbolData
{
const char* file;
Expand Down Expand Up @@ -79,11 +82,10 @@ debuginfod_client* GetDebuginfodClient();

extern "C"
{
typedef unsigned long (__stdcall *___tracy_t_RtlWalkFrameChain)( void**, unsigned long, unsigned long );
TRACY_API extern ___tracy_t_RtlWalkFrameChain ___tracy_RtlWalkFrameChain;
TRACY_API unsigned long ___tracy_RtlWalkFrameChain( void**, unsigned long, unsigned long );
}

static tracy_force_inline void* Callstack( int depth )
static tracy_force_inline void* Callstack( int32_t depth )
{
assert( depth >= 1 && depth < 63 );
auto trace = (uintptr_t*)tracy_malloc( ( 1 + depth ) * sizeof( uintptr_t ) );
Expand Down Expand Up @@ -112,7 +114,7 @@ static _Unwind_Reason_Code tracy_unwind_callback( struct _Unwind_Context* ctx, v
return _URC_NO_REASON;
}

static tracy_force_inline void* Callstack( int depth )
static tracy_force_inline void* Callstack( int32_t depth )
{
assert( depth >= 1 && depth < 63 );

Expand All @@ -127,7 +129,7 @@ static tracy_force_inline void* Callstack( int depth )

#elif TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6

static tracy_force_inline void* Callstack( int depth )
static tracy_force_inline void* Callstack( int32_t depth )
{
assert( depth >= 1 );

Expand Down
6 changes: 4 additions & 2 deletions libs/tracy/client/TracyLock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ class Lockable
m_ctx.CustomName( name, size );
}

private:
T m_lockable;

private:
LockableCtx m_ctx;
};

Expand Down Expand Up @@ -535,8 +536,9 @@ class SharedLockable
m_ctx.CustomName( name, size );
}

private:
T m_lockable;

private:
SharedLockableCtx m_ctx;
};

Expand Down
Loading
Loading