gdb

linux 分析进程占用CPU过高

心不动则不痛 提交于 2021-02-10 11:17:44
<div id="article_content" csdn-tracking-statistics"="" data-pid="blog" data-mod="popu_307" data-dsm="post" style="box-sizing: inherit; outline: 0px; padding: 0px; margin: 0px; word-break: break-all;"><div style="box-sizing: inherit; outline: 0px; padding: 0px; margin: 0px; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif, SimHei, SimSun; word-break: break-all;"><p style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 16px; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align:

linux 分析进程占用CPU过高

一曲冷凌霜 提交于 2021-02-10 10:01:52
重点是查看进程的线程中,哪个线程占用cpu过高,然后用gdb附加到进程,调试线程,看是否有死循环或者死锁等问题,步骤如下: 1 先用ps + grep找出该死的进程pid,比如 1706 2 top -H -p 1706,(top然后shift+H可以看出某个线程,左上角有提示:thread on 则为可查看线程)所有该进程的线程都列出来, 看看哪个线程pid占用最多,记下对应的线程号,如:1723 gdb attach 到进程号码(1706) (仍然在gdb中) info threads 结果大致如下: (gdb) info threads 8 Thread 0x7f9fa9366700 (LWP 1716 ) 0x0000003cec00b98e in pthread_cond_timedwait @@GLIBC_2.3.2 () from /lib64/libpthread.so.0 7 Thread 0x7f9fa8965700 (LWP 1720 ) 0x0000003cec00b98e in pthread_cond_timedwait @@GLIBC_2.3.2 () from /lib64/libpthread.so.0 6 Thread 0x7f9fa7f64700 (LWP 1721 ) 0x0000003cec00f4b5 in sigwait () from

How does gdb set software breakpoints in shared library functions?

元气小坏坏 提交于 2021-02-08 13:21:41
问题 I know that software breakpoints in an executable file can work through replacing some assembler instruction at the desired place with another one, which cause interrupt. So debugger can stop execution exactly at this place and replace this instruction with original one and ask user about what to do the next or call some commands and etc. But code of such executable file is not used by another programs and has only one copy in memory. How can software breakpoints work with a shared libraries?

Debug error before main() using GDB

寵の児 提交于 2021-02-08 08:54:25
问题 Is there anyway to debug a link error or any kind of error that may occur before the execution of the main() function using GDB? 回答1: Is there anyway to debug a link error Presumably you are asking about runtime link error (e.g. `error: libfoo.so: no such file or directory'), and not about (static) link step of your build process. The trick is to set a breakpoint on exit or ( exit_group on Linux) system call with e.g. catch syscall exit . You will then be stopped inside ld.so at the point

How to passing input data in GDB mode for programming C. Already passed parameters and run program

↘锁芯ラ 提交于 2021-02-08 08:36:32
问题 I already know how to pass parameters in GDB mode by running: "run parameters". However, when continuing to debug by using n or s to go, I would like to pass data to my program, let say a text/string. For example, I want to send a string as "Testing" to my program because my program always waits to receive command from console. If I type "Testing" it will say "undefined command: "Testing". Try help". (gdb) b 100 (gdb) run "pass parameters to program here" (gdb) n (gdb) Now I want to send a

GDB script flow control for remote target

强颜欢笑 提交于 2021-02-08 08:01:26
问题 I would like to do only flash the code on a remote gdb target if it has changed since last time gdb was run. I envisage something along the lines of the following in gdb script; target extended-remote /dev/<device> <Attach to Target> file <Target Program> if ![compare-sections -r] load start ...however, I cannot see how to make a conditional on a command output. Can anyone help? I think I probably missed something, but I've no idea what.... 回答1: The compare-sections command doesn't return a

With option -tui, GDB exits with “TUI mode is not allowed”

喜你入骨 提交于 2021-02-08 02:03:53
问题 I am running gdb GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7 version. My TUI mode was working seamlessly. Suddenly, now it is giving error "TUI mode not allowed" upon issuing command layout src . When I try to run gdb with -tui option, gdb is exiting immediately with "TUI mode not allowed" . *Asked as new question because none of other threads could help. 回答1: I had the same issue. To solve it you have to recompile gdb with TUI support. These are the steps for Ubuntu: apt-get build

With option -tui, GDB exits with “TUI mode is not allowed”

江枫思渺然 提交于 2021-02-08 02:00:45
问题 I am running gdb GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7 version. My TUI mode was working seamlessly. Suddenly, now it is giving error "TUI mode not allowed" upon issuing command layout src . When I try to run gdb with -tui option, gdb is exiting immediately with "TUI mode not allowed" . *Asked as new question because none of other threads could help. 回答1: I had the same issue. To solve it you have to recompile gdb with TUI support. These are the steps for Ubuntu: apt-get build

With option -tui, GDB exits with “TUI mode is not allowed”

为君一笑 提交于 2021-02-08 02:00:08
问题 I am running gdb GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7 version. My TUI mode was working seamlessly. Suddenly, now it is giving error "TUI mode not allowed" upon issuing command layout src . When I try to run gdb with -tui option, gdb is exiting immediately with "TUI mode not allowed" . *Asked as new question because none of other threads could help. 回答1: I had the same issue. To solve it you have to recompile gdb with TUI support. These are the steps for Ubuntu: apt-get build

gdb exiting instead of spawning a shell

淺唱寂寞╮ 提交于 2021-02-07 20:09:15
问题 I am trying to exploit a SUID program. The program is: #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> #define e(); if(((unsigned int)ptr & 0xff000000)==0xca000000) { setresuid(geteuid(), geteuid(), geteuid()); execlp("/bin/sh", "sh", "-i", NULL); } void print(unsigned char *buf, int len) { int i; printf("[ "); for(i=0; i < len; i++) printf("%x ", buf[i]); printf(" ]\n"); } int main() { unsigned char buf[512]; unsigned char *ptr = buf + (sizeof(buf)/2); unsigned