GDB调试问题集

GDB远程调试 gdb主要调试的是C/C++的程序。要调试C/C++的程序,首先在编译时,必须要把调试信息加到可执行文件中。使用编译器(cc/gcc/g++)的 -g 参数即可。要用gdb调试程序,必须在编译时加上-g和-ggdb选项,如果没有-g,将看不见程序的函数名和变量名,代替它们的全是运行时的内存地址。 阅读详情

ptrace: Operation not permitted

早上发现一个进程没有相应, 试图gdb之.

(gdb) attach 30721
Attaching to program: /data0/s/bin/s, process 30721
ptrace: Operation not permitted.

晕倒, 俺已经是sudo权限了. 后来看到一篇博客说:当他已经在 gdb 某个进程时, 试图再利用 gcore 来手动产生一个 core 文件而不得(可以在gdb下用 generate-core-file 完成), 我有所启发, 莫非还有别人在gdb 这个进程.

ps 一下, 发现我的猜想是对的, 我进一步猜想, strace 也应该会失败.

0> strace -p 30721
attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted

果然如此, 两者都用到了 ptrace 这个系统调用.  man ptrace 可以查看详情:

The  ptrace  system  call provides a means by which a parent process may observe and control the execution of another pro-cess, and examine and change its core image and registers.  It is primarily used to  implement  breakpoint  debugging  and system call tracing.

看linux内核详解的话, 应该能给出更深层次的解释, 我现在还留在意会阶段.


转自 http://gcoder.blogbus.com/logs/37656869.html

Linux: debug: strace: attach: ptrace(PTRACE_SEIZE, 25): Operation not permitted 最近遇到一个错误:./strace: attach: ptrace(PTRACE_SEIZE, 25): Operation not permitted原因,在内核里,如果所属的thread不在一个group,就不让strace。另一个原因,如果之前已经有ptrace了,就不允许再次来ptrace;或者进程已经在退出的状态。 阅读详情

相关推荐

【SystemVerilog笔记(一)】数据类型

(一)内建数据类型 1.按照四值逻辑和二值逻辑分类 四值逻辑类型:integer、logic、reg、wire等线网类型 二值逻辑类型:byte、shortint、int、longint、bit 2.按照有符号和无符号分类 有符号类型:byte、shortint、int、longint、integer 无符号类型:bit、logic、reg、wire等线网类型 ※记忆:按位定义的变量是无符号的。 (二)软件常用类型 1.定宽数组 在这里插入代码片 ...

cc__cc__的博客 1万+

docker strace ptrace 报错 Operation not permitted 解决方法

