LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-05-2008, 08:50 PM   #1
jackandking
Member
 
Registered: Dec 2004
Posts: 92

Rep: Reputation: 15
Question any gdb script to parse string?


how can i get the addr following "saved eip" and "Arglist at" from the output of "info f" in gdb?
Code:
(gdb) info f
Stack level 9, frame at 0xbfffcc78:
 eip = 0x42d5310e in EvalAll (epeval.c:218); saved eip 0x42d53c3a
 called by frame at 0xbfffccb8, caller of frame at 0xbfffcc38
 source language c.
 Arglist at 0xbfffcc78, args: r=0x894a488, sArg=0x89f6e83 " $$searchdata{starfirst} ", flags=0, sName=0x89ffe28 "$衆224\b\001", 
    pRet=0xbfffcca8
 Locals at 0xbfffcc78, Previous frame's sp is 0x0
 Saved registers:
  ebx at 0xbfffcc6c, ebp at 0xbfffcc78, esi at 0xbfffcc70, edi at 0xbfffcc74, eip at 0xbfffcc7c
I wanna use the two addr in my gdb script.
 
Old 12-07-2008, 09:28 AM   #2
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by jackandking View Post
how can i get the addr following "saved eip" and "Arglist at" from the output of "info f" in gdb?
Code:
(gdb) info f
Stack level 9, frame at 0xbfffcc78:
 eip = 0x42d5310e in EvalAll (epeval.c:218); saved eip 0x42d53c3a
 called by frame at 0xbfffccb8, caller of frame at 0xbfffcc38
 source language c.
 Arglist at 0xbfffcc78, args: r=0x894a488, sArg=0x89f6e83 " $$searchdata{starfirst} ", flags=0, sName=0x89ffe28 "$衆224\b\001", 
    pRet=0xbfffcca8
 Locals at 0xbfffcc78, Previous frame's sp is 0x0
 Saved registers:
  ebx at 0xbfffcc6c, ebp at 0xbfffcc78, esi at 0xbfffcc70, edi at 0xbfffcc74, eip at 0xbfffcc7c
I wanna use the two addr in my gdb script.
You can redirect output to the file, then process file with any external program (invoked by the gdb's shell call), write output in the form of

$name1 = value1
$name2 = value2

to the file, source this file to gdb and use those variables.

Tricky and ugly but doable.
You can have a look for something resembling here:
http://statifier.sf.net

Statifier is a program that convert dynamically linked executable to pseudo-static.
It uses gdb to dump process memory and registers to the files as part of statifying process

Files src/gdb_runner.gdb and src/statifier.gdb are examples of such tricks.
PLease notes, that those files are preprocessed with sed before be used, but anyway you should get idea.

EDIT: Statifier don't use gdb any more, but files mentioned above still can be found in the release < 1.7.0 or in SVN - tag 1.6.15

Last edited by Valery Reznic; 02-25-2010 at 09:01 AM.
 
Old 12-07-2008, 08:18 PM   #3
jackandking
Member
 
Registered: Dec 2004
Posts: 92

Original Poster
Rep: Reputation: 15
It's very useful to me,
thanks a lot.
 
Old 12-07-2008, 11:19 PM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by jackandking View Post
It's very useful to me,
thanks a lot.
You are welcome
 
  


Reply

Tags
gdb, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse String in a Bash script jimwelc Linux - Newbie 8 11-09-2012 07:47 AM
how to parse the xml string Dyuri Linux - Software 2 09-03-2008 08:49 AM
Bash script: Parse folders in path string miceagol Programming 3 03-25-2008 06:31 PM
parse a string in perl 2007fld Programming 13 08-07-2007 02:41 PM
Parse a perl string djgerbavore Programming 3 10-31-2004 07:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration