Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-08

Thread List Window in the IDE

9 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

As far as I know, Lazarus doesn't have a Thread List Window available. So I am trying to setup and external tools menu item which will do this for me, but I am have some problems with it.

This is the actual setup strings used for the external tool.

Program Filename:
/usr/bin/gnome-terminal

Parameters:
--title="Thread Monitor - $NameOnly($TargetFile())" --command="watch -n.1 'ps -C $NameOnly($TargetFile()) -L -o pid,tid,pcpu,state'"

When I run Lazarus from the command line under Linux, this is the output shown to stdout when I try and run my external tool.

[TExternalToolList.Run] CmdLine="/usr/bin/gnome-terminal --title="Thread Monitor - project1" --command="watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'"" WorkDir=""

As far as I can see the macros used in the External Tool step was converted correctly. I can even copy and paste the CmdLine without the outer quotes and it executes fine from a teminal window. Yet, if I run it from the Tools menu gnome-terminal gives an error. The error is: "There was an error creating the child process for this terminal"

Anybody know what I am doing wrong?

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Mattias Gaertner
to Graeme Geldenhuys
Show quoted text 31 lines
Hi, As far as I know, Lazarus doesn't have a Thread List Window available. So I am trying to setup and external tools menu item which will do this for me, but I am have some problems with it. This is the actual setup strings used for the external tool. Program Filename: /usr/bin/gnome-terminal Parameters: --title="Thread Monitor - $NameOnly($TargetFile())" --command="watch -n.1 'ps -C $NameOnly($TargetFile()) -L -o pid,tid,pcpu,state'" When I run Lazarus from the command line under Linux, this is the output shown to stdout when I try and run my external tool. [TExternalToolList.Run] CmdLine="/usr/bin/gnome-terminal --title="Thread Monitor - project1" --command="watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'"" WorkDir="" As far as I can see the macros used in the External Tool step was converted correctly. I can even copy and paste the CmdLine without the outer quotes and it executes fine from a teminal window. Yet, if I run it from the Tools menu gnome-terminal gives an error. The error is: "There was an error creating the child process for this terminal" Anybody know what I am doing wrong?

It is a bug in fcl-process/src/unix/process.inc proc CommandToList used by TProcess.
It only removes the outer ".
Please report it.

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote
It is a bug in fcl-process/src/unix/process.inc proc CommandToList used by TProcess. It only removes the outer ".

I copied the CommandToList() from process.inc to my own test application and named it MyCommandToList().

I then passed the lProcess.CommandLine to that function with a stringlist, and then did a writeln() of MyStringList.Text. Below is the output and it looks correct to me? I'm using FPC 2.3.1 (fixes_2_4 branch) of yesterday.

$ ./project1
/usr/bin/gnome-terminal
--title="Thread Monitor - project1"
--command="watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'"

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Mattias Gärtner
to Graeme Geldenhuys

Zitat von Graeme Geldenhuys :

Show quoted text 17 lines
Mattias Gaertner wrote: > > It is a bug in fcl-process/src/unix/process.inc proc CommandToList > used by TProcess. It only removes the outer ". I copied the CommandToList() from process.inc to my own test application and named it MyCommandToList(). I then passed the lProcess.CommandLine to that function with a stringlist, and then did a writeln() of MyStringList.Text. Below is the output and it looks correct to me? I'm using FPC 2.3.1 (fixes_2_4 branch) of yesterday. $ ./project1 /usr/bin/gnome-terminal --title="Thread Monitor - project1" --command="watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'"

And that is wrong. This is the command as given to a shell, which removes the outer level " and ' and then executes it. TProcess only removes the ",' if the parameter starts with a ",'.

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gärtner
Mattias G?rtner wrote 8 lines
> $ ./project1 > /usr/bin/gnome-terminal > --title="Thread Monitor - project1" > --command="watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'" And that is wrong. This is the command as given to a shell, which removes the outer level " and ' and then executes it. TProcess only removes the ",' if the parameter starts with a ",'.

OK, but should the following then work.

----------[ ~/bin/lsthreads ]------------------
/usr/bin/gnome-terminal --title="Thread Monitor" \ --command="watch -n.1 'ps -C ${1} -L -o pid,tid,pcpu,state'" ----------------[ end ]------------------

Now I can call that using:

$ lsthreads project1

Creating another External Tool entry with the following information still doesn't produce a result. Now I don't get any error, but I don't even get a command prompt (gnome-terminal) either. :-(

Program Filename:
lsthreads
or
/home/graemeg/bin/lsthreads

Parameters:
$NameOnly($TargetFile())

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Mattias Gärtner
to Graeme Geldenhuys

Zitat von Graeme Geldenhuys :

Show quoted text 17 lines
Mattias G?rtner wrote: >> $ ./project1 >> /usr/bin/gnome-terminal >> --title="Thread Monitor - project1" >> --command="watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'" > > And that is wrong. This is the command as given to a shell, which > removes the outer level " and ' and then executes it. > TProcess only removes the ",' if the parameter starts with a ",'. OK, but should the following then work. ----------[ ~/bin/lsthreads ]------------------ /usr/bin/gnome-terminal --title="Thread Monitor" \ --command="watch -n.1 'ps -C ${1} -L -o pid,tid,pcpu,state'" ----------------[ end ]------------------

No. Still the " are in the parameters.
This works:
"--title=Thread Monitor" "--command=watch -n.1 'ps -C ${1} -L -o pid,tid,pcpu,state'"

Show quoted text 8 lines
Now I can call that using: $ lsthreads project1 Creating another External Tool entry with the following information still doesn't produce a result. Now I don't get any error, but I don't even get a command prompt (gnome-terminal) either. :-(

Keep trying.

Show quoted text 7 lines
Program Filename: lsthreads or /home/graemeg/bin/lsthreads Parameters: $NameOnly($TargetFile())

Mattias

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 6 lines
Mattias G?rtner wrote: > > No. Still the " are in the parameters. > Keep trying. I give up! :-) I'll file a bug report with whatever you said. ;-)

That's not very serious.

It's not because TProcess does not do what you want exactly the way you want it, that it is buggy ?

if you would change the gnome command with a command that simply echoes the passed parameters one by one to the terminal (or write a FPGUI program that shows a dialog), that would help you in understanding what happens.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
It's not because TProcess does not do what you want exactly the way you want it, that it is buggy ?

OK, I see now what Mattias was talking about. Me using quotes in the parameters confuses TProcess somewhere along the line.

Changing what I enter in Lazarus External Tools Parameters editbox to

"--title=Thread Monitor - $NameOnly($TargetFile())" "--command=watch -n.1 'ps -C $NameOnly($TargetFile()) -L -o pid,tid,pcpu,state'"

...or without the Lazarus macros...

"--title=Thread Monitor - project1" "--command=watch -n.1 'ps -C project1 -L -o pid,tid,pcpu,state'"

...allows TProcess to function correctly. Now TProcess treats each --<whatever> as a parameter.

I agree with Mattias now, it still seems like a bug to me.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email