原因就是因为ptrace被Docker默认禁止的问题。下表列出了由于不在白名单而被有效阻止的重要(但不是全部)系统调用。该表包含每个系统调用被阻止的原因。当然从安全角度考虑,如只是想使用gdb进行debug的话,建议使用第三种。)是 Linux 内核功能,可以使用它来限制容器内可用的操作。安全计算模式(secure computing mode,配置文件是一个白名单,它指定了允许的调用。3、仅开放ptrace限制。1、关闭seccomp。Docker 的默认。2、采用超级权限模式。

ss810540895的博客 2720

从零上手:基于英飞凌TC377的UDE STK 5.0实战调试指南

本文详细介绍了基于英飞凌TC377芯片和UDE STK 5.0的实战调试指南,涵盖硬件连接、工作空间配置、程序烧录、多核调试等关键步骤。特别针对汽车电子领域常见的多核架构调试难题,提供了断点设置、变量监控等实用技巧,帮助开发者快速上手并优化调试效率。

weixin_30839881的博客 683

GDB 提示 ptrace: Operation not permitted.的解决办法

之前好几次遇到这个问题,我用gdb attach 进程后,会提示ptrace: Operation not permitted.以前的解决办法是关掉服务器进程,然后重新attach就可以了。今天到公司又遇到这个问题,查看服务器进程还在,网上搜索,说是有gdb在正在调试该进程,然后我用ps -ef | grep gdb 查看,果然有gdb正附加到服务器进程上,想想是上周我attach后,没有关闭...

终极程序 8823

Dify使用教程(创建应用)

Dify的安装部署我已经写过了,简单的模型配置我也在前面进行了讲解,今天我们主要来讲讲如何使用Dify。

wal1314520的博客 1万+

AI人工智能与模拟退火:碰撞出的智慧火花

本文旨在为读者全面介绍模拟退火算法在人工智能领域的应用。我们将涵盖从基础理论到实际实现的完整知识体系,帮助读者理解这一受自然界启发的优化技术如何解决复杂的计算问题。文章首先介绍模拟退火的基本概念,然后深入其工作原理和数学基础,接着通过Python实现展示具体应用,最后讨论实际应用场景和未来发展方向。模拟退火(Simulated Annealing, SA):一种受物理退火过程启发的概率性优化算法能量函数(Energy Function):评估系统状态的函数,对应优化问题的目标函数。

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 452

strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted

在docker里面用strace -p pid 查看进程当前调用栈报错 $ strace -p 7 ptrace(PTRACE_ATTACH, ...): Operation not permitted //报错信息 解决办法 I would like to add that I needed --security-opt apparmor=unconfined along with th...

SakuraLLj的专栏 8338

Keil5与ARM编译器V5安装指南:从下载到配置全流程解析

本文提供Keil5与ARM Compiler V5的完整安装与配置指南。针对新版Keil5默认不包含V5编译器导致老工程编译失败的问题,详细解析了从软件下载、授权管理到获取并正确安装ARM Compiler V5(AC5)的全流程,确保开发者能顺利搭建兼容老项目的稳定开发环境。

weixin_29158047的博客 874

gdb 调试多线程程序 问题集锦

gdb 调试多线程程序 问题集锦 作者:yipie   标签:linuxgdb调试源文件2011-06-11 10:51 星期六 晴   http://coolshell.cn/articles/3643.html      一、多线程调试       多线程调试可能是问得最多的。其实,重要就是下面几个命令:      info thread 查看当前进程的线程。 th

jfkidear的专栏 1191

Aloudata 荣登“数智技术系列榜单”和“数据智能服务商 TOP30”

持续助力各行业数智化先进企业突破数据管理技术瓶颈,以更加敏捷、精准和可靠的数据交付驱动企业业务创新与经营提效

Aloudata的博客 666

开发者的避坑指南:在Apple Silicon Mac上构建RocketMQ Python客户端的完整心路历程

本文详细记录了在Apple Silicon Mac上构建RocketMQ Python客户端的完整过程,重点解决了架构兼容性问题。通过源码编译rocketmq-client-cpp库,修复构建脚本和CMake配置,最终成功在M2芯片MacBook Pro上部署RocketMQ Python客户端,为开发者提供了实用的避坑指南。

Pepper的专栏 696

GDB调试命令详解

GDB是什么 调试程序 程序中出现的语法错误可以借助编译器解决;但逻辑错误则只能靠自己解决。实际场景中解决逻辑错误最高效的方法,就是借助调试工具对程序进行调试。 所谓调试(Debug),就是让代码一步一步慢慢执行,跟踪程序的运行过程。比如,可以让程序停在某个地方,查看当前所有变量的值,或者内存中的数据;也可以让程序一次只执行一条或者几条语句,看看程序到底执行了哪些代码。 也就是说,通过调试程序,我们可以监控程序执行的每一个细节,包括变量的值、函数的调用过程、内存中数据、线程的调度等,从而发现隐藏的错误或者低

Hello World 9万+

数仓建模:维度表合并时,如何处理可能出现的数据冲突?

通过以上方法,可以有效地处理维度表合并时可能出现的数据冲突,确保合并后的数据完整性、一致性和准确性,满足业务需求和数据仓库的性能要求。在合并过程中,需要根据实际情况选择合适的处理方法,并进行充分的测试和验证。(2)实战中总结的SQL技巧,帮助SQLBOY在SQL语言上有质的飞越,无论你应对业务难题及面试都会游刃有余【如果您觉得本文还不错,对你有帮助,那么不妨可以关注一下我的数字化建设实践之路专栏,这里的内容会更精彩。技巧总结,让你认识不一样的数仓。,数据库会抛出异常,可根据异常处理机制解决。

石榴姐yyds 1132

gdb调试详解

一、gdb调试coredump文件 二、gdb调试多线程       【Note】:

青萍之末的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

GDB调试操作

GDB是一个由GNU开源组织发布的、UNIX/LINUX操作系统下的、基于命令行的、功能强大的程序调试工具。 对于一名Linux下工作的c/c++程序员,gdb是必不可少的工具。 1、启动gdb 使用vim编辑器编写一个简单的测试程序并保存: vim hello.c 然后使用gcc将其编译为可执行文件,同时使用-g表示该程序可调试: gcc -g hello.c -o hello 接下来启动gdb进行调试: gdb hello 或 gdb -q hello -q参数可以屏

Yan__Ran的博客 2万+

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

GDB调试

转载至从 0 开始学习 Linux 系列之「08.15 个 gdb 调试基础命令」 此处仅想保存下来自己记录 gdb 简介 gdb 是 UNIX 及 UNIX-like 下的调试工具,在 Linux 下一般都直接在命令行中用 gdb 来调试程序,相比 Windows 上的集成开发环境 IDE 提供的图形界面调试,一开始使用 gdb 调试可能会让你感到生无可恋,但是只要熟悉了 gdb 调试的常用命令,调试出程序会很有成就感,一方面因为这些命令就类似图形界面调试按钮背后的逻辑,另一方面用命令行来调试程序,逼格瞬

小白的成长 1万+

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

如何使用GDB调试

文章目录一、GDB的介绍二、GDB的使用三、使用GDB调试实际例子 一、GDB的介绍 GDB(全称:GNU Debugger)是GNU工程为GNU操作系统开发的调试器。它可以用于调试C、C++、Objective-C、Pascal、Ada等语言编写的程序。 二、GDB的使用 GDB的使用条件 程序要用GDB调试,需要添加调试信息。 添加方法: gcc的-g选项为程序添加调试信息。 例如:gcc –g –o helloworld helloworld.c 启动GDB 启动方法: gdb [程序名称

Harriet的博客 6556

gdb调试小结

一、启动 1、gdb 2、调试在线进程 (1)启动gdb时链接目标进程 (2)gdb中链接目标进程: (3)断开链接: 二、信息显示 1、栈信息 2、变量 3、寄存器 4、内存 5、源代码 6、显示格式 三、断点 1、设置断点 2、 查看、删除断点 3、设置无效、有效断点: 4、条件断点 5、监视点 6、断点命令 四、其他 1、强制函数返回 2、强制调用函数 参考 ...

milletluo的博客 1万+

GDB 调试

嵌入式 linux 应用程序 和内核 gdb 调试

weixin_44579363的博客 2万+

GDB调试指南

GDB是linux下非常好用且强大的调试工具,能够使让用户在程序运行的过程中观察内部结构与内存的使用情况,掌握gdb对于二进制pwn手的学习是入门的要求。不会进入调试界面,跟直接运行程序差不多这是pwntools用于在exp脚本方便调试的部分context.terminal = ["tmux","splitw","-h"]#产生左右分屏,不带的话是上下分屏比较难受gdb.attach() #放到想要在exp中停止的位置,程序在运行时候会停止在该处进行调试运行脚本得到注意:要在tmux模式下才可以。

qq_62531518的博客 2610

GDB调试大全

GDB详细调试大全

m0_60524373的博客 4126

gdb调试

命令名称命令缩写命令说明runr运行一个程序continuec让暂停的程序继续运行nextn运行到下一行steps如果有调用函数,进入调用的函数内部(相当于step intountilu运行到指定行停下来finishfi结束当前调用函数,到上一层函数调用处returnreturn结束当前调用函数并返回指定值,到上一层函数调用处jumpj将当前程序执行流跳转到指定行或地址printp打印变量或寄存器值backtracebt查看当前线程的调用堆栈。

m0_74186706的博客 2753

C++调试@认识GDB调试

GDB(GNU Debugger)是Linux及Unix环境中常用的程序调试工具,windows 下也有许多移植版可以用深入理解程序执行:GDB命令行提供了对程序执行流程的底层控制,帮助你更深入地理解程序的运行机制。通过手动控制每一步执行,你能够更细致地观察变量变化、函数调用、内存状态等,这对于复杂问题的排查非常有帮助。轻量级和灵活性:相比IDE,GDB是一个轻量级工具,尤其适合远程服务器或资源受限环境下的调试。

xuchaoxin1375的博客 1367
上一篇: placement new, operator new and new operator
下一篇: 重载,覆盖和隐藏的区别
wind19
博客等级 码龄23年 477粉丝 170原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值