skipcheck

TM1 client · Docs · Processes and chores

ProcessDebugService

using Skipcheck.Tm1.Client.Services;

Process debugging: a run of a process that stops at breakpoints and steps line by line, held on the server as a ProcessDebugContext until deleted.

DebugAsync starts one, paused before the first line; ResumeAsync runs to the next breakpoint (or the end), and the step… methods move a line at a time. Each returns the context as it then is. TM1 (11.8) answers a start, a resume or a step without waiting for the run to stop again, so the status is RUNNING or PAUSED depending on which came first; GetAsync reads it again. A step past a procedure's last line either pauses with an empty call stack or completes the run.

TM1 (11.8) refuses to delete a debug context: a run ends by running to completion, which FinishAsync does, and DebuggingAsync does when its work is done. A finished context stays readable until the session ends. ProcessDebugContexts lists none, though each reads by ID.

Stop at a breakpoint and see where the run is, with DebuggingAsync finishing the run afterwards:

// Where the run stops at a breakpoint on line 3 of the prolog. DebuggingAsync
// runs it to the end afterwards.
var debug = tm1.ProcessDebugging;
return debug.DebuggingAsync("Load Sales", new Dictionary<string, object?> { ["pVersion"] = "Forecast" }, context => Stack(context.Id!));

async IAsyncEnumerable<string> Stack(string id)
{
    var line3 = ProcessDebugContextLineBreakpointPatch
        .Builder()
        .Id(1) // TM1 needs an ID chosen by the caller
        .ProcessName("Load Sales")
        .Procedure(ProcessProcedure.Prolog)
        .LineNumber(3)
        .Enabled(true)
        .Build();
    await debug.AddBreakpointAsync(id, line3);
    await debug.ResumeAsync(id);
    await foreach (var frame in debug.CallStackAsync(id))
    {
        yield return $"{frame.Procedure}, line {frame.LineNumber}";
    }
}

Step through a run started with DebugAsync, and finish it:

// Without DebuggingAsync, end the run with FinishAsync: TM1 can't delete it
var debug = tm1.ProcessDebugging;
var context = await debug.DebugAsync("Load Sales");
await debug.StepOverAsync(context.Id!);
await debug.StepOverAsync(context.Id!);
return await debug.FinishAsync(context.Id!);

Members

