gdb

GDB - strcmp not working: __strcmp_sse2_unaligned

本秂侑毒 提交于 2021-01-27 10:46:25
问题 I'm unable to create conditional breakpoint in GDB using strcmp: break x if strcmp(str.c_str(), "foo") == 0 Why you ask? Because: print strcmp("hello", "hello") Yield's (int (*)(const char *, const char *)) 0x7ffff76ffe70 <__strcmp_sse2_unaligned> Even when casting it to an integer: print (int)strcmp("hello", "hello") It returns some nonsensical value like -143655312 Here's a less graceful way to "solve" my problem. I can define a function in my own code: int mystrcmp(const char *str1, const

understanding stack trace of a segmentation fault

余生长醉 提交于 2021-01-27 05:34:32
问题 I am doing an snprintf and getting a seg fault. when I loaded the core file on gdb like this: gdb my_executable core ; and did bt to get the backtrace, I got following: Program terminated with signal 11, Segmentation fault. #0 0x88207fc2 in memcpy () from /usr/lib/libc.so.6 (gdb) bt #0 0x88207fc2 in memcpy () from /usr/lib/libc.so.6 #1 0x88205eb6 in __sfvwrite () from /usr/lib/libc.so.6 #2 0x881fbc95 in strchr () from /usr/lib/libc.so.6 #3 0xbfbe6c14 in ?? () #4 0xbfbe69d8 in ?? () #5

GCC:优化 Linux、互联网和一切

 ̄綄美尐妖づ 提交于 2021-01-23 09:05:21
软件如果不能被电脑运行,那么它就是无用的。而在处理运行时run-time性能的问题上,即使是最有才华的开发人员也会受编译器的支配 —— 因为如果没有可靠的编译器工具链,就无法构建任何重要的东西。GNU 编译器集合GNU Compiler Collection(GCC)提供了一个健壮、成熟和高性能的工具,以帮助你充分发挥你代码的潜能。经过数十年成千上万人的开发,GCC 成为了世界上最受尊敬的编译器之一。如果你在构建应用程序是没有使用 GCC,那么你可能错过了最佳解决方案。 根据 LLVM.org 的说法,GCC 是“如今事实上的标准开源编译器” [1] ,也是用来构建完整系统的基础 —— 从内核开始。GCC 支持超过 60 种硬件平台,包括 ARM、Intel、AMD、IBM POWER、SPARC、HP PA-RISC 和 IBM Z,以及各种操作环境,包括 GNU、Linux、Windows、macOS、FreeBSD、NetBSD、OpenBSD、DragonFly BSD、Solaris、AIX、HP-UX 和 RTEMS。它提供了高度兼容的 C/C++ 编译器,并支持流行的 C 库,如 GNU C Library(glibc)、Newlib、musl 和各种 BSD 操作系统中包含的 C 库,以及 Fortran、Ada 和 GO 语言的前端。GCC

嵌入式开发新手路线教程:嵌入式linux学习路线

最后都变了- 提交于 2021-01-21 10:56:05
Linux是一个开源、免费的操作系统,主要应用于服务器(网站服务器、云计算集群、DNS 等)和嵌入式,同时也被很多程序员用作个人操作系统。Linux 使用 GPL 许可证,允许任何人以任何形式传播其源代码。GPL 许可证的内涵很简单:你随意使用我的代码,只要标明这是我的代码就可以了。 1、嵌入式高级C语言 Linux系统 Linux Ubuntu操作系统安装、使用、Linux常用命令、samba服务器、SSH远程登录GCC编译器、GDB调试器、VI编辑器 1、嵌入式C语言高级编程 1、C数据类型、控制语句 2、C程序结构设计、数组、函数、预处理: 3、指针及字符串操作 4、结构体、共用体、宏、枚举 5、文件I/O操作 数据结构及算法 1、数据结构之单向链表、双向链表 2、数据结构之队列、栈 3、数据结构之树、图 4、算法之各种排序(选择法、冒泡法、插入法等) 5、递归 6、算法之二分查找 2、嵌入式设备及GUI开发 嵌入式环境配置与开发工具学习 1、Linux下项目管理工具Make以及Makefile工作原理及其编写 2、Linux下shell脚本相关知识及其编写 3、嵌入式开发环境的基本概念及其搭建 4、A53开发板介绍、设备使用、A53开发板与电脑通信、交叉编译 GUI图形界面开发 1、常用控件——button、label、text edit等 2、常用布局方式——水平布局

GDB conditional break on function parameter

