Simple GDB case

to be added...

gdb a.out

[Inferior 1 (process 9718) exited with code 05]

(gdb) list

Line number 15 out of range; t.c has 14 lines.

(gdb) list 1

1       #include

2       char foo(char *s)

3       {

4         char *c=s;

5         return *(c+2);

6       }

7       int main()

8       {

9         char arr[5]="abc\n";

10        char b=foo(arr);

(gdb)

11        printf("%c\n",b);

12        printf("%s\n",arr);

13

14      }

(gdb) disass /m

Dump of assembler code for function main:

8       {

0x08048449 <+0>:     push   ?p

0x0804844a <+1>:     mov    %esp,?p

0x0804844c <+3>:     and    $0xfffffff0,%esp

0x0804844f <+6>:     sub    $0x20,%esp

9         char arr[5]="abc\n";

0x08048452 <+9>:     movl   $0xa636261,0x1a(%esp)

0x0804845a <+17>:    movb   $0x0,0x1e(%esp)

10        char b=foo(arr);

=> 0x0804845f <+22>:    lea    0x1a(%esp),?x //eip 

0x08048463 <+26>:    mov    ?x,(%esp)

0x08048466 <+29>:    call   0x8048434

0x0804846b <+34>:    mov    %al,0x1f(%esp)

(gdb) info registers esp

esp            0xbfffefb0       0xbfffefb0

#another shell

[email protected]:~> echo $((0xbfffefb0+0x1a))

3221221322

[email protected]:~> echo ‘obase=16;base=10;3221221322‘ | bc

BFFFEFCA

(gdb) x /s 0xbfffefca

0xbfffefca:      "abc\n" //find the "abc\n"

(gdb)

gdb) help catch

Set catchpoints to catch events.

List of catch subcommands:

catch assert -- Catch failed Ada assertions

catch catch -- Catch an exception

catch exception -- Catch Ada exceptions

catch exec -- Catch calls to exec

catch fork -- Catch calls to fork

catch syscall -- Catch system calls by their names and/or numbers

catch throw -- Catch an exception

catch vfork -- Catch calls to vfork

Type "help catch" followed by catch subcommand name for

full documentation.

Type "apropos word" to search for commands related to "word".

Command name abbreviations are allowed if unambiguous.

(gdb)

(gdb) info breakpoints

Num     Type           Disp Enb Address    What

7       breakpoint     keep y   0x08048440 in foo

at t.c:5

breakpoint already hit 1 time

8       catchpoint     keep y              syscall ""

9       breakpoint     keep y    exception catch

10      catchpoint     keep y              fork

(gdb) disable breakpoints 7

(gdb)

condition

Simple GDB case,布布扣,bubuko.com

时间: 2024-12-21 05:20:30

Simple GDB case的相关文章

A simple json-rpc case for bitcoin blockchains

#!/usr/bin/env python import json import jsonrpc import requests #url = "http://user:[email protected]:port/ #you can find user and password in multichain.conf file in path ~/.multichain/chain2 url = "http://multichainrpc:[email protected]:4352/

gdb 支持 c++ stl 调试

http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt 将网页的文本保存到 ~/.gdbinit 之后就可以用 p 指令查看stl容器中的内容了 # # STL GDB evaluators/views/utilities - 1.03 # # The new GDB commands: # are entirely non instrumental # do not depend on any "inline"(s

使用linux的GDB打印STL(vector,map,set..................)

在linux用gdb或者cgdb计较不爽的地方是无法打印STL的东西,所有啊去网上找了找解决方案https://www.douban.com/note/182826844/?qq-pf-to=pcqq.c2c 本帖把怎么配置这个东西写出了,万一以后忘了,可以回头找找. 首先是下载gdb文件 https://sourceware.org/gdb/wiki/STLSupport    ------>找到网页里面的  然后点击进去下载stl_views_1.0.3.gdb 接下来把这个东西当到linu

gdb和gdbserver调试android应用与可执行

学习android5.0以后的ART虚拟机,看了看源码,比较头疼,决定通过动态调试的方式去学习. Art虚拟机有一个dex2oat的可执行程序.就想到了通过gdb和gdbserver来debug这个dex2oat. 记录一下调试方法: gdb运行在本地系统(windows/linux) gdbserver运行在android真机/模拟器上(adb shell ls /system/bin查看是否有gdbserver,如果没有,可以从源代码prebuild文件夹中获取,也可以从ndk的文件中获取)

prologue epilogue

https://www.hackerschool.com/blog/7-understanding-c-by-learning-assemblyhttps://www.hackerschool.com/blog/5-learning-c-with-gdb Last time, Alan showed how to use GDB as a tool to learn C. Today I want to go one step further and use GDB to help us und

CPython对象模型:List

此系列前几篇: CPython对象模型:基础 CPython对象模型:整型 CPython对象模型:string list是一种经常用到的数据结构,在python中常使用list来构造高级的数据结构. 本文记录了我对list对象的解析所得. 1 PyListObject 首先,来看看PyListObject的定义: typedef struct { PyObject_VAR_HEAD PyObject **ob_item; Py_ssize_t allocated; } PyListObject

Page Object Model (Selenium, Python)

时间 2015-06-15 00:11:56  Qxf2 blog 原文  http://qxf2.com/blog/page-object-model-selenium-python/ 主题 SeleniumPython We have come a long way since our post on implementing the Page Object Model - Implementing the Page Object Model (Selenium + Python) Whil

神经网络指南Hacker&#39;s guide to Neural Networks

Hi there, I'm a CS PhD student at Stanford. I've worked on Deep Learning for a few years as part of my research and among several of my related pet projects is ConvNetJS - a Javascript library for training Neural Networks. Javascript allows one to ni

ngrok原理浅析(转载)

之前在进行 微信Demo开发时曾用到过 ngrok这个强大的tunnel(隧道)工具,ngrok在其github官方页面上的自我诠释是 "introspected tunnels to localhost",这个诠释有两层含义: 1.可以用来建立public到localhost的tunnel,让居于内网主机上的服务可以暴露给public,俗称内网穿透. 2.支持对隧道中数据的introspection(内省),支持可视化的观察隧道内数据,并replay(重放)相关请求(诸如http请