Find the answer to your Linux question:
Results 1 to 9 of 9
Because i also need shell scripting help ill just post my questions here. How do I make him just write this: gdb a.out break main run ptype CA I wrote ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19

    need shell scripting help

    Because i also need shell scripting help ill just post my questions here.

    How do I make him just write this:
    gdb a.out
    break main
    run
    ptype CA

    I wrote this and when i run it, it just executed first line.

  2. #2
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19
    I hope you understand what i mean.

  3. #3
    Linux Newbie
    Join Date
    Jan 2008
    Location
    UK
    Posts
    211
    I mean this in the nicest possible way, but,I think you need to re-think how you put your question across & state what you are trying to achieve.

  4. #4
    Just Joined!
    Join Date
    Jan 2008
    Posts
    25
    Its not at all clear from your post, what you want to do.
    Is it that you want to write a shell script which run a gdb debugger for you? break the loop when something criteria is failed, etc.? Could you please a bit more clear.

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19
    Yes i want my script to run gdb debuger and then set a breakpoint at main
    and run the debug. Then the script should write ptype CA so i get my whole CA
    class writen on screen or if it is possible to save it in a .txt file
    (ptype CA > some.txt doesnt work).


    I wrote this shell script:
    gdb a.out
    break main
    run
    ptype CA

    But it didnt work.
    It just ran gdb debuger and nothing else.

    I hope you understand what i mean now.

    Sorry for my previous post.

  6. #6
    Just Joined!
    Join Date
    Oct 2007
    Posts
    7
    Create a file with your GDB command inside say "cmd1" then run:

    Code:
    gdb -x cmd1 a.out
    Scorp

  7. #7
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19
    I dont understand what does this do scorp?

    Tnx for your reply

  8. #8
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Alrighty. We need to go back to a few basics.

    A Bash script is a script for the Bash shell. When you execute it, Bash will execute each command in sequence. So your script tells Bash: "Run the command 'gdb a.out'. When that finishes, run the command 'break main'. When that finishes, run the command 'run'. When that finishes, run the command 'ptype CA'." Obviously, this is not what you want.

    What you want is to run "gdb a.out", and have it automatically run those commands. And by looking at the gdb man page, I see the following:
    Code:
           -command=file
    
           -x file
                   Execute GDB commands from file file.
    So this is where scorp's advice comes in. Let's create a new file called "gdb_commands", and in it, we will put:
    Code:
    break main
    run
    ptype CA
    Now, we can run gdb by saying:
    Code:
    gdb -x gdb_commands a.out
    gdb will read this list of commands and process it.

    Does that make sense?
    DISTRO=Arch
    Registered Linux User #388732

  9. #9
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19
    yes Cabhan that was a very helpful explenation.
    Thank you i understand now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...