@@ -22,14 +22,17 @@ namespace onnxruntime {
2222
2323namespace {
2424
25- Status ErrorCodeToStatus (const std::error_code& ec) {
25+ Status ErrorCodeToStatus (const std::error_code& ec, const fs::path& path, std::string_view context ) {
2626 if (!ec) {
2727 return Status::OK ();
2828 }
2929
3030 return Status{common::StatusCategory::ONNXRUNTIME, common::StatusCode::FAIL,
3131 MakeString (" Error: std::error_code with category name: " , ec.category ().name (),
32- " , value: " , ec.value (), " , message: " , ec.message ())};
32+ " , value: " , ec.value (),
33+ " , message: " , ec.message (),
34+ " , filesystem path: " , path,
35+ " , context: " , context)};
3336}
3437
3538struct GpuSysfsPathInfo {
@@ -41,7 +44,7 @@ Status DetectGpuSysfsPaths(std::vector<GpuSysfsPathInfo>& gpu_sysfs_paths_out) {
4144 std::error_code error_code{};
4245 const fs::path sysfs_class_drm_path = " /sys/class/drm" ;
4346 const bool sysfs_class_drm_path_exists = fs::exists (sysfs_class_drm_path, error_code);
44- ORT_RETURN_IF_ERROR (ErrorCodeToStatus (error_code));
47+ ORT_RETURN_IF_ERROR (ErrorCodeToStatus (error_code, sysfs_class_drm_path, " Checking existance of DRM sysfs path " ));
4548
4649 if (!sysfs_class_drm_path_exists) {
4750 gpu_sysfs_paths_out = std::vector<GpuSysfsPathInfo>{};
@@ -70,7 +73,7 @@ Status DetectGpuSysfsPaths(std::vector<GpuSysfsPathInfo>& gpu_sysfs_paths_out) {
7073 std::vector<GpuSysfsPathInfo> gpu_sysfs_paths{};
7174
7275 auto dir_iterator = fs::directory_iterator{sysfs_class_drm_path, error_code};
73- ORT_RETURN_IF_ERROR (ErrorCodeToStatus (error_code));
76+ ORT_RETURN_IF_ERROR (ErrorCodeToStatus (error_code, sysfs_class_drm_path, " Iterating over DRM sysfs devices " ));
7477
7578 for (const auto & dir_item : dir_iterator) {
7679 const auto & dir_item_path = dir_item.path ();
@@ -122,7 +125,7 @@ Status GetPciBusId(const std::filesystem::path& sysfs_path, std::optional<std::s
122125
123126 std::error_code error_code;
124127 auto pci_bus_id_path = std::filesystem::canonical (sysfs_path / " device" , error_code); // resolves symlink to PCI bus id, e.g. 0000:65:00.0
125- ORT_RETURN_IF_ERROR (ErrorCodeToStatus (error_code));
128+ ORT_RETURN_IF_ERROR (ErrorCodeToStatus (error_code, sysfs_path / " device " , " Getting PCI bus id from DRM device by resolving symlink " ));
126129
127130 auto pci_bus_id_filename = pci_bus_id_path.filename ();
128131 if (std::regex_match (pci_bus_id_filename.string (), pci_bus_id_regex)) {
0 commit comments