How to display the code window when debugging by GDB - linux

Can anyone tell me which command is used to display the source code when debugging through GDB.
Would be of great help.

You can enter or leave the TUI mode with code window using Ctrl+x A key binding. Or use layout src command to enter TUI mode. See other TUI key bindings and commands.

Start gdb using gdb -tui. tui stands for Text User Interface.
Or, use 'ddd' -- a graphical front end for gdb.

The list command will show the code around the line where the program is currently stopped. If you type list again you'll see more.

This is what the commands in the source category of the manual are for. More specifically, the sub-category list mentions the command list.
Note that gdb is not typically using "windows", it's a console application.

By using layout next we can see the source code on different window. If the program didn't start running we will see empty screen for the beginning, when it starts the program will appear on different window.

Related

How to copy text to system clipboard in emacs while working in terminal buffer?

I usually use emacs in a text terminal environment to manipulate text. In some particular situations, however, I want to interact with the system's clipboard, for example, copy text from emacs to a website. Is it possible to yank text to the system's clipboard directly from or to emacs? How?
Terminal in emacs is nothing but a buffer. If you are running terminal using eshell, you can directly copy to clipboard using M-w like you do in normal buffer.
If you are running terminal using ansi-term, yanking/copying is little tricky. You need to go to term-line-mode using C-c C-j copy whatever you want and come back to term-char-mode using C-c C-k. See this answer for more info.
There's support for doing just that in Emacs-25 (see the NEWS file, looking for xterm-extra-capabilities), tho it depends on your terminal emulator providing corresponding support, which is apparently usually disabled by default, so you additionally need to configure your termninal emulator as well.
Another option is to install the xclip package, which is available on GNU ELPA.
This article (http://blog.binchen.org/posts/copypaste-in-emacs.html) helps me. In it, the author implement a function to fulfil such a task.

Run Selection in MATLAB from Linux Command Line

I am running an SSH into a linux computer. The MATLAB GUI can be very slow and unresponsive. Is there a way I can use MATLAB in command line mode so that I can highlight part of my code and run that section? In GUI, it is possible to do this in the Editor window by right clicking and choosing 'Run Selection' or by pressing F9. In command line mode, I only know how to run the entire script.
In a similar vein, can I run a section of the code (the 'Run and Advance' button in the GUI) using command line?
Also, is it possible to see the workspace (like the Workspace window in the GUI version) from the command line?
AFAIK there is a no-desktop mode in MATLAB, which you can access by running it with -nodesktop parameter, this should provide you with what you need. You can find more info on official MATLAB pages
As Niemand said you can start MATLAB with the flag -nodesktop.
You won't be able to select and run a potion of code with -nodesktop. You could just put that chunk of code in a separate function or script and call that.
If you're doing a lot of work without the GUI I would recommend looking at http://matlab-emacs.sourceforge.net. This is a MATLAB mode for Emacs that provides many of the same functionalities as the MATLAB desktop.
Lastly check out who and whos to see the workspace variables.

alt-tab like functionality when using terminal?

When working in GUI we do alt-tab (or cmd-tab in mac) to switch between multiple programs, for example I am writing a text file in a text editor and then I do alt-tab to switch to already running browser to google up something then I alt-tab again to come back to keep editing.
How do you perform such "switch between" programs in command line interface - for example working with a ssh command line shell?
EDIT: I forgot to mention it, I am using ssh to connect to my university's server, and they don't have screen & tmux installed, and my account have no right to install any new apps... Is there any built-in functionality to perform this task, or any work around? For exmaple can I "minimize" running proggram and come back to regular shell interface, do some work, then display the "minimized" process again?
Another workaround: use the shell's job control, eg if you're editing a file, CTRL-z pauses the editor and brings you back to the shell, where you can compile, see manpages, browse the web or whatever -- and of course you can background the browser or anything else.
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.
As a crude workaround, run multiple terminal windows on your computer, and alt-tab between them.
Incidentally, at the Linux console, you can switch virtual terminals with ctrl+alt+F for at least F1 through F6, commonly F8 or more (depends on how the distro sets them up). Not your case, I know, but in case future visitors should benefit.
If you are comfortable in Emacs, it allows you to run multiple independent ansi-term buffers.
You can also use "GNU screen" to emulate multiple terminals in one terminal.

Cygwin alway's interpreted with Ctrl-C

My cygwin terminal (known as Mintty) can't work, when I minimize it to the windows taskbar, and restore it, and it will receive the Ctrl-C signal, but i didn't touch any key.
This is wierd. when a long time command is running, i swith it to see wether is finishe, then it is interputed my Ctrl -C. I refresh intall it several times. it's still there.
This situation can also happened when i select some text on the terminal.
Thanks
Some translator software have the "Hyper Translate" function, which will copy texts selected then tries to translate it, the way how it copy strings is to simulate a Ctrl-C from keyboard. When using cygwin or some ssh/telnet terminal tools (e.g. SecureCRT, putty, NX Client..) and the Ctrl-C is not set as the hotkey for copy action, and you tries to select a block of texts, trouble comes.
I guess the one who asking this question is also a Chinese like me. Then, the famous software which will bring this trouble is "Youdao Dictionary".
Disabling the "Hyper Translate / HuaCiFanYi" function of the "Youdao Dictionary" is a remedy.
As Leif Zhang mentioned, if you are using Lingoes or other dictionary you should uncheck the option Translate Selected Text as the following image.

How can I use the Perl debugger's *supported* editor?

The Perl debugger always says: "Editor support available". I believe every one can see this, but how can I use it?
my-computer$ perl -de2
Loading DB routines from perl5db.pl version 1.33
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): 2
DB<1>
By the way, I got the above prompt on a Linux/UbuntuĀ 11.04 (Natty Narwhal) machine.
The message is a little confusing. It's telling you it can support running inside an editor, not that there is a special Perl debugger editor.
The Perl debugger can detect if it's talking to a terminal or if it's running inside an editor. This controls a number of things, the biggest is whether the debugger prints anything or leaves it up to the editor to handle the display. If you're really curious, look through the debugger code for $slave_editor.
Why does it feel the need to inform the user of this? I did a little digging and the debugger used to only support Emacs debugging. It's a bit more useful to inform the user "Emacs support available" than that some editor somewhere will work with the debugger. The Emacs message came in with the first version of the debugger sprung fully formed from the head of Ilya.
The Perl debugger is also really three entities. The perl5db.pl script, the DB API, and the debugging hooks in the language itself which those two use. An editor may use perl5db.pl, or it may talk directly using DB.
There are a few editors which can hook into the Perl debugger. One is Emacs which you can start by opening a Perl program in Emacs and using M-x perldb. Komodo and Padre also have debugger support.

Resources