Author: gschneider
Date: Sun Oct 12 16:34:05 2008
New Revision: 36735
URL:
http://svn.reactos.org/svn/reactos?rev=36735&view=rev
Log:
RosDbg Part 1/3:
- Add process name and process state to process view
- Separate start communication functions
- Make kdbg command "next" usable
- Misc preparations for named pipe communication
Modified:
trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs
trunk/tools/reactosdbg/DebugProtocol/IDebugProtocol.cs
trunk/tools/reactosdbg/DebugProtocol/KDBG.cs
Modified: trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/DebugProtocol/Deb…
==============================================================================
--- trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs [iso-8859-1] Sun Oct 12
16:34:05 2008
@@ -5,6 +5,7 @@
using
System.Net;
using System.Net.Sockets;
using System.IO.Ports;
+using System.Threading;
using AbstractPipe;
using DebugProtocol;
using KDBGProtocol;
@@ -85,8 +86,12 @@
public bool Current { get { return mCurrent; } set { mCurrent = value; } }
ulong mPid;
public ulong ProcessId { get { return mPid; } set { mPid = value; } }
+ string mState;
+ public string State { get { return mState; } set { mState = value; } }
+ string mName;
+ public string Name { get { return mName; } set { mName = value; } }
public Dictionary<ulong, ThreadElement> Threads = new
Dictionary<ulong,ThreadElement>();
- public ProcessElement(ulong pid, bool current) { mPid = pid; mCurrent = current;
}
+ public ProcessElement(ulong pid, bool current, string state, string name) { mPid
= pid; mCurrent = current; mState = state; mName = name; }
}
public class DebugProcessThreadChangeEventArgs : EventArgs
@@ -165,6 +170,8 @@
#region Named Pipe Members
NamedPipe mNamedPipe;
+ Thread ReadThread;
+ Thread WriteThread;
#endregion
public event DebugRegisterChangeEventHandler DebugRegisterChangeEvent;
@@ -213,7 +220,7 @@
mKdb.ThreadListEvent += ThreadListEvent;
}
- public void Start(string host, int port)
+ public void StartTCP(string host, int port)
{
Close();
mRemotePort = port;
@@ -226,16 +233,31 @@
mDnsAsyncResult = Dns.BeginGetHostEntry(host, mDnsLookup, this);
}
- public void Start(string pipeName)
+ public void StartPipe(string pipeName, ConnectionMode mode)
{
Close();
ConnectionMode = Mode.PipeMode;
mNamedPipe = new NamedPipe();
- mNamedPipe.Create(pipeName);
- mNamedPipe.Listen();
- }
-
- public void Start(int baudrate, string port)
+ if (mNamedPipe.CreatePipe(pipeName, mode))
+ {
+ mKdb = new KDBG(mNamedPipe);
+ mNamedPipe.PipeReceiveEvent += PipeReceiveEvent;
+ mNamedPipe.PipeErrorEvent += MediumError;
+ Running = true;
+ ConnectEventHandlers();
+ /* retrieve input seperate thread */
+ ReadThread = new Thread(mNamedPipe.ReadLoop);
+ ReadThread.Start();
+ WriteThread = new Thread(mNamedPipe.WriteLoop);
+ WriteThread.Start();
+ }
+ else
+ {
+ ConnectionMode = Mode.ClosedMode;
+ }
+ }
+
+ public void StartSerial(string port, int baudrate)
{
Close();
ConnectionMode = Mode.SerialMode;
@@ -248,6 +270,7 @@
//create pipe and kdb instances, connect internal receive pipe
mMedium = new SerialPipe(mSerialPort);
mMedium.PipeReceiveEvent += PipeReceiveEvent;
+ mMedium.PipeErrorEvent += MediumError;
mKdb = new KDBG(mMedium);
ConnectEventHandlers();
Running = true;
@@ -270,7 +293,7 @@
mKdb.GetThreads(mNewCurrentProcess);
}
else
- mAccumulateProcesses[args.Pid] = new ProcessElement(args.Pid,
args.Current);
+ mAccumulateProcesses[args.Pid] = new ProcessElement(args.Pid,
args.Current, args.State, args.Name);
if (args.Current)
mNewCurrentProcess = args.Pid;
@@ -313,9 +336,14 @@
Running = false;
break;
case Mode.PipeMode:
- mNamedPipe.Close();
- mNamedPipe = null;
+ if (mNamedPipe != null)
+ {
+ mNamedPipe.Close();
+ mNamedPipe = null;
+ }
Running = false;
+ ReadThread.Abort();
+ WriteThread.Abort();
break;
}
@@ -405,6 +433,13 @@
Running = false;
}
+ public void Next()
+ {
+ Running = true;
+ if (mKdb != null) mKdb.Next();
+ Running = false;
+ }
+
public void Go()
{
if (mKdb != null)
Modified: trunk/tools/reactosdbg/DebugProtocol/IDebugProtocol.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/DebugProtocol/IDe…
==============================================================================
--- trunk/tools/reactosdbg/DebugProtocol/IDebugProtocol.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/DebugProtocol/IDebugProtocol.cs [iso-8859-1] Sun Oct 12
16:34:05 2008
@@ -74,9 +74,10 @@
{
public readonly bool Reset, Current, End;
public readonly ulong Pid;
+ public readonly string Name, State;
public ProcessListEventArgs() { Reset = true; }
public ProcessListEventArgs(bool end) { End = true; }
- public ProcessListEventArgs(ulong pid, bool current) { Current = current; Pid =
pid; }
+ public ProcessListEventArgs(ulong pid, bool current, string state, string name) {
Current = current; Pid = pid; State = state; Name = name; }
}
public delegate void ProcessListEventHandler(object sender, ProcessListEventArgs
args);
Modified: trunk/tools/reactosdbg/DebugProtocol/KDBG.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/DebugProtocol/KDB…
==============================================================================
--- trunk/tools/reactosdbg/DebugProtocol/KDBG.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/DebugProtocol/KDBG.cs [iso-8859-1] Sun Oct 12 16:34:05 2008
@@ -40,7 +40,7 @@
static Regex mSregLine = new Regex("[CDEFGS]S
0x(?<seg>[0-9a-fA-F]+).*");
static Regex mProcListHeading = new Regex("PID[ \\t]+State[
\\t]+Filename.*");
static Regex mThreadListHeading = new Regex("TID[ \\t]+State[
\\t]+Prio.*");
- static Regex mProcListEntry = new
Regex("^(?<cur>([*]|))0x(?<pid>[0-9a-fA-F]+)[
\\t]+(?<state>.*)");
+ static Regex mProcListEntry = new
Regex("^(?<cur>([*]|))0x(?<pid>[0-9a-fA-F]+)[ \\t](?<state>[a-zA-Z
]+)[ \\t](?<name>[a-zA-Z. ]+).*");
static Regex mThreadListEntry = new
Regex("^(?<cur>([*]|))0x(?<tid>[0-9a-fA-F]+)[
\\t]+(?<state>.*)0x(?<eip>[0-9a-fA-F]*)");
bool mFirstModuleUpdate = false;
@@ -254,10 +254,12 @@
if (pidEntryMatch.Success && mReceivingProcs)
{
if (ProcessListEvent != null)
- ProcessListEvent(this, new
ProcessListEventArgs(ulong.Parse(pidEntryMatch.Groups["pid"].ToString(),
NumberStyles.HexNumber), pidEntryMatch.Groups["cur"].Length > 0));
+ ProcessListEvent(this, new
ProcessListEventArgs(ulong.Parse(pidEntryMatch.Groups["pid"].ToString(),
NumberStyles.HexNumber), pidEntryMatch.Groups["cur"].Length > 0,
+
pidEntryMatch.Groups["state"].ToString(),
pidEntryMatch.Groups["name"].ToString()));
}
else
{
+ /* TODO: this is called by far too often, results in
several "thread list xx" commands */
if ((mReceivingProcs || cleanedLine.Contains("No
processes")) && ProcessListEvent != null)
ProcessListEvent(this, new
ProcessListEventArgs(true));
}
@@ -350,7 +352,8 @@
if (mCommandBuffer.Count == 1)
{
mConnection.Write(command + "\r");
- mCommandBuffer.RemoveAt(0); //useful???
+ /* remove the command after sending */
+ mCommandBuffer.RemoveAt(0);
}
}
}