96 const QStringList read_lines=QString(process->readAllStandardOutput()).split(QRegExp(
"\n"));
99 for(
int i=0; i<read_lines.size(); ++i){
100 const QString line=read_lines.at(i).trimmed();
102 if (line.isEmpty())
continue;
103 if (line.startsWith(
"~")){
107 if (line.startsWith(
"&")){
108 job->gdbTextEdit->append(line);
111 if (line.startsWith(
"=library-loaded")){
112 job->gdbTextEdit->append(QString(
"Loading %1").arg(line.split(QRegExp(
"\"")).at(1)));
115 if (line.startsWith(
"=")){
123 if (line==
"^running")
continue;
124 if (line.startsWith(
"*running"))
continue;
125 if (line==
"(gdb)")
continue;
127 outputs.enqueue(line);
132 while (!outputs.isEmpty()){
133 const QString output=outputs.dequeue();
140 if (state==QHyodaGdb::Detach){
141 state=QHyodaGdb::None;
142 qDebug() <<
"\t[QHyodaGdb::gdbmi] breaks cleanup, detaching and exit";
143 commands.enqueue(
"-var-assign qhyoda_hooked 0");
144 commands.enqueue(
"-break-disable 1");
145 commands.enqueue(
"-break-disable 2");
146 commands.enqueue(
"-break-disable 3");
147 commands.enqueue(
"-break-disable 4");
148 commands.enqueue(
"-break-delete 1");
149 commands.enqueue(
"-break-delete 2");
150 commands.enqueue(
"-break-delete 3");
151 commands.enqueue(
"-break-delete 4");
152 commands.enqueue(
"-target-detach");
153 commands.enqueue(
"-gdb-exit");
158 if (output.startsWith(
"^exit")){
159 qDebug() <<
"\t[QHyodaGdb::gdbmi] EXIT";
165 if (output.startsWith(
"*stopped,reason=\"exited-normally\"")){
166 qDebug() <<
"\t[QHyodaGdb::gdbmi] Exiting normally!";
181 if (output.startsWith(
"*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"4\"")){
184 if (!output.contains(
"next_entry_point_address")){
185 qDebug(
"\33[7mNo address for Hyoda!\33[m");
188 QStringList tokens=output.split(QRegExp(
"\""));
189 for(i=0;i<tokens.count();i+=1){
191 if (tokens.at(i).startsWith(
"next_entry_point_address"))
break;
194 if (i==tokens.count()) {
195 qDebug(
"File not found from address for Hyoda!");
198 QString adrs=tokens.at(i+2);
199 qDebug() <<
"\t[QHyodaGdb::gdbmi] adrs="<<adrs;
200 int idxOfEntryPoint=entryPoints.indexOf(adrs);
201 qDebug() <<
"\t[QHyodaGdb::gdbmi] idxOfEntryPoint="<<idxOfEntryPoint;
203 if (idxOfEntryPoint==-1){
207 commands.enqueue(QString(
"3782526747-data-disassemble -s %1 -e %1+1 -- 1").arg(adrs));
209 entryPoints.append(adrs);
212 if (!entryPointsFile.at(idxOfEntryPoint).isEmpty()){
213 showViaEmacsClient(entryPointsFile.at(idxOfEntryPoint),entryPointsLine.at(idxOfEntryPoint));
214 job->startButton->setEnabled(
true);
215 job->stepButton->setEnabled(
true);
218 commands.enqueue(
"-exec-continue");
222 if (output.startsWith(
"3782526747")){
225 QString lineNumber(
"+");
226 if (output.contains(
"file=")){
227 QStringList tokens=output.split(QRegExp(
","));
229 fileName=tokens.at(2).split(QRegExp(
"\"")).at(1);
230 lineNumber.append(tokens.at(1).split(QRegExp(
"\"")).at(1));
231 qDebug()<<
"\33[7m"<<fileName<<lineNumber<<
"\33[m";
234 entryPointsFile.append(fileName);
235 entryPointsLine.append(lineNumber);
236 commands.enqueue(
"-exec-continue");
244 if (output.startsWith(
"*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"3\"")){
247 QString lineNumber(
"+");
249 const QStringList tokens=output.split(QRegExp(
","));
250 for(
int i=0; i<tokens.size(); ++i){
251 const QString token=tokens.at(i).trimmed();
253 if (token.isEmpty())
continue;
254 if (token.startsWith(
"{name=\"fileName\"")){
255 const QStringList values=tokens.at(i+1).trimmed().split(QRegExp(
"\""));
257 fileName=values.value(2);
259 if (token.startsWith(
"{name=\"lineNumber\"")){
260 const QStringList values=tokens.at(i+1).trimmed().split(QRegExp(
"\""));
262 lineNumber.append(values.value(1));
265 fileName.remove(
'\\');
268 showViaEmacsClient(fileName,lineNumber);
269 job->startButton->setEnabled(
true);
270 job->stepButton->setEnabled(
true);
278 if (output.startsWith(
"*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"2\"")){
281 if (state==QHyodaGdb::TargetCell){
283 commands.enqueue(
"-break-enable 1");
286 commands.enqueue(
"-exec-continue");
290 commands.enqueue(data_read_memory.toLocal8Bit().constData());
295 if (output.startsWith(
"^done,addr")){
297 const QStringList splitted_output=output.split(QRegExp(
"\""));
298 job->refresh_common_variables(splitted_output);
300 if (job->bottomRightTools->tabText(job->bottomRightTools->currentIndex())==
"Cell")
301 job->bottomRightTools->cell->refresh(splitted_output);
304 if (state==QHyodaGdb::Interrupt){
305 state=QHyodaGdb::None;
306 commands.enqueue(
"-exec-interrupt");
307 job->tackButton->setEnabled(
false);
308 job->startButton->setEnabled(
true);
309 job->stepButton->setEnabled(
true);
314 if (state==QHyodaGdb::Step){
315 commands.enqueue(
"-break-enable 3");
317 job->startButton->setEnabled(
true);
318 job->stepButton->setEnabled(
true);
319 commands.enqueue(
"-exec-continue");
324 if (state==QHyodaGdb::Untack){
325 state=QHyodaGdb::None;
327 commands.enqueue(
"-break-disable 3");
328 commands.enqueue(
"-break-disable 4");
329 commands.enqueue(
"-var-assign qhyoda_hooked 0");
332 commands.enqueue(
"-exec-continue");
342 if (output.startsWith(
"^done,value")){
345 if (!data_read_memory.isNull())
continue;
346 data_read_memory.append(
"-data-read-memory ");
347 data_read_memory.append(output.split(QRegExp(
"\"")).at(1));
348 data_read_memory.append(
" x 8 1 32");
355 if (output.startsWith(
"*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"1\"")){
358 if (state==QHyodaGdb::Retack){
359 state=QHyodaGdb::None;
361 commands.enqueue(
"-var-assign qhyoda_hooked 1");
362 commands.enqueue(
"-break-disable 1");
363 commands.enqueue(
"-break-disable 3");
364 commands.enqueue(
"-break-disable 4");
365 commands.enqueue(
"-exec-continue");
370 if (state==QHyodaGdb::TargetCell){
371 state=QHyodaGdb::None;
373 commands.enqueue(QString(
"-var-assign target_cell_uid %1").arg(job->data->target_cell_uid));
374 commands.enqueue(
"-break-disable 1");
375 commands.enqueue(
"-exec-continue");
380 commands.enqueue(
"-var-create data * m_data");
381 commands.enqueue(
"-var-set-format data hexadecimal");
382 commands.enqueue(
"-var-evaluate-expression data");
384 commands.enqueue(
"-var-create target_cell_uid * m_target_cell_uid");
385 commands.enqueue(
"-var-set-format target_cell_uid hexadecimal");
386 commands.enqueue(
"-var-assign target_cell_uid 0");
388 commands.enqueue(
"-var-create qhyoda_hooked * m_qhyoda_hooked");
389 commands.enqueue(
"-var-set-format qhyoda_hooked hexadecimal");
392 commands.enqueue(
"-var-assign qhyoda_hooked 1");
395 commands.enqueue(
"-break-disable 1");
400 commands.enqueue(
"-exec-continue");
404 if (output.startsWith(
"^done,name=\"target_cell_uid\""))
continue;
405 if (output.startsWith(
"^done,name=\"qhyoda_hooked\""))
continue;
406 if (output.startsWith(
"^done,name=\"data\""))
continue;
407 if (output.startsWith(
"^done,format"))
continue;
408 if (output.startsWith(
"^done,bkpt")){
410 job->gdbTextEdit->append(output);
415 if (output.startsWith(
"*stopped")){
417 if (state==QHyodaGdb::Retack){
418 qDebug() <<
"\tQHyodaGdb::gdbmi RETACK";
419 commands.enqueue(
"-break-enable 1");
422 commands.enqueue(
"-exec-continue");
425 job->gdbTextEdit->append(output);
427 commands.enqueue(
"-exec-continue");
432 if (output.startsWith(
"^connected")){
433 state=QHyodaGdb::None;
434 qDebug() <<
"\tQHyodaGdb::gdbmi ^connected";
436 job->arcaneCommonVariablesGroupBox->setEnabled(
true);
437 job->stopButton->setEnabled(
true);
438 job->stepButton->setEnabled(
true);
439 job->startButton->setEnabled(
false);
440 job->tackButton->setEnabled(
true);
441 job->cellButton->setEnabled(
true);
442 job->meshButton->setEnabled(
true);
445 qDebug() <<
"ARCANE_HYODA_MATRIX_RENDER:"<<qgetenv(
"ARCANE_HYODA_MATRIX_RENDER").count();
446 if (qgetenv(
"ARCANE_HYODA_MATRIX_RENDER").count()>0) job->matrix_slot();
455 if (output.startsWith(
"*running")){
456 qDebug() <<
"\tQHyodaGdb::gdbmi gdb_async_running";
457 job->gdbTextEdit->append(output);
461 if (output.startsWith(
"^error")){
462 state=QHyodaGdb::None;
463 qDebug() <<
"\tQHyodaGdb::gdbmi ^error"<<output;
464 job->gdbTextEdit->append(output);
468 if (output.startsWith(
"~")){
469 qDebug() <<
"\tQHyodaGdb::gdbmi console-stream-output:"<<output;
470 job->gdbTextEdit->append(output);
474 if (output.startsWith(
"=")){
475 qDebug() <<
"\tQHyodaGdb::gdbmi notify-async-output:"<<output;
476 job->gdbTextEdit->append(output);
480 qDebug() <<
"\tQHyodaGdb::gdbmi UNFILTERED "<<output;
481 job->gdbTextEdit->append(output);