Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Startting remote program from GDB using "target remote"

Roman,

See my comments inline.

----- Original Message ----- From: "Roman Levenstein" <romixlev@xxxxxxxxx>
To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Sent: Monday, November 28, 2005 4:48 PM
Subject: Re: [cdt-dev] Startting remote program from GDB using "target remote"


Hi Mikhail,

It seems to me that I misunderstood the way how
Command parameters for postCommand are created. My
understanding was that the postCommand method requires
a Command object as its parameter. CDT defines classes
for many of GDB MI commands, but not for all possible
commands. Now if I read a free-form command (i.e. any
kind of command that is permitted by GDB) from the
gdbinit-like file and want to submit it to GDB, how do
I create a  Command object from such a free-form
command? I was thinking that am I not allowed to
create Command objects on the fly and initiate them
with any text string representing the command from the
file. But now I tried it out (suing constructs like
"new MICommand(miVersion, freeFormGDBCommand)") and it
seems to work, though I'm not sure that it would work
for all commands (e.g "ptype struct FILE" or some
other commands with many arguments sometimes misbehave
when I issue them in the createLaunchSession using
postCommand. Some others, like "info target" or "print
1" work just fine. I don't understand yet why it is
like that.) Anyway, thanks for the postCommand hint!

Two more questions:
1) How do I get a programmatic access to the GDB
console windows? The solution above solved the problem
of sumbmitting the command to GDB. But I'd like also
to echo such commands in the GDB console and/or be
able to write some other custom messages in this
console. Any ideas?


There is no direct way to access the gdb console programmatically. You may try to get IProcess from ILaunch and use the IStreamsProxy interface. But I am not sure that it's what you are looking for.

2) If I use the async mode for remote target, i.e.
"target async", does it mean that GDB is able to
receive some events from target asynchronously, while
waiting for user input? In particular, what happens if
CDT/GDB assumes that the target is in the suspended
state, but then suddenly an event from target comes,
e.g. if the target was rebooted using hard-reset? Can
CDT handle such a situation? Do I go in the right
direction, when I think about "target async" instead
of "target remote"? Or do you think that for this use
case it does not make any difference?


I am not familiar with this mode so the answer is I don't know.

Regards,
Roman

--- Mikhail Khodjaiants <mikhailk@xxxxxxx> wrote:

I'm not sure that I understand the question. Why
wouldn't you use the
"postCommand" method of MISession instead?

----- Original Message ----- From: "Roman Levenstein" <romixlev@xxxxxxxxx>
To: "CDT General developers list."
<cdt-dev@xxxxxxxxxxx>
Sent: Monday, November 28, 2005 2:37 PM
Subject: Re: [cdt-dev] Startting remote program from
GDB using "target
remote"


> Hi Mikhail,
>
> Now it works. Thanks!
>
> BTW, I'd like to submit some "free-form" commands
> (i.e. not  to GDB programmatically, as if they
were
> entered by the user or read from .gdbinit file.
The
> idea is to have something like .gdbinit scripts,
but
> to be able to execute them at any time during the
> debugging. Which class/method should I look at? I
> guess, I just need to get access to the input
> (console) stream of GDB process and basically
write
> the GDB commands into it, or?
>
> Thanks,
> Roman
>
> --- Mikhail Khodjaiants <mikhailk@xxxxxxx> wrote:
>
>> Sorry, I was mistaken. You can use the
>> "MITargetSelect" class to establish
>> remote connection. As an example, see the
>> implementation of
>> GDBServerDebugger.
>>
>> ----- Original Message ----- >> From: "Roman Levenstein" <romixlev@xxxxxxxxx>
>> To: "CDT General developers list."
>> <cdt-dev@xxxxxxxxxxx>
>> Sent: Monday, November 28, 2005 9:19 AM
>> Subject: Re: [cdt-dev] Startting remote program
from
>> GDB using "target
>> remote"
>>
>>
>> > Hi Mikhail,
>> >
>> > See my comments inline.
>> >
>> >>> 1) Now I execute "target remote" from the
>> .gdbinit
>> >>> file. This seems to work, but it is a bit
>> annoying
>> > for
>> >>> the customers, who have to enter the path to
>> this
>> > file
>> >>> for each project. Is it possible to sent this
>> > command
>> >>> directly to GDB somewhere in my launcher
class
>> or
>> > in
>> >>> some class derived from session classes?
>> >>>
>> >>
>> >> You can resume your session from the launcher
by
>> > calling the "resume" method of IDebugTarget.
>> >
>> > I don't quite understand you. How does "resume"
>> method
>> > helps me with establishing a remote connection?
>> What I
>> > need is the way to programmatically execute the
>> > "target remote /dev/ttyS1" command, so that
the
>> > embedded developers  do not need to enter the
path
>> to
>> > the .gdbinit for each project. My guess is that
it
>> > should be done somewhere in a
>> GDBCDIDebugger-derived
>> > class, e.g. in createLaunchSession method. But
>> when I
>> > try to do something like:
>> > CommandFactory factory =
>> > miSession.getCommandFactory();
>> > MIGDBSet set = factory.createMIGDBSet(new
String[]
>> {
>> > "target remote myhostname:myportnumber" });
>> > miSession.postCommand(set);
>> > MIInfo info = set.getMIInfo();
>> >
>> > then it does not work as expected. What I'm
doing
>> > wrong?
>> > BTW, I haven't found any Command classes for
>> > connections to remote targets. It is not
supported
>> by
>> > CDT yet, isn't it?
>> >
>> >>> 2) Almost the same question about the path to
>> the
>> >>> custom version of GDB. Can I preset this
value
>> >>> somewhere to point to our GDB executable and
not
>> to
>> >>> the Cygwin's one by default? Should I
redefine
>> the
>> > Tab
>> >>> class for Debugger settings for it? Or may be
>> >>> somewhere in the plugin.xml?
>> >>>
>> >>
>> >> The "official" way is to define your own
debugger
>> by
>> > using the
'org.eclipse.cdt.debug.core.CDebugger"
>> > extension point and contribute UI for it using
the
>> > "org.eclipse.cdt.debug.ui.CDebuggerPage"
extension
>> > point. (see for example the implementations of
>> Cygwin
>> > debugger or gdb server).
>> >
>> > I've done as you suggested and it seems to
work!
>> >
>> >>> 4) I've noticed that when GDB successfully
>> connects
>> > to
>> >>> the target and establishes a  session, it is
not
>> >>> possible to enter GDB commands from the
console
>> any
>> >>> more. On the other hand, if it cannot
establish
>> the
>> >>> connection correctly, I can enter GDB
commands
>> from
>> >>> the console. What I would like to have is the
>> >>> possibility to enter GDB commands from
console
>> in
>> > both
>> >>> cases. I think it cab be useful in many
>> situations.
>> >>> Any ideas how to enable it?
>> >>>
>> >>
>> >> I don't know why you can not enter commands to
>> the
>> > console. It should be possible if gdb is
>> responsive
>> > (the program is suspended).
>> >
>> > Sorry, it was my fault. I looked at the
>> application
>> > console, instead looking at the GDB console.
>> > Everything works as expected.
>> >
>> > Regards,
>> > Roman
>> >
>> >
>> >
>> >
>> >
>> > __________________________________
>> > Start your day with Yahoo! - Make it your home
>> page!
>> > http://www.yahoo.com/r/hs
>> > _______________________________________________
>> > cdt-dev mailing list
>> > cdt-dev@xxxxxxxxxxx
>> >
https://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/cdt-dev

=== message truncated ===





__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top