美好的一天,我正在嘗試除錯這個與 XDMA 設備互動的 C 代碼:
#include <fstream>
#include <iostream>
#include <unistd.h>
int main()
{
std::ofstream output_;
const char* output_name = "/dev/xdma/card0/h2c0";
output_.exceptions(std::ios::failbit | std::ios::badbit);
output_.rdbuf()->pubsetbuf(nullptr, 0);
output_.open(output_name, std::ios::binary | std::ios::out);
std::streamoff offset = 0x1e00000;
output_.seekp(offset, std::ios::beg);
const char buf[1] = "";
std::streamsize size = 1;
auto pos = output_.tellp();
output_.write(buf, size); // <--- IOSTREAM ERROR
output_.seekp(pos size, std::ios::beg);
return 0;
}
但是這個程式失敗了output_.write(buf, size);- 帶有相當模糊的錯誤訊息:
terminate called after throwing an instance of 'std::__ios_failure'
what(): basic_ios::clear: iostream error
Aborted (core dumped)
而且,如果我將其包裝output_.write(buf, size);在 try & catch 塊中:
try {
output_.write(buf, size);
}
catch (std::system_error& e) {
std::cerr << e.code().message() << "(" << e.code().value() << ")\n";
return 1;
}
它變為iostream error(1). 這并不能說明失敗的原因...我確信我可以寫入 0x1e00000 偏移量,因為替代的 C 代碼可以完美地作業。所以錯誤出在 C 代碼或庫中。如何獲取更多除錯資訊?
uj5u.com熱心網友回復:
雖然我沒有成功獲得更多除錯資訊,但解決方案是將提供/dev/xdma/card0/h2c0設備的 XDMA 驅動程式從v2017.1.47舊v2017.0.45版本降級(需要自定義補丁才能在新作業系統上運行)。不幸的是,這些新驅動程式真的有問題......
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/375396.html
下一篇:TensorFlowTextVectorization從pickle加載后生成不帶填充的RaggedTensor
