gdb 之 attach

参考链接

https://cloud.tencent.com/developer/article/1521208

csharp 复制代码
thread 266
set scheduler-locking step
csharp 复制代码
(gdb) bt
#0  facebook::velox::HdfsReadFile::pread (this=0x7f3670186010, offset=18513484, length=16305, buf=0x7f37651cf540,
    stats=0x7f3670192600)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp:168
#1  0x00007f36d39af1ea in facebook::velox::ReadFile::preadv (this=0x7f3670186010, offset=18513484,
    buffers=std::vector of length 73, capacity 128 = {...}, stats=0x7f3670192600)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/common/file/File.cpp:84
#2  0x00007f36d3e59837 in facebook::velox::dwio::common::ReadFileInputStream::read (this=0x7f36701b9980,
    buffers=std::vector of length 73, capacity 128 = {...}, offset=4,
    logType=facebook::velox::dwio::common::MetricsLog::MetricsType::FILE)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/dwio/common/InputStream.cpp:105
#3  0x00007f36da96f918 in facebook::velox::dwio::common::DirectCoalescedLoad::loadData (this=0x7f3670194ce0, prefetch=true)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/dwio/common/DirectBufferedInput.cpp:321
#4  0x00007f36d39451af in facebook::velox::cache::CoalescedLoad::loadOrFuture (this=0x7f3670194ce0, wait=0x0,
    ssdSavable=true) at /work/gluten/ep/build-velox/build/velox_ep/velox/common/caching/AsyncDataCache.cpp:302
#5  0x00007f36da96ee5c in operator() (__closure=0x7f36697e9800)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/dwio/common/DirectBufferedInput.cpp:226
#6  0x00007f36da970ed0 in folly::detail::function::call_<facebook::velox::dwio::common::DirectBufferedInput::readRegions(const std::vector<facebook::velox::dwio::common::LoadRequest*>&, bool, const std::vector<int>&)::<lambda()>, true, false, void>(folly::detail::function::Data &) (p=...) at /work/gluten/dev/vcpkg/vcpkg_installed/x64-linux-avx/include/folly/Function.h:341
#7  0x00007f36db04f634 in folly::detail::function::FunctionTraits<void ()>::operator()() (this=0x7f36697e9800)
    at /work/dev/vcpkg/.vcpkg/buildtrees/folly/src/4.07.01.00-4ae9f6791f.clean/folly/Function.h:368
#8  folly::catch_exception<folly::Function<void ()>&, void (&)(char const*) noexcept, char const*&, void>(folly::Function<void ()>&, void (&)(char const*) noexcept, char const*&) (c=<optimized out>, t=...)
    at /work/dev/vcpkg/.vcpkg/buildtrees/folly/src/4.07.01.00-4ae9f6791f.clean/folly/lang/Exception.h:290
#9  folly::Executor::invokeCatchingExns<folly::Function<void ()> >(char const*, folly::Function<void ()>) (f=...,
    p=0x7f36e17f9cd5 "ThreadPoolExecutor: func")
    at /work/dev/vcpkg/.vcpkg/buildtrees/folly/src/4.07.01.00-4ae9f6791f.clean/folly/Executor.h:234
#10 folly::ThreadPoolExecutor::runTask (this=0x7f3ad0311e00, thread=std::shared_ptr (count 6, weak 0) 0x7f36701c22c0,
    task=...)
    at /work/dev/vcpkg/.vcpkg/buildtrees/folly/src/4.07.01.00-4ae9f6791f.clean/folly/executors/ThreadPoolExecutor.cpp:142
#11 0x00007f36db0454bb in operator() (__closure=0x7f3670185dd0)
    at /opt/rh/devtoolset-11/root/usr/include/c++/11/ext/atomicity.h:109
单步调试运行

参考链接:

csharp 复制代码
thread 266
set scheduler-locking step

# 让 GDB 不因 SIGSEGV 而停止
(gdb) handle SIGSEGV nostop noprint pass
csharp 复制代码
# 或完全忽略
(gdb) handle SIGSEGV ignore

handle SIGPIPE nostop noprint pass
统计 breakpoint 命中次数
csharp 复制代码
commands
continue
end
csharp 复制代码
(gdb) bt
#0  hdfsRead (fs=<optimized out>, f=0x7f4bdf4b8350, buffer=0x7f4bdc05b83c, length=720900)
    at /build/source/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c:1514
#1  0x00007f4c66b6bf71 in facebook::velox::filesystems::arrow::io::internal::LibHdfsShim::Read (
    this=0x7f4c73f33560 <facebook::velox::filesystems::arrow::io::internal::(anonymous namespace)::libhdfs_shim>,
    fs=0x7f5062475510, file=0x7f4bdf4b8350, buffer=0x7f4bdc05b83c, length=720900)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/external/hdfs/ArrowHdfsInternal.cpp:447
