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 {
|
for symbol in g.extern_symbols {
|
||||||
sym := symbol.all_after('C.')
|
mut sym := symbol.all_after('C.')
|
||||||
mut found := false
|
mut found := false
|
||||||
for mut dll in dlls {
|
for mut dll in dlls {
|
||||||
if sym in dll.exports {
|
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 {
|
if !found {
|
||||||
eprintln('could not find symbol `${sym}` in ${dll_files}')
|
eprintln('could not find symbol `${sym}` in ${dll_files}')
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ fn (mut g Gen) lookup_system_dll(dll string) !SystemDll {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} $else {
|
} $else {
|
||||||
// TODO: look into librarys dirs
|
// TODO: look into library's dirs
|
||||||
return SystemDll{
|
return SystemDll{
|
||||||
name: dll
|
name: dll
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ fn test_native() {
|
||||||
eprintln('>> skipping testing on FreeBSD/OpenBSD for now')
|
eprintln('>> skipping testing on FreeBSD/OpenBSD for now')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mut bench := benchmark.new_benchmark()
|
mut bench := benchmark.new_benchmark()
|
||||||
vexe := os.getenv('VEXE')
|
vexe := os.getenv('VEXE')
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
|
@ -26,12 +27,14 @@ fn test_native() {
|
||||||
defer {
|
defer {
|
||||||
os.rmdir_all(wrkdir) or {}
|
os.rmdir_all(wrkdir) or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
os.chdir(wrkdir) or {}
|
os.chdir(wrkdir) or {}
|
||||||
tests := files.filter(it.ends_with('.vv'))
|
tests := files.filter(it.ends_with('.vv'))
|
||||||
if tests.len == 0 {
|
if tests.len == 0 {
|
||||||
println('no native tests found')
|
println('no native tests found')
|
||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.set_total_expected_steps(tests.len)
|
bench.set_total_expected_steps(tests.len)
|
||||||
for test in tests {
|
for test in tests {
|
||||||
if test == 'libc.vv' {
|
if test == 'libc.vv' {
|
||||||
|
@ -41,6 +44,7 @@ fn test_native() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.step()
|
bench.step()
|
||||||
full_test_path := os.real_path(os.join_path(dir, test))
|
full_test_path := os.real_path(os.join_path(dir, test))
|
||||||
test_file_name := os.file_name(test)
|
test_file_name := os.file_name(test)
|
||||||
|
@ -64,7 +68,6 @@ fn test_native() {
|
||||||
err := os.read_file(tmperrfile) or { panic(err) }
|
err := os.read_file(tmperrfile) or { panic(err) }
|
||||||
eprintln(err)
|
eprintln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +98,7 @@ fn test_native() {
|
||||||
errstr := os.read_file(tmperrfile) or {
|
errstr := os.read_file(tmperrfile) or {
|
||||||
panic('${err}: ${os.quoted_path(exe_test_path)} 2> ${os.quoted_path(tmperrfile)}')
|
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')
|
mut err_found := errstr.trim_right('\r\n').replace('\r\n', '\n')
|
||||||
if err_expected != err_found {
|
if err_expected != err_found {
|
||||||
println(term.red('FAIL'))
|
println(term.red('FAIL'))
|
||||||
|
@ -107,6 +111,7 @@ fn test_native() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os.rm(tmperrfile) or {}
|
os.rm(tmperrfile) or {}
|
||||||
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
|
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
|
||||||
mut found := res.output.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()
|
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'))
|
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()
|
bench.stop()
|
||||||
eprintln(term.h_divider('-'))
|
eprintln(term.h_divider('-'))
|
||||||
eprintln(bench.total_message('native'))
|
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