Open AthanasiusOfAlex opened 11 years ago
Could you give me parts of your code you tried to debug? I just stepped through my entire trivial program and it never crashed..I see that variables' contents aren't shown in the tool tip box. But for variable watches, most of the stuff works (except trying to access field members)
Sorry should have thought of that. I was able to reproduce this effect with the following code (taken and slightly modified from the tuturial on http://www.informit.com/articles/article.aspx?p=1381876&seqNum=5):
module main;
import std.algorithm, std.ascii, std.regex, std.range, std.stdio, std.string;
string INPUT = " Pol. Marry, I will teach you! Think yourself a baby\n" ~
" That you have ta'en these tenders for true pay,\n" ~
" Which are not sterling. Tender yourself more dearly,\n" ~
" Or (not to crack the wind of the poor phrase,\n" ~
" Running it thus) you'll tender me a fool.\n" ~
" Oph. My lord, he hath importun'd me with love\n" ~
" In honourable fashion.\n" ~
" Pol. Ay, fashion you may call it. Go to, go to!\n";
struct PersonaData {
ulong totalWordsSpoken;
ulong[string] wordCount;
}
void main(string[] args){
PersonaData[string] info;
introduce();
// Fill info
string currentParagraph;
char[][] inputArray = cast(char[][])splitLines(INPUT);
foreach (line; inputArray) {
if (line.startsWith(" ") && line.length > 4 && isAlpha(line[4])) {
// Persona is continuing a line
currentParagraph ~= line[3 .. $];
} else if (line.startsWith(" ") && line.length > 2 && isAlpha(line[2])) {
// Persona just started speaking
addParagraph(currentParagraph, info);
currentParagraph = line[2 .. $].idup;
}
}
addParagraph(currentParagraph, info); // Don't forget to do it for the last time.
// Done, now print collected information
printResults(info);
//dumpResults(info);
}
void introduce(){
writeln("This is the text we will be analysing:\n");
writeln(INPUT);
}
void addParagraph(string line, ref PersonaData[string] info) {
// Figure out persona and sentence
line = strip(line);
auto sentence = line.find(". ");
if (sentence.empty) {
return;
}
auto persona = line[0 .. $ - sentence.length];
// Purify the sentence of various characters;
sentence = toLower(strip(sentence[2 .. $]));
sentence = strip(sentence);
// Get the words spoken
auto words = split(sentence);
// Insert or update information
PersonaData* data = persona in info;
if (data) {
// heard this persona before
data.totalWordsSpoken += words.length;
foreach (word; words) ++data.wordCount[word];
} else {
// first time this persona speaketh
PersonaData newData;
newData.totalWordsSpoken = words.length;
foreach (word; words) newData.wordCount[word]++;
info[persona] = newData;
}
}
void printResults(PersonaData[string] info) {
foreach (persona, data; info) {
writefln("%20s %6u %6u", persona, data.totalWordsSpoken,
data.wordCount.length);
}
}
void dumpResults(PersonaData[string] info){
foreach (persona, data; info) {
writeln(persona,":");
foreach(word, number; data.wordCount){
writeln("\t", word, "\t", number);
}
}
}
Okay, this exception was thrown because it didn't catch the internal gdb exception when a symbol wasn't found..fixed this.
Great! The update solves 95% of the problem. (It runs pretty smoothly now, it no longer crashes, and the popups work without any problem.)
However, try setting a break point at line 52. (It should read line = strip(line);
in any case, the first line of the void addParagraph
function.) Again, the yellow highlighting disappears. The good news is that it reappears after I hit F10 a couple of times, and it does not crash. I consider it a minor issue at this point, but there may be an underlying bug that would be interesting to fix.
Thanks for your help!
Louis Melahn, L.C.
it's probably just some notification and threading issue deep somewhere in the MD code..perhaps it's just required not to use ThreadPool functions for incoming gdb messages but the DispatchService of MD or so..so many possibilites :)
Thanks for your help yesterday. I have upgraded to 0.5.8 of the binding add-in.
I realize that the debugger is a work in progress :), but it does something interesting:
Note: with further testing, it seems that these issues arise when I set one of those pop-up pins that watch a variable's values. I had a stray one open that I couldn't find, and the problem mostly disappeared once I closed it. Thus, readers might be interested that, for the moment, the D debugger is incompatible with the popup watch pins.
[looks like this when I first hit F5:]
[After I hit F9 twice:]
Thanks for your quick responses!