How can I get command history for console-based debugging in PyCharm? - debugging

When I use PyCharm I find myself frequently trying out pieces of code interactively. So far, my workflow has been to use pdbfor this and set a breakpoint as pdb.set_trace, which then drops me into the console.
However, for PyCharm the resulting console has no command history - the up arrow instead moves the cursor upwards into the previous output, which is a pain to use.
I realize there's also the built-in debugger that has a console with history, but getting there involves more clicks (run the debugger, switch to Console tab and clicking on "Show Python Prompt").
There is a built-in console that does have a command history (Tools > Python Console), however, unfortunately that's not the console that's being run for pdbbreak points. Is it possible to get PyCharm to use a different console for pdb?

No, it's not possible. PyCharm has no control over what happens when you invoke pdb.set_trace().

Related

golang: optional console on windows

I am writing a service program which is expected to run in background. On Windows it will open a console window when run. I want it to go to background directly without that console window, so I used the -ldconf "-H=windowsgui" option, which worked as expected.
However, there is a catch. The program has a command line option -help, which output command line usage in the console. If I use -H=windowsgui, the help text is NOT printed even I start it in cmd.exe prompt.
It seems that the windowsgui option is not what I want. Is there anyway that the -help still works at commant line, and the console window will not persist if the program runs normally. I do not care if there is a console window pops up, provided that it disappears shortly without user intervention. i.e. I want a way on windows which is similar to the & operator on Linux.
P.S. if provided solution uses any other tools, I want that tool to be a Windows component, not any 3rd-party program. Thanks.

ctrl+f2 keyboard shortcut does not work in VSCode on macOs

