gdb

How to add breakpoint when thread sanitizer repoorts data-race?

╄→гoц情女王★ 提交于 2021-02-05 11:24:46
问题 There is a similar question for address sanitizers, but for thread sanitizers, it doesn't work, I have tried to break on __sanitizer_print_stack_trace, which don't work either. 回答1: Run the program under GDB, set breakpoints on exit and _exit . On Linux, also set catch syscall exit_group . set halt_on_error=1 in TSAN_OPTIONS to ask thread sanitizer to exit on first error: (gdb) set env TSAN_OPTIONS=halt_on_error=1 (gdb) run ... error should be reported and one of the breakpoints should fire.

How to add breakpoint when thread sanitizer repoorts data-race?

≯℡__Kan透↙ 提交于 2021-02-05 11:24:08
问题 There is a similar question for address sanitizers, but for thread sanitizers, it doesn't work, I have tried to break on __sanitizer_print_stack_trace, which don't work either. 回答1: Run the program under GDB, set breakpoints on exit and _exit . On Linux, also set catch syscall exit_group . set halt_on_error=1 in TSAN_OPTIONS to ask thread sanitizer to exit on first error: (gdb) set env TSAN_OPTIONS=halt_on_error=1 (gdb) run ... error should be reported and one of the breakpoints should fire.

Why is GDB breakpoint set at the wrong address for an x86 assembly function?

狂风中的少年 提交于 2021-02-05 06:52:38
问题 I am experiencing an issue where gdb is mapping a line number to the wrong memory address when adding a breakpoint. The following x86 Linux assembly program prints "hello". /* hello.s */ .section .data str: .ascii "hello\n" strlen = . - str .section .text print: pushl %ebp movl %esp, %ebp pushl %ebx movl $4, %eax movl $1, %ebx movl $str, %ecx movl $strlen, %edx int $0x80 popl %ebx movl %ebp, %esp popl %ebp ret .globl _start _start: call print movl $1, %eax movl $0, %ebx int $0x80 I compile it

gdb jumps previous lines after finish main

删除回忆录丶 提交于 2021-02-04 21:12:12
问题 I am trying to figure out why gdb is not behaving as expected. Not sure what triggered this. After seeing this problem, I wrote a minimal version of the main function. It finished the last line and exited properly. After adding one more function, the jumping came back. Even after commenting out the added line the jumping back does not go away. I am not sure this is related the the linking to my own library even after commenting out most of the code (not a single line reference my own library)

Very large address copied as negative value

你。 提交于 2021-02-04 19:51:10
问题 I was going through a binary file corresponding to a C program. I have a very large address stored in %eax . When tried to see the value via gdb , it prints a negative value (reason here). Now when mov %eax, 0x4c(%esp) is performed, the resulted value in 0x4c(%esp) is sometimes positive and sometimes negative. This effect cmp $0, 0x4c(%esp) statement that follows! Can someone please explain this behavior? If this helps: core: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style

在win10环境下安装Cygwin,可以GCC编译

给你一囗甜甜゛ 提交于 2021-02-02 12:21:01
参考博客: http://www.cnblogs.com/hchacha/p/7147603.html 1. 上述网址提供了setup-x86_64.exe,用于安装 Cygwin 2. 我在安装时,选择了如下网址去下载mirros: 3. 现在的cywin默认是最小化安装,但并不包括Gcc,如果要使用gcc,g++,make,gdb工具,是需要选择这些包的 gcc-core、gcc-g++、make、gdb、binutils,五个包都在Category下的Devel下 。 4. 后来,我又安装了 git vim openssh 3个组件,安装流程如下: 点开setup-x86.exe,一路Next:选择在线安装 -> 填写根路径cygwin -> 填写下载的临时安装文件保存路径cygwinsetup -> 选择镜像站点(选国内163或阿里云) ->点击列表ALL 然后通过search查找,将旁边的Default将其切换到Install状态 ->继续一路Next完成安装 来源: oschina 链接: https://my.oschina.net/u/4311561/blog/3552417

