Is it possible to jump to current line being executed in the Source Window of cgdb?
It would be great to have a command or a shortcut to do this, especially after browsing files in the File Dialog mode for a long time.
It turned out that you can jump to current line easily: just use gdb frame command without arguments, or simply f.
I don't think we have a shortcut for it. I usually do a quick up and down (or vice versa) in gdb.
You can use '.. Please please See https://github.com/cgdb/cgdb/issues/53
Related
Today I was just experimenting with Linux shell. Here is what I did.
I wrote the output of clear to a file :
clear > clear.txt
Now I have some contents on the shell, (non-empty). Then I try to cat the contents of clear.txt
cat clear.txt
For my surprise, the entire screen got cleared. Can somone explain me why? if this is true, why cant we do the same for all the commands?
clear works very simply by transmitting a sequence of control codes which are interpreted by your terminal. The magic of actually clearing the screen is handled by your terminal (or terminal emulator, or console interface, or whatever you happen to be using) in response to receiving these control codes.
See also e.g. https://en.wikipedia.org/wiki/ANSI_escape_code
Well it's not a real explanation but it's how it is supposed to work:
http://man7.org/linux/man-pages/man1/clear.1.html
#CLEAR# writes to the standard output. You can redirect the standard
output to a file (which prevents #CLEAR# from actually clearing the
screen), and later cat the file to the screen, clearing it at that
point.
It is a visual representation of the clear command. Editing the text file yields:
^[[3J^[[H^[[2J
source: https://unix.stackexchange.com/questions/400142/terminal-h2j-caret-square-bracket-h-caret-square-bracket-2-j
I have this nifty couple of lines in my .bashrc that clears my unix terminal when I press shift+alt+c:
alias cls='printf "\033c"'
bind -x '"\eC":"cls"'
However, as you could probably guess, it only works when I'm actually at the prompt. If I'm in the middle of a program such as, let's say, tail -f, then I have to get back to the prompt, press shift+alt+c, then go back to the program (or ctrl+z, shift+alt+c, then fg).
I'm thinking it would be cool if I could somehow listen for keys while this other program is running. It's probably impossible, but I figured I'd ask here before I gave up. Any ideas?
Thanks!
Not going to work. That's your shell doing that.
Your shell isn't active when something else is.
You could do this sort of thing with your terminal if you really wanted to though (assuming it allows you to control it sufficiently) since your terminal sees the keys first.
There doesn't appear to be easy way to halt execution and enter the ISE debugger from a Powershell script. Currently I do the following:
Set-PSBreakPoint -command BreakIntoDebug | Out-Null # at start of script.
function BreakIntoDebug {} # elsewhere in code.
BreakIntoDebug # wherever I want to go into debugger.
However, this is awkward. At the breakpoint, I need to hit F10 two times to see where it was called from. Then I need to use "exit" to continue running the program. Is there a better way? I know someone will tell me that this is a bad way to debug. However there are times when this is the best way to find a very rare bug that only appears in a specific code path. (I indented 4 spaces to format as code, but it keeps displaying it inline.)
Your way is pretty clever. :-) Take a look at the help on the Set-PSDebug command as another way of tracing/debugging the execution of your script.
I sometimes need to run a very long shell command, and I don't want to copy the long command to an editor and edit it there.
Is there a way in the shell to move the cursor quickly in instead of holding the left key for almost a minute and get to the most left?
Like move the cursor by word when you hold some key?
Or a combo could jump to the beginning of the command?
Assuming you're using bash in the default mode, ctrl-e should do that for you.
Also helpful: Ctrl-x-e will take your current command line and open it in an editor, chosen via $EDITOR. (see commandlinefu.com)
Yes - in almost all shells, control-A will jump to the beginning of the line, and control-E to the end.
If you're using bash shell you can use control-a to jump to the start of the line, control-e to jump to the end.
More explanation and commands here.
While debugging some code in gdb, I want to see which line will be executed if I say next or step.
Of course I can say l, but if I say l a couple times (and don't remember how many times), then l does not print the line that will be executed.
I can also scroll back to the last time gdb stopped and see which line it was at, but that sometimes involve digging through a bunch of output.
I am wondering if I am missing a simple command in gdb which shows me the current line the debugger is stopped at?
To see the current line the debugger stopped at, you can use frame command with no arguments. This achieves the same effect as update command. It works both in tui and command line mode.
You can use
list *$eip
or the shorter form
l *$eip
This will instruct gdb to print the source lines near the current program counter.
You can say l +0; the current line will be the first one listed.
The command l +offset lists the code starting from offset lines from the current line.
Note that, if you have already used the list command, the current line will have changed, i.e., it will no longer be the next executing line. So this will only work on your first list command.
It sounds like you want to run GDB in Emacs (which will show you current file and mark the current line), in DDD, or in tui mode.