I have ctrl+f2 mapped to toggle bookmark in my vscode keyboard shortcuts.
{ "key": "ctrl+f2", "command": "bookmarks.toggle", "when": "editorTextFocus" },
It work correctly on Linux and Windows, but not on macOs.
I have enabled the setting to switch function keys (f1, f2, etc) to behave as standard function keys.
I have then unmapped ctrl+f2 in macOs keyboard shortcut settings.
But still ctrl+f2 keyboard shortcut is not registering with vscode.
Troubleshooting VS-Code Keybinding Issues
The best way to troubleshoot an issue with Keybindings in V.S. Code is to use the tool that was created for solving keybinding issues
The tool is simply named: "Keyboard Shortcut Troubleshooting Tool"
The tool comes with V.S. Code "out of the box", as a result; no downloading, or installation is needed. To use the tool you just activate it from the Quick Input Menu that drops open by pressing the F1-Key. If you cannot find it your self I posted instructions below, and an image. If you can find it yourself, then skip the "Activating the Troubleshooting Tool" Section, and go ahead and read, "Effectively Troubleshooting Issues with the Troubleshoot Keyboard-Shortcut Tool"
Activate V.S. Code's Troubleshooting Tool
Hit the F1-Key
When the quick input drops open type the following into the text input:
"Toggle Keyboard Shortcuts Troubleshooting"
Select the option: Developer: Toggle Keyboard Shortcuts Troubleshooting
It should automatically open the OUTPUT panel, which is located in the same panel that your terminal is. Make sure that the OUTPUT is set to LOG(Window) in the drop down. (I took a picture and posted it below if you can't find the Keyboard Shortcut Troubleshooter).
The image might have funny declensions because I am on a dual monitor setup with 1 1080x1920 curved screen and one 1080x720 screen.... I cropped it to a STD HD 1920 width.
HELPFUL SIDE NOTE:
"This tool may be the most verbose program ever written, as far as I can tell, it logs data to the OUTPUT Console each & every time you activate a keyboard event. Truth be told, I find this tool to be extremely distracting, and very annoying. Because of this, it is important to note, that even if you switch out of your OUTPUT console to your terminal or something. The Troubleshooter is still actively logging to the OUTPUT Console. Make sure when you are finished to turn it off."
Turning off the Keyboard Troubleshooter, requires the same process as turning it on.
Using V.S. Code's Troubleshooter
STEP-1: Close VS Code
This is not to be confused with reload V.S. Code. The only mechanism that VS-Code has for reloading its-self, doesn't provide the same functionality as closing, and reopening V.S. Code. The two are similar, but they are not equal (discussion for another time).
actually stop its process from running by hitting the X in the upper right corner of the title-bar, or hit
**[Alt + F4].
Step-2: Reopen V.S. Code W/O Any Extensions
Don't worry, you won't have to uninstall anything. You will start V.S. Code from the command-line though. Open up your bash terminal, or Powershell, and enter the following command:
$ code --disable-extensions
V.S. Code should start almost immediately
If the V.S. Code CLI doesn't open your editor, or this doesn't disable your extensions, you should refer to this link
Step-3: Start the Keyboard Shortcut Troubleshooter
I already explained this step above, so their is no reason to go over it again. Do make sure you have your panel open, and the OUTPUT tab is selected. You should see a bunch of logging being output, in the VS-Code output (that is redundant sounding), logging when you use any keybinding. The drop-down should have Log(Window) showing, as the current log selected.
Step-4: Test Your Keybinding
At this point you can use your keybinding, and get results. They might not be the results that you were hoping for, but the troubleshooter should give you details as to what is happening when you use your keyboard shortcut (aka bound-key, aka key-binding).
Step-5:
Fix the issue by opening the Keyboards Shortcuts configuration file by opening the quick input, (like I described above for the troubleshooter), and type Keyboard Shortcuts. Their will be two options, one is the default Keybindings that cannot be written too, the other is a configuration file, where you are allowed to overwrite all of the default keybindings if you choose. Look in the default keybinding.json file and make sure the keybinding that you feel is assigned to a certain task, really is assigned to it. Look in the regular keybindings.json file, and make sure if anything is written in it, that those keybindings are not affecting the keybinding that is not working for you. Use the information from the troubleshooter to help guide you through the process.
These links below further elaborate on V.S. Code keybindings:
V.S. Code Community Docs (Community Contributed)
V.S. Code Official Docs (Keybindings)

Documentation for LLDB's GUI

I've been recently been playing around with LLDB's gui feature. (A stackoverflow link about this feature is described here. My current lldb is lldb-320.4.156)
So far, it seems very convenient, especially the ability to view local variables in the current stack frame. But is there any documentation (or tutorial) on how to use the LLDB's GUI mode?
Aside: I specifically have a few questions:
How to show the source code upon going into GUI mode. (Unless I stop at a breakpoint and type gui within LLDB, I can never get source code to show up.)
How to rerun a program while in GUI mode. (There is nowhere to type while in GUI mode.)
Are there colors in GUI mode? I notice if you type lldb --help in the command line, lldb tells you you could invoke it with a --no-use-colors option. (That being said, I've never seen colors with normal lldb mode...)
Is there a way to set breakpoints, prior to running lldb?
The GUI mode in lldb is a feature that Greg Clayton did over a few weeks of nights & weekends -- it's a really cool hack. But it's not completed to product-quality level and there's no documentation short of the command key tips that you can see with its built in help system. The biggest omission is definitely the lack of a console window where you could type arbitrary lldb commands - but adding a console pane like that was where things started to get tricky. :)
Hopefully an interested developer will pick up the gui mode work and add these features. For people who can't use a full IDE, it can be really helpful to have a text mode windowed UI when using a debugger.
But is there any documentation (or tutorial) on how to use the LLDB's GUI mode?
I don't know any official documentation. But this random video was helpful for me. Also, pressing h in TUI gives you a minimal documentation.
1. How to show the source code upon going into GUI mode. (Unless I stop at a breakpoint and type gui within LLDB, I can never get source code to show up.)
As you observed, unless gui command is executed while the program is paused due to a breakpoint or something, nothing happens in TUI.
2. How to rerun a program while in GUI mode. (There is nowhere to type while in GUI mode.)
AFAIK, impossible. Press Esc and execute run again.
3. Are there colors in GUI mode? I notice if you type lldb --help in the command line, lldb tells you you could invoke it with a --no-use-colors option. (That being said, I've never seen colors with normal lldb mode...)
In my environment (M1 Macbook Air), color works with no option (i.e. by default) both in CUI and TUI.
4. Is there a way to set breakpoints, prior to running lldb?
See #Johan's answer. You can also use ~/.lldbinit file if the breakpoint condition is fixed.
Don't have an answer for all your questions, but regarding breakpoints, you can save all your debug session "setup" commands in a file and then just load that file:
lldb -S <filename>
Found this option from here:
https://stackoverflow.com/a/34275770/1345329

Xamarin Studio fails to execute code with login shell in Mac Terminal

I'm new to Xamarin on the Mac, and I'm running into some issues running my code. I don't think it should matter, but I'm using the D language plugin to develop my code.
When Terminal is set to Shells open with: Default login shell (which is zsh in my case, but bash results in the same issue), hitting the execute button causes Xamarin Studio to pop up a Terminal window which closes before it can do anything, and then Xamarin Studio reports Cannot execute "blah". ScriptError. I added an infinite loop at the beginning of my program to make sure the shell isn't exiting because the program terminated quickly, and sure enough the program seems not to be starting at all.
If I instead tell Terminal Shells open with: Command (complete path): /opt/local/bin/zsh, the terminal happily opens up and the window is named correctly as "Xamarin Studio External Console" but of course nothing is executed except for the shell itself.
Any way to debug or fix this would be greatly appreciated!
MonoDevelop/XamarinStudio uses xterm by default. Dunno if that piece of info might help.

Is it possible to run terminal/command prompt inside Rubymine?

I would work much faster if I could have some kind of command line running inside rubymine, is this possible? When testing I repeatedly have to switch to my terminal window and it gets quite annoying.
I can run rails console and also the sandboxed version side rubymine aswell as my rails server and spork server.
It would be nice to have a command prompt inside rubymine also would speed things up. Infact that would make rubymine 100% perfect for my rails development as it does everything else require.
There is no such feature in IDEA platform based products. You need to run terminal externally. Note that you can create an External Tool to run terminal window in the current file or module directory for convenience.
UPDATE: Terminal (SSH console) was added in PhpStorm/WebStorm 7.0, IDEA 13, RubyMine 6, PyCharm 2.7.3.
I have used CrazyCoder's instructions to do this. Here are the instructions for Windows:
File, Settings
bottom half of menu is titled IDE Settings, look in this list to find External Tools
Click in the only available button (for most), [+]
give your custom thing a name ("terminal"? "command prompt"?)
most of this stuff you just leave blank
click the [...] button next to Program, then simply navigate to Windows/system32/cmd.exe
Lastly, unless you want to have your starting command line (terminal) path as C:\Windows\system32 (CHANGE YOUR PATH), simply click on the [...] next to the "Working Directory" just below, and change your path to Desktop or whatever it is you prefer.
Click OK.
You're done! It's that easy. Now to access this (no restart required), click on Tools, and then under 'XML actions' (for me anyway) you should find your "terminal" or "cmd" or whatever it is you called it. You can test it out with an 'ipconfig' command. You can always go back to the the settings/external-tools place you went to in the first place to edit your settings (like your default path), or to make another custom tool, because this (RubyMine External Tools creator) is obviously a very powerful tool.
If someone is searching this for rubymine in version 7.
Press Alt+f12 for the terminal.
Source : https://www.jetbrains.com/ruby/webhelp/working-with-embedded-local-terminal.html

Resources