Giter Club home page Giter Club logo

cma's People

Contributors

teawater avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cma's Issues

Not record a type of breakpoint but still keep it

Wrong code:
#try:
#b = Break_alloc("malloc", "<malloc")
#except BreakException:
#record_malloc = False
#else:
#break_is_available = True
#record_malloc = yes_no(lang.string("Do you want to record memory function malloc/calloc/realloc/free?"), True)
#if record_malloc:
#breaks[b.trigger] = b
#try:
#b = Break_calloc("calloc", "<calloc", memtype="malloc")
#breaks[b.trigger] = b
#except BreakException:
#pass
#try:
#b = Break_realloc("realloc", "<realloc", memtype="malloc")
#breaks[b.trigger] = b
#except BreakException:
#pass
#try:
#b = Break_release("free", "<free", memtype="malloc")
#breaks[b.trigger] = b
#except BreakException:
#pass

    #try:
        #b = Break_alloc("operator new", r'<operator new\(', '<operator new(', 'new')
    #except BreakException:
        #record_new = False
    #else:
        #break_is_available = True
        #record_new = yes_no(lang.string("Do you want to record memory function new/delete?"), True)
    #if record_new:
        #breaks[b.trigger] = b
        #try:
            #b = Break_release("operator delete", r'<operator delete\(', '<operator delete(', 'new')
            #breaks[b.trigger] = b
        #except BreakException:
            #pass

arch.get_arg1() pops up 'Cannot access memory at address 0x9'

the following error can be reproduced everytime. Tried target: redis-server, redis-cli. ran on Linux ubuntu 3.3.8, 32bit vmware. ubuntu-12.04.3-desktop-i386, rebuild kernel to 3.3.8, x86

root@ubuntu:~/db/src# gdb redis-server
GNU gdb (GDB) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from redis-server...done.
(gdb) source /root/gdb-7.7.1/cma.py
Please Input the config file:[/root/db/src/cma.conf]
Language is set to Chinese.
记录文件是“/root/db/src/cma.csv”。
脚本将记录已经被释放掉的内存信息。
脚本将记录backtrace信息。
脚本将记录内存函数“malloc/free”。
Breakpoint 3 at 0xb7e51d80 (2 locations)
Breakpoint 4 at 0xb7e52260 (2 locations)
Continuing.

Breakpoint 3, 0xb7e51d80 in malloc () from /lib/i386-linux-gnu/libc.so.6
Continuing.

Breakpoint 3, 0xb7e51d80 in malloc () from /lib/i386-linux-gnu/libc.so.6
Continuing.

Breakpoint 3, 0xb7e51d80 in malloc () from /lib/i386-linux-gnu/libc.so.6
Continuing.

Breakpoint 3, 0xb7e51d80 in malloc () from /lib/i386-linux-gnu/libc.so.6
Traceback (most recent call last):
File "/root/gdb-7.7.1/cma.py", line 364, in
size = arch.get_arg1()
File "/root/gdb-7.7.1/cma.py", line 196, in get_arg1
return long(gdb.parse_and_eval("*(unsigned long *)($ebp+8)"))
gdb.MemoryError: Cannot access memory at address 0x10
(gdb)

No symbol gdb will not get error

gdb
(gdb) target remote :1111
Remote debugging using :1111
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0x00007ffff7ddb2d0 in ?? ()
(gdb) info b
No breakpoints or watchpoints.
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x0000000000400e82 in ?? ()
(gdb) source ~/cma/cma.py
Please Input the config file:[/home/teawater/tmp/cma.conf]
Language is set to Chinese.
记录文件是“/home/teawater/tmp/cma.csv”。
脚本将记录已经被释放掉的内存信息。
脚本将记录backtrace信息。
是否记录内存函数malloc/calloc/realloc/free? [Yes]/No:
是否记录内存函数new/delete? [Yes]/No:
是否记录内存函数kmalloc/kfree? [Yes]/No:
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x0000000000400e82 in ?? ()
[0] 记录内存信息到“/home/teawater/tmp/cma.csv”。
[1] 继续。
[2] 退出并记录内存信息到“/home/teawater/tmp/cma.csv”。
哪个操作?[0]2
内存信息存入“/home/teawater/tmp/cma.csv”。

finish is interrupt by ctrl-c

tried 3 times, only got a traceback one time while press ctrl ^ C, the others got csv files successfully. The traceback should not be a big as we are debugging and we can try again. I think you can mark this issue as fixed. Thank you for your hard work!

The traceback attached below whatever:

Breakpoint 5, 0xb7e50260 in free () from /lib/i386-linux-gnu/libc.so.6

Continuing.

Breakpoint 5, 0xb7e50260 in free () from /lib/i386-linux-gnu/libc.so.6

^CTraceback (most recent call last):

File "/root/cma.py", line 549, in

breaks[r.group(1)].event()

File "/root/cma.py", line 373, in event

gdb.execute("finish", False, True)

KeyboardInterrupt: Quit

(gdb) bt
#0 0xb7e50260 in free () from /lib/i386-linux-gnu/libc.so.6
#1 0xb7e18c3d in vfprintf () from /lib/i386-linux-gnu/libc.so.6
#2 0xb7e4026b in vsnprintf () from /lib/i386-linux-gnu/libc.so.6
#3 0xb7e22f43 in snprintf () from /lib/i386-linux-gnu/libc.so.6
#4 0x08064d97 in zmalloc_get_rss () at zmalloc.c:369
#5 0x0805d494 in serverCron (eventLoop=0x60037350, id=0, clientData=0x0) at redis.c:1029
#6 0x0805915e in processTimeEvents (eventLoop=0x60037350) at ae.c:311
#7 0x08059444 in aeProcessEvents (eventLoop=0x60037350, flags=3) at ae.c:423
#8 0x0805954f in aeMain (eventLoop=0x60037350) at ae.c:455
#9 0x08063314 in main (argc=1, argv=0xbffff2d4) at redis.c:3178

Leon

No licence file

I was hoping to use a modified version of this tool to assist in a new python based gdb ui. To do that I would need this software to have a license permitting such use. My tool will be open source, and I will most certainly give credit where it is due.

What license have you released this tool under?

Exception when debugged process is compiled without "-g"

I've tested the cma tool and it only works with binaries compiled with the "-g" option. Otherwise, an exception is raised. IMHO it shouldn't crash if that information isn't available.

Breakpoint 2, 0x00007ffff7a9cf20 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
Traceback (most recent call last):
File "cma.py", line 558, in
breaks[r.group(1)].event()
File "cma.py", line 360, in event
not_released_add(arch.get_ret(), size, self.memtype)
File "cma.py", line 230, in not_released_add
not_released[addr].append(get_info_line(True))
File "cma.py", line 165, in get_info_line
raise Exception
Exception

My simple malloc and static memory test tool:

/* compile with: gcc -O2 -Wall -o malloctest malloctest.c */

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

static int magic_var = 0xdeadbeef;

int main (void)
{
        int i = 0;
        int *j;

        while(1) {
                sleep(1);
                j = malloc(sizeof(int));
                *j = i;
                printf("&magic_var: %p, magic_var: %#x, value: %#x\n",
                        &magic_var, magic_var, magic_var + *j);
                free(j);
                i++;
                if (i > 15)
                        i = 0;
        }
        return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.