home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / emxtutor.zip / emxsrcd1.zip / emx / src / pmgdb / breakpoi.h < prev    next >
C/C++ Source or Header  |  1996-09-07  |  5KB  |  196 lines

  1. /* breakpoi.h -*- C++ -*-
  2.    Copyright (c) 1996 Eberhard Mattes
  3.  
  4. This file is part of pmgdb.
  5.  
  6. pmgdb is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. pmgdb is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with pmgdb; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. class command_window;
  23. class gdbio;
  24. class capture;
  25. class breakpoint_list;
  26. class breakpoints_window;
  27.  
  28. class breakpoint
  29. {
  30. public:
  31.  
  32.   enum bpt
  33.   {
  34.     BPT_BREAKPOINT,
  35.     BPT_HW_BREAKPOINT,
  36.     BPT_UNTIL,
  37.     BPT_FINISH,
  38.     BPT_WATCHPOINT,
  39.     BPT_HW_WATCHPOINT,
  40.     BPT_READ_WATCHPOINT,
  41.     BPT_ACC_WATCHPOINT,
  42.     BPT_LONGJMP,
  43.     BPT_LONGJMP_RESUME,
  44.     BPT_STEP_RESUME,
  45.     BPT_SIGTRAMP,
  46.     BPT_WATCHPOINT_SCOPE,
  47.     BPT_CALL_DUMMY,
  48.     BPT_SHLIB_EVENTS,
  49.     BPT_UNKNOWN
  50.   };
  51.  
  52.   enum bpd
  53.   {
  54.     BPD_DEL,
  55.     BPD_DIS,
  56.     BPD_KEEP,
  57.     BPD_UNKNOWN
  58.   };
  59.  
  60.   // Constructors and destructors
  61.   breakpoint ();
  62.   breakpoint (const breakpoint &bp);
  63.   ~breakpoint ();
  64.  
  65.   // Assignment
  66.   breakpoint &operator = (const breakpoint &src);
  67.  
  68.   // Setting members
  69.   void set_number (int v) { number = v; }
  70.   void set_enable (bool v) { enable = v; }
  71.   void set_address (ULONG v) { address = v; }
  72.   void set_source (const char *s, int len) { source.set (s, len); }
  73.   void set_lineno (int v) { lineno = v; }
  74.   void set_ignore (int v) { ignore = v; }
  75.   void set_disposition (const char *s);
  76.   void set_condition (const char *s) { condition.set (s); }
  77.   void copy (const breakpoint &src);
  78.  
  79.   // Querying members
  80.   int get_number ()         const { return number; }
  81.   bpt get_type ()           const { return type; }
  82.   bpd get_disposition ()    const { return disposition; }
  83.   bool get_enable ()        const { return enable; }
  84.   ULONG get_address ()      const { return address; }
  85.   const char *get_source () const { return source; }
  86.   int get_lineno ()         const { return lineno; }
  87.   int get_ignore ()         const { return ignore; }
  88.   const char *get_condition () const { return condition; }
  89.   const char *get_disposition_as_string () const;
  90.  
  91.   bool operator == (const breakpoint b) const;
  92.   bool operator != (const breakpoint b) const { return !operator== (b); }
  93.  
  94.   bool set_from_capture (const capture &capt);
  95.  
  96.   // Dialog box
  97.   MRESULT breakpoint_msg (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  98.  
  99. private:
  100.   int number;
  101.   bpt type;
  102.   bpd disposition;
  103.   bool enable;
  104.   ULONG address;
  105.   // TODO: Use numbers for identifying source files
  106.   fstring source;
  107.   int lineno;
  108.   fstring condition;
  109.   int ignore;
  110.   // *** Update copy() when adding members!
  111.   // *** Update eq_brkpt() when adding members!
  112.  
  113.   // Friends
  114.   friend breakpoint_list;
  115.   friend breakpoints_window;
  116. };
  117.  
  118. class breakpoint_list
  119. {
  120. public:
  121.  
  122.   typedef void (command_window::*update_fun)(int index,
  123.                                              const breakpoint *old_bpt,
  124.                                              const breakpoint *new_bpt);
  125.  
  126.   // Constructors and destructors
  127.   breakpoint_list ();
  128.   ~breakpoint_list ();
  129.  
  130.   void steal (breakpoint_list &from);
  131.   void add (const breakpoint &bp);
  132.   void delete_all ();
  133.   void update (const breakpoint_list &old, command_window *cmd,
  134.                update_fun fun);
  135.   const breakpoint *find (ULONG addr) const;
  136.   const breakpoint *find (const char *fname, int lineno) const;
  137.   const breakpoint *get (int n) const;
  138.   bool any_enabled () const;
  139.  
  140. private:
  141.  
  142.   class brkpt_node : public breakpoint
  143.   {
  144.   public:
  145.     brkpt_node (const breakpoint &bp) : breakpoint (bp) { next = NULL; }
  146.     ~brkpt_node () {}
  147.     class brkpt_node *next;
  148.   };
  149.  
  150.   brkpt_node *list, **end;
  151.  
  152.   // Friends
  153.   friend command_window;
  154. };
  155.  
  156.  
  157. // Breakpoint list
  158. class breakpoints_window : public pmtxt
  159. {
  160. public:
  161.  
  162.   typedef pmtxt parent;
  163.  
  164.   breakpoints_window (command_window *cmd, gdbio *gdb, unsigned id,
  165.                       const char *fontnamesize);
  166.   ~breakpoints_window ();
  167.  
  168.   void add_all ();
  169.   void update (int index, const breakpoint *old_bpt,
  170.                const breakpoint *new_bpt);
  171.   void add_line (const char *default_source = NULL, int line_no = -1);
  172.  
  173. private:
  174.   // Override member functions of pmframe
  175.   MRESULT wm_activate (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  176.   MRESULT wm_close (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  177.   MRESULT wm_command (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  178.   void button_event (int line, int column, int tab, int button, int clicks);
  179.  
  180.   // Painting
  181.   void put_bpt (int line, const breakpoint &bpt);
  182.   void select_line (int line, bool toggle = false);
  183.  
  184.   void show_source (int line);
  185.   bool dialog (breakpoint *bpt);
  186.   void send_disposition (int number, breakpoint::bpd disposition, bool enable);
  187.  
  188.   command_window *cmd;
  189.   gdbio *gdb;
  190.   pmtxt_attr sel_attr;          // Attribute used for hilighting selection
  191.   int sel_line;
  192.  
  193.   // Expected new breakpoint
  194.   int exp_number;
  195. };
  196.