Home » Eclipse Projects » Eclipse Titan » Debugging using Titan Debugger(Debugging ttcn3/compiled C++ files using Titan debugger)
|
Re: Debugging using Titan Debugger [message #1830000 is a reply to message #1829998] |
Wed, 15 July 2020 14:04 |
|
Hi Mujeeb,
you should not need to use the gdb; in majority of cases, the generated log (and possibly added log statements) will supply the user sufficient information
to continue. The log granularity can be controlled from the configuration file.
If you feel you need more, please check the built-in TTCN-3 debugger (see reference guide), that permits the user to add breakpoints,
print variables etc. (the usual debugger stuff) controlled both interactively and from a batch file. Examples are supplied in the reference guide.
Needless to say, debugger is command-line only.
We'd appreciate your feedback regarding the TTCN-3 debugger .
Best regards
Elemer
|
|
| |
Re: Debugging using Titan Debugger [message #1830069 is a reply to message #1830057] |
Thu, 16 July 2020 15:56 |
|
Hi Mujeeb,
as you might already know, a Titan executable can run in single mode (on one component only , that component being the MTC) , or in parallel mode (MTC plus a number of PTCs-parallel test components).
I will expand the example on the single mode execution that is offered in the referenceguide; this will be followed by an example for parallel execution, but that will take me some time.
So let's consider the piece of code in the example:
module demo {
type component CT {
// component variables
const integer ct_int := 4;
var charstring ct_str := "abc";
}
type record Rec {
integer num,
charstring str
}
type record of integer IntList;
// global variable
template integer t_int := (1..10);
function f_fact(in integer n) return integer {
if (n == 0 or n == 1) {
return 1; // line 21
}
return n * f_fact(n - 1);
}
testcase tc_demo() runs on CT {
// local variables
var Rec v_rec := { num := ct_int, str := ct_str };
var template IntList vt_list := { [0] := 1, [2] := * };
if (match(f_fact(v_rec.num), t_int)) {
v_rec.str := v_rec.str & "!";
}
else {
v_rec.str := v_rec.str & "?";
}
var IntList v_list := { 1, 2, 9 };
if (match(v_list, vt_list)) { // dynamic test case error, line 40
action("matched");
}
}
} // end of module
and generate a makefile to it:
makefilegen -sgn demo.ttcn
and also let's add a simple configuration file cfg.cfg as below:
After compiled with make a single mode executable demo will result.
If we run it with no parameters, it will tell us a bit more about itself:
./demo
TTCN-3 Test Executor (single mode), version CRL 113 200/7 R1B
usage: ./demo [-h] [-b file] configuration_file
or ./demo -l
or ./demo -p
or ./demo -v
OPTIONS:
-b file: run specified batch file at start (debugger must be activated)
-h: automatically halt execution at start (debugger must be activated)
-l: list startable test cases and control parts
-p: list module parameters
-v: show version and module information
namely that there are two options related to the debugger: -b and -h.
Option -h will let us run the executable interactively:
[/home/ethlel/Debug] -> ./demo -h cfg.cfg
TTCN-3 Test Executor (single mode), version CRL 113 200/7 R1B
Using configuration file: `cfg.cfg'
Test execution halted.
DEBUG> debug on
Debugger switched on.
DEBUG> dsetbp demo 21
Breakpoint added in module 'demo' at line 21 with no batch file.
DEBUG> dcont
Test execution resumed.
Test case tc_demo started.
User breakpoint reached at line 21 in module 'demo'.
Test execution halted.
DEBUG> dprintstack
1. [function] f_fact([in] n := 1)*
2. [function] f_fact([in] n := 2)
3. [function] f_fact([in] n := 3)
4. [function] f_fact([in] n := 4)
5. [testcase] tc_demo()
DEBUG> dlistvar all
n t_int
DEBUG> dstacklevel 5
Stack level set to:
5. [testcase] tc_demo()
DEBUG> dlistvar comp
ct_int ct_str
DEBUG> dprintvar ct_int
[integer] ct_int := 4
DEBUG> dlistvar local
v_rec vt_list
DEBUG> dprintvar $
[Rec] v_rec := { num := 4, str := "abc" }
[IntList template] vt_list := { 1, <uninitialized template>, * }
DEBUG> dcont
Test execution resumed.
demo.ttcn:40: Dynamic test case error: Matching with an uninitialized/unsupported integer template.
Test case tc_demo finished. Verdict: error
Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 1 error (100.00 %).
Test execution summary: 1 test case was executed. Overall verdict: error
Please go through the above step by step; briefly this is what happens:
debug mode is switched on
a breakpoint is set on line 21
execution is continued until the breakpoint
some information is printed using commands
execution is continued until the end
Besides the interactive execution, debugging can also be controlled by batch files.
Let's create the below three batch files:
start1.bat:
debug on
dautobp error on error.bat
dsetbp demo 21 bp21.bat
(this switches the debug on; sets a breakpoint at line 21 at which bp21.bat will also be executed;in case of error error.bat will be executed)
bp21.bat:
dprintstack
dlistvar all
dstacklevel 5
dlistvar comp
dprintvar ct_int
dlistvar local
dprintvar $
dcont
(prints stuff, then continues execution)
error.bat:
dprintcalls
dlistvar local v_*
dprintvar $
dcont
(prints some other stuff , then continues execution)
these batch files have to reside in the same directory as ./demo and cfg.cfg.
Note:please mind that there is a typo in error.bat in the documentation:
in errror.bat dprintss has to be replaced with dprintcalls.
If demo is executed with the batch file start1.bat (and implicitly the referred error.bat and bp21.bat), the following happens:
./demo -b start1.bat cfg.cfg
TTCN-3 Test Executor (single mode), version CRL 113 200/7 R1B
Using configuration file: `cfg.cfg'
Test execution halted.
Executing batch file 'start1.bat'.
debug on
Debugger switched on.
dautobp error on error.bat
Automatic breakpoint at error verdict switched on with batch file 'error.bat'.
dsetbp demo 21 bp21.bat
Breakpoint added in module 'demo' at line 21 with batch file 'bp21.bat'.
Test execution resumed.
Test case tc_demo started.
User breakpoint reached at line 21 in module 'demo'.
Test execution halted.
Executing batch file 'bp21.bat'.
dprintstack
1. [function] f_fact([in] n := 1)*
2. [function] f_fact([in] n := 2)
3. [function] f_fact([in] n := 3)
4. [function] f_fact([in] n := 4)
5. [testcase] tc_demo()
dlistvar all
n t_int
dstacklevel 5
Stack level set to:
5. [testcase] tc_demo()
dlistvar comp
ct_int ct_str
dprintvar ct_int
[integer] ct_int := 4
dlistvar local
v_rec vt_list
dprintvar $
[Rec] v_rec := { num := 4, str := "abc" }
[IntList template] vt_list := { 1, <uninitialized template>, * }
dcont
Test execution resumed.
demo.ttcn:40: Dynamic test case error: Matching with an uninitialized/unsupported integer template.
Automatic breakpoint (error verdict) reached at line 40 in module 'demo'.
Test execution halted.
Executing batch file 'error.bat'.
dprintcalls
17:19:06.380067 [testcase] started tc_demo()
17:19:06.380458 [function] started f_fact([in] n := 4)
17:19:06.380482 [function] started f_fact([in] n := 3)
17:19:06.380492 [function] started f_fact([in] n := 2)
17:19:06.380502 [function] started f_fact([in] n := 1)
17:19:06.382685 [function] finished f_fact([in] n := -) returned 1
17:19:06.382697 [function] finished f_fact([in] n := -) returned 2
17:19:06.382707 [function] finished f_fact([in] n := -) returned 6
17:19:06.382718 [function] finished f_fact([in] n := -) returned 24
dlistvar local v_*
v_rec v_list
dprintvar $
[Rec] v_rec := { num := 4, str := "abc?" }
[IntList] v_list := { 1, 2, 9 }
dcont
Test execution resumed.
Test case tc_demo finished. Verdict: error
Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 1 error (100.00 %).
Test execution summary: 1 test case was executed. Overall verdict: error
Basically the same thing as we did at the interactive execution, but this was controlled by batch files containing similar commands as in the interactive case.
So this should answer your first question and also the second , as interactive execution can be started with executable_name -h config_file.
As for your third question, no, currently there is no graphical support for the debugger, it is command line only.
As soon as I will assemble an example for parallel execution , I will continue.
In parallel mode the user communicates directly with the main controller;there
are special commands to manage parallel execution, e.g. address different components etc.
I hope this helps
Best regards
Elemer
|
|
| |
Re: Debugging using Titan Debugger [message #1830096 is a reply to message #1830074] |
Fri, 17 July 2020 09:09 |
|
Hi Mujeeb,
I'll continue now with the same example but compiled in parallel mode. Please notice that , although this is not a real parallel mode as there is only one component,
namely the MTC, the command interface changes as we are talking directly to the main controller.( In single mode, debug commands have been received and acted upon by the executable).
So first , we need to compile in parallel mode:
makefilegen -gn demo.ttcn
make
The configuration file cfg.cfg is slightly changed to set a TCP port used for internal communication:
[EXECUTE]
demo.tc_demo
[MAIN_CONTROLLER]
TCPPort := 9034
First I will demonstrate the interactive usage in parallel mode.
Lets start the main controller in a console window:
mctr_cli cfg.cfg
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: CRL 113 200/7 R1B *
* Copyright (c) 2000-2020 Ericsson Telecom AB *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v2.0 *
* which accompanies this distribution, and is available at *
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
*************************************************************************
Using configuration file: cfg.cfg
MC@esekilxxen1844: Unix server socket created successfully.
MC@esekilxxen1844: Listening on TCP port 9034.
In a separate console, let's start the executable:
./demo localhost 9034
TTCN-3 Host Controller (parallel mode), version CRL 113 200/7 R1B
The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
Let's return now to the first console:
MC2> MC@esekilxxen1844: New HC connected from 127.0.0.1 [127.0.0.1]. esekilxxen1844: Linux 3.0.101-108.74-xen on x86_64.
MC2>
MC2> cmtc
MC@esekilxxen1844: Downloading configuration file to all HCs.
HC@esekilxxen1844: Warning: The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
MC@esekilxxen1844: Configuration file was processed on all HCs.
MC@esekilxxen1844: Creating MTC on host 127.0.0.1.
MC@esekilxxen1844: MTC is created.
MC2> debug on
MC2> MTC@esekilxxen1844: Debugger switched on.
MC2> dsetbp demo 21
MC2> MTC@esekilxxen1844: Breakpoint added in module 'demo' at line 21 with no batch file.
MC2>
MC2> smtc
Executing all items of [EXECUTE] section.
MC2> MTC@esekilxxen1844: Test case tc_demo started.
MTC@esekilxxen1844: User breakpoint reached at line 21 in module 'demo'.
MTC@esekilxxen1844: Test execution halted.
MC2> dprintstack
MC2> MTC@esekilxxen1844:
1. [function] f_fact([in] n := 1)*
2. [function] f_fact([in] n := 2)
3. [function] f_fact([in] n := 3)
4. [function] f_fact([in] n := 4)
5. [testcase] tc_demo()
MC2> dlistvar all
MC2> MTC@esekilxxen1844:
n t_int
MC2> dstacklevel 5
MC2> MTC@esekilxxen1844: Stack level set to:
5. [testcase] tc_demo()
MC2> dlistvar comp
MC2> MTC@esekilxxen1844:
ct_int ct_str
MC2> dprintvar ct_int
MC2> MTC@esekilxxen1844:
[integer] ct_int := 4
MC2> dlistvar local
MC2> MTC@esekilxxen1844:
v_rec vt_list
MC2> dprintvar $
MC2> MTC@esekilxxen1844:
[Rec] v_rec := { num := 4, str := "abc" }
[IntList template] vt_list := { 1, <uninitialized template>, * }
MC2> dcont
MC2> MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: demo.ttcn:40: Dynamic test case error: Matching with an uninitialized/unsupported integer template.
MTC@esekilxxen1844: Test case tc_demo finished. Verdict: error
MC@esekilxxen1844: Test execution finished.
Execution of [EXECUTE] section finished.
MC2> exit
MC@esekilxxen1844: Terminating MTC.
MTC@esekilxxen1844: Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 1 error (100.00 %).
MTC@esekilxxen1844: Test execution summary: 1 test case was executed. Overall verdict: error
MC@esekilxxen1844: MTC terminated.
MC@esekilxxen1844: Shutting down session.
MC@esekilxxen1844: Shutdown complete.
Here's what happens:
-first the main controller accepts the connection from the executable
-then an MTC is created by the user (cmtc)
-debug is set to on (debug on)
- a breakpoint is set on line 21 (dsetbp demo 21)
-the MTC is started, execution commences and it's stopped at line 21 (smtc)
-some information is printed interactively, then execution continues and finishes (dcont)
-the main controller is shut down (exit)
Besides the interactive mode, the batch file controlled mode can be used in parallel execution as well.
Let's start the main controller:
mctr_cli cfg.cfg
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: CRL 113 200/7 R1B *
* Copyright (c) 2000-2020 Ericsson Telecom AB *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v2.0 *
* which accompanies this distribution, and is available at *
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
*************************************************************************
Using configuration file: cfg.cfg
MC@esekilxxen1844: Unix server socket created successfully.
MC@esekilxxen1844: Listening on TCP port 9034.
Let's start the executable in a separate console:
./demo localhost 9034
TTCN-3 Host Controller (parallel mode), version CRL 113 200/7 R1B
The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
and then run the debug session in the first console , controlled by start1.bat:
MC2> MC@esekilxxen1844: New HC connected from 127.0.0.1 [127.0.0.1]. esekilxxen1844: Linux 3.0.101-108.74-xen on x86_64.
MC2> cmtc
MC@esekilxxen1844: Downloading configuration file to all HCs.
HC@esekilxxen1844: Warning: The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
MC@esekilxxen1844: Configuration file was processed on all HCs.
MC@esekilxxen1844: Creating MTC on host 127.0.0.1.
MC@esekilxxen1844: MTC is created.
MC2> batch start1.bat
Executing batch file 'start1.bat'.
debug on
dautobp error on error.bat
dsetbp demo 21 bp21.bat
MC2> MTC@esekilxxen1844: Debugger switched on.
MTC@esekilxxen1844: Automatic breakpoint at error verdict switched on with batch file 'error.bat'.
MTC@esekilxxen1844: Breakpoint added in module 'demo' at line 21 with batch file 'bp21.bat'.
MC2> smtc
Executing all items of [EXECUTE] section.
MC2> MTC@esekilxxen1844: Test case tc_demo started.
MTC@esekilxxen1844: User breakpoint reached at line 21 in module 'demo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'bp21.bat'.
dprintstack
dlistvar all
dstacklevel 5
dlistvar comp
dprintvar ct_int
dlistvar local
dprintvar $
dcont
MTC@esekilxxen1844:
1. [function] f_fact([in] n := 1)*
2. [function] f_fact([in] n := 2)
3. [function] f_fact([in] n := 3)
4. [function] f_fact([in] n := 4)
5. [testcase] tc_demo()
MTC@esekilxxen1844:
n t_int
MTC@esekilxxen1844: Stack level set to:
5. [testcase] tc_demo()
MTC@esekilxxen1844:
ct_int ct_str
MTC@esekilxxen1844:
[integer] ct_int := 4
MTC@esekilxxen1844:
v_rec vt_list
MTC@esekilxxen1844:
[Rec] v_rec := { num := 4, str := "abc" }
[IntList template] vt_list := { 1, <uninitialized template>, * }
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: demo.ttcn:40: Dynamic test case error: Matching with an uninitialized/unsupported integer template.
MTC@esekilxxen1844: Automatic breakpoint (error verdict) reached at line 40 in module 'demo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'error.bat'.
dprintcalls
dlistvar local v_*
dprintvar $
dcont
MTC@esekilxxen1844:
10:34:00.422876 [testcase] started tc_demo()
10:34:00.423222 [function] started f_fact([in] n := 4)
10:34:00.423247 [function] started f_fact([in] n := 3)
10:34:00.423258 [function] started f_fact([in] n := 2)
10:34:00.423282 [function] started f_fact([in] n := 1)
10:34:00.425431 [function] finished f_fact([in] n := -) returned 1
10:34:00.425444 [function] finished f_fact([in] n := -) returned 2
10:34:00.425454 [function] finished f_fact([in] n := -) returned 6
10:34:00.425464 [function] finished f_fact([in] n := -) returned 24
MTC@esekilxxen1844:
v_rec v_list
MTC@esekilxxen1844:
[Rec] v_rec := { num := 4, str := "abc?" }
[IntList] v_list := { 1, 2, 9 }
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: Test case tc_demo finished. Verdict: error
MC@esekilxxen1844: Test execution finished.
Execution of [EXECUTE] section finished.
MC2> exit
MC@esekilxxen1844: Terminating MTC.
MTC@esekilxxen1844: Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 1 error (100.00 %).
MTC@esekilxxen1844: Test execution summary: 1 test case was executed. Overall verdict: error
MC@esekilxxen1844: MTC terminated.
MC@esekilxxen1844: Shutting down session.
MC@esekilxxen1844: Shutdown complete.
So here's what happens:
-first the main controller accepts the connection from the executable
-then an MTC is created by the user (cmtc)
-batch file start1.bat is set (batch start1.bat)
-with smtc, the main controller is started, execution continues to line 21 , where bp21.bat is executed, then execution is recommenced; when encountering the error, error.bat is called, then execution is finished
-main controller is shut down (manually, with exit)
I might add a third part later, with a real parallel execution, with MTC and PTCs, but this will not add any great novelty; the command interface will be as exemplified here.
Best regards
Elemer
[Updated on: Fri, 17 July 2020 09:18] Report message to a moderator
|
|
|
Re: Debugging using Titan Debugger [message #1830154 is a reply to message #1830096] |
Sat, 18 July 2020 09:59 |
|
I will continue with an exemple with two components, the MTC and a PTC.
In order for a PTC to be addressed directly , it has to be in an active state.
Here's the TTCN-3 code used:
module demo {
type port Control_PT message
{
inout charstring
}with { extension "internal"}
type component Main_CT {
// component variables
const integer ct_int := 4;
var charstring ct_str := "abc";
var Parallel_CT v_Parallel_CT:=null;
port Control_PT Ctlr_PCO;
}
type component Parallel_CT {
// component variables
const integer ct_int := 5;
var charstring ct_str := "efg";
port Control_PT Ctlr_PCO;
}
type record Rec {
integer num,
charstring str
}
type record of integer IntList;
// global variable
template integer t_int := (1..10);
function f_fact(in integer n) runs on Main_CT return integer {
if (n == 0 or n == 1) {
return 1; // line 37
}
return n * f_fact(n - 1);
}
function f_index(in integer n) runs on Parallel_CT return integer {
alt {
[]Ctlr_PCO.receive("go");
}
return ct_int + n;
}
testcase tc_demo() runs on Main_CT {
v_Parallel_CT:=Parallel_CT.create("PTC_#3");
connect(self:Ctlr_PCO, v_Parallel_CT:Ctlr_PCO)
v_Parallel_CT.start(f_index(10));
// local variables
var Rec v_rec := { num := ct_int, str := ct_str };
var template IntList vt_list := { [0] := 1, [2] := * };
if (match(f_fact(v_rec.num), t_int)) {
v_rec.str := v_rec.str & "!";
}
else {
v_rec.str := v_rec.str & "?";
}
var IntList v_list := { 1, 2, 9 };
if (match(v_list, vt_list)) { // dynamic test case error, line 69
action("matched");
}
Ctlr_PCO.send("go");
}
} // end of module
The alt in the function running on the PTC is meant to avoid early termination of PTC and keep the PTC active:
function f_index(in integer n) runs on Parallel_CT return integer {
alt {
[]Ctlr_PCO.receive("go");
}
return ct_int + n;
}
Let's generate the makefile and compile:
makefilegen -gn demo.ttcn
make
Configuration file used:
cfg.cfg
[EXECUTE]
demo.tc_demo
[MAIN_CONTROLLER]
TCPPort := 9034
In an error situation, error.bat will be invoked:
dprintcalls
dlistvar local v_*
dprintvar $
dcont
Let's start the main controller in the first console:
mctr_cli cfg.cfg
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: CRL 113 200/7 R1B *
* Copyright (c) 2000-2020 Ericsson Telecom AB *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v2.0 *
* which accompanies this distribution, and is available at *
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
*************************************************************************
Using configuration file: cfg.cfg
MC@esekilxxen1844: Unix server socket created successfully.
MC@esekilxxen1844: Listening on TCP port 9034.
MC2> MC@esekilxxen1844: New HC connected from 127.0.0.1 [127.0.0.1]. esekilxxen1844: Linux 3.0.101-108.74-xen on x86_64.
and the executable in the second:
./demo localhost 9034
TTCN-3 Host Controller (parallel mode), version CRL 113 200/7 R1B
The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
then we can continue interactively in the first:
MC2> cmtc
MC@esekilxxen1844: Downloading configuration file to all HCs.
HC@esekilxxen1844: Warning: The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
MC@esekilxxen1844: Configuration file was processed on all HCs.
MC@esekilxxen1844: Creating MTC on host 127.0.0.1.
MC@esekilxxen1844: MTC is created.
MC2> debug on
MC2> MTC@esekilxxen1844: Debugger switched on.
MC2> dautobp error on error.bat
MC2> MTC@esekilxxen1844: Automatic breakpoint at error verdict switched on with batch file 'error.bat'.
MC2> dsetbp demo 37
MC2> MTC@esekilxxen1844: Breakpoint added in module 'demo' at line 37 with no batch file.
MC2> dsettings
MC2> MTC@esekilxxen1844:
Debugger is switched on.
Output is printed to the console.
Global batch file not set.
Function call data buffer size: infinite.
User breakpoints:
demo 37
Automatic breakpoints:
error on error.bat
fail off
MC2> smtc
Executing all items of [EXECUTE] section.
MC2> MTC@esekilxxen1844: Test case tc_demo started.
MTC@esekilxxen1844: User breakpoint reached at line 37 in module 'demo'.
MTC@esekilxxen1844: Test execution halted.
PTC_#3(3)@esekilxxen1844: Test execution halted.
MC2> dlistcomp
MC@esekilxxen1844: MTC(1)* PTC_#3(3)
MC2> dlistvar all
MC2> MTC@esekilxxen1844:
n t_int Ctlr_PCO ct_int ct_str v_Parallel_CT
MC2> dprintvar $
MC2> MTC@esekilxxen1844:
[integer] n := 1
[integer template] demo.t_int := (1 .. 10)
[port] Ctlr_PCO := port Ctlr_PCO
[integer] ct_int := 4
[charstring] ct_str := "abc"
[component] v_Parallel_CT := PTC_#3(3)
MC2> dlistvar comp
MC2> MTC@esekilxxen1844:
Ctlr_PCO ct_int ct_str v_Parallel_CT
MC2> dprintvar $
MC2> MTC@esekilxxen1844:
[port] Ctlr_PCO := port Ctlr_PCO
[integer] ct_int := 4
[charstring] ct_str := "abc"
[component] v_Parallel_CT := PTC_#3(3)
MC2> dlistvar local
MC2> MTC@esekilxxen1844:
n
MC2> dprintvar $
MC2> MTC@esekilxxen1844:
[integer] n := 1
MC2> dsetcomp 3
MC@esekilxxen1844: Debugger set to print data from PTC PTC_#3(3).
MC2> dlistvar all
MC2> PTC_#3(3)@esekilxxen1844:
n t_int Ctlr_PCO ct_int ct_str
MC2> dprintvar $
MC2> PTC_#3(3)@esekilxxen1844:
[integer] n := 10
[integer template] demo.t_int := (1 .. 10)
[port] Ctlr_PCO := port Ctlr_PCO
[integer] ct_int := 5
[charstring] ct_str := "efg"
MC2> dlistvar comp
MC2> PTC_#3(3)@esekilxxen1844:
Ctlr_PCO ct_int ct_str
MC2> dprintvar $
MC2> PTC_#3(3)@esekilxxen1844:
[port] Ctlr_PCO := port Ctlr_PCO
[integer] ct_int := 5
[charstring] ct_str := "efg"
MC2> dlistvar local
MC2> PTC_#3(3)@esekilxxen1844:
n
MC2> dprintvar $
MC2> PTC_#3(3)@esekilxxen1844:
[integer] n := 10
MC2> dcont
MC2> MTC@esekilxxen1844: Test execution resumed.
PTC_#3(3)@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: demo.ttcn:69: Dynamic test case error: Matching with an uninitialized/unsupported integer template.
MTC@esekilxxen1844: Automatic breakpoint (error verdict) reached at line 69 in module 'demo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'error.bat'.
dprintcalls
dlistvar local v_*
dprintvar $
dcont
MTC@esekilxxen1844:
11:38:25.101982 [testcase] started tc_demo()
11:38:25.127104 [function] started f_fact([in] n := 4)
11:38:25.127129 [function] started f_fact([in] n := 3)
11:38:25.127140 [function] started f_fact([in] n := 2)
11:38:25.127162 [function] started f_fact([in] n := 1)
11:40:36.685118 [function] finished f_fact([in] n := -) returned 1
11:40:36.685134 [function] finished f_fact([in] n := -) returned 2
11:40:36.685145 [function] finished f_fact([in] n := -) returned 6
11:40:36.685156 [function] finished f_fact([in] n := -) returned 24
PTC_#3(3)@esekilxxen1844: Test execution halted.
PTC_#3(3)@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844:
v_rec v_list
MTC@esekilxxen1844:
[Rec] v_rec := { num := 4, str := "abc?" }
[IntList] v_list := { 1, 2, 9 }
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: Test case tc_demo finished. Verdict: error
MC@esekilxxen1844: Test execution finished.
Execution of [EXECUTE] section finished.
MC2> exit
MC@esekilxxen1844: Terminating MTC.
MTC@esekilxxen1844: Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 1 error (100.00 %).
MTC@esekilxxen1844: Test execution summary: 1 test case was executed. Overall verdict: error
MC@esekilxxen1844: MTC terminated.
MC@esekilxxen1844: Shutting down session.
MC@esekilxxen1844: Shutdown complete.
Here's the summary of what happens:
-MTC is created (cmtc)
-debug set to on (debug on)
-error.bat file is activated for error situations(dautobp error on error.bat)
-breakpoint is set on line 37 (dsetbp demo 37)
-main settings are displayed (dsettings)
-execution is started (smtc)
-execution is halted at breakpoint
-components are listed (dlistcomp); we have MTC , active (marked with asterisk) , and PTC_#3; components
can be addressed by name (MTC, PTC_#3) or reference (1,3)
-variables (all, component and local) are listed and printed
-PTC set as active component
-again, variables (all, component and local) are listed and printed; compare the list of local variables
-execution is continued (dcont)
-when encountering an error, error.bat is executed, then test execution is finished
-MC is shut down (exit)
Best regards
Elemer
[Updated on: Sat, 18 July 2020 10:02] Report message to a moderator
|
|
| |
Re: Debugging using Titan Debugger [message #1830313 is a reply to message #1830301] |
Thu, 23 July 2020 08:41 |
|
Hi Mujeeb,
1. it's difficult to diagnose with this amount of info; maybe you just forgot to switch debug on?
Please bear in mind also that the function has to contain executable code.
Here's an example:
I split the code into two modules, demo and subdemo:
module demo {
import from subdemo all;
type record Rec {
integer num,
charstring str
}
type record of integer IntList;
// global variable
template integer t_int := (1..10);
testcase tc_demo() runs on Main_CT {
v_Parallel_CT:=Parallel_CT.create("PTC_#3");
connect(self:Ctlr_PCO, v_Parallel_CT:Ctlr_PCO)
v_Parallel_CT.start(f_index(10));
// local variables
var Rec v_rec := { num := ct_int, str := ct_str };
var template IntList vt_list := { [0] := 1, [2] := * };
if (match(f_fact(v_rec.num), t_int)) {
v_rec.str := v_rec.str & "!";
}
else {
v_rec.str := v_rec.str & "?";
}
var IntList v_list := { 1, 2, 9 };
if (match(v_list, vt_list)) { // dynamic test case error, line 69
action("matched");
}
Ctlr_PCO.send("go");
}
} // end of module
module subdemo
{
type port Control_PT message
{
inout charstring
}with { extension "internal"}
type component Main_CT {
// component variables
const integer ct_int := 4;
var charstring ct_str := "abc";
var Parallel_CT v_Parallel_CT:=null;
port Control_PT Ctlr_PCO;
}
type component Parallel_CT {
// component variables
const integer ct_int := 5;
var charstring ct_str := "efg";
port Control_PT Ctlr_PCO;
}
function f_fact(in integer n) runs on Main_CT return integer {
if (n == 0 or n == 1) {
return 1;
}
return n * f_fact(n - 1);
}
function f_index(in integer n) runs on Parallel_CT return integer {
alt {
[]Ctlr_PCO.receive("go");
}
return ct_int + n;
}
}
and the debug session went on as below:
mctr_cli cfg.cfg
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: CRL 113 200/7 R1B *
* Copyright (c) 2000-2020 Ericsson Telecom AB *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v2.0 *
* which accompanies this distribution, and is available at *
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
*************************************************************************
Using configuration file: cfg.cfg
MC@esekilxxen1844: Unix server socket created successfully.
MC@esekilxxen1844: Listening on TCP port 9034.
MC2> MC@esekilxxen1844: New HC connected from 127.0.0.1 [127.0.0.1]. esekilxxen1844: Linux 3.0.101-108.74-xen on x86_64.
MC2> cmtc
MC@esekilxxen1844: Downloading configuration file to all HCs.
HC@esekilxxen1844: Warning: The address of MC was set to a local IP address. This may cause incorrect behavior if a HC from a remote host also connects to MC.
MC@esekilxxen1844: Configuration file was processed on all HCs.
MC@esekilxxen1844: Creating MTC on host 127.0.0.1.
MC@esekilxxen1844: MTC is created.
MC2>
MC2>
MC2> debug on
MC2> MTC@esekilxxen1844: Debugger switched on.
MC2>
MC2> dsetbp subdemo f_fact f_fact.bat
MC2> MTC@esekilxxen1844: Breakpoint added in module 'subdemo' at function 'f_fact' with batch file 'f_fact.bat'.
MC2> smtc
Executing all items of [EXECUTE] section.
MC2> MTC@esekilxxen1844: Test case tc_demo started.
MTC@esekilxxen1844: User breakpoint reached at line 29 in module 'subdemo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'f_fact.bat'.
dprintstack
dlistvar all
dstacklevel 5
dlistvar comp
dprintvar ct_int
dlistvar local
dprintvar $
dcont
PTC_#3(3)@esekilxxen1844: Test execution halted.
PTC_#3(3)@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844:
1. [function] f_fact([in] n := 4)*
2. [testcase] tc_demo()
MTC@esekilxxen1844:
n Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844: Invalid new stack level. Expected 1 - 2.
MTC@esekilxxen1844:
Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844:
[integer] ct_int := 4
MTC@esekilxxen1844:
n
MTC@esekilxxen1844:
[integer] n := 4
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: User breakpoint reached at line 29 in module 'subdemo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'f_fact.bat'.
dprintstack
dlistvar all
dstacklevel 5
dlistvar comp
dprintvar ct_int
dlistvar local
dprintvar $
dcont
PTC_#3(3)@esekilxxen1844: Test execution halted.
PTC_#3(3)@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844:
1. [function] f_fact([in] n := 3)*
2. [function] f_fact([in] n := 4)
3. [testcase] tc_demo()
MTC@esekilxxen1844:
n Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844: Invalid new stack level. Expected 1 - 3.
MTC@esekilxxen1844:
Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844:
[integer] ct_int := 4
MTC@esekilxxen1844:
n
MTC@esekilxxen1844:
[integer] n := 3
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: User breakpoint reached at line 29 in module 'subdemo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'f_fact.bat'.
dprintstack
dlistvar all
dstacklevel 5
dlistvar comp
dprintvar ct_int
dlistvar local
dprintvar $
dcont
PTC_#3(3)@esekilxxen1844: Test execution halted.
PTC_#3(3)@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844:
1. [function] f_fact([in] n := 2)*
2. [function] f_fact([in] n := 3)
3. [function] f_fact([in] n := 4)
4. [testcase] tc_demo()
MTC@esekilxxen1844:
n Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844: Invalid new stack level. Expected 1 - 4.
MTC@esekilxxen1844:
Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844:
[integer] ct_int := 4
MTC@esekilxxen1844:
n
MTC@esekilxxen1844:
[integer] n := 2
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: User breakpoint reached at line 29 in module 'subdemo'.
MTC@esekilxxen1844: Test execution halted.
Executing batch file 'f_fact.bat'.
dprintstack
dlistvar all
dstacklevel 5
dlistvar comp
dprintvar ct_int
dlistvar local
dprintvar $
dcont
PTC_#3(3)@esekilxxen1844: Test execution halted.
PTC_#3(3)@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844:
1. [function] f_fact([in] n := 1)*
2. [function] f_fact([in] n := 2)
3. [function] f_fact([in] n := 3)
4. [function] f_fact([in] n := 4)
5. [testcase] tc_demo()
MTC@esekilxxen1844:
n Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844: Stack level set to:
5. [testcase] tc_demo()
MTC@esekilxxen1844:
Ctlr_PCO ct_int ct_str v_Parallel_CT
MTC@esekilxxen1844:
[integer] ct_int := 4
MTC@esekilxxen1844:
v_rec vt_list
MTC@esekilxxen1844:
[Rec] v_rec := { num := 4, str := "abc" }
[IntList template] vt_list := { 1, <uninitialized template>, * }
MTC@esekilxxen1844: Test execution resumed.
MTC@esekilxxen1844: demo.ttcn:38: Dynamic test case error: Matching with an uninitialized/unsupported integer template.
MTC@esekilxxen1844: Test case tc_demo finished. Verdict: error
MC@esekilxxen1844: Test execution finished.
Execution of [EXECUTE] section finished.
MC2> exit
MC@esekilxxen1844: Terminating MTC.
MTC@esekilxxen1844: Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 1 error (100.00 %).
MTC@esekilxxen1844: Test execution summary: 1 test case was executed. Overall verdict: error
MC@esekilxxen1844: MTC terminated.
MC@esekilxxen1844: Shutting down session.
MC@esekilxxen1844: Shutdown complete.
Please observe that the batch file was executed at every call of the function f_fact.
2. Yes , that is possible.
I hope this helps
Best regards
Elemer
|
|
| |
Goto Forum:
Current Time: Sun Oct 13 07:17:23 GMT 2024
Powered by FUDForum. Page generated in 0.04458 seconds
|