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     }
相关推荐
m0_7345717612 分钟前
深入理解C++ 构造函数<十一> initializer_list 构造
开发语言·c++
水饺编程28 分钟前
第5章,[Win32 章节] :绘制平面直角坐标系
c语言·c++·windows·visual studio
没文化的阿浩34 分钟前
【Linux系统】进程状态详解
android·linux·c++·c
All for pursuit.40 分钟前
【数组-5】560.和为K的子数组
数据结构·c++·算法·leetcode
影视飓风TIM41 分钟前
C++异常与RAII智能指针笔记
开发语言·c++·笔记
欧特克_Glodon41 分钟前
OpenCV计算机视觉开发入门与实践<四十二>:手势识别
c++·人工智能·opencv·计算机视觉·手势识别
草莓熊Lotso1 小时前
【Redis 初阶】C++ 客户端实战:从 RESP 协议到 redis-plus-plus 工程化用法
linux·开发语言·网络·数据库·c++·redis·缓存
郝学胜-神的一滴1 小时前
C++11 工程级应用 10:减少拷贝,让容器跑得更快
服务器·开发语言·c++·游戏引擎·opengl
估值探索者2 小时前
【AI+量化实战 #05】财报季的信息洪流:用LLM给业绩预告分类+算事件窗口收益
java·c语言·c++·人工智能·python·分类·数据挖掘
Zixhy3 小时前
手撕Reactor模型实现同步高并发服务器及Muduo网络库深入解析
linux·服务器·网络·数据库·c++