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     }
相关推荐
WBluuue1 小时前
数据结构与算法:康托展开、约瑟夫环、完美洗牌
c++·算法
木子墨5162 小时前
LeetCode 热题 100 精讲 | 并查集篇:最长连续序列 · 岛屿数量 · 省份数量 · 冗余连接 · 等式方程的可满足性
数据结构·c++·算法·leetcode
王老师青少年编程3 小时前
csp信奥赛C++高频考点专项训练之贪心算法 --【线性扫描贪心】:均分纸牌
c++·算法·编程·贪心·csp·信奥赛·均分纸牌
weixin_513449963 小时前
PCA、SVD 、 ICP 、kd-tree算法的简单整理总结
c++·人工智能·学习·算法·机器人
烟锁池塘柳03 小时前
一文讲透 C++ / Java 中方法重载(Overload)与方法重写(Override)在调用时机等方面的区别
java·c++·面向对象
yolo_guo4 小时前
glog单行 30000 字节限制问题
c++
cccccc语言我来了5 小时前
C++轻量级消息队列服务器
java·服务器·c++
闻缺陷则喜何志丹5 小时前
【背包 组合】P7552 [COCI 2020/2021 #6] Anagramistica|普及+
c++·算法·背包·洛谷·组合
xiaoye-duck5 小时前
【C++:C++11】C++11新特性深度解析:从类新功能、Lambda表达式到包装器实战
开发语言·c++·c++11
一个行走的民5 小时前
C++ Lambda 表达式语法详解
c++