@@ -33,7 +33,6 @@ bool WildCardListMatch(wxString list, wxString name)
3333
3434int ID_LangMenu_Settings=wxNewId();
3535int ID_LangMenu_Run=wxNewId();
36- int ID_LangMenu_DebugSendCommand=wxNewId();
3736int ID_LangMenu_ShowWatch=wxNewId();
3837int ID_LangMenu_UpdateWatch=wxNewId();
3938
@@ -45,44 +44,32 @@ int ID_LangMenu_RunPiped = wxNewId();//XRCID("idPyDebuggerMenuDebug");
4544
4645// events handling
4746BEGIN_EVENT_TABLE (PyDebugger, cbDebuggerPlugin)
48- EVT_MENU (ID_LangMenu_DebugSendCommand,PyDebugger::OnSendCommand)
4947 EVT_END_PROCESS (ID_PipedProcess, PyDebugger::OnTerminatePipedProcess)
5048 EVT_TIMER(ID_TimerPollDebugger, PyDebugger::OnTimer)
5149END_EVENT_TABLE()
5250
5351
54- void PyDebugger::OnStep(wxCommandEvent &event )
52+ void PyDebugger::SendCommand( const wxString& cmd, bool debugLog )
5553{
56- Step ();
57- }
58-
59- void PyDebugger::OnStop (wxCommandEvent &event)
60- {
61- Stop ();
62- }
63-
64- void PyDebugger::OnNext (wxCommandEvent &event)
65- {
66- Next ();
67- }
68-
69- void PyDebugger::OnContinue (wxCommandEvent &event)
70- {
71- Continue ();
54+ wxString scmd = cmd;
55+ if (!m_DebuggerActive) // could be unsafe, but allows user to provide program input
56+ return ;
57+ if (!scmd.EndsWith (_T (" \n " )))
58+ scmd+=_T (" \n " );
59+ DispatchCommands (scmd,DBGCMDTYPE_USERCOMMAND ,true );
7260}
7361
74- void PyDebugger::OnSendCommand (wxCommandEvent &event )
62+ bool PyDebugger::SupportsFeature (cbDebuggerFeature::Flags f )
7563{
76- if (!m_DebuggerActive /* || m_TimerPollDebugger.IsRunning() */ ) // could be unsafe, but allows user to provide program input
77- return ;
78- wxString cmd;
79- SendCommandDlg dlg (NULL );
80- if (dlg.ShowModal ()==wxID_OK)
64+ switch (f)
8165 {
82- wxString cmd=dlg.m_cmd ->GetValue ();
83- if (dlg.m_newline ->IsChecked ())
84- cmd+=_T (" \n " );
85- DispatchCommands (cmd,DBGCMDTYPE_USERCOMMAND ,true );
66+ case Disassembly:
67+ case ExamineMemory:
68+ case CPURegisters:
69+ case Threads: // Will be true with rpdb
70+ return false ;
71+ default :
72+ return true ;
8673 }
8774}
8875
@@ -166,14 +153,14 @@ wxString PyDebugger::AssembleAliasCommands()
166153 // NB: \001 is the separator character used when parsing in OnTimer
167154
168155 // Print variables associated with a child
169- commands+=_T (" alias pm for x in sorted(%1.__dict__): print '%s\\ 001%s\\ 001'%(x,type(%1.__dict__[x])),%1.__dict__[x],'\\ 001',\n " );
156+ commands+=_T (" alias pm for x in sorted(%1.__dict__): print '%s\\ 001%s\\ 001'%(x,type(%1.__dict__[x])),str( %1.__dict__[x])[:800 ],'\\ 001',\n " );
170157 // Print variable name, type and value
171- commands+=_T (" alias ps print '%1\\ 001',;print str(type(%1))+'\\ 001',;print %1 \n " );
158+ commands+=_T (" alias ps print '%1\\ 001',;print str(type(%1))+'\\ 001',;print str(%1)[:800] \n " );
172159 // Print comment
173160 commands+=_T (" alias pc print '%1'\n " );
174161
175162 // Alias for creating tooltip watch output
176- commands+=_T (" alias pw print '%1',type(%1);print %1 \n " );
163+ commands+=_T (" alias pw print '%1',type(%1);print str(%1)[:800] \n " );
177164 return commands;
178165}
179166
@@ -442,31 +429,8 @@ bool PyDebugger::IsAttachedToProcess() const
442429}
443430
444431
445- void PyDebugger::OnDebugTarget (wxCommandEvent &event)
446- {
447- if (m_DebuggerActive)
448- return ;
449- if (m_RunTarget==_T (" " )||!m_RunTargetSelected)
450- {
451- OnSetTarget (event);
452- if (m_RunTarget==_T (" " ))
453- return ;
454- }
455- m_RunTargetSelected=false ;
456- if (m_RunTarget.Contains (_T (" " )))
457- {
458- wxFileName f (m_RunTarget);
459- m_RunTarget=f.GetShortPath ();
460- }
461- Debug (false );
462- }
463-
464432bool PyDebugger::Debug (bool breakOnEntry)
465433{
466- // TODO: need to setup path finding for a pdb runner that will be embedded in the plugins resources
467- // m_DefaultDebugCmdLine=_T(" -u c:\\codeblockssrc\\cbpythonplugin\\pdb2.py ");
468- //
469-
470434// TODO: figure out why debug watch and breakpoints fail after the first debug session - not erasing the command list with clear()???
471435 if (m_DebuggerActive)
472436 return 0 ;
@@ -490,7 +454,6 @@ bool PyDebugger::Debug(bool breakOnEntry)
490454 m_RunTarget=s;
491455 }
492456
493- // m_DebugLog->Clear();
494457 m_TimerPollDebugger.SetOwner (this , ID_TimerPollDebugger);
495458 m_pp=new wxProcess (this ,ID_PipedProcess);
496459 m_pp->Redirect ();
@@ -503,19 +466,6 @@ bool PyDebugger::Debug(bool breakOnEntry)
503466 wxString commandln = cfg.GetCommandLine (cfg.GetState ());
504467 commandln.Replace (wxT (" $target" ),target);
505468
506- // wxString f=wxFileName(m_DefaultInterpreter).GetShortPath();
507- // wxString commandln=f + m_DefaultDebugCmdLine+target;
508-
509-
510- // cbMessageBox(commandln);
511- #ifdef EXPERIMENTAL_PYTHON_DEBUG
512- // LogMessage(wxString::Format(_("Launching '%s': %s (in %s)"), consolename.c_str(), commandstr.c_str(), workingdir.c_str()));
513- // InterpretedLangs* plugin = Manager::Get()->GetPluginManager()->LoadPlugin(_T("InterpretedLangs"));
514- // m_ilplugin->m_shellmgr->LaunchProcess(commandln,_(T"PyDEBUG"),0);
515- // m_ilplugin->ShowConsole();
516- // ilShellTermEvent e;
517- // ProcessEvent(e);
518- #else
519469 m_pid=wxExecute (commandln,wxEXEC_ASYNC,m_pp);
520470 if (!m_pid)
521471 {
@@ -524,7 +474,6 @@ bool PyDebugger::Debug(bool breakOnEntry)
524474 }
525475 m_ostream=m_pp->GetOutputStream ();
526476 m_istream=m_pp->GetInputStream ();
527- #endif
528477
529478 wxSetWorkingDirectory (olddir);
530479
@@ -542,6 +491,10 @@ bool PyDebugger::Debug(bool breakOnEntry)
542491 DispatchCommands (wcommands,DBGCMDTYPE_WATCHEXPRESSION ,false );
543492 DispatchCommands (_T (" w\n " ),DBGCMDTYPE_CALLSTACK ,true ); // where
544493 m_DebuggerActive=true ;
494+
495+ CodeBlocksLogEvent evtlog (cbEVT_SWITCH_TO_LOG_WINDOW,m_DebugLog);
496+ Manager::Get ()->ProcessEvent (evtlog);
497+
545498 return 0 ;
546499}
547500
@@ -887,11 +840,11 @@ int PyDebugger::GetActiveStackFrame() const
887840 return m_stackinfo.activeframe ;
888841}
889842
890- void PyDebugger::OnRunPiped (wxCommandEvent &event)
891- {
892- m_RunTarget=_T (" " );
893- OnDebugTarget (event);
894- }
843+ // void PyDebugger::OnRunPiped(wxCommandEvent &event)
844+ // {
845+ // m_RunTarget=_T("");
846+ // OnDebugTarget(event);
847+ // }
895848
896849void PyDebugger::OnTerminatePipedProcess (wxProcessEvent &event)
897850{
@@ -905,27 +858,6 @@ void PyDebugger::OnTerminatePipedProcess(wxProcessEvent &event)
905858 MarkAsStopped ();
906859}
907860
908- void PyDebugger::OnSettings (wxCommandEvent& event)
909- {
910- wxMessageBox (_T (" Settings..." ));
911- }
912-
913- void PyDebugger::OnSubMenuSelect (wxUpdateUIEvent& event)
914- {
915- }
916-
917- void PyDebugger::OnSetTarget (wxCommandEvent& event)
918- {
919- // TODO: use default file extensions
920- wxFileDialog *fd=new wxFileDialog (NULL ,_T (" Choose the interpreter Target" ),_T (" " ),_T (" " ),m_PythonFileExtensions,wxOPEN|wxFILE_MUST_EXIST);
921- if (fd->ShowModal ()==wxID_OK)
922- {
923- m_RunTarget=fd->GetPath ();
924- } else
925- m_RunTarget=_T (" " );
926- delete fd;
927- }
928-
929861// constructor
930862PyDebugger::PyDebugger () : cbDebuggerPlugin(_T(" PyDebugger" ),_T(" py_debugger" ))
931863{
@@ -1060,110 +992,3 @@ void PyDebugger::OnValueTooltip(CodeBlocksEvent& event)
1060992 m_watch_tooltip_pos=pos;
1061993}
1062994
1063-
1064- void PyDebugger::CreateMenu ()
1065- {
1066- // TODO: This should all disappear and use native SDK implementations
1067- // LangMenu->Append(ID_LangMenu_Run,_T("Python &Run..."),_T(""));
1068- // LangMenu->AppendSeparator();
1069- // LangMenu->Append(ID_LangMenu_RunPiped,_T("Start &Debug..."),_T(""));
1070- // LangMenu->Append(XRCID("idPyDebuggerMenuDebug"),_T("&Continue"),_T(""));
1071- // LangMenu->Append(XRCID("idPyDebuggerMenuNext"),_T("&Next"),_T(""));
1072- // LangMenu->Append(XRCID("idPyDebuggerMenuStep"),_T("Step &Into"),_T(""));
1073- // LangMenu->Append(XRCID("idPyDebuggerMenuStop"),_T("&Stop"),_T(""));
1074- LangMenu->Append (ID_LangMenu_DebugSendCommand,_T (" &Send Debugger Command" ),_T (" " ));
1075- // LangMenu->Append(ID_LangMenu_ShowWatch,_T("Toggle &Watch"),_T(""),wxITEM_CHECK);
1076- // LangMenu->Append(ID_LangMenu_UpdateWatch,_T("&Update Watch"),_T(""));
1077- }
1078-
1079-
1080- void PyDebugger::UpdateMenu ()
1081- {
1082- }
1083-
1084-
1085- void PyDebugger::SetupToolsMenu (wxMenu& menuBar)
1086- {
1087- // TODO: This should all be deleted once native implementations are in place
1088- // The application is offering its menubar for your plugin,
1089- // to add any menu items you want...
1090- // Append any items you need in the menu...
1091- // NOTE: Be careful in here... The application's menubar is at your disposal.
1092- LangMenu=new wxMenu;
1093- CreateMenu ();
1094- // int pos = menuBar.FindMenu(_("P&lugins"));
1095- int pos=-1 ;
1096- if (pos!=wxNOT_FOUND)
1097- menuBar.AppendSubMenu (LangMenu, _ (" P&ython Debugger" ));
1098- else
1099- {
1100- delete LangMenu;
1101- LangMenu=0 ;
1102- }
1103- }
1104-
1105- void PyDebugger::BuildModuleMenu (const ModuleType type, wxMenu* menu, const FileTreeData* data)
1106- {
1107- // Some library module is ready to display a pop-up menu.
1108- // Check the parameter \"type\" and see which module it is
1109- // and append any items you need in the menu...
1110- // TIP: for consistency, add a separator as the first item...
1111- if (type==mtProjectManager)
1112- {
1113- if (data)
1114- {
1115- if (data->GetKind ()==FileTreeData::ftdkFile)
1116- {
1117- ProjectFile *f=data->GetProjectFile ();
1118- if (f)
1119- {
1120- wxString name=f->file .GetFullPath ();
1121- wxString ext=f->file .GetExt ();
1122- if (IsPythonFile (name))
1123- {
1124- m_RunTarget=name;
1125- m_RunTargetSelected=true ;
1126- menu->AppendSeparator ();
1127- // menu->Append(ID_LangMenu_Run,_T("Python Run"),_T(""));
1128- menu->Append (ID_LangMenu_RunPiped,_T (" Python Debug" ),_T (" " ));
1129- }
1130- }
1131- }
1132- }
1133- }
1134- if (type==mtEditorManager) // also type==mtOpenFilesList - not sure how to find out which file has been right clicked.
1135- {
1136- EditorManager* edMan = Manager::Get ()->GetEditorManager ();
1137- wxFileName activefile (edMan->GetActiveEditor ()->GetFilename ());
1138- wxString name=activefile.GetFullPath ();
1139- if (IsPythonFile (name))
1140- {
1141- m_RunTarget=name;
1142- m_RunTargetSelected=true ;
1143- menu->AppendSeparator ();
1144- // menu->Append(ID_LangMenu_Run,_T("Python Run"),_T(""));
1145- menu->Append (ID_LangMenu_RunPiped,_T (" Python Debug" ),_T (" " ));
1146-
1147- }
1148- }
1149- if (type==mtUnknown) // also type==mtOpenFilesList - not sure how to find out which file has been right clicked.
1150- {
1151- if (data->GetKind ()==FileTreeData::ftdkFile) // right clicked on folder in file explorer
1152- {
1153- wxFileName f (data->GetFolder ());
1154- wxString filename=f.GetFullPath ();
1155- wxString name=f.GetFullName ();
1156- // cbMessageBox(filename+_T(" ")+name);
1157- if (IsPythonFile (name))
1158- {
1159- m_RunTarget=filename;
1160- m_RunTargetSelected=true ;
1161- menu->AppendSeparator ();
1162- // menu->Append(ID_LangMenu_Run,_T("Python Run"),_T(""));
1163- menu->Append (ID_LangMenu_RunPiped,_T (" Python Debug" ),_T (" " ));
1164-
1165- }
1166- }
1167- }
1168- }
1169-
0 commit comments