* How to access files (open/read/close) from gdb script ? [not found] <6541ed4c050926074274c08518@mail.gmail.com> @ 2005-09-26 14:45 ` David Lamy-Charrier 2005-09-26 14:51 ` Ramana Radhakrishnan 0 siblings, 1 reply; 14+ messages in thread From: David Lamy-Charrier @ 2005-09-26 14:45 UTC (permalink / raw) To: gdb Hello, Does anyone of you know how to perform file operations (open/read/close) from a GDB script ? Each time GDB stops on a breakpoint I read a value from memory and then I want to open a file on the host and search for the value in this file ? any hints ? Thanks, David ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 14:45 ` How to access files (open/read/close) from gdb script ? David Lamy-Charrier @ 2005-09-26 14:51 ` Ramana Radhakrishnan 2005-09-26 15:53 ` David Lamy-Charrier 0 siblings, 1 reply; 14+ messages in thread From: Ramana Radhakrishnan @ 2005-09-26 14:51 UTC (permalink / raw) To: David Lamy-Charrier; +Cc: gdb On Mon, 2005-09-26 at 16:44 +0200, David Lamy-Charrier wrote: > Hello, > > Does anyone of you know how to perform file operations > (open/read/close) from a GDB script ? Maybe you can integrate this with an expect / tcl script ? AFAIK gdb scripting does not allow such stuff. cheers Ramana ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 14:51 ` Ramana Radhakrishnan @ 2005-09-26 15:53 ` David Lamy-Charrier 2005-09-26 17:03 ` Joel Brobecker 2005-09-26 17:27 ` Jim Ingham 0 siblings, 2 replies; 14+ messages in thread From: David Lamy-Charrier @ 2005-09-26 15:53 UTC (permalink / raw) To: gdb > Maybe you can integrate this with an expect / tcl script ? AFAIK gdb > scripting > does not allow such stuff. I am not sure to understand correclty: you mean that I can write a tcl script to do that, but how can I then launch the tcl script ? Thanks, David ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 15:53 ` David Lamy-Charrier @ 2005-09-26 17:03 ` Joel Brobecker 2005-09-26 17:22 ` Jim Ingham 2005-09-26 17:27 ` Jim Ingham 1 sibling, 1 reply; 14+ messages in thread From: Joel Brobecker @ 2005-09-26 17:03 UTC (permalink / raw) To: David Lamy-Charrier; +Cc: gdb > I am not sure to understand correclty: > you mean that I can write a tcl script to do that, but how can I then > launch the tcl script ? You can launch any command from GDB using the "shell" command. Just as a comment regarding TCL, I would personally use anything but TCL. It's your choice: You can use bourne scripts, or even write a program in C or Ada... -- Joel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:03 ` Joel Brobecker @ 2005-09-26 17:22 ` Jim Ingham 2005-09-26 17:34 ` David Lamy-Charrier 2005-09-26 17:35 ` Daniel Jacobowitz 0 siblings, 2 replies; 14+ messages in thread From: Jim Ingham @ 2005-09-26 17:22 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb Since ALL the gdb testsuites are written in Tcl (that's what Expect uses, and that is consequently what dejagnu uses) this seems a particularly unfortunate place to be airing your prejudices. Jim On Sep 26, 2005, at 10:03 AM, Joel Brobecker wrote: >> I am not sure to understand correclty: >> you mean that I can write a tcl script to do that, but how can I then >> launch the tcl script ? >> > > You can launch any command from GDB using the "shell" command. > > Just as a comment regarding TCL, I would personally use anything but > TCL. It's your choice: You can use bourne scripts, or even write a > program in C or Ada... > > -- > Joel > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:22 ` Jim Ingham @ 2005-09-26 17:34 ` David Lamy-Charrier 2005-09-26 17:36 ` Daniel Jacobowitz 2005-09-26 17:35 ` Daniel Jacobowitz 1 sibling, 1 reply; 14+ messages in thread From: David Lamy-Charrier @ 2005-09-26 17:34 UTC (permalink / raw) To: gdb > > You can launch any command from GDB using the "shell" command. > > > > Just as a comment regarding TCL, I would personally use anything but > > TCL. It's your choice: You can use bourne scripts, or even write a > > program in C or Ada... Thanks a lot for your help, but with an external script or program, I can not retrieve results of the external program from my gdb script (except maybe the exit_code) ? Is there anywhere a list of allowed functions from gdb script (I know that printf, strcmp... are allowed) ? Thanks, David ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:34 ` David Lamy-Charrier @ 2005-09-26 17:36 ` Daniel Jacobowitz 2005-09-27 13:57 ` David Lamy-Charrier 0 siblings, 1 reply; 14+ messages in thread From: Daniel Jacobowitz @ 2005-09-26 17:36 UTC (permalink / raw) To: David Lamy-Charrier; +Cc: gdb On Mon, Sep 26, 2005 at 07:34:10PM +0200, David Lamy-Charrier wrote: > > > You can launch any command from GDB using the "shell" command. > > > > > > Just as a comment regarding TCL, I would personally use anything but > > > TCL. It's your choice: You can use bourne scripts, or even write a > > > program in C or Ada... > > Thanks a lot for your help, > but with an external script or program, I can not retrieve results of > the external program from my gdb script (except maybe the exit_code) ? > > Is there anywhere a list of allowed functions from gdb script (I know > that printf, strcmp... are allowed) ? They aren't "allowed" per se. You're calling functions in the program you're debugging when you do this. You have two options: use "shell" and its limitations, or wrap GDB in something that processes its input and output, like Expect. -- Daniel Jacobowitz CodeSourcery, LLC ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:36 ` Daniel Jacobowitz @ 2005-09-27 13:57 ` David Lamy-Charrier 2005-09-27 13:59 ` Daniel Jacobowitz 0 siblings, 1 reply; 14+ messages in thread From: David Lamy-Charrier @ 2005-09-27 13:57 UTC (permalink / raw) To: gdb > > Is there anywhere a list of allowed functions from gdb script (I know > > that printf, strcmp... are allowed) ? > > They aren't "allowed" per se. You're calling functions in the program > you're debugging when you do this. > > You have two options: use "shell" and its limitations, or wrap GDB in > something that processes its input and output, like Expect. Thanks for your hints, but I am using a GUI front-end (Elicpse) for GDB, so I can't process GDB's input and ouput. That's why I was trying to do it from a GDB script... By the way, in a "debugguee" program, is there any way to know if the program is currently running "in" GDB or if it is freely running (without debuuger connected) ?? Thanks again, David ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-27 13:57 ` David Lamy-Charrier @ 2005-09-27 13:59 ` Daniel Jacobowitz 0 siblings, 0 replies; 14+ messages in thread From: Daniel Jacobowitz @ 2005-09-27 13:59 UTC (permalink / raw) To: David Lamy-Charrier; +Cc: gdb On Tue, Sep 27, 2005 at 03:57:12PM +0200, David Lamy-Charrier wrote: > By the way, in a "debugguee" program, is there any way to know if the > program is currently running "in" GDB or if it is freely running > (without debuuger connected) ?? In general there shouldn't be. It's supposed to be transparent. -- Daniel Jacobowitz CodeSourcery, LLC ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:22 ` Jim Ingham 2005-09-26 17:34 ` David Lamy-Charrier @ 2005-09-26 17:35 ` Daniel Jacobowitz 2005-09-26 17:42 ` Jim Ingham 1 sibling, 1 reply; 14+ messages in thread From: Daniel Jacobowitz @ 2005-09-26 17:35 UTC (permalink / raw) To: Jim Ingham; +Cc: Joel Brobecker, gdb On Mon, Sep 26, 2005 at 10:23:10AM -0700, Jim Ingham wrote: > Since ALL the gdb testsuites are written in Tcl (that's what Expect > uses, and that is consequently what dejagnu uses) this seems a > particularly unfortunate place to be airing your prejudices. In fact I find it excessively appropriate; they are some of the worst testsuite codes I've ever had the misfortune to work with and TCL is a big part of the reason why. As the currently most active TCL programmer in the GDB project, I think I've earned the right to agree with Joel. If I had the luxury to redo it I'd do it in Anything But TCL, probably by improving QMTest's support for interactive testing. -- Daniel Jacobowitz CodeSourcery, LLC ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:35 ` Daniel Jacobowitz @ 2005-09-26 17:42 ` Jim Ingham 2005-09-26 21:48 ` Joel Brobecker 0 siblings, 1 reply; 14+ messages in thread From: Jim Ingham @ 2005-09-26 17:42 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb I totally disagree with this. The reason why so much of the gdb testsuite is horrible is that it was written by people who never bothered to learn Tcl, and instead programmed it wishing it was "sh" - which is a pretty perverse thing to wish anyway. If you take the trouble to actually learn how it works, rather than just cutting & pasting examples you don't fully understand, it is a perfectly fine language. Any language will work poorly for you if you have decided up front that it's going to do so. Jim On Sep 26, 2005, at 10:35 AM, Daniel Jacobowitz wrote: > On Mon, Sep 26, 2005 at 10:23:10AM -0700, Jim Ingham wrote: > >> Since ALL the gdb testsuites are written in Tcl (that's what Expect >> uses, and that is consequently what dejagnu uses) this seems a >> particularly unfortunate place to be airing your prejudices. >> > > In fact I find it excessively appropriate; they are some of the worst > testsuite codes I've ever had the misfortune to work with and TCL is a > big part of the reason why. As the currently most active TCL > programmer in the GDB project, I think I've earned the right to agree > with Joel. > > If I had the luxury to redo it I'd do it in Anything But TCL, probably > by improving QMTest's support for interactive testing. > > -- > Daniel Jacobowitz > CodeSourcery, LLC > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:42 ` Jim Ingham @ 2005-09-26 21:48 ` Joel Brobecker 0 siblings, 0 replies; 14+ messages in thread From: Joel Brobecker @ 2005-09-26 21:48 UTC (permalink / raw) To: Jim Ingham; +Cc: Daniel Jacobowitz, gdb > If you take the trouble to actually learn how it works, rather than > just cutting & pasting examples you don't fully understand, it is a > perfectly fine language. Any language will work poorly for you if > you have decided up front that it's going to do so. Sorry guys, my intention wasn't really to bash on TCL at all, just to let him know that TCL was not the only option for writing his external tool. The point was for him to use whatever language he's most familiar with, even if it is TCL. I'm sorry that my personal opinion of the language seeped through, again, that was not my intention. -- Joel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 15:53 ` David Lamy-Charrier 2005-09-26 17:03 ` Joel Brobecker @ 2005-09-26 17:27 ` Jim Ingham 2005-09-26 17:33 ` Daniel Jacobowitz 1 sibling, 1 reply; 14+ messages in thread From: Jim Ingham @ 2005-09-26 17:27 UTC (permalink / raw) To: David Lamy-Charrier; +Cc: gdb The gdb testsuites are an example of how to do this. They use "expect" to drive gdb and parse it's output. There are also a lot of Tcl helper libraries in the testsuite/lib directory that manage stepping, etc. So one pretty easy option is to use the dejagnu harness. In any case, you can run the gdb testsuite (using "make check") to get an example of how to use Tcl & Expect to script gdb. Also, if you can get the Insight debugger, that has a Tcl Interpreter build into gdb, and you can write scripts and just "source" them in Insight. At that point, you can do anything you could do in plain Tcl... I think DanielJ also has mentioned working on scripting bindings using the MI in the past, but I don't know the state of this. That is a little bit more work, but would allow you to run gdb under another scripting language if you wanted. Jim On Sep 26, 2005, at 8:53 AM, David Lamy-Charrier wrote: >> Maybe you can integrate this with an expect / tcl script ? AFAIK gdb >> scripting >> does not allow such stuff. >> > > I am not sure to understand correclty: > you mean that I can write a tcl script to do that, but how can I then > launch the tcl script ? > > Thanks, > David > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to access files (open/read/close) from gdb script ? 2005-09-26 17:27 ` Jim Ingham @ 2005-09-26 17:33 ` Daniel Jacobowitz 0 siblings, 0 replies; 14+ messages in thread From: Daniel Jacobowitz @ 2005-09-26 17:33 UTC (permalink / raw) To: Jim Ingham; +Cc: David Lamy-Charrier, gdb On Mon, Sep 26, 2005 at 10:28:46AM -0700, Jim Ingham wrote: > I think DanielJ also has mentioned working on scripting bindings > using the MI in the past, but I don't know the state of this. That > is a little bit more work, but would allow you to run gdb under > another scripting language if you wanted. The current state is I'm hoping to piggyback on Nick's current interpreter work but haven't tried lately. -- Daniel Jacobowitz CodeSourcery, LLC ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2005-09-27 13:59 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <6541ed4c050926074274c08518@mail.gmail.com> 2005-09-26 14:45 ` How to access files (open/read/close) from gdb script ? David Lamy-Charrier 2005-09-26 14:51 ` Ramana Radhakrishnan 2005-09-26 15:53 ` David Lamy-Charrier 2005-09-26 17:03 ` Joel Brobecker 2005-09-26 17:22 ` Jim Ingham 2005-09-26 17:34 ` David Lamy-Charrier 2005-09-26 17:36 ` Daniel Jacobowitz 2005-09-27 13:57 ` David Lamy-Charrier 2005-09-27 13:59 ` Daniel Jacobowitz 2005-09-26 17:35 ` Daniel Jacobowitz 2005-09-26 17:42 ` Jim Ingham 2005-09-26 21:48 ` Joel Brobecker 2005-09-26 17:27 ` Jim Ingham 2005-09-26 17:33 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).