fdbPlugin0.4.5.0公開(flexSDK3.03とFlashDevelop-3.0.0-Beta9で動作確認)

変更点は以下

ダウンロードは以下から
http://orange.zero.jp/zbn39616.pine/download/download.html

スクリーンショット
デバッグ中の画面
ブレークポイントの情報を表示するパネル
スタックフレームを表示するパネル
quick watch

fdbPlugin0.3.5.0公開

0.2.4.0からの変更点は以下。 ダウンロードはここから。

  • ソースをSVNベースに変更
  • メニューの「Clear BreakPoints」に対応
  • PreLoadに対応
  • ActionScriptベースAIRデバッグに対応
  • ブレークポイント設定に関するバグを修正
  • 例外ダイアログ前面表示で使用するダイアログの検索方法を変更
  • デバッグのためにログをファイルとして保存する機能を追加
問題ないようだったら変更、修正をSVNに適用する予定。 TODOメモ

Configlib(設定ダイアログ作成補助ライブラリ)

設定ダイアログはPropertyGridを使用すると簡単に作成できるが変更のキャンセルができない。 (FlashDevelopの設定もキャンセルがない) 猫歩きさんの解説にあるようにキャンセルのためにはクローンを作成したり色々と面倒なので猫歩きさんの解説Kuonのソースを参考にしてライブラリを作成した。 たぶんメモリリークなどがたくさんあると思う。 ダウンロードはここから。 MTIライセンスでソース公開。 下のような設定ダイアログが使用できる。 以下サンプル

TextBoxを貼り付けたフォーム

using System;
using System.Windows.Forms;
using System.IO;

namespace demo
{
    public partial class Form1 : Form
    {
        private Setting setting;
        public Form1()
        {
            InitializeComponent();
            this.Load += new EventHandler(Form1_Load);
            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
        }

        void Form1_Load(object sender, EventArgs e)
        {
            if (File.Exists("setting.xml"))
            {
                setting = Configlib.Util.SerializeXML<Setting>.Load("setting.xml");
                textBox1.BackColor = setting.backcolor;
                textBox1.ForeColor = setting.forecolor;
                textBox1.Font = setting.font;
                textBox1.WordWrap = setting.Wrap;
                setting.StringList.ForEach(delegate(string s)
                {
                    textBox1.Text += s+ Environment.NewLine;
                });             
                this.Location = setting.point;
                this.Size = setting.size;
            }
            else
            {
                setting = new Setting();
                setting.font = new System.Drawing.Font("MS Pゴシック", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
             }

            //設定ダイアログで変更が決定された場合に発生するイベント
            setting.AppliedEvent += new Configlib.ConfigEventHandler(setting_AppliedEvent);
        }

        void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            setting.point = this.Location;
            setting.size = this.Size;
            Configlib.Util.SerializeXML<Setting>.Save("setting.xml", setting);
        }

        //設定ダイアログで変更が決定された場合に発生するイベント
        //configが変更されたインスタンス
        void setting_AppliedEvent(object sender, object config)
        {
            setting.Dispose();
            setting = (Setting)config;

            textBox1.BackColor = setting.backcolor;
            textBox1.ForeColor = setting.forecolor;
            textBox1.Font = setting.font;
            textBox1.WordWrap = setting.Wrap;
            setting.StringList.ForEach(delegate(string s)
            {
                textBox1.Text += s + Environment.NewLine;
            });
        }

        private void configToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //設定ダイアログ表示
            Configlib.ConfigForm.Show(setting);
        }
    }
}

設定クラスのソース

using System;
using System.Collections.Generic;
using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;
using Configlib.Controls;

namespace demo
{
    //ConfigObjectを継承する
    public class Setting : Configlib.ConfigObject, IDisposable
    {
        private Color _foreColor;
        [XmlIgnore]
        public Color forecolor
        {
            get { return _foreColor; }
            set { _foreColor = value; }
        }

