mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
native: fix missing symbols CaptureStackBackTrace and __debugbreak (#23765)
This commit is contained in:
parent
af3f6c18f5
commit
0dd7698fd1
4 changed files with 34 additions and 4 deletions
|
@ -635,7 +635,7 @@ fn (mut g Gen) gen_pe_idata() {
|
|||
]
|
||||
|
||||
for symbol in g.extern_symbols {
|
||||
sym := symbol.all_after('C.')
|
||||
mut sym := symbol.all_after('C.')
|
||||
mut found := false
|
||||
for mut dll in dlls {
|
||||
if sym in dll.exports {
|
||||
|
@ -645,6 +645,21 @@ fn (mut g Gen) gen_pe_idata() {
|
|||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
if sym == 'CaptureStackBackTrace' {
|
||||
sym = 'RtlCaptureStackBackTrace'
|
||||
} else if sym == '__debugbreak' {
|
||||
sym = 'DebugBreak'
|
||||
}
|
||||
for mut dll in dlls {
|
||||
if sym in dll.exports {
|
||||
found = true
|
||||
dll.exports[sym] = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
eprintln('could not find symbol `${sym}` in ${dll_files}')
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ fn (mut g Gen) lookup_system_dll(dll string) !SystemDll {
|
|||
}
|
||||
}
|
||||
} $else {
|
||||
// TODO: look into librarys dirs
|
||||
// TODO: look into library's dirs
|
||||
return SystemDll{
|
||||
name: dll
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ fn test_native() {
|
|||
eprintln('>> skipping testing on FreeBSD/OpenBSD for now')
|
||||
return
|
||||
}
|
||||
|
||||
mut bench := benchmark.new_benchmark()
|
||||
vexe := os.getenv('VEXE')
|
||||
vroot := os.dir(vexe)
|
||||
|
@ -26,12 +27,14 @@ fn test_native() {
|
|||
defer {
|
||||
os.rmdir_all(wrkdir) or {}
|
||||
}
|
||||
|
||||
os.chdir(wrkdir) or {}
|
||||
tests := files.filter(it.ends_with('.vv'))
|
||||
if tests.len == 0 {
|
||||
println('no native tests found')
|
||||
assert false
|
||||
}
|
||||
|
||||
bench.set_total_expected_steps(tests.len)
|
||||
for test in tests {
|
||||
if test == 'libc.vv' {
|
||||
|
@ -41,6 +44,7 @@ fn test_native() {
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
bench.step()
|
||||
full_test_path := os.real_path(os.join_path(dir, test))
|
||||
test_file_name := os.file_name(test)
|
||||
|
@ -64,7 +68,6 @@ fn test_native() {
|
|||
err := os.read_file(tmperrfile) or { panic(err) }
|
||||
eprintln(err)
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -95,6 +98,7 @@ fn test_native() {
|
|||
errstr := os.read_file(tmperrfile) or {
|
||||
panic('${err}: ${os.quoted_path(exe_test_path)} 2> ${os.quoted_path(tmperrfile)}')
|
||||
}
|
||||
|
||||
mut err_found := errstr.trim_right('\r\n').replace('\r\n', '\n')
|
||||
if err_expected != err_found {
|
||||
println(term.red('FAIL'))
|
||||
|
@ -107,6 +111,7 @@ fn test_native() {
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
os.rm(tmperrfile) or {}
|
||||
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
|
||||
mut found := res.output.trim_right('\r\n').replace('\r\n', '\n')
|
||||
|
@ -123,7 +128,8 @@ fn test_native() {
|
|||
}
|
||||
bench.ok()
|
||||
eprintln(bench.step_message_ok('${relative_test_path:-45} , took ${compile_time_ms:4}ms to compile, ${runtime_ms:4}ms to run'))
|
||||
}
|
||||
} // for loop
|
||||
|
||||
bench.stop()
|
||||
eprintln(term.h_divider('-'))
|
||||
eprintln(bench.total_message('native'))
|
||||
|
|
9
vlib/v/gen/native/tests/pe_test.v
Normal file
9
vlib/v/gen/native/tests/pe_test.v
Normal file
|
@ -0,0 +1,9 @@
|
|||
module tests
|
||||
|
||||
import os
|
||||
|
||||
fn test_prevent_could_not_find_symbols_regression() {
|
||||
res := os.execute('${os.quoted_path(@VEXE)} -b native examples/hello_world.v')
|
||||
assert !res.output.contains('CaptureStackBackTrace'), 'Test failed system unable to find symbol: CaptureStackBackTrace'
|
||||
assert !res.output.contains('__debugbreak'), 'Test failed system unable to find symbol: __debugbreak'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue