gdb with ddd scripting -> graph undefined command

683 Views Asked by At

I use ddd as frontend for gdb.

I want to prepare a small file which contains some commands like

(gdb) graph display x

But if I do a

(gdb) source myfile

and myfile contains any graph command the result is:

(gdb) source myfile
x:1: Error in sourced command file:
Undefined command: "graph".  Try "help".
(gdb) graph display res

Any idea how I can script ddd. It looks that the source command is executed from gdb and gdb itself knows no "graph" command. But how to load a script in ddd itself?

2

There are 2 best solutions below

0
On

I found that in DDD, we can define sequence of commands into a new command using the menu 'Commands- Define Command' menu. There you can define any DDD command sequences into a new command and place a button for the command where you want (right on console window or on source window). For example, to define a command disp1, you can define it like this.
First press 'Commands'-'Define Command' in the menu. Click on the 'Record' button. Then enter the commands in the command window. Then click on the 'End' button.
Now you select where the command button you want appeared. Select 'Console' or 'Source' or 'Data'. For example, if you select 'source' button, the command button appears above the source window pane, if you select 'data', it appears in the 'data' window. You can try 'Execute' while you edit it to see if it works fine. Now press 'Close' button. You can see button 'Disp1' sits where you chose. This button appears after you close the ddd and restart it. (The command defintion is kept in ~/.ddd/init script.

enter image description here

after you defined the command, it appears above the command/source/data window like below. You can execute it by pressing the button.

enter image description here

0
On

graph display command is of ddd, not gdb.

source <file_name> is of gdb. You can execute gdb commands listed in file using this.

So in your case, it is like you are entering graph display command on gdb. And gdb doesn't know any graph display command, hence gives error.

As per ddd manual, I think there is no such support to load script in ddd yet.