Skip to content

Commit e2b2cb8

Browse files
committed
CDB and WER integration, more logs, PCH and some minor updates
1 parent 207aac0 commit e2b2cb8

File tree

4 files changed

+127
-35
lines changed

4 files changed

+127
-35
lines changed

smoke/CMakeLists.txt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ add_compile_options(
6363
$<$<CONFIG:Debug,RelWithDebInfo>:/GF>
6464
)
6565

66+
set(CMAKE_SYSTEM_VERSION 10.0)
67+
6668
project(NablaSmoke CXX)
67-
add_executable(smoke main.cpp)
69+
add_executable(smoke main.cpp pch.hpp cdb.ps1)
6870
target_link_libraries(smoke PRIVATE Nabla)
71+
target_precompile_headers(smoke PRIVATE pch.hpp)
6972

70-
set(CMAKE_CTEST_ARGUMENTS --output-on-failure)
73+
set(CMAKE_CTEST_ARGUMENTS --verbose)
7174
enable_testing()
7275

7376
set(OPTS
@@ -76,7 +79,23 @@ set(OPTS
7679
NBL_INSTALL_DIRECTORY=${NBL_INSTALL_PREFIX}
7780
)
7881

79-
add_test(NAME NBL_INSTALL_LOAD_API
80-
COMMAND "$<TARGET_FILE:smoke>"
81-
)
82+
option(ENABLE_CRASH_HANDLER "Enable crash handler" ON)
83+
84+
if(WIN32)
85+
if(ENABLE_CRASH_HANDLER)
86+
set(CMD
87+
powershell -NoProfile -ExecutionPolicy Bypass
88+
-File "$<SHELL_PATH:${CMAKE_CURRENT_LIST_DIR}/cdb.ps1>"
89+
-Exe "$<TARGET_FILE:smoke>"
90+
)
91+
endif()
92+
endif()
93+
94+
if(NOT ENABLE_CRASH_HANDLER)
95+
set(CMD
96+
"$<TARGET_FILE:smoke>"
97+
)
98+
endif()
99+
100+
add_test(NAME NBL_INSTALL_LOAD_API COMMAND ${CMD})
82101
set_tests_properties(NBL_INSTALL_LOAD_API PROPERTIES ENVIRONMENT "${OPTS}")

smoke/cdb.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$Exe,
3+
[string]$cdb = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe"
4+
)
5+
6+
$scriptDir = Split-Path -Parent $PSCommandPath
7+
8+
if (-not (Test-Path $Exe)) {
9+
Write-Host "Error: File $Exe does not exist!" -ForegroundColor Red
10+
exit -2
11+
}
12+
if (-not (Test-Path $cdb)) {
13+
Write-Host "Error: cdb not found at $cdb" -ForegroundColor Red
14+
exit -2
15+
}
16+
17+
$p = Start-Process -FilePath $Exe -NoNewWindow -Wait -PassThru
18+
$exitCode = $p.ExitCode
19+
20+
if ($exitCode -eq 0) {
21+
Write-Host "Application exited with code 0 (success)" -ForegroundColor Green
22+
exit 0
23+
}
24+
25+
Write-Host "Application exited with code $exitCode (crash)" -ForegroundColor Red
26+
Write-Host "Re-running with CDB attached!" -ForegroundColor Cyan
27+
28+
$dumpFile = "$env:TEMP\$name.dmp"
29+
30+
if (Test-Path $dumpFile) {
31+
Remove-Item $dumpFile -Force
32+
}
33+
34+
& $cdb -lines -y srv* -c "sxn ld; g; !analyze -v; lm v; kp; .dump /ma $dumpFile; q" $Exe | Out-Host
35+
Write-Host "Process execution completed" -ForegroundColor Yellow
36+
37+
$exeName = [IO.Path]::GetFileName($Exe)
38+
$werPaths = @(
39+
"$env:PROGRAMDATA\Microsoft\Windows\WER",
40+
"$env:LOCALAPPDATA\Microsoft\Windows\WER"
41+
)
42+
43+
$lastWer = Get-ChildItem $werPaths -Recurse -Filter Report.wer -ErrorAction SilentlyContinue |
44+
Sort-Object LastWriteTime -Descending |
45+
Where-Object { Select-String -Path $_.FullName -SimpleMatch $exeName -Quiet } |
46+
Select-Object -First 1
47+
48+
if ($lastWer) {
49+
Write-Host "WER report for ${exeName}:" -ForegroundColor Cyan
50+
Get-Content $lastWer.FullName | Out-Host
51+
} else {
52+
Write-Host "Could not find last WER report for $exeName" -ForegroundColor DarkYellow
53+
}
54+
55+
exit -1

smoke/main.cpp

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
1-
#include <nabla.h>
2-
#include "nbl/system/IApplicationFramework.h"
3-
4-
#include <iostream>
5-
#include <cstdlib>
6-
#include <string>
7-
#include <algorithm>
1+
#define ENABLE_SMOKE
82

93
using namespace nbl;
104
using namespace nbl::system;
115
using namespace nbl::core;
126
using namespace nbl::asset;
137

8+
#ifdef ENABLE_SMOKE
9+
1410
class Smoke final : public system::IApplicationFramework
1511
{
16-
using base_t = system::IApplicationFramework;
12+
using base_t = system::IApplicationFramework;
1713

1814
public:
19-
using base_t::base_t;
20-
21-
bool onAppInitialized(smart_refctd_ptr<ISystem>&& system) override
22-
{
23-
const auto argc = argv.size();
24-
25-
if (isAPILoaded())
26-
{
27-
std::cout << "Loaded Nabla API";
28-
}
29-
else
30-
{
31-
std::cerr << "Could not load Nabla API, terminating!";
32-
return false;
33-
}
34-
35-
return true;
36-
}
37-
38-
void workLoopBody() override {}
39-
40-
bool keepRunning() override { return false; }
15+
using base_t::base_t;
16+
17+
bool onAppInitialized(smart_refctd_ptr<ISystem>&& system) override
18+
{
19+
const char* sdk = std::getenv("NBL_INSTALL_DIRECTORY");
20+
21+
if (sdk)
22+
{
23+
auto dir = std::filesystem::absolute(std::filesystem::path(sdk).make_preferred()).string();
24+
std::cout << "[INFO]: NBL_INSTALL_DIRECTORY = \"" << dir.c_str() << "\"\n";
25+
}
26+
else
27+
std::cerr << "[INFO]: NBL_INSTALL_DIRECTORY env was not defined!\n";
28+
29+
if (isAPILoaded())
30+
{
31+
std::cout << "[INFO]: Loaded Nabla API\n";
32+
}
33+
else
34+
{
35+
std::cerr << "[ERROR]: Could not load Nabla API, terminating!\n";
36+
return false;
37+
}
38+
39+
return true;
40+
}
41+
42+
void workLoopBody() override {}
43+
bool keepRunning() override { return false; }
4144
};
4245

4346
NBL_MAIN_FUNC(Smoke)
47+
#else
48+
int main() { return 0; }
49+
#endif

smoke/pch.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef SMOKE_PCH_HPP
2+
#define SMOKE_PCH_HPP
3+
4+
#include <nabla.h>
5+
#include <nbl/system/IApplicationFramework.h>
6+
7+
#include <iostream>
8+
#include <cstdlib>
9+
#include <string>
10+
#include <algorithm>
11+
12+
#endif // SMOKE_PCH_HPP

0 commit comments

Comments
 (0)