#2  0x00007f4c66950de4 in facebook::velox::HdfsFile::read (this=0x7f4bdcb9e960, pos=0x7f4bdc05b83c "", length=720900)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp:57
#3  0x00007f4c66951326 in facebook::velox::HdfsReadFile::Impl::preadInternal (this=0x7f4d081a1170, offset=4, length=1048576,
    pos=0x7f4bdc05b83c "")
    at /work/gluten/ep/build-velox/build/velox_ep/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp:100
#4  0x00007f4c6695137a in facebook::velox::HdfsReadFile::Impl::pread (this=0x7f4d081a1170, offset=4, length=1048576,
    buf=0x7f4bdc00b840)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp:107
#5  0x00007f4c66950871 in facebook::velox::HdfsReadFile::pread (this=0x7f4d08180920, offset=4, length=1048576,
    buf=0x7f4bdc00b840, stats=0x7f4d0818b550)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp:167
#6  0x00007f4c639af1ea in facebook::velox::ReadFile::preadv (this=0x7f4d08180920, offset=4,
    buffers=std::vector of length 73, capacity 128 = {...}, stats=0x7f4d0818b550)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/common/file/File.cpp:84
#7  0x00007f4c63e59837 in facebook::velox::dwio::common::ReadFileInputStream::read (this=0x7f4d081a1af0,
    buffers=std::vector of length 73, capacity 128 = {...}, offset=4,
    logType=facebook::velox::dwio::common::MetricsLog::MetricsType::FILE)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/dwio/common/InputStream.cpp:105
#8  0x00007f4c6a96f918 in facebook::velox::dwio::common::DirectCoalescedLoad::loadData (this=0x7f4d0818dc30, prefetch=true)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/dwio/common/DirectBufferedInput.cpp:321
#9  0x00007f4c639451af in facebook::velox::cache::CoalescedLoad::loadOrFuture (this=0x7f4d0818dc30, wait=0x0, ssdSavable=true)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/common/caching/AsyncDataCache.cpp:302
#10 0x00007f4c6a96ee5c in operator() (__closure=0x7f4bf8be5800)
    at /work/gluten/ep/build-velox/build/velox_ep/velox/dwio/common/DirectBufferedInput.cpp:226
案例
csharp 复制代码
1472 /**
1473  * If the underlying stream supports the ByteBufferReadable interface then
1474  * this method will transparently use read(ByteBuffer). This can help
1475  * improve performance as it avoids unnecessarily copying data on to the Java
1476  * heap. Instead the data will be directly copied from kernel space to the C
1477  * heap.
1478  */
1479 tSize hdfsRead(hdfsFS fs, hdfsFile f, void* buffer, tSize length)
1480 {
1481     jobject jInputStream;
1482     jbyteArray jbRarray;
1483     jvalue jVal;
1484     jthrowable jthr;
1485     JNIEnv* env;
1486
1487     if (length == 0) {
1488         return 0;
1489     } else if (length < 0) {
1490         errno = EINVAL;
1491         return -1;
1492     }
1493     if (f->flags & HDFS_FILE_SUPPORTS_DIRECT_READ) {
1494       return readDirect(fs, f, buffer, length);
1495     }
csharp 复制代码
1508     //Parameters
1509     if (readPrepare(env, fs, f, &jInputStream) == -1) {
1510       return -1;
1511     }
1512
1513     //Read the requisite bytes
1514     jbRarray = (*env)->NewByteArray(env, length);
1515     if (!jbRarray) {
1516         errno = printPendingExceptionAndFree(env, PRINT_EXC_ALL,
1517             "hdfsRead: NewByteArray");
1518         return -1;
1519     }
相关推荐
老歌老听老掉牙16 小时前
案例 7:二维 Rosenbrock 函数最小值(香蕉函数)
c++·pso
Severus_black17 小时前
【C++初阶】Stack、Queue算法题大练兵!
c语言·c++·算法·stl
xiaoye-duck21 小时前
《C++ 项目:手写大模型接入 SDK》DataManager数据管理模块:SQLite持久化存储
开发语言·数据库·c++·sqlite
是main不是漫1 天前
【C++——类和对象(上)】筑基篇:以封装奠定面向对象之基
c语言·开发语言·c++
小七在进步1 天前
string的使用(1)
c++·visual studio
白杨尚青1 天前
C++进阶篇(六):map 和 set 的模拟实现——用红黑树封装 mymap/myset(迭代器 + operator[])
开发语言·c++·迭代器·stl·set·map·红黑树
kloc2 天前
聊天室项目入口网关子服务的实现
linux·c++
csdn_aspnet2 天前
C++ 3个有序点的方向(Orientation of 3 ordered points)
c++·算法
小七在进步2 天前
string的使用(2)
c++
青少儿编程课堂2 天前
蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级:折半搜索优化子集枚举(Meet in the Middle)解析
c++·python·算法·bfs·信息学竞赛