Skip to content

Commit f1601fd

Browse files
printf debugging aw yiss
1 parent d3491e9 commit f1601fd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

rubicon/src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ macro_rules! compatibility_check {
358358

359359
#[cfg(windows)]
360360
fn get_shared_object_name() -> Option<String> {
361+
eprintln!("Entering get_shared_object_name function");
361362
use std::mem::MaybeUninit;
362363
use std::ptr;
363364
use std::ffi::OsString;
@@ -388,28 +389,39 @@ macro_rules! compatibility_check {
388389
}
389390

390391
unsafe {
392+
eprintln!("Calling GetModuleHandleW");
391393
let module = GetModuleHandleW(ptr::null());
392394
if module.is_null() {
395+
eprintln!("GetModuleHandleW returned null");
393396
return None;
394397
}
395398

396399
let mut buffer_size = MAX_PATH;
397400
loop {
401+
eprintln!("Entering loop with buffer_size: {}", buffer_size);
398402
let mut buffer = Vec::<u16>::with_capacity(buffer_size as usize);
403+
eprintln!("Calling GetModuleFileNameW");
399404
let result = GetModuleFileNameW(module, buffer.as_mut_ptr(), buffer_size);
400405

401406
if result == 0 {
407+
eprintln!("GetModuleFileNameW returned 0");
402408
return None;
403409
}
404410

405411
if result < buffer_size {
412+
eprintln!("GetModuleFileNameW succeeded with result: {}", result);
406413
buffer.set_len(result as usize);
407-
return Some(OsString::from_wide(&buffer).to_string_lossy().into_owned());
414+
let os_string = OsString::from_wide(&buffer);
415+
let string = os_string.to_string_lossy().into_owned();
416+
eprintln!("Returning string: {}", string);
417+
return Some(string);
408418
}
409419

410420
if GetLastError() == ERROR_INSUFFICIENT_BUFFER {
421+
eprintln!("Buffer insufficient, doubling size");
411422
buffer_size *= 2;
412423
} else {
424+
eprintln!("Unexpected error: {}", GetLastError());
413425
return None;
414426
}
415427
}
@@ -476,21 +488,25 @@ macro_rules! compatibility_check {
476488

477489
#[ctor]
478490
fn check_compatibility() {
491+
eprintln!("Entering check_compatibility function");
479492
let imported: &[(&str, &str)] = &[
480493
("rustc-version", $crate::RUBICON_RUSTC_VERSION),
481494
("target-triple", $crate::RUBICON_TARGET_TRIPLE),
482495
$($feature)*
483496
];
484497
let exported = unsafe { COMPATIBILITY_INFO };
485498

499+
eprintln!("Comparing imported and exported compatibility info");
486500
let missing: Vec<_> = imported.iter().filter(|&item| !exported.contains(item)).collect();
487501
let extra: Vec<_> = exported.iter().filter(|&item| !imported.contains(item)).collect();
488502

489503
if missing.is_empty() && extra.is_empty() {
504+
eprintln!("No compatibility issues found");
490505
// all good
491506
return;
492507
}
493508

509+
eprintln!("Compatibility issues detected, preparing error message");
494510
let so_name = get_shared_object_name().unwrap_or("unknown_so".to_string());
495511
// get only the last bit of the path
496512
let so_name = so_name.rsplit('/').next().unwrap_or("unknown_so");
@@ -503,6 +519,7 @@ macro_rules! compatibility_check {
503519

504520
error_message.push_str(&format!("Loading {} would mix different configurations of the {} crate.\n\n", blue(so_name), red(env!("CARGO_PKG_NAME"))));
505521

522+
eprintln!("Calculating column widths for grid display");
506523
// Compute max lengths for alignment
507524
let max_exported_len = exported.iter().map(|(k, v)| format!("{}={}", k, v).len()).max().unwrap_or(0);
508525
let max_ref_len = imported.iter().map(|(k, v)| format!("{}={}", k, v).len()).max().unwrap_or(0);
@@ -570,6 +587,7 @@ macro_rules! compatibility_check {
570587
}
571588
}
572589

590+
eprintln!("Creating grid for compatibility info display");
573591
let mut grid = Grid::new();
574592

575593
// Add header
@@ -599,6 +617,7 @@ macro_rules! compatibility_check {
599617
grid.add_row(vec![key_column, binary_column, module_column]);
600618
}
601619

620+
eprintln!("Writing grid to error message");
602621
grid.write_to(&mut error_message);
603622

604623
struct MessageBox {
@@ -648,6 +667,7 @@ macro_rules! compatibility_check {
648667

649668
error_message.push_str("More info: \x1b[4m\x1b[34mhttps://crates.io/crates/rubicon\x1b[0m\n");
650669

670+
eprintln!("Creating message box for additional information");
651671
let mut message_box = MessageBox::new();
652672
message_box.add_line(format!("To fix this issue, {} needs to enable", blue(so_name)));
653673
message_box.add_line(format!("the same cargo features as {} for crate {}.", blue(&exe_name), red(env!("CARGO_PKG_NAME"))));
@@ -658,6 +678,7 @@ macro_rules! compatibility_check {
658678
message_box.write_to(&mut error_message);
659679
error_message.push_str("\n\x1b[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n");
660680

681+
eprintln!("Panicking with error message");
661682
panic!("{}", error_message);
662683
}
663684
};

0 commit comments

Comments
 (0)