How to capture stack trace for Ncurses app? - stack-trace

Typically, when running an application from the command line, I get a nicely printed trace when things go wrong. But, since I happen to be working on an Ncurses application, the trace gets mixed in with the interface that was running, and the output gets all jumbled. Like so:
Specifically, I'm working on this project: todo-curses.
I'm running the app as a Rake task, so I figured the --trace option would help me, but I just can't seem to figure it out. Is there a good way to log the output of the app to a file or something and not include the Ncurses interface with it?

It depends on the application: curses writes to the standard output by default. If you (as the developer of the curses application) use newterm for initializing the library rather than initscr, then you can tell it to write the screen interface to the standard error.
But developers of bindings for curses from other languages typically leave out newterm as an alternative, just to make things simple. For instance, the Ruby curses shown on github has this deficiency. Perhaps a bug report is due.

Related

How do I get the full compile log in Activator?

I have a large (> 25k) app that I've been developing in Scala/Akka/Play for a couple of years now. I'm in the process of upgrading it to the current version of the world (everything was a major version or two behind), which means getting it running in Activator. I'm gradually wrestling my way through that, but I'm somewhat stymied by the fact that Activator's "compile" window is very short -- only a few screens long -- so most of my 50-some-odd remaining compile errors are scrolling off the top. I'd really like to be able to read the entire thing, since I assume that most of these are knock-on errors, and only a few are really significant.
Where does the actual compile log go? How can I get to the whole thing?
It sounds like you're trying to use the UI mode when you were happy with the command line mode in Play 2.2; the command line mode is still there, see http://typesafe.com/blog/typesafe-activator---an-update-and-roadmap-preview for some background. Just run "activator" instead of "activator ui". The UI mode is not something that's "production hardened" yet, it is primarily intended for tutorials (though we are working to change that).
That said the compile log should not be truncated in the UI and we appreciate bug reports at https://github.com/typesafehub/activator/issues including one about this truncation.

Changing Code At Runtime While Debugging

I am using Eclipse Kepler Service Release 2 , EPIC 0.5.46 and Strawberry Perl 5 version 18 for perl programming. For debugging I am using Eclipse debugger and PadWalker .
I have an interactive perl program that writes to files based on answers provided by the users to multiple prompts. While debugging , every time i change a single line of code I have to rerun the whole program again and provide inputs to every prompt , which is really time consuming.
Is there a way to make changes to the code in a sub routine , in the middle of debugging session such that the instruction pointer resets itself to the first line of that sub routine. This way i do not have to restart the session to recompile the new code.
Appreciate your inputs and suggestions. Thank You!!!
What you want to do can be done, and I've done it many times in Perl myself. For example, see this.
However although what you describe may work (and is a bit dangerous), the way it is generally done a bit different and safer.
First one has to assume a regular kind of command structure like a command processor, or say a web server.
In a command processor or web server, you read a command (or get a web request), perform an action, then read another command, perform another action and so on. From your description, it sounds like you have such a structure.
In my case, I have each debugger command stored as in Perl file. This is helpful not only for facilitating this task, but also for understanding, testing and changing the code.
Given this kind of program structure, instead of trying to change the program counter, you complete the command and at the level where you are about to read a new command, you make the change and then reload the file which changes the code.
The specific Perl construct to do this is called do. Don't use require or use which will load in a Perl file only if that file or module hasn't been previously loaded. In your situation, you want to reload even if it has been loaded before.
So now how do you get to be able to issue a do command? As you suggest, you could do it through a debugger. Assuming you have this overall program stucture as described above, you put the breakpoint somewhere a common point in the caller which loops over things to process, rather than try to change things in indvidual commands.
And you don't even need a debugger to do this! Many web frameworks like Ruby on Rails, have a "development" mode where they save timestamps on files that implement functionality. If the file has changed they issue the "do" command before running the request.

System.out.print on Android

Using Eclipse I was testing a simple app by running it on a device emulator. The application itself was working fine. I just had a thought of displaying some text on the console by means of System.out.print.
My app is merely a single instance of the Activity class. I imported java.lang.. For some reason, I was unable to display any text on the console with this: System.out.print("Hello");
Also, the Eclipse editor kept showing a warning that java.lang. was never used!
Was I doing something wrong? Or, does the Dalvik VM require something different from a Java VM when it comes to outputing text on the console?
Thank you.
There is no console like in Java. If you want to print debug information, use "logcat"
You can view these in eclipse.
If you have ever used i.e. the python logging module, the syntax will be familiar to you.

Debugging perl CGI

I am using a web form I created as an interface to query a MySQL database. I have written some
perl CGI scripts to process the queries. But I am not getting the desired output, so I need to
debug the scripts. How do I do that? I mostly use Eclipse for debugging perl, but now I have the
web form parameters (checkboxes, listboxes) as input to the script. Is there any way I can pass
in the inputs from the web page and then debug the script in Eclipse? Or is there any other way
of debugging in this case? Hope I have made myself clear. Thanks.
I use this Perl module for CGI debugging. It lets you capture all data sent to a CGI script, when running from a normal browser. It then lets you "replay" the script from anywhere (command line, within a debugger) using the captured data.
CGI::Inspect looks promising, though I haven't tried it yet myself.
Using Devel::DumpTrace during a normal CGI session (with the data being logged to a file, via DUMPTRACE_FH) is a way to do in-depth debugging, without using an actual debugger.
Yes, of course you can use Apaches error log to do debugging; which a very lazy but efficient way to work.
You mention you use Eclipse so I assume you also use the EPIC plug-in for Perl development. Check out this chapter on how to configure Eclipse/EPIC for debugging CGI:
http://www.epic-ide.org/guide/ch06s02.php
I would hope Eclipse has a way to simulate CGI.
I use ActiveState's Komodo IDE, and it can simulate CGI (including input params), so I can recommend that as a good tool for this purpose. The IDE is NOT free, though, but consider this an investment if you're going to be doing this a lot. (I'm NOT affiliated with ActiveState - just a happy customer.)
It's not clear what exactly you want to debug, but a few tips:
When running under Apache, warnings go to the error.log, so you could follow your variables there.
The CGI.pm module allows you to run CGI scripts from the command-line (with parameters).
if you have a hypothetical CGI program written in perl, called webawesome.pl and you want to pass it two parameters: name and age, you can use a shell command like this:
prompt> perl -d webawesome.pl name=sifl age=21
Now you're in the perl debugger and you can step through your program, and the key/value pairs from the command line will be loaded as form parameters by CGI.pm
Setting these command line switches in Eclipse is left as an exercise to the reader, as I am an unabashed vi user, and haven't use eclipse in two or three years. I know there's dialogs to set run/debug options.
You can use Firebug or Fiddler to watch your requests made from the form, to ensure you are sending exactly what you think you are. You can also open a file open(fh,">>debug.txt") and print out the sql calls that you are making to a log file. I would also suggest learning about Data::Dumper which will print out objects prettily so you can see their structure.

Perl ptkdb different outcome with breakpoint

I have a perl script, if i run it normally, it doesn't work right.
But if i run it with the debugger and set a breakpoint at a very specific line, then the script operates correctly.
What side effects can the, breakpoints of the ptkdb module, have?
Loading of any perl debugger has quite significant impact on all environment -- for an idea look into perldebguts. While the debuggers try hardly to minimize its effects, there are additional packages loaded, some special variable has different contents, timing of runtime changes, etc. Without more detail it is hard to say what difference is affecting you.
I would recommend to debug using logger (I found easy mode of Log::Log4perl very handy for this). Also many useful hints on debugging art is in perldebtut.