假如想象 提交于 2021-01-21 06:44:11
问题 I'm wanting to set a breakpoint on a function parameter if it is greater than a certain value. Dummy code below: int main(void) { uint64_t num = 123456; uint64_t x = 847534; uint64_t other = (num*x) - (x/num); .... other stuff here (multithreaded stuff) calc(other); } void calc(uint64_t size) { ...do some stuff with size } I've tried to set a breakpoint by: (gdb) b calc if size == 852479 but it does not know what size is since it is a parameter I'm guessing. How would I break if the parameter

GDB conditional break on function parameter

时间秒杀一切 提交于 2021-01-21 06:43:23
问题 I'm wanting to set a breakpoint on a function parameter if it is greater than a certain value. Dummy code below: int main(void) { uint64_t num = 123456; uint64_t x = 847534; uint64_t other = (num*x) - (x/num); .... other stuff here (multithreaded stuff) calc(other); } void calc(uint64_t size) { ...do some stuff with size } I've tried to set a breakpoint by: (gdb) b calc if size == 852479 but it does not know what size is since it is a parameter I'm guessing. How would I break if the parameter

Why do the addresses in my assembler dump differ from the addresses of registers?

隐身守侯 提交于 2021-01-20 06:58:30
问题 I have a very basic program that I compiled with gcc -m32 -g -o hello32.out hello.c When I run disassemble main in gdb I get the following output: 0x0000051d <+0>: lea ecx,[esp+0x4] 0x00000521 <+4>: and esp,0xfffffff0 0x00000524 <+7>: push DWORD PTR [ecx-0x4] 0x00000527 <+10>: push ebp 0x00000528 <+11>: mov ebp,esp 0x0000052a <+13>: push ebx 0x0000052b <+14>: push ecx 0x0000052c <+15>: sub esp,0x10 0x0000052f <+18>: call 0x420 <__x86.get_pc_thunk.bx> 0x00000534 <+23>: add ebx,0x1aa4

When using a coredump in gdb how do I know exactly which thread caused SIGSEGV? [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-18 05:56:48
问题 This question already has an answer here : How to find which thread caused SEGFAULT in a post-mortem gdb session? (1 answer) Closed 6 years ago . My application uses more than 8 threads. When I run info threads in gdb I see the threads and the last function they were executing. It does not seem obvious to me exactly which thread caused the SIGSEGV. Is it possible to tell it? Is it thread 1? How are the threads numbered? 回答1: When you use gdb to analyze the core dump file, the gdb will stop at

When using a coredump in gdb how do I know exactly which thread caused SIGSEGV? [duplicate]

六月ゝ 毕业季﹏ 提交于 2021-01-18 05:56:04
问题 This question already has an answer here : How to find which thread caused SEGFAULT in a post-mortem gdb session? (1 answer) Closed 6 years ago . My application uses more than 8 threads. When I run info threads in gdb I see the threads and the last function they were executing. It does not seem obvious to me exactly which thread caused the SIGSEGV. Is it possible to tell it? Is it thread 1? How are the threads numbered? 回答1: When you use gdb to analyze the core dump file, the gdb will stop at

1 visual studio code 配置C++开发环境 (windows 开发环境)

核能气质少年 提交于 2021-01-11 10:00:04
0 引言 最近帮GF(不幸变成ex了)配置C++开发环境,一开始想给她装个visual studio13完事,但是一想到自己安装以及使用时的诸多麻烦,就有点退却,觉得没有这个必要。正好了解到vscode大行其道,决定按照官网指示配置一版。由于本人非计算机科班出身,对编译原理了解不多,在配置环境的时候遇到了一些麻烦,参照网上的诸多教程,最后发现还是官网比较靠谱,所以结合自己配置的教训,写个帖子,希望能够帮到大家。 1 下载安装vscode 下载网址链接如下。 https://code.visualstudio.com/ 直接下载安装即可。 2 配置语言 1)shift + ctrl + P,打开命令行。 2)在输入框中输入“Configure Display Language”,点击打开locale.json. 3) 编辑locale.json文件,如图所示。“locale”: "zh-CN"保存,然后重新打开编辑器即可。 3 安装C/C++相关插件,包括以下插件。 1)C/C++ 2)C++ Intellisense 3) Chinese(Simplified)中文简体 4 安装C++ 编译器 选择安装tdm64-gcc-5.1.0-2.exe,下载网址链接如下。 https://sourceforge.net/projects/tdm-gcc/files/TDM-GCC