        //シリアライズのために追加
        [Browsable(false)]
        public string ForeColorText
        {
            get { return ColorTranslator.ToHtml(this._foreColor); }
            set { this._foreColor = ColorTranslator.FromHtml(value); }
        }

        private Color _backColor;
        [XmlIgnore]
        public Color backcolor
        {
            get { return _backColor; }
            set { _backColor = value; }
        }

        //シリアライズのために追加
        [Browsable(false)]
        public string BackColorText
        {
            get { return ColorTranslator.ToHtml(this._backColor); }
            set { this._backColor = ColorTranslator.FromHtml(value); }
        }

        private Font _font;
        [XmlIgnore]
        public Font font
        {
            get { return _font; }
            set { _font = value; }
        }

        //シリアライズのために追加
        [Browsable(false)]
        public string TextFont
        {
            get 
            {
                FontConverter fc = new FontConverter();
                return fc.ConvertToString(_font);
            }
            set 
            {
                FontConverter fc = new FontConverter();
                this._font = fc.ConvertFromString(value) as Font;
            }
        }

        private Size _size;
        [Browsable(false)]
        public Size size
        {
            get { return _size; }
            set { _size = value; }
        }

        private Point _pos;
        [Browsable(false)]
        public Point point
        {
            get { return _pos; }
            set { _pos = value; }
        }

        private bool _wrap;
        public bool Wrap
        {
            get { return _wrap; }
            set { _wrap = value; }
        }

        //Listの変更通知を受け取るため属性を追加
        private List<string> _stringList = new List<string>();
        [Editor(typeof(CustomCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
        public List<string> StringList
        {
            get { return this._stringList; }
            set { this._stringList = value; }
        }

        public override string name
        {
            get { return "demo"; }
        }

        #region IDisposable メンバ

        public void Dispose()
        {
            if (_font != null)
            {
                _font.Dispose();
                _font = null;
            }
        }

        #endregion
    }
}

FdbPlugin PreLoader対応のバグ

PreLoaderでブレークポイント設定せずにデバッグを開始するとプレイヤーを閉じてもfdbが終了しないと報告が来た。

これのパッチを送った。ついでにPause時のメニュー、ツールバーの状態の修正も含めた。
次はActionScriptベースAIRへの対応を行う。

FdbPlugin PreLoader対応のバグ

PreLoaderでブレークポイント設定せずにデバッグを開始するとプレイヤーを閉じてもfdbが終了しないと報告が来た。
原因はデバッグ開始時にブレークポイントがないのにブレークポイント設定コマンドを入力していたこと。そのため、終了判定が変になっていた様子。
現在、ActionScriptベースAIRデバッグ対応修正をしているがこのバグ修正パッチを先に送る予定。

FdbPlugin改良点

FdbPluginの改良点として以下の項目がある。

  1. addEventListener(Event.ENTER_FRAME, progress)で止まってしまうPreLoaderに対応する
  2. AIRデバッグをサポートする
  3. FlashPlayerが閉じられてもそれを感知できないことがたまにある

1はメールに現象が再現できるプロジェクトが添付されていた。デバッガを走らせると

Additional ActionScript code has been loaded from a SWF or a frame.
To see all currently loaded files, type 'info files'.
Set additional breakpoints as desired, and then type 'continue'.

とメッセージが出て入力状態になりデバッグが続けられなくなる。解決方法は単にcontinueでデバッグを続けるだけ。

2はActionScriptベースのAIRならデバッグ可能なのでサポートする予定。AIRの場合のデバッグの手順は以下のようになっている。

  1. AIRのプロジェクトをデバッグモードでコンパイル
  2. 引数なしでfdb起動
  3. runコマンド入力して接続待ち
  4. adlでAIR起動
  5. fdb接続完了
  6. デバッグ開始

3はタイマーでプロセスを監視しては?とあるので試してみる。