Pol  Revision:cb584c9
poldbg.cpp
Go to the documentation of this file.
1 
12 #include "poldbg.h"
13 
14 #include <fstream>
15 #include <stddef.h>
16 #include <string>
17 
18 #include "../bscript/berror.h"
19 #include "../bscript/bobject.h"
20 #include "../bscript/bstruct.h"
21 #include "../bscript/eprog.h"
22 #include "../bscript/executor.h"
23 #include "../bscript/impstr.h"
24 #include "../clib/clib.h"
25 #include "../clib/compilerspecifics.h"
26 #include "../clib/esignal.h"
27 #include "../clib/rawtypes.h"
28 #include "../clib/refptr.h"
29 #include "../clib/sckutil.h"
30 #include "../clib/socketsvc.h"
31 #include "../clib/stlutil.h"
32 #include "../clib/strutil.h"
33 #include "../clib/weakptr.h"
34 #include "../clib/wnsckt.h"
35 #include "../plib/systemstate.h"
36 #include "module/osmod.h"
37 #include "module/uomod.h"
38 #include "scrdef.h"
39 #include "scrsched.h"
40 #include "uoexec.h"
41 
42 namespace Pol
43 {
44 namespace Core
45 {
46 using namespace Bscript;
47 
48 // 14 members
49 const char* poldbg_base_members[] = {"x", "y", "z", "name", "objtype",
50  "graphic", "serial", "color", "facing", "height",
51  "weight", "multi", "realm", "dirty"};
52 // 28 members
53 const char* poldbg_itemref_members[] = {"amount",
54  "layer",
55  "container",
56  "usescript",
57  "equipscript",
58  "desc",
59  "movable",
60  "invisible",
61  "decayat",
62  "sellprice",
63  "buyprice",
64  "newbie",
65  "insured",
66  "tile_layer",
67  "unequipscript",
68  "item_count",
69  "stackable",
70  "saveonexit",
71  "resist_fire",
72  "resist_cold",
73  "resist_energy",
74  "resist_poison",
75  "resist_physical",
76  "resist_fire_mod",
77  "resist_cold_mod",
78  "resist_energy_mod",
79  "resist_poison_mod",
80  "resist_physical_mod"};
81 // 59 members
82 const char* poldbg_mobileref_members[] = {"warmode",
83  "gender",
84  "race",
85  "trueobjtype",
86  "truecolor",
87  "ar_mod",
88  "hidden",
89  "concealed",
90  "frozen",
91  "paralyzed",
92  "poisoned",
93  "stealthsteps",
94  "squelched",
95  "dead",
96  "ar",
97  "backpack",
98  "weapon",
99  "acctname",
100  "acct",
101  "cmdlevel",
102  "cmdlevelstr",
103  "criminal",
104  "ip",
105  "gold",
106  "title_prefix",
107  "title_suffix",
108  "title_guild",
109  "title_race",
110  "guildid",
111  "guild",
112  "murderer",
113  "attached",
114  "reportables",
115  "clientversion",
116  "delay_mod",
117  "shield",
118  "uclang",
119  "clientver_detail",
120  "clientinfo",
121  "createdat",
122  "opponent",
123  "connected",
124  "trading_with",
125  "cursor",
126  "gump",
127  "prompt",
128  "movemode",
129  "hitchance_mod",
130  "evasionchance_mod",
131  "resist_fire",
132  "resist_cold",
133  "resist_energy",
134  "resist_poison",
135  "resist_physical",
136  "resist_fire_mod",
137  "resist_cold_mod",
138  "resist_energy_mod",
139  "resist_poison_mod",
140  "resist_physical_mod"};
141 
142 class DebugContext : public ref_counted
143 {
144 public:
145  DebugContext();
146  ~DebugContext();
147 
148  std::string prompt() const;
149  typedef std::vector<std::string> Results;
150  bool process( const std::string& cmd, Results& results );
151  bool done() const { return _done; }
152 
153 protected:
154  std::string cmd_attach( unsigned pid );
155  std::string cmd_kill( unsigned pid );
156  std::string cmd_loadsym( unsigned pid );
157  std::string cmd_detach();
158  std::string cmd_quit();
159  std::string cmd_start( const std::string& rest );
160  std::string cmd_call( const std::string& rest, Results& results );
161  std::string cmd_state();
162  std::string cmd_pc();
163  std::string cmd_ins( Results& results );
164  std::string cmd_instrace();
165  std::string cmd_stepinto();
166  std::string cmd_stepover();
167  std::string cmd_run();
168  std::string cmd_break();
169  std::string cmd_setbp( const std::string& rest );
170  std::string cmd_clrbp( const std::string& rest );
171  std::string cmd_clrallbp();
172  std::string cmd_fileline( const std::string& rest );
173  std::string cmd_files( Results& results );
174  std::string cmd_stacktrace( Results& results );
175  std::string cmd_filecont( const std::string& rest, Results& results );
176  std::string cmd_funcprof( const std::string& rest, Results& results );
177  std::string cmd_localvars( Results& results );
178  std::string cmd_globalvars( Results& results );
179  std::string cmd_localvar( const std::string& rest );
180  std::string cmd_localvarmembers( const std::string& rest, Results& results );
181  std::string cmd_inslist( const std::string& rest, Results& results );
182  std::string cmd_pidlist( const std::string& rest, Results& results );
183  std::string cmd_getlocalpacked( const std::string& rest );
184  std::string cmd_getglobalpacked( const std::string& rest );
185  std::string cmd_setlocalpacked( const std::string& rest );
186  std::string cmd_setglobalpacked( const std::string& rest );
187  std::string cmd_scriptlist( const std::string& rest, Results& results );
188  std::string cmd_scriptprofile( const std::string& rest, Results& results );
189  std::string cmd_scriptins( const std::string& rest, Results& results );
190  std::string cmd_scriptsrc( const std::string& rest, Results& results );
191  std::string cmd_srcprof( const std::string& rest, Results& results );
192  std::string cmd_setscript( const std::string& rest, Results& results );
193  std::string cmd_funclist( const std::string& rest, Results& results );
194 
195 private:
197  bool _done;
200 
201  // not implemented:
202  DebugContext( const DebugContext& );
203  DebugContext& operator=( const DebugContext& );
204 };
205 
208 class DebugContextObjImp : public DebugContextObjImpBase
209 {
210 public:
211  explicit DebugContextObjImp( ref_ptr<DebugContext> rcdctx );
212  virtual const char* typeOf() const POL_OVERRIDE;
213  virtual u8 typeOfInt() const POL_OVERRIDE;
214  virtual BObjectImp* copy() const POL_OVERRIDE;
215  virtual BObjectImp* call_method( const char* methodname, Executor& ex ) POL_OVERRIDE;
216  virtual BObjectRef get_member( const char* membername ) POL_OVERRIDE;
217 };
219  : DebugContextObjImpBase( &debugcontextobjimp_type, rcdctx )
220 {
221 }
222 const char* DebugContextObjImp::typeOf() const
223 {
224  return "DebugContext";
225 }
227 {
228  return OTDebugContext;
229 }
231 {
232  return new DebugContextObjImp( value() );
233 }
234 BObjectImp* DebugContextObjImp::call_method( const char* methodname, Executor& ex )
235 {
236  if ( stricmp( methodname, "process" ) == 0 )
237  {
238  if ( !ex.hasParams( 1 ) )
239  return new BError( "Not enough parameters" );
240  const String* str;
241  if ( ex.getStringParam( 0, str ) )
242  {
243  std::vector<std::string> results;
244  value()->process( str->value(), results );
245  std::unique_ptr<ObjArray> arr( new ObjArray );
246  for ( unsigned i = 0; i < results.size(); ++i )
247  {
248  arr->addElement( new String( results[i] ) );
249  }
250  return arr.release();
251  }
252  else
253  {
254  return new BError( "Invalid parameter type" );
255  }
256  }
257  return new BError( "undefined" );
258 }
260 {
261  if ( stricmp( membername, "prompt" ) == 0 )
262  return BObjectRef( new String( value()->prompt() ) );
263  else
264  return BObjectRef( new BError( "Undefined member" ) );
265 }
266 
268 {
269  DebugContext* dctx = new DebugContext;
270  std::vector<std::string> tmp;
271  dctx->process( "password " + Plib::systemstate.config.debug_password, tmp );
272  return new DebugContextObjImp( ref_ptr<DebugContext>( dctx ) );
273 }
274 
276  : _authorized( Plib::systemstate.config.debug_password.empty() ),
277  _done( false ),
278  uoexec_wptr( 0 )
279 {
280 }
281 
283 {
284  cmd_detach();
285 }
286 
287 std::string DebugContext::prompt() const
288 {
289  if ( !_authorized )
290  return "Authorization required.";
291  else
292  return "Ready.";
293 }
294 
323 
324 bool DebugContext::process( const std::string& cmdline, std::vector<std::string>& results )
325 {
326  try
327  {
328  results.clear();
329  std::string result;
330 
331  std::string cmd, rest;
332  Clib::splitnamevalue( cmdline, cmd, rest );
333  if ( !_authorized )
334  {
335  if ( cmd == "password" )
336  {
338  results.push_back( std::string( "Password" ) + ( _authorized ? "" : " not" ) +
339  " recognized." );
340  }
341  return _authorized;
342  }
343 
344  if ( cmd == "attach" )
345  result = cmd_attach( atoi( rest.c_str() ) );
346  else if ( cmd == "stacktrace" )
347  result = cmd_stacktrace( results );
348  else if ( cmd == "quit" )
349  result = cmd_quit();
350  else if ( cmd == "detach" )
351  result = cmd_detach();
352  else if ( cmd == "start" )
353  result = cmd_start( rest );
354  else if ( cmd == "call" )
355  result = cmd_call( rest, results );
356  else if ( cmd == "state" )
357  result = cmd_state();
358  else if ( cmd == "pc" )
359  result = cmd_pc();
360  else if ( cmd == "ins" )
361  result = cmd_ins( results );
362  else if ( cmd == "instrace" )
363  result = cmd_instrace();
364  else if ( cmd == "stepinto" )
365  result = cmd_stepinto();
366  else if ( cmd == "stepover" )
367  result = cmd_stepover();
368  else if ( cmd == "run" )
369  result = cmd_run();
370  else if ( cmd == "break" )
371  result = cmd_break();
372  else if ( cmd == "setbp" )
373  result = cmd_setbp( rest );
374  else if ( cmd == "clrbp" )
375  result = cmd_clrbp( rest );
376  else if ( cmd == "clrallbp" )
377  result = cmd_clrallbp();
378  else if ( cmd == "fileline" )
379  result = cmd_fileline( rest );
380  else if ( cmd == "files" )
381  result = cmd_files( results );
382  else if ( cmd == "filecont" )
383  result = cmd_filecont( rest, results );
384  else if ( cmd == "localvars" )
385  result = cmd_localvars( results );
386  else if ( cmd == "globalvars" )
387  result = cmd_globalvars( results );
388  else if ( cmd == "localvar" )
389  result = cmd_localvar( rest );
390  else if ( cmd == "localvarmembers" )
391  result = cmd_localvarmembers( rest, results );
392  else if ( cmd == "inslist" )
393  result = cmd_inslist( rest, results );
394  else if ( cmd == "pidlist" )
395  result = cmd_pidlist( rest, results );
396  else if ( cmd == "scriptlist" )
397  result = cmd_scriptlist( rest, results );
398  else if ( cmd == "scriptprofile" )
399  result = cmd_scriptprofile( rest, results );
400  else if ( cmd == "scriptins" )
401  result = cmd_scriptins( rest, results );
402  else if ( cmd == "scriptsrc" )
403  result = cmd_scriptsrc( rest, results );
404  else if ( cmd == "srcprof" )
405  result = cmd_srcprof( rest, results );
406  else if ( cmd == "funclist" )
407  result = cmd_funclist( rest, results );
408  else if ( cmd == "setscript" )
409  result = cmd_setscript( rest, results );
410  else if ( cmd == "getlocalpacked" )
411  result = cmd_getlocalpacked( rest );
412  else if ( cmd == "getglobalpacked" )
413  result = cmd_getglobalpacked( rest );
414  else if ( cmd == "setlocalpacked" )
415  result = cmd_setlocalpacked( rest );
416  else if ( cmd == "setglobalpacked" )
417  result = cmd_setglobalpacked( rest );
418  else if ( cmd == "kill" )
419  result = cmd_kill( atoi( rest.c_str() ) );
420  else if ( cmd == "loadsym" )
421  result = cmd_loadsym( atoi( rest.c_str() ) );
422  else
423  result = "Command '" + cmdline + "' not recognized.";
424 
425  if ( !result.empty() )
426  {
427  results.push_back( result );
428  }
429  return true;
430  }
431  catch ( std::exception& ex )
432  {
433  std::string text = "Exception thrown while processing command: ";
434  text += ex.what();
435  results.push_back( text );
436  return false;
437  }
438 }
439 
440 std::string DebugContext::cmd_stacktrace( Results& results )
441 {
442  if ( !uoexec_wptr.exists() )
443  return "No script attached.";
444 
445  UOExecutor* exec = uoexec_wptr.get_weakptr();
446  if ( !exec->halt() )
447  {
448  return "Script must be halted to retreive stack trace.";
449  }
450  EScriptProgram* prog = const_cast<EScriptProgram*>( exec->prog() );
451  prog->read_dbg_file();
452 
453  const_cast<EScriptProgram*>( prog )->read_dbg_file();
454  if ( !prog->debug_loaded )
455  return "No debugging information available.";
456 
457 
458  std::vector<BObjectRefVec*> upperLocals2 = exec->upperLocals2;
459  std::vector<ReturnContext> stack = exec->ControlStack;
460 
461  unsigned int PC;
462 
463  {
464  ReturnContext rc;
465  rc.PC = exec->PC;
466  rc.ValueStackDepth = static_cast<unsigned int>( exec->ValueStack.size() );
467  stack.push_back( rc );
468  }
469  upperLocals2.push_back( exec->Locals2 );
470 
471  results.push_back( Clib::decint( stack.size() ) );
472 
473  while ( !stack.empty() )
474  {
475  ReturnContext& rc = stack.back();
476  BObjectRefVec* Locals2 = upperLocals2.back();
477  PC = rc.PC;
478  stack.pop_back();
479  upperLocals2.pop_back();
480 
481  BStruct stackEntry;
482 
483  size_t left = Locals2->size();
484 
485  results.push_back( Clib::decint( PC ) );
486  results.push_back( Clib::decint( prog->dbg_filenum[PC] ) );
487  results.push_back( Clib::decint( prog->dbg_linenum[PC] ) );
488 
489  std::vector<std::string> results2;
490  unsigned block = prog->dbg_ins_blocks[PC];
491  while ( left )
492  {
493  while ( left <= prog->blocks[block].parentvariables )
494  {
495  block = prog->blocks[block].parentblockidx;
496  }
497  const EPDbgBlock& progblock = prog->blocks[block];
498  size_t varidx = left - 1 - progblock.parentvariables;
499  left--;
500  BObjectImp* ptr = ( *Locals2 )[varidx]->impptr();
501 
502  results2.push_back( progblock.localvarnames[varidx] + " " + ptr->pack() );
503  }
504  results.push_back( Clib::decint( results2.size() ) );
505 
506  for ( std::vector<std::string>::iterator it = results2.begin(); it < results2.end(); ++it )
507  results.push_back( *it );
508  }
509  return "";
510 }
511 std::string DebugContext::cmd_attach( unsigned pid )
512 {
513  UOExecutor* uoexec;
514  if ( find_uoexec( pid, &uoexec ) )
515  {
516  uoexec->attach_debugger();
517  uoexec_wptr = uoexec->weakptr;
518  EScriptProgram* prog = const_cast<EScriptProgram*>( uoexec->prog() );
519  prog->read_dbg_file();
520  _script.set( prog );
521  return "Attached to PID " + Clib::tostring( pid ) + ".";
522  }
523  else
524  {
525  return "PID not found.";
526  }
527 }
528 
529 std::string DebugContext::cmd_loadsym( unsigned pid )
530 {
531  UOExecutor* uoexec;
532  if ( find_uoexec( pid, &uoexec ) )
533  {
534  int res = const_cast<EScriptProgram*>( uoexec->prog() )->read_dbg_file();
535  if ( res )
536  return "Failed to load symbols.";
537  else
538  return "Loaded debug symbols.";
539  }
540  else
541  {
542  return "PID not found.";
543  }
544 }
545 
546 std::string DebugContext::cmd_kill( unsigned pid )
547 {
548  UOExecutor* uoexec;
549  if ( find_uoexec( pid, &uoexec ) )
550  {
551  uoexec->seterror( true );
552  return "Marked PID " + Clib::tostring( pid ) + " with an error.";
553  }
554  else
555  {
556  return "PID not found.";
557  }
558 }
559 
561 {
562  if ( !uoexec_wptr.exists() )
563  return "No script attached.";
564 
565  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
566  if ( uoexec->os_module->in_debugger_holdlist() )
567  uoexec->os_module->revive_debugged();
568 
569  uoexec->detach_debugger();
570  uoexec_wptr.clear();
571  return "Detached.";
572 }
573 
575 {
576  _done = true;
577  return "Bye.";
578 }
579 
580 std::string DebugContext::cmd_start( const std::string& rest )
581 {
582  std::string filename = rest;
583  ScriptDef sd;
584  if ( !sd.config_nodie( filename, nullptr, "scripts/" ) )
585  return "Error in script name.";
586  if ( !sd.exists() )
587  return "Script " + sd.name() + " does not exist.";
588 
589  Module::UOExecutorModule* new_uoemod = Core::start_script( sd, nullptr );
590  if ( new_uoemod == nullptr )
591  {
592  return "Unable to start script";
593  }
594 
595  UOExecutor* uoexec = static_cast<UOExecutor*>( &new_uoemod->exec );
596 
597  return "PID " + Clib::tostring( uoexec->os_module->pid() );
598 }
599 
601 
602 std::string DebugContext::cmd_call( const std::string& rest, Results& /*results*/ )
603 {
604  std::string filename, parameters_packed;
605  Clib::splitnamevalue( rest, filename, parameters_packed );
606 
607  ScriptDef sd;
608  if ( !sd.config_nodie( filename, nullptr, "scripts/" ) )
609  return "Error in script name.";
610  if ( !sd.exists() )
611  return "Script " + sd.name() + " does not exist.";
612 
613  try
614  {
615  UOExecutor ex;
616  BObject params( new UninitObject );
617  if ( !parameters_packed.empty() )
618  {
619  params.setimp( BObjectImp::unpack( parameters_packed.c_str() ) );
620  if ( !params.isa( BObjectImp::OTArray ) )
621  {
622  return "Parameters must be an array.";
623  }
624  ObjArray* arr = static_cast<ObjArray*>( params.impptr() );
625  for ( int i = static_cast<int>( arr->ref_arr.size() - 1 ); i >= 0; --i )
626  {
627  ex.pushArg( arr->ref_arr[i]->impptr() );
628  }
629  }
630  BObject ret( run_executor_to_completion( ex, sd ) );
631  return "Return value packed: " + ret.impptr()->pack();
632  }
633  catch ( ... )
634  {
635  return "Exception calling script";
636  }
637 }
638 
639 std::string DebugContext::cmd_pidlist( const std::string& rest, Results& results )
640 {
641  std::string match = Clib::strlower( rest );
642 
643  for ( PidList::const_iterator citr = scriptScheduler.getPidlist().begin();
644  citr != scriptScheduler.getPidlist().end(); ++citr )
645  {
646  UOExecutor* uoexec = ( *citr ).second;
647  std::string name = Clib::strlower( uoexec->scriptname() );
648  if ( strstr( name.c_str(), match.c_str() ) != nullptr )
649  {
650  results.push_back( Clib::decint( ( *citr ).first ) + " " + uoexec->scriptname() );
651  }
652  }
653 
654  return "";
655 }
656 
657 std::string DebugContext::cmd_scriptlist( const std::string& /*rest*/, Results& results )
658 {
659  for ( ScriptStorage::const_iterator citr = scriptScheduler.scrstore.begin();
660  citr != scriptScheduler.scrstore.end(); ++citr )
661  {
662  const char* nm = ( ( *citr ).first ).c_str();
663  EScriptProgram* eprog = ( ( *citr ).second ).get();
664  std::string scriptname = eprog->name;
665  results.push_back( nm );
666  }
667  return "";
668 }
669 
670 std::string DebugContext::cmd_setscript( const std::string& rest, Results& /*results*/ )
671 {
672  _script.clear();
673 
674  // const char* fn = rest.c_str();
675  ScriptStorage::iterator itr = scriptScheduler.scrstore.find( rest );
676  if ( itr == scriptScheduler.scrstore.end() )
677  return "No such script.";
678 
679  ref_ptr<EScriptProgram> res( ( *itr ).second );
680  EScriptProgram* eprog = res.get();
681  if ( eprog->read_dbg_file() != 0 )
682  return "Failed to load symbols.";
683 
684  _script = res;
685  return "";
686 }
687 
688 std::string DebugContext::cmd_funclist( const std::string& /*rest*/, Results& results )
689 {
690  if ( _script.get() == 0 )
691  return "use setscript first";
692 
693  // no parameters.
694 
695  for ( unsigned i = 0; i < _script->dbg_functions.size(); ++i )
696  {
697  const EPDbgFunction& func = _script->dbg_functions[i];
698 
699  unsigned int cycles = 0;
700  for ( unsigned pc = func.firstPC; pc <= func.lastPC; ++pc )
701  {
702  const Instruction& ins = _script->instr[pc];
703  cycles += ins.cycles;
704  }
705 
706  std::string result = func.name + " " + Clib::decint( func.firstPC ) + " " +
707  Clib::decint( func.lastPC ) + " " + Clib::decint( cycles );
708  results.push_back( result );
709  }
710 
711  return "";
712 }
713 
714 std::string DebugContext::cmd_srcprof( const std::string& rest, Results& results )
715 {
716  if ( _script.get() == 0 )
717  return "use setscript first";
718 
719  // parameter: file#
720  int fileno = atoi( rest.c_str() );
721 
722  typedef std::map<unsigned int, unsigned int> Cycles;
723  Cycles cycle_counts; // key is line#, val is cycles
724 
725  size_t count = _script->instr.size();
726 
727  for ( size_t i = 0; i < count; ++i )
728  {
729  int filenum = _script->dbg_filenum[i];
730  if ( filenum == fileno )
731  {
732  int linenum = _script->dbg_linenum[i];
733  const Instruction& ins = _script->instr[i];
734  cycle_counts[linenum] += ins.cycles;
735  }
736  }
737 
738  for ( Cycles::iterator itr = cycle_counts.begin(); itr != cycle_counts.end(); ++itr )
739  {
740  unsigned int linenum = ( *itr ).first;
741  unsigned int cycles = ( *itr ).second;
742  std::string result = Clib::decint( linenum ) + " " + Clib::decint( cycles );
743  results.push_back( result );
744  }
745 
746  return "";
747 }
748 
749 std::string DebugContext::cmd_funcprof( const std::string& /*rest*/, Results& /*results*/ )
750 {
751  if ( _script.get() == 0 )
752  return "use setscript first";
753 
754  return "";
755 }
756 
757 std::string DebugContext::cmd_scriptprofile( const std::string& rest, Results& results )
758 {
759  ScriptStorage::iterator itr = scriptScheduler.scrstore.find( rest.c_str() );
760  if ( itr == scriptScheduler.scrstore.end() )
761  return "No such script.";
762 
763  ref_ptr<EScriptProgram> res( ( *itr ).second );
764  EScriptProgram* eprog = res.get();
765  size_t count = eprog->instr.size();
766  for ( size_t i = 0; i < count; ++i )
767  {
768  const Instruction& ins = eprog->instr[i];
769  std::string result = Clib::decint( i ) + " " + Clib::decint( ins.cycles );
770  results.push_back( result );
771  }
772  return "";
773 }
774 
775 std::string DebugContext::cmd_scriptins( const std::string& rest, Results& results )
776 {
777  ScriptStorage::iterator itr = scriptScheduler.scrstore.find( rest.c_str() );
778  if ( itr == scriptScheduler.scrstore.end() )
779  return "No such script.";
780 
781  ref_ptr<EScriptProgram> res( ( *itr ).second );
782  EScriptProgram* eprog = res.get();
783  if ( eprog->read_dbg_file() != 0 )
784  return "Failed to load symbols.";
785 
786  size_t count = eprog->instr.size();
787  for ( size_t i = 0; i < count; ++i )
788  {
789  std::string result = Clib::decint( i ) + " " + eprog->dbg_get_instruction( i );
790  results.push_back( result );
791  }
792  return "";
793 }
794 
795 std::string get_fileline( EScriptProgram* prog, int filenum, int linenum )
796 {
797  if ( filenum == 0 || filenum >= static_cast<int>( prog->dbg_filenames.size() ) )
798  return "";
799  std::ifstream ifs( prog->dbg_filenames[filenum].c_str() );
800  std::string tmp;
801  for ( int skip = 1; skip < linenum; ++skip )
802  {
803  if ( !getline( ifs, tmp ) )
804  return "";
805  }
806  if ( getline( ifs, tmp ) )
807  return tmp;
808  else
809  return "";
810 }
811 
812 std::string DebugContext::cmd_scriptsrc( const std::string& rest, Results& results )
813 {
814  ScriptStorage::iterator itr = scriptScheduler.scrstore.find( rest.c_str() );
815  if ( itr == scriptScheduler.scrstore.end() )
816  return "No such script.";
817 
818  ref_ptr<EScriptProgram> res( ( *itr ).second );
819  EScriptProgram* eprog = res.get();
820  if ( eprog->read_dbg_file() != 0 )
821  return "Failed to load symbols.";
822 
823  int last_filenum = -1;
824  int last_linenum = -1;
825  size_t count = eprog->instr.size();
826  for ( size_t ins = 0; ins < count; ++ins )
827  {
828  int filenum = eprog->dbg_filenum[ins];
829  int linenum = eprog->dbg_linenum[ins];
830  if ( filenum == last_filenum && linenum == last_linenum )
831  continue;
832 
833  std::string result = get_fileline( eprog, filenum, linenum );
834  if ( result != "" )
835  results.push_back( Clib::decint( ins ) + " " + result );
836 
837  last_filenum = filenum;
838  last_linenum = linenum;
839  }
840  return "";
841 }
842 
844 {
845  if ( !uoexec_wptr.exists() )
846  return "No script attached.";
847  return uoexec_wptr.get_weakptr()->state();
848 }
849 
850 std::string DebugContext::cmd_pc()
851 {
852  if ( !uoexec_wptr.exists() )
853  return "No script attached.";
854  return Clib::tostring( uoexec_wptr.get_weakptr()->PC );
855 }
856 
857 std::string DebugContext::cmd_ins( std::vector<std::string>& results )
858 {
859  if ( !uoexec_wptr.exists() )
860  return "No script attached.";
861  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
862  int start = uoexec->PC - 5;
863  int end = uoexec->PC + 5;
864  if ( start < 0 )
865  start = 0;
866  if ( end >= static_cast<int>( uoexec->nLines ) )
867  end = uoexec->nLines - 1;
868  for ( int i = start; i <= end; ++i )
869  {
870  results.push_back( uoexec->dbg_get_instruction( i ) );
871  }
872  return "";
873 }
874 
876 {
877  if ( !uoexec_wptr.exists() )
878  return "No script attached.";
879  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
880  if ( !uoexec->os_module->in_debugger_holdlist() )
881  return "Script not ready to trace.";
882 
883  uoexec->dbg_ins_trace();
884  uoexec->os_module->revive_debugged();
885  return "Tracing.";
886 }
887 
889 {
890  if ( !uoexec_wptr.exists() )
891  return "No script attached.";
892  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
893  if ( !uoexec->os_module->in_debugger_holdlist() )
894  return "Script not ready to trace.";
895 
896  uoexec->dbg_step_into();
897  uoexec->os_module->revive_debugged();
898  return "Stepping In.";
899 }
900 
902 {
903  if ( !uoexec_wptr.exists() )
904  return "No script attached.";
905  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
906  if ( !uoexec->os_module->in_debugger_holdlist() )
907  return "Script not ready to trace.";
908 
909  uoexec->dbg_step_over();
910  uoexec->os_module->revive_debugged();
911  return "Stepping Over.";
912 }
913 
915 {
916  if ( !uoexec_wptr.exists() )
917  return "No script attached.";
918  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
919  if ( !uoexec->os_module->in_debugger_holdlist() )
920  return "Script not ready to trace.";
921 
922  uoexec->dbg_run();
923  uoexec->os_module->revive_debugged();
924  return "Running.";
925 }
927 {
928  if ( !uoexec_wptr.exists() )
929  return "No script attached.";
930  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
931  // if (!uoexec->os_module->in_debugger_holdlist())
932  // return "Script not ready to trace.";
933 
934  uoexec->dbg_break();
935  return "Marked for break-into.";
936 }
937 std::string DebugContext::cmd_setbp( const std::string& rest )
938 {
939  if ( !uoexec_wptr.exists() )
940  return "No script attached.";
941  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
942  uoexec->dbg_setbp( atoi( rest.c_str() ) );
943  return "Breakpoint set.";
944 }
945 std::string DebugContext::cmd_clrbp( const std::string& rest )
946 {
947  if ( !uoexec_wptr.exists() )
948  return "No script attached.";
949  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
950  uoexec->dbg_clrbp( atoi( rest.c_str() ) );
951  return "Breakpoint cleared.";
952 }
954 {
955  if ( !uoexec_wptr.exists() )
956  return "No script attached.";
957  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
958  uoexec->dbg_clrallbp();
959  return "All breakpoints cleared.";
960 }
961 std::string DebugContext::cmd_fileline( const std::string& rest )
962 {
963  if ( !uoexec_wptr.exists() )
964  return "No script attached.";
965  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
966  const EScriptProgram* prog = uoexec->prog();
967  if ( !prog->debug_loaded )
968  return "No debug information available.";
969 
970  unsigned ins = uoexec->PC;
971  if ( !rest.empty() )
972  ins = atoi( rest.c_str() );
973  int filenum, linenum;
974  if ( prog->dbg_filenum.size() <= ins )
975  return "out of range";
976  filenum = prog->dbg_filenum[ins];
977  if ( prog->dbg_linenum.size() <= ins )
978  return "out of range";
979  linenum = prog->dbg_linenum[ins];
980  return Clib::decint( filenum ) + " " + Clib::decint( linenum );
981 }
982 
983 std::string DebugContext::cmd_files( Results& results )
984 {
985  const EScriptProgram* prog = nullptr;
986 
987  if ( _script.get() != 0 )
988  prog = _script.get();
989  else if ( uoexec_wptr.exists() )
990  prog = uoexec_wptr.get_weakptr()->prog();
991  else
992  return "attach or setscript first";
993 
994  if ( !prog->debug_loaded )
995  return "No debug information available.";
996 
997  for ( unsigned i = 0; i < prog->dbg_filenames.size(); ++i )
998  {
999  std::string tmp = Clib::decint( i ) + " " + prog->dbg_filenames[i];
1000  results.push_back( tmp );
1001  }
1002  return "";
1003 }
1004 
1005 std::string DebugContext::cmd_filecont( const std::string& rest, Results& results )
1006 {
1007  const EScriptProgram* prog = nullptr;
1008 
1009  if ( _script.get() != 0 )
1010  prog = _script.get();
1011  else if ( uoexec_wptr.exists() )
1012  prog = uoexec_wptr.get_weakptr()->prog();
1013  else
1014  return "attach or setscript first";
1015 
1016  if ( !prog->debug_loaded )
1017  return "No debug information available.";
1018 
1019  unsigned filenum, firstline, lastline;
1020 
1021  ISTRINGSTREAM is( rest );
1022  if ( !( is >> filenum ) )
1023  return "File # must be specified";
1024  if ( !( is >> firstline ) )
1025  firstline = 1; // start at beginning
1026  if ( !( is >> lastline ) )
1027  lastline = 0; // all lines
1028 
1029  if ( filenum >= prog->dbg_filenames.size() )
1030  return "File # out of range";
1031 
1032  std::ifstream ifs( prog->dbg_filenames[filenum].c_str() );
1033  std::string tmp;
1034  for ( unsigned skip = 1; skip < firstline; ++skip )
1035  {
1036  if ( !getline( ifs, tmp ) )
1037  break;
1038  }
1039  while ( ( lastline == 0 || firstline++ <= lastline ) && getline( ifs, tmp ) )
1040  {
1041  tmp.erase( tmp.find_last_not_of( "\n\r" ) + 1 );
1042  results.push_back( tmp );
1043  }
1044 
1045  return "";
1046 }
1047 std::string DebugContext::cmd_localvars( Results& results )
1048 {
1049  if ( !uoexec_wptr.exists() )
1050  return "No script attached.";
1051  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1052  const EScriptProgram* prog = uoexec->prog();
1053  if ( !prog->debug_loaded )
1054  return "No debug information available.";
1055 
1056  // for now, always asking given the current instruction = PC
1057  unsigned block = prog->dbg_ins_blocks[uoexec->PC];
1058  size_t left = uoexec->Locals2->size();
1059  results.resize( left );
1060  while ( left )
1061  {
1062  while ( left <= prog->blocks[block].parentvariables )
1063  {
1064  block = prog->blocks[block].parentblockidx;
1065  }
1066  size_t varidx = left - 1 - prog->blocks[block].parentvariables;
1067  results[left - 1] = prog->blocks[block].localvarnames[varidx];
1068  --left;
1069  }
1070  return "";
1071 }
1072 std::string DebugContext::cmd_globalvars( Results& results )
1073 {
1074  if ( !uoexec_wptr.exists() )
1075  return "No script attached.";
1076  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1077  const EScriptProgram* prog = uoexec->prog();
1078  if ( !prog->debug_loaded )
1079  return "No debug information available.";
1080 
1081  BObjectRefVec::const_iterator itr = uoexec->Globals2.begin(), end = uoexec->Globals2.end();
1082 
1083  for ( unsigned idx = 0; itr != end; ++itr, ++idx )
1084  {
1085  if ( prog->globalvarnames.size() > idx )
1086  results.push_back( prog->globalvarnames[idx].c_str() );
1087  else
1088  results.push_back( Clib::decint( idx ).c_str() );
1089  }
1090  return "";
1091 }
1092 std::string DebugContext::cmd_localvar( const std::string& rest )
1093 {
1094  if ( !uoexec_wptr.exists() )
1095  return "No script attached.";
1096  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1097  // const EScriptProgram* prog = uoexec->prog();
1098 
1099  unsigned varidx = atoi( rest.c_str() );
1100  if ( varidx >= uoexec->Locals2->size() )
1101  return "Error: Index out of range"; // vector
1102  return "Value: " + ( *uoexec->Locals2 )[varidx]->impref().getStringRep();
1103 }
1104 
1105 std::string DebugContext::cmd_localvarmembers( const std::string& rest, Results& results )
1106 {
1107  if ( !uoexec_wptr.exists() )
1108  return "No script attached.";
1109  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1110 
1111  unsigned varidx = atoi( rest.c_str() );
1112  if ( varidx >= uoexec->Locals2->size() )
1113  return "Error: Index out of range"; // vector
1114  BObjectImp& var = ( *uoexec->Locals2 )[varidx]->impref();
1115 
1116  std::string strrep = var.getStringRep();
1117  const char* memname;
1118  int i;
1119  OSTRINGSTREAM os;
1120  if ( strrep.find( "ItemRef" ) != std::string::npos )
1121  {
1122  for ( i = 0; i < 14; i++ ) // i = member count for poldbg_base_members
1123  {
1124  memname = poldbg_base_members[i];
1125  os << memname << " " << var.get_member( memname ).get()->impptr()->getStringRep();
1126 
1127  results.push_back( OSTRINGSTREAM_STR( os ) );
1128  os.str( "" );
1129  }
1130 
1131  for ( i = 0; i < 27; i++ ) // i = 27 members
1132  {
1133  memname = poldbg_itemref_members[i];
1134  os << memname << " " << var.get_member( memname ).get()->impptr()->getStringRep();
1135 
1136  results.push_back( OSTRINGSTREAM_STR( os ) );
1137  os.str( "" );
1138  }
1139  }
1140 
1141  else if ( strrep.find( "MobileRef" ) != std::string::npos )
1142  {
1143  for ( i = 0; i < 14; i++ ) // i = member count for poldbg_base_members
1144  {
1145  memname = poldbg_base_members[i];
1146  os << memname << " " << var.get_member( memname ).get()->impptr()->getStringRep();
1147 
1148  results.push_back( OSTRINGSTREAM_STR( os ) );
1149  os.str( "" );
1150  }
1151 
1152  for ( i = 0; i < 59; i++ ) // i = 59 members
1153  {
1154  memname = poldbg_mobileref_members[i];
1155  os << memname << " " << var.get_member( memname ).get()->impptr()->getStringRep();
1156 
1157  results.push_back( OSTRINGSTREAM_STR( os ) );
1158  os.str( "" );
1159  }
1160  }
1161  return "Value: " + strrep;
1162 }
1163 
1164 std::string DebugContext::cmd_inslist( const std::string& rest, Results& results )
1165 {
1166  unsigned filenum, linenum;
1167  if ( !uoexec_wptr.exists() )
1168  return "No script attached.";
1169  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1170  const EScriptProgram* prog = uoexec->prog();
1171  if ( !prog->debug_loaded )
1172  return "No debug information available.";
1173 
1174  ISTRINGSTREAM is( rest );
1175  if ( !( is >> filenum ) )
1176  return "File # must be specified";
1177  if ( !( is >> linenum ) )
1178  return "Line # must be specified";
1179 
1180  if ( filenum >= prog->dbg_filenames.size() )
1181  return "File # out of range";
1182 
1183  for ( unsigned i = 0; i < prog->dbg_filenum.size(); ++i )
1184  {
1185  if ( prog->dbg_filenum[i] == filenum && prog->dbg_linenum[i] == linenum )
1186  {
1187  results.push_back( Clib::decint( i ) );
1188  }
1189  else
1190  {
1191  if ( !results.empty() )
1192  break;
1193  }
1194  }
1195  return "";
1196 }
1197 std::string DebugContext::cmd_getlocalpacked( const std::string& rest )
1198 {
1199  if ( !uoexec_wptr.exists() )
1200  return "No script attached.";
1201  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1202  // const EScriptProgram* prog = uoexec->prog();
1203 
1204  unsigned varidx = atoi( rest.c_str() );
1205  if ( varidx >= uoexec->Locals2->size() )
1206  return "Error: Index out of range";
1207  return "Value: " + ( *uoexec->Locals2 )[varidx]->impref().pack();
1208 }
1209 std::string DebugContext::cmd_getglobalpacked( const std::string& rest )
1210 {
1211  if ( !uoexec_wptr.exists() )
1212  return "No script attached.";
1213  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1214  // const EScriptProgram* prog = uoexec->prog();
1215 
1216  unsigned varidx = atoi( rest.c_str() );
1217  if ( varidx >= uoexec->Globals2.size() )
1218  return "Error: Index out of range";
1219  return "Value: " + uoexec->Globals2[varidx]->impref().pack();
1220 }
1221 std::string DebugContext::cmd_setlocalpacked( const std::string& rest )
1222 {
1223  if ( !uoexec_wptr.exists() )
1224  return "No script attached.";
1225  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1226  // const EScriptProgram* prog = uoexec->prog();
1227 
1228  ISTRINGSTREAM is( rest );
1229  unsigned varidx;
1230  char space;
1231  if ( !( is >> varidx ) )
1232  return "format: setlocalpacked [varidx] [packedvalue]";
1233 
1234  is.unsetf( std::ios::skipws );
1235  is >> space;
1236  is.setf( std::ios::skipws );
1237 
1238  if ( varidx >= uoexec->Locals2->size() )
1239  return "Error: Index out of range";
1240 
1241  BObjectRef& ref = ( *uoexec->Locals2 )[varidx];
1242  BObject& obj = *ref;
1243  BObjectImp* newimp = BObjectImp::unpack( is );
1244  if ( newimp == nullptr )
1245  return "Error: unable to unpack";
1246 
1247  obj.setimp( newimp );
1248 
1249  return "Value: " + ( *uoexec->Locals2 )[varidx]->impref().pack();
1250 }
1251 std::string DebugContext::cmd_setglobalpacked( const std::string& rest )
1252 {
1253  if ( !uoexec_wptr.exists() )
1254  return "No script attached.";
1255  UOExecutor* uoexec = uoexec_wptr.get_weakptr();
1256  // const EScriptProgram* prog = uoexec->prog();
1257  ISTRINGSTREAM is( rest );
1258  unsigned varidx;
1259  char space;
1260  if ( !( is >> varidx ) )
1261  return "format: setglobalpacked [varidx] [packedvalue]";
1262  is.unsetf( std::ios::skipws );
1263  is >> space;
1264  is.setf( std::ios::skipws );
1265 
1266  if ( varidx >= uoexec->Globals2.size() )
1267  return "Error: Index out of range";
1268 
1269  BObjectRef& ref = uoexec->Globals2[varidx];
1270  BObject& obj = *ref;
1271  BObjectImp* newimp = BObjectImp::unpack( is );
1272  if ( newimp == nullptr )
1273  return "Error: unable to unpack";
1274 
1275  obj.setimp( newimp );
1276 
1277  return "Value: " + uoexec->Globals2[varidx]->impref().pack();
1278 }
1279 
1280 
1282 {
1283 public:
1284  DebugClientThread( Clib::SocketListener& SL ) : Clib::SocketClientThread( SL ) {}
1285  virtual void run() POL_OVERRIDE;
1286 };
1287 
1289 {
1290  if ( Plib::systemstate.config.debug_local_only )
1291  {
1292  if ( !_sck.is_local() )
1293  {
1294  Clib::writeline( _sck, "Only accepting connections from localhost." );
1295  return;
1296  }
1297  }
1298  DebugContext dctx;
1299  std::string cmdline;
1300  std::vector<std::string> results;
1301  while ( !dctx.done() )
1302  {
1303  Clib::writeline( _sck, dctx.prompt() );
1304  if ( !readline( _sck, cmdline ) )
1305  break;
1306 
1307  bool ret = dctx.process( cmdline, results );
1308  if ( ret )
1309  Clib::writeline( _sck, "Results: " + Clib::tostring( results.size() ) );
1310  else
1311  Clib::writeline( _sck, "Failure: " + Clib::tostring( results.size() ) );
1312  for ( unsigned i = 0; i < results.size(); ++i )
1313  {
1314  Clib::writeline( _sck, results[i] );
1315  }
1316  }
1317 }
1318 
1320 {
1321  if ( Plib::systemstate.config.debug_port )
1322  {
1323  Clib::SocketListener SL( Plib::systemstate.config.debug_port );
1324  while ( !Clib::exit_signalled )
1325  {
1326  if ( SL.GetConnection( 5 ) )
1327  {
1329  p->start();
1330  }
1331  }
1332  }
1333 }
1334 }
1335 }
std::string cmd_kill(unsigned pid)
Definition: poldbg.cpp:546
std::string cmd_detach()
Definition: poldbg.cpp:560
unsigned char u8
Definition: rawtypes.h:25
virtual BObjectRef get_member(const char *membername)
Definition: object.cpp:930
std::vector< unsigned > dbg_ins_blocks
Definition: eprog.h:141
unsigned parentvariables
Definition: eprog.h:57
#define POL_OVERRIDE
virtual std::string getStringRep() const =0
const EScriptProgram * prog() const
Definition: executor.h:423
const std::string & value() const
Definition: impstr.h:67
bool in_debugger_holdlist() const
Definition: osmod.cpp:869
std::string get_fileline(EScriptProgram *prog, int filenum, int linenum)
Definition: poldbg.cpp:795
std::string cmd_scriptins(const std::string &rest, Results &results)
Definition: poldbg.cpp:775
void splitnamevalue(const std::string &istr, std::string &propname, std::string &propvalue)
Definition: strutil.cpp:107
std::string cmd_clrallbp()
Definition: poldbg.cpp:953
const char * poldbg_base_members[]
Definition: poldbg.cpp:49
ValueStackCont ValueStack
Definition: executor.h:120
bool config_nodie(const std::string &name, const Plib::Package *pkg, const char *mainpfx)
Definition: scrdef.cpp:84
bool done() const
Definition: poldbg.cpp:151
std::string cmd_stacktrace(Results &results)
Definition: poldbg.cpp:440
ref_ptr< EScriptProgram > _script
Definition: poldbg.cpp:199
std::string cmd_ins(Results &results)
Definition: poldbg.cpp:857
std::string debug_password
Definition: polcfg.h:73
SystemState systemstate
Definition: systemstate.cpp:12
std::string cmd_loadsym(unsigned pid)
Definition: poldbg.cpp:529
BApplicObj< ref_ptr< DebugContext > > DebugContextObjImpBase
Definition: poldbg.cpp:207
Core::PolConfig config
Definition: systemstate.h:43
void seterror(bool err)
Definition: executor.h:437
bool find_uoexec(unsigned int pid, UOExecutor **pp_uoexec)
Definition: scrsched.cpp:60
std::string cmd_attach(unsigned pid)
Definition: poldbg.cpp:511
std::string cmd_inslist(const std::string &rest, Results &results)
Definition: poldbg.cpp:1164
T * get() const
Definition: refptr.h:176
std::string decint(unsigned short v)
Definition: strutil.cpp:64
int match(char *a, char *b)
std::vector< BObjectRef > BObjectRefVec
Definition: exectype.h:21
std::string cmd_getlocalpacked(const std::string &rest)
Definition: poldbg.cpp:1197
std::string cmd_quit()
Definition: poldbg.cpp:574
std::string cmd_setglobalpacked(const std::string &rest)
Definition: poldbg.cpp:1251
boost_utils::script_name_flystring name
Definition: eprog.h:91
std::string cmd_call(const std::string &rest, Results &results)
Definition: poldbg.cpp:602
void debug_listen_thread(void)
Definition: poldbg.cpp:1319
#define OSTRINGSTREAM_STR(x)
Definition: stlutil.h:76
bool process(const std::string &cmd, Results &results)
[1] Debugger Commands: password [pwd] Authorize with password quit exit debugger start [eclfile] Star...
Definition: poldbg.cpp:324
u64 pid
Definition: osmod.cpp:945
std::string cmd_setscript(const std::string &rest, Results &results)
Definition: poldbg.cpp:670
unsigned int pid() const
Definition: osmod.cpp:129
bool isa(BObjectImp::BObjectType type) const
Definition: bobject.h:423
const char * poldbg_itemref_members[]
Definition: poldbg.cpp:53
std::string cmd_break()
Definition: poldbg.cpp:926
virtual std::string pack() const
Definition: object.cpp:201
std::string cmd_funclist(const std::string &rest, Results &results)
Definition: poldbg.cpp:688
std::string cmd_setbp(const std::string &rest)
Definition: poldbg.cpp:937
std::string cmd_localvars(Results &results)
Definition: poldbg.cpp:1047
const std::string & name() const
Definition: scrdef.h:45
std::string dbg_get_instruction(size_t atPC) const
Definition: executor.cpp:2905
std::string cmd_localvar(const std::string &rest)
Definition: poldbg.cpp:1092
void pushArg(BObjectImp *arg)
Definition: executor.cpp:3021
bool exists() const
Definition: scrdef.cpp:126
std::vector< std::string > Results
Definition: poldbg.cpp:149
void setimp(BObjectImp *imp)
Definition: bobject.h:446
BObjectRefVec Globals2
Definition: executor.h:109
std::vector< std::string > globalvarnames
Definition: eprog.h:133
std::vector< ReturnContext > ControlStack
Definition: executor.h:113
Definition: refptr.h:65
std::vector< std::string > dbg_filenames
Definition: eprog.h:136
std::string cmd_globalvars(Results &results)
Definition: poldbg.cpp:1072
std::vector< BObjectRefVec * > upperLocals2
Definition: executor.h:111
std::string cmd_instrace()
Definition: poldbg.cpp:875
void writeline(Socket &sck, const std::string &s)
Definition: sckutil.cpp:58
std::string tostring(const Bscript::BTokenType &v)
Definition: tokens.cpp:19
std::string cmd_files(Results &results)
Definition: poldbg.cpp:983
#define OSTRINGSTREAM
Definition: stlutil.h:75
std::string cmd_srcprof(const std::string &rest, Results &results)
Definition: poldbg.cpp:714
std::string dbg_get_instruction(size_t atPC) const
Definition: eprog2.cpp:502
DebugContextObjImp(ref_ptr< DebugContext > rcdctx)
Definition: poldbg.cpp:218
std::string cmd_filecont(const std::string &rest, Results &results)
Definition: poldbg.cpp:1005
virtual u8 typeOfInt() const POL_OVERRIDE
Definition: poldbg.cpp:226
std::vector< Instruction > instr
Definition: eprog.h:124
static BObjectImp * unpack(const char *pstr)
Definition: object.cpp:120
virtual BObjectImp * copy() const POL_OVERRIDE
Definition: poldbg.cpp:230
std::string cmd_state()
Definition: poldbg.cpp:843
std::string cmd_localvarmembers(const std::string &rest, Results &results)
Definition: poldbg.cpp:1105
weak_ptr_owner< UOExecutor > weakptr
Definition: uoexec.h:62
std::string cmd_scriptlist(const std::string &rest, Results &results)
Definition: poldbg.cpp:657
BObjectImp * impptr()
Definition: bobject.h:428
std::string cmd_stepover()
Definition: poldbg.cpp:901
std::string cmd_scriptprofile(const std::string &rest, Results &results)
Definition: poldbg.cpp:757
std::vector< EPDbgBlock > blocks
Definition: eprog.h:134
unsigned int count() const
Definition: refptr.h:130
std::string cmd_getglobalpacked(const std::string &rest)
Definition: poldbg.cpp:1209
virtual const char * typeOf() const POL_OVERRIDE
Definition: poldbg.cpp:222
BObjectImp * create_debug_context()
Definition: poldbg.cpp:267
ScriptScheduler scriptScheduler
void dbg_setbp(unsigned atPC)
Definition: executor.cpp:3086
std::string cmd_run()
Definition: poldbg.cpp:914
const PidList & getPidlist()
std::string cmd_start(const std::string &rest)
Definition: poldbg.cpp:580
const std::string & scriptname() const
Definition: executor.h:413
#define ISTRINGSTREAM
Definition: stlutil.h:73
std::vector< unsigned > dbg_linenum
Definition: eprog.h:140
std::vector< unsigned > dbg_filenum
Definition: eprog.h:139
const String * getStringParam(unsigned param)
Definition: executor.cpp:347
BApplicObjType debugcontextobjimp_type
Definition: poldbg.cpp:206
std::string strlower(const std::string &str)
Definition: strutil.cpp:276
void dbg_clrbp(unsigned atPC)
Definition: executor.cpp:3090
std::string prompt() const
Definition: poldbg.cpp:287
virtual BObjectRef get_member(const char *membername) POL_OVERRIDE
Definition: poldbg.cpp:259
std::string cmd_funcprof(const std::string &rest, Results &results)
Definition: poldbg.cpp:749
std::string cmd_pidlist(const std::string &rest, Results &results)
Definition: poldbg.cpp:639
std::vector< std::string > localvarnames
Definition: eprog.h:58
std::string name
Definition: osmod.cpp:943
std::string cmd_setlocalpacked(const std::string &rest)
Definition: poldbg.cpp:1221
bool hasParams(unsigned howmany) const
Definition: executor.h:144
weak_ptr< UOExecutor > uoexec_wptr
Definition: poldbg.cpp:198
virtual void run() POL_OVERRIDE
Definition: poldbg.cpp:1288
std::string cmd_stepinto()
Definition: poldbg.cpp:888
std::string cmd_pc()
Definition: poldbg.cpp:850
std::string cmd_clrbp(const std::string &rest)
Definition: poldbg.cpp:945
virtual BObjectImp * call_method(const char *methodname, Executor &ex) POL_OVERRIDE
Definition: poldbg.cpp:234
BObjectRefVec * Locals2
Definition: executor.h:115
bool run(int argc, char **argv)
unsigned int cycles
Definition: eprog.h:41
void start_script(const char *filename, Bscript::BObjectImp *param0, Bscript::BObjectImp *param1)
Definition: scrsched.cpp:150
bool GetConnection(unsigned int timeout_sec)
Definition: socketsvc.cpp:38
bool readline(Socket &sck, std::string &s, bool *timeout_exit, unsigned int timeout_secs, unsigned maxlen)
Definition: sckutil.cpp:17
std::string cmd_scriptsrc(const std::string &rest, Results &results)
Definition: poldbg.cpp:812
Definition: berror.cpp:12
bool halt() const
Definition: executor.h:452
DebugClientThread(Clib::SocketListener &SL)
Definition: poldbg.cpp:1284
BObjectImp * run_executor_to_completion(UOExecutor &ex, const ScriptDef &script)
Definition: scrsched.cpp:367
std::atomic< bool > exit_signalled
Module::OSExecutorModule * os_module
Definition: uoexec.h:37
const char * poldbg_mobileref_members[]
Definition: poldbg.cpp:82
std::string cmd_fileline(const std::string &rest)
Definition: poldbg.cpp:961