win10下安装Cygwin配置gcc编译环境

China☆狼群 提交于 2021-02-02 12:20:43
首先要说明的是,我个人安装cygwin的用途是为了使用kenlm工具训练通及语言模型。 注: 统计语言模型工具有比较多的选择,目前比较好的有srilm以及kenlm,其中kenlm比srilm晚出来,训练速度也更快,而且支持单机大数据的训练。 因为使用该工具在Linux环境下比较方便,我是win10系统,所以需要使用cywin 64模拟linux环境 (先确保linux环境已经按照1.36.0的Boost和zlib。) 然后gcc版本需要是4.8.2及以上。 之后出现的界面,默认为第一个选项,意思是从网络下载并安装(从官网下载的不是完整安装包,只是安装引导程序) 之后都没什么问题,就默认下一步就ok了 然后会出现一个界面,ustc是中科大的镜像,neusoft是东软的镜像下载速度较快,当然也可也选香港的(一个hk的什么网站,很好找)。 在搜索框出处分别搜索 gcc-core、gcc-g++、make、gdb、binutils,以上所有项目都在 devel 文件夹下。点击想要下载的包后面的skip即可。 然后点击下一步。 将安装目录下的 bin目录 添加到 Path 环境变量。我用的是 windows 10,添加环境变量的具体方法自行百度。 最后在terminal中 输入gcc -v + enter,出现如下界面即为安装成功。 来源: oschina 链接: https://my

Linux C编程之十四 线程、线程控制、线程属性

放肆的年华 提交于 2021-02-01 02:45:22
一、整体大纲 二、线程相关 1. 什么是线程 LWP:light weight process 轻量级的进程,本质仍是进程(在Linux环境下) 进程:独立地址空间,拥有PCB 线程:也有PCB,但没有独立的地址空间(共享) 区别:在于是否共享地址空间。 独居(进程);合租(线程)。 Linux下: 线程:最小的执行单位 进程:最小分配资源单位,可看成是只有一个线程的进程。 2. Linux内核线程实现原理 (1)线程实现原理 类Unix系统中,早期是没有“线程”概念的,80年代才引入,借助进程机制实现出了线程的概念。因此在这类系统中,进程和线程关系密切。 1)轻量级进程(light-weight process),也有PCB,创建线程使用的底层函数和进程一样,都是clone 2)从内核里看进程和线程是一样的,都有各自不同的PCB,但是PCB中指向内存资源的三级页表是相同的 3)进程可以蜕变成线程 4)线程可看做寄存器和栈的集合 5)在linux下,线程最是小的执行单位;进程是最小的分配资源单位 察看LWP号:ps -Lf pid 查看指定线程的lwp号。 三级映射:进程PCB --> 页目录(可看成数组,首地址位于PCB中) --> 页表 --> 物理页面 --> 内存单元 参考:《Linux内核源代码情景分析》 ----毛德操 对于进程来说,相同的地址(同一个虚拟地址

Linux Kernel Module Cheat - Qemu Baremetal Xilinx Zynq A9

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 20:00:38
问题 My goal is to emulate the ARM A9 processor as found on the Zynq-7000, running baremetal software. I have tried 2 different approaches to this and run into road blocks on both. Any suggestions on how to proceed would be appreciated. Current answers on StackOverflow: How to make bare metal ARM programs and run them on QEMU? which links to Linux Kernel Module Cheat (LKMC, using v3.0) built using ./build --arch arm qemu-baremetal The examples on the site of using the ARM virtual machine ( -virt

GDB breakpoints do not hit template functions

血红的双手。 提交于 2021-01-29 14:30:49
问题 I am trying set breakpoints in template functions in C++ via GDB I tried three possible approaches. break fileName:functionName => works for non-templated functions (specific to one function) rbreak fileName:. => breakpoints at all functions in a given file, but it does not seem to work for template functions break fileName:lineNumber => works for both non-templated and templated functions but problem here for me is I have to modify this linenumber everytime. A overall objective is am using a