ProcessDebugService constructorA service that sends its requests through session.
DebugAsyncStarts debugging a process, paused before its first line.
DebuggingAsyncDebugs a process for the length of work.
DebuggingAsyncDebugs a process for the length of work, as the streaming overload, for work with a single result.
ListAsyncGET ProcessDebugContexts, streamed.
GetAsyncGET ProcessDebugContexts('id').
FinishAsyncEnds a run.
ResumeAsyncRuns to the next breakpoint, or the end.
StepInAsyncOne line, into an ExecuteProcess.
StepOutAsyncRuns out of the current process, back to its caller.
StepOverAsyncOne line, over an ExecuteProcess.
BreakpointsAsyncGET ProcessDebugContexts('id')/Breakpoints, streamed.
AddBreakpointAsyncAdds a breakpoint (a line, data or object breakpoint, by its patch's type).
UpdateBreakpointAsyncChanges a breakpoint, such as switching it off.
RemoveBreakpointAsyncDELETE ProcessDebugContexts('id')/Breakpoints(n).
CurrentBreakpointAsyncThe breakpoint the run is paused at.
CallStackAsyncWhere the run is, innermost first, streamed.
VariablesAsyncA frame's variables, streamed.
FrameProcessAsyncThe process a frame runs.
ProcessAsyncThe process being debugged.
ThreadAsyncThe thread running the process.

ProcessDebugService

constructor
ProcessDebugService(Tm1Session session)

A service that sends its requests through session.

DebugAsync

Task<ProcessDebugContext> DebugAsync( string process, IReadOnlyDictionary<string, object?>? parameters = null, ODataQuery? query = null, CancellationToken cancellationToken = default )

tm1.Debug: starts debugging a process, paused before its first line. parameters are its parameters, by name, in order; may be empty.

TM1 REST Action Process/Debug

DebuggingAsync

IAsyncEnumerable<TResult> DebuggingAsync<TResult>( string process, IReadOnlyDictionary<string, object?>? parameters, Func<ProcessDebugContext, IAsyncEnumerable<TResult>> work, [EnumeratorCancellation] CancellationToken cancellationToken = default )

Debugs a process for the length of work: starts the run, streams what the work yields, and finishes the run afterwards, when the work completes, fails or is cancelled.

TM1 REST Action Process/Debug EntitySet ProcessDebugContexts

DebuggingAsync

Task<TResult> DebuggingAsync<TResult>( string process, IReadOnlyDictionary<string, object?>? parameters, Func<ProcessDebugContext, Task<TResult>> work, CancellationToken cancellationToken = default )

Debugs a process for the length of work, as the streaming overload, for work with a single result.

TM1 REST Action Process/Debug EntitySet ProcessDebugContexts

ListAsync

IAsyncEnumerable<ProcessDebugContext> ListAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts, streamed. TM1 (11.8) lists none, though each reads by ID.

TM1 REST EntitySet ProcessDebugContexts

GetAsync

Task<ProcessDebugContext> GetAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts('id').

TM1 REST EntitySet ProcessDebugContexts

FinishAsync

Task<ProcessDebugContext> FinishAsync(string id, CancellationToken cancellationToken = default)

Ends a run: removes its breakpoints (those with an ID of 0 or more; TM1 stores one without as -1, which can't be removed) and resumes until it's complete, up to 100 times. Returns the context as it last was.

TM1 REST Action ProcessDebugContext/Continue Navigation ProcessDebugContext/Breakpoints

ResumeAsync

Task<ProcessDebugContext> ResumeAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

tm1.Continue: runs to the next breakpoint, or the end.

TM1 REST Action ProcessDebugContext/Continue

StepInAsync

Task<ProcessDebugContext> StepInAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

tm1.StepIn: one line, into an ExecuteProcess.

TM1 REST Action ProcessDebugContext/StepIn

StepOutAsync

Task<ProcessDebugContext> StepOutAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

tm1.StepOut: runs out of the current process, back to its caller.

TM1 REST Action ProcessDebugContext/StepOut

StepOverAsync

Task<ProcessDebugContext> StepOverAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

tm1.StepOver: one line, over an ExecuteProcess.

TM1 REST Action ProcessDebugContext/StepOver

BreakpointsAsync

IAsyncEnumerable<ProcessDebugContextBreakpoint> BreakpointsAsync( string id, ODataQuery? query = null, CancellationToken cancellationToken = default )

GET ProcessDebugContexts('id')/Breakpoints, streamed.

TM1 REST Navigation ProcessDebugContext/Breakpoints

AddBreakpointAsync

Task<ProcessDebugContextBreakpoint> AddBreakpointAsync( string id, ProcessDebugContextBreakpointPatch breakpoint, CancellationToken cancellationToken = default )

POST ProcessDebugContexts('id')/Breakpoints: adds a breakpoint (a line, data or object breakpoint, by its patch's type). It needs an ID of 0 or more: TM1 stores one without as -1, which can't be changed or removed, so one without is refused here with an ArgumentException.

TM1 REST Navigation ProcessDebugContext/Breakpoints

UpdateBreakpointAsync

Task UpdateBreakpointAsync(string id, int breakpoint, ProcessDebugContextBreakpointPatch patch, CancellationToken cancellationToken = default)

PATCH ProcessDebugContexts('id')/Breakpoints(n): changes a breakpoint, such as switching it off.

TM1 REST Navigation ProcessDebugContext/Breakpoints

RemoveBreakpointAsync

Task RemoveBreakpointAsync(string id, int breakpoint, CancellationToken cancellationToken = default)

DELETE ProcessDebugContexts('id')/Breakpoints(n).

TM1 REST Navigation ProcessDebugContext/Breakpoints

CurrentBreakpointAsync

Task<ProcessDebugContextBreakpoint> CurrentBreakpointAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts('id')/CurrentBreakpoint: the breakpoint the run is paused at.

TM1 REST Navigation ProcessDebugContext/CurrentBreakpoint

CallStackAsync

IAsyncEnumerable<ProcessDebugContextStackFrame> CallStackAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts('id')/CallStack: where the run is, innermost first, streamed.

TM1 REST Navigation ProcessDebugContext/CallStack

VariablesAsync

IAsyncEnumerable<ProcessDebugContextVariable> VariablesAsync( string id, string frame, ODataQuery? query = null, CancellationToken cancellationToken = default )

GET ProcessDebugContexts('id')/CallStack('frame')/Variables: a frame's variables, streamed.

TM1 REST Navigation ProcessDebugContextStackFrame/Variables

FrameProcessAsync

Task<Process> FrameProcessAsync(string id, string frame, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts('id')/CallStack('frame')/Process: the process a frame runs.

TM1 REST Navigation ProcessDebugContextStackFrame/Process

ProcessAsync

Task<Process> ProcessAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts('id')/Process: the process being debugged.

TM1 REST Navigation ProcessDebugContext/Process

ThreadAsync

Task<Tm1Thread> ThreadAsync(string id, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ProcessDebugContexts('id')/Thread: the thread running the process.

TM1 REST Navigation ProcessDebugContext/Thread