Advanced

Fun with strace and the GDB Debugger

Posted by nixcraft on · 3 comments
IBM developerworks; By William B. Zimmerly
Mail this story
Print this story

Programming a UNIX system can be fun as well as educational. With the UNIX strace tool and GDB, the GNU Project Debugger, you can really dig deep into the functionality of your system and learn a lot about the various programs that comprise it. Using both tools in concert can be a rewarding experience as you look under the hood of your UNIX machine.

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: GNU

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments (3)

GDB READ WRITE

Hi, Can you can tell me the GDB command to do following: 1. Read a register 2. Read a memory location 3. Write a register 4. Write a memory location

It would so nice if you could help me!

thanks, mudassir.
Hi,

I got the answer of how to read/write registers. i am writing it here for anyone else's use. it is as follows

to read: gdb> print $ e.g: gdb> print $PC

and to write gdb> print $= e.g: gdb> print $PC=0x01000ffc4

And to read write memory contents:

to read: gdb> print (*(int*)) e.g: gdb> print (*(int*)0x01000ffc4)

and to write

gdb> print (*(int*))= e.g: gdb> print (*(int*)0x01000ffc4=0x01014433 Note: memory region should be readable/writable for the purpose ofcourse!

But i am still interesting in knowing, how to read a chunk of memory say 100 bytes. I should specify a range with address somewhere.

thanks, mudassir shabbir.

detect memory leaks with valgrind in a shared lib

hi, I developed a shared libarary as the end result of a c++ project.Now I need to detect the memory leaks in that shared library using valgrind.Pls anybody tell me how to do this.when I try to check the memory leaks in the source file itself I get a permission defined message(yer I tried as the root too, but again permission defined) why is this ? Thanks -rajika

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post