Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Using GDB debugger for debugging CC files(Using GDB debugger for debugging CC files)
Using GDB debugger for debugging CC files [message #1831761] Fri, 28 August 2020 09:48 Go to next message
Mujeeb Ur Rehman is currently offline Mujeeb Ur RehmanFriend
Messages: 16
Registered: January 2020
Junior Member
Hi,

As we know that it is not possible to add breakpoints and debug the compiled C++ files using Titan command line debugger. So is it possible to use GDB debugger for debugging the executable generated. I have tried and tried to add breakpoints to the executable on HC but i am not catching up the right steps to do this while having MTC and HC active (connected). Can you guys guide me?

Best Regards,
Mujeeb


Re: Using GDB debugger for debugging CC files [message #1831763 is a reply to message #1831761] Fri, 28 August 2020 10:00 Go to previous messageGo to next message
roland gecse is currently offline roland gecseFriend
Messages: 20
Registered: December 2015
Junior Member
You can use gdb to debug TITAN generated code as long as you build your ETS in single mode. You shall link with the single mode base library, which lacks support for parallelism i.e. no HC and no PTCs.

Using gdb for debugging multi process applications is non-trivial: https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_25.html

BTW, what is your objective of debugging the generated code on C/C++ level?
Re: Using GDB debugger for debugging CC files [message #1831764 is a reply to message #1831761] Fri, 28 August 2020 10:48 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 134
Registered: December 2015
Senior Member
In parallel mode every components, including the MTC, runs in different process.
You should attach the right process with the gdb.

Re: Using GDB debugger for debugging CC files [message #1831765 is a reply to message #1831763] Fri, 28 August 2020 11:50 Go to previous messageGo to next message
Mujeeb Ur Rehman is currently offline Mujeeb Ur RehmanFriend
Messages: 16
Registered: January 2020
Junior Member
I need to print and debug some information. I was unable to do this using the command line debugger inside CPP files( specially PORTS files). I am getting issue when the HC is connected to MTC. Before that the GDB works but after that i have no control over GDB in HC? did any one tried it? how can i add breakpoints and have control over GDB?
Re: Using GDB debugger for debugging CC files [message #1831766 is a reply to message #1831765] Fri, 28 August 2020 12:02 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 134
Registered: December 2015
Senior Member
The HC spawns a separate process for MTC and any other PTC. So any test code is running on MTC or PTC process not inside the HC process.

You should attach the gdb to the right process not the HC process.

But I recommend to add some log statement to the test port code.
Re: Using GDB debugger for debugging CC files [message #1831777 is a reply to message #1831766] Fri, 28 August 2020 16:47 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Hi all,

I use very often the gdb for debugging complex external functions and codecs (as Roland said in single mode for unit tests for the particular modules I am working). And it works perfectly!

Regards,
Olaf
Re: Using GDB debugger for debugging CC files [message #1831870 is a reply to message #1831766] Tue, 01 September 2020 12:37 Go to previous messageGo to next message
Mujeeb Ur Rehman is currently offline Mujeeb Ur RehmanFriend
Messages: 16
Registered: January 2020
Junior Member
Gábor Szalai wrote on Fri, 28 August 2020 12:02
The HC spawns a separate process for MTC and any other PTC. So any test code is running on MTC or PTC process not inside the HC process.

You should attach the gdb to the right process not the HC process.

But I recommend to add some log statement to the test port code.


I need some guidance on this

Well i tried to attach the process and this worked but i am facing an issue when i attach the process i am not able to give gdb related commands in the terminal as test executions starts, the same happens on the client side where the executable is run,

Server Side:


Quote:

[mreh@abc bin]$ gdb ./mctr_cli cfg.cfg
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-92.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/mreh/Desktop/TTCN/ttcn3-6.5.pl0-linux64-gcc4.4.5-rhel6/bin/mctr_cli...(no debugging symbols found)...done.
"/home/mreh/Desktop/TTCN/ttcn3-6.5.pl0-linux64-gcc4.4.5-rhel6/bin/cfg.cfg" is not a core dump: File format not recognized
(gdb) run cfg.cfg
Starting program: /home/mreh/Desktop/TTCN/ttcn3-6.5.pl0-linux64-gcc4.4.5-rhel6/bin/mctr_cli cfg.cfg
[Thread debugging using libthread_db enabled]

*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: CRL 113 200/6 R5A *
* Copyright (c) 2000-2018 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@abc Unix server socket created successfully.
[New Thread 0x7ffff7fdc700 (LWP 2902)]
MC@abc: Listening on TCP port 9034.
MC2> MC@abc: New HC connected from 127.0.0.1 [127.0.0.1]. abc: Linux 2.6.32-754.14.2.el6.x86_64 on x86_64.
cmtc
MC@abc: Downloading configuration file to all HCs.
MC@abc: Configuration file was processed on all HCs.
MC@abc: Creating MTC on host 127.0.0.1.
MC@abc: MTC is created.
MC2> smtc
Executing all items of [EXECUTE] section.
MC2> MTC@abc: Test case TC_22_2_1 started.
3@abc: Warning: Unknown XER encoding requested; using Basic XER.

Program received signal SIGINT, Interrupt.
0x0000003cf560e82d in read () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6_10.3.x86_64 libgcc-4.4.7-23.el6.x86_64 libstdc++-4.4.7-23.el6.x86_64 ncurses-libs-5.7-4.20090207.el6.x86_64 openssl-1.0.1e-58.el6_10.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) quit
A debugging session is active.
Inferior 1 [process 2899] will be killed.


Client Side:

Quote:
[mreh@abc NBIOT]$ gdb ./TTCN3_testcases.exe
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-92.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/mreh/Desktop/TTCN/ttcn3-6.5.pl0-linux64-gcc4.4.5-rhel6/NBIOT/TTCN3_testcases.exe...(no debugging symbols found)...done.
(gdb) run -s IPADDRESSES 9034
Starting program: /home/mreh/Desktop/TTCN/ttcn3-6.5.pl0-linux64-gcc4.4.5-rhel6/NBIOT/TTCN3_testcases.exe -sIPADDRESSES 9034
[Thread debugging using libthread_db enabled]
TTCN-3 Host Controller (parallel mode), version CRL 113 200/6 R5A
Detaching after fork from child process 3298.
Detaching after fork from child process 3307.


So kindly is there some solution to this? how i give gdb commands during test execution? and can bring back the gdb terminal?

Thanks again every one for your kind advices and help :)

Best Regards,
Mujeeb

[Updated on: Thu, 03 September 2020 14:36]

Report message to a moderator

Re: Using GDB debugger for debugging CC files [message #1831974 is a reply to message #1831870] Fri, 04 September 2020 06:54 Go to previous message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 134
Registered: December 2015
Senior Member
For debugging external function I suggest to use single mode. In single mode there are no separate mctr, host controller and MTC/PTC processes. Just one mtc, on which the code is executed. Much easier to use gdb.

Also I advise to use debug printouts instead of gdb.

Just add a similar function to your code:

void my_debug(const char *fmt, ...) { /
  TTCN_Logger::begin_event(TTCN_DEBUG);
  TTCN_Logger::log_event("My debug: ");
  va_list args;
  va_start(args, fmt);
  TTCN_Logger::log_event_va_list(fmt, args);
  va_end(args);
  TTCN_Logger::end_event();
} 


And call this function like the printf. And add the DEBUG flag to the FileMask like:
FileMask:= LOG_ALL | DEBUG

How to find the pid of the MTC or ptc:

When the MTC or PTC is created the pid is logged into the hc log file. Start the test case, check the hc log for the pid, and attach the gdb to that process.
Probably you need to add some delays to the test code to have enough time to attach the gdb.

Previous Topic:Titan compiler for windows
Next Topic:The Titan runtime configuration file
Goto Forum:
  


Current Time: Sat Oct 12 04:37:44 GMT 2024

Powered by FUDForum. Page generated in 0.04307 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top