linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* strace write/read output
@ 2005-03-22 17:05 Fabio Miranda Hamburger
  2005-03-22 19:05 ` Eric Bambach
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Miranda Hamburger @ 2005-03-22 17:05 UTC (permalink / raw)
  To: linux-c-programming

hello,

I am debugging a tcpip app on linux, I would like to use strace to show me
*all* the data passed to read() and write() function to the sockets
stream.

thanks,

---
Fabio Andres Miranda
Ingenieria de sistemas informaticos
Universidad Latina - Costa Rica


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: strace write/read output
  2005-03-22 19:05 ` Eric Bambach
@ 2005-03-22 18:16   ` Fabio Miranda Hamburger
  2005-03-23  2:17     ` Eric Bambach
                       ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Fabio Miranda Hamburger @ 2005-03-22 18:16 UTC (permalink / raw)
  To: Eric Bambach; +Cc: linux-c-programming

> On Tuesday 22 March 2005 11:05 am, Fabio Miranda Hamburger wrote:
> > hello,
> >
> > I am debugging a tcpip app on linux, I would like to use strace to show me
> > *all* the data passed to read() and write() function to the sockets
> > stream.
> >
> > thanks,
> >
>       Does strace with the -e option do what you want? man strace. It seems to
> do read and write. Prepare for big logfiles ;)

I was trying to figure out how to do it. Can you provide an example?
Usually strace shows few characters and at the end, the total length of
what was received. Well, I need the entire string of characters.

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: strace write/read output
  2005-03-22 17:05 strace write/read output Fabio Miranda Hamburger
@ 2005-03-22 19:05 ` Eric Bambach
  2005-03-22 18:16   ` Fabio Miranda Hamburger
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Bambach @ 2005-03-22 19:05 UTC (permalink / raw)
  To: Fabio Miranda Hamburger; +Cc: linux-c-programming

On Tuesday 22 March 2005 11:05 am, Fabio Miranda Hamburger wrote:
> hello,
>
> I am debugging a tcpip app on linux, I would like to use strace to show me
> *all* the data passed to read() and write() function to the sockets
> stream.
>
> thanks,
>
      Does strace with the -e option do what you want? man strace. It seems to 
do read and write. Prepare for big logfiles ;)
> ---
> Fabio Andres Miranda
> Ingenieria de sistemas informaticos
> Universidad Latina - Costa Rica
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
----------------------------------------
--EB

> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?

The latitude and longtitude of the bios writers current position, and
a ballistic missile.

                --Alan Cox LKML-December 08,2000 

----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: strace write/read output
  2005-03-22 18:16   ` Fabio Miranda Hamburger
@ 2005-03-23  2:17     ` Eric Bambach
  2005-03-23 17:34     ` Rechberger Markus
  2005-04-04 14:32     ` Array Empty Slots Chris
  2 siblings, 0 replies; 9+ messages in thread
From: Eric Bambach @ 2005-03-23  2:17 UTC (permalink / raw)
  To: linux prg

(forgot to cc the list)

On Tuesday 22 March 2005 12:16 pm, you wrote:
> > On Tuesday 22 March 2005 11:05 am, Fabio Miranda Hamburger wrote:
> > > hello,
> > >
> > > I am debugging a tcpip app on linux, I would like to use strace to show
> > > me *all* the data passed to read() and write() function to the sockets
> > > stream.
> > >
> > > thanks,
> >
> >       Does strace with the -e option do what you want? man strace. It
> > seems to do read and write. Prepare for big logfiles ;)
>
> I was trying to figure out how to do it. Can you provide an example?
> Usually strace shows few characters and at the end, the total length of
> what was received. Well, I need the entire string of characters.

Here is a quick and dirty example on a small text file. Notice I dont know 
what fd's cat uses so I just guessed 1-5. Below is the output of the example 
too. It outputs the ENTIRE file that was read in hex and ascii you just have 
to know what file desciptors you want to trace. To trace write calls this way 
just change -e read=1,2,3,4,5 to -e write=1,2,3,4,5 or you could even use 
them together.

command:
strace -e read=1,2,3,4,5 -o file.log cat unison.log

Outputs this to file.log (truncated for sake of the mailer and example):

read(3, "Fatal error: Lost connection wit"..., 131072) = 270
46 61 74 61 6c 20 65 72  72 6f 72 3a 20 4c 6f 73  Fatal er ror: Los |
74 20 63 6f 6e 6e 65 63  74 69 6f 6e 20 77 69 74  t connec tion wit |
68 20 74 68 65 20 73 65  72 76 65 72 0a 46 61 74  h the se rver.Fat |
61 6c 20 65 72 72 6f 72  3a 20 4c 6f 73 74 20 63  al error : Lost c |
6f 6e 6e 65 63 74 69 6f  6e 20 77 69 74 68 20 74  onnectio n with t |
68 65 20 73 65 72 76 65  72 0a 46 61 74 61 6c 20  he serve r.Fatal  |
65 72 72 6f 72 3a 20 4c  6f 73 74 20 63 6f 6e 6e  error: L ost conn |
65 63 74 69 6f 6e 20 77  69 74 68 20 74 68 65 20  ection w ith the  |
73 65 72 76 65 72 0a 46  61 74 61 6c 20 65 72 72  server.F atal err |
6f 72 3a 20 4c 6f 73 74  20 63 6f 6e 6e 65 63 74  or: Lost  connect |
69 6f 6e 20 77 69 74 68  20 74 68 65 20 73 65 72  ion with  the ser |
76 65 72 0a 46 61 74 61  6c 20 65 72 72 6f 72 3a  ver.Fata l error: |
20 4c 6f 73 74 20 63 6f  6e 6e 65 63 74 69 6f 6e   Lost co nnection |
20 77 69 74 68 20 74 68  65 20 73 65 72 76 65 72   with th e server |
0a 46 61 74 61 6c 20 65  72 72 6f 72 3a 20 4c 6f  .Fatal e rror: Lo |
73 74 20 63 6f 6e 6e 65  63 74 69 6f 6e 20 77 69  st conne ction wi |
 74 68 20 74 68 65 20 73  65 72 76 65 72 0a        th the s erver.   |

-- 
----------------------------------------
--EB

> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?

The latitude and longtitude of the bios writers current position, and
a ballistic missile.

                --Alan Cox LKML-December 08,2000 

----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: strace write/read output
  2005-03-22 18:16   ` Fabio Miranda Hamburger
  2005-03-23  2:17     ` Eric Bambach
@ 2005-03-23 17:34     ` Rechberger Markus
  2005-04-04 14:32     ` Array Empty Slots Chris
  2 siblings, 0 replies; 9+ messages in thread
From: Rechberger Markus @ 2005-03-23 17:34 UTC (permalink / raw)
  To: Fabio Miranda Hamburger; +Cc: linux-c-programming

hey,

here two small examples the first one will attach strace to a running
process, the second one will fire up your application attached to
strace.

strace -e 'read,write' -p <processid> or
strace -e 'read,write' <yourapplication>

Markus


On Tue, 22 Mar 2005 12:16:55 -0600 (CST), Fabio Miranda Hamburger
<fabmirha@ns.isi.ulatina.ac.cr> wrote:
> > On Tuesday 22 March 2005 11:05 am, Fabio Miranda Hamburger wrote:
> > > hello,
> > >
> > > I am debugging a tcpip app on linux, I would like to use strace to show me
> > > *all* the data passed to read() and write() function to the sockets
> > > stream.
> > >
> > > thanks,
> > >
> >       Does strace with the -e option do what you want? man strace. It seems to
> > do read and write. Prepare for big logfiles ;)
> 
> I was trying to figure out how to do it. Can you provide an example?
> Usually strace shows few characters and at the end, the total length of
> what was received. Well, I need the entire string of characters.
> 
> Thanks.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Array Empty Slots
  2005-03-22 18:16   ` Fabio Miranda Hamburger
  2005-03-23  2:17     ` Eric Bambach
  2005-03-23 17:34     ` Rechberger Markus
@ 2005-04-04 14:32     ` Chris
  2005-04-05  8:39       ` M.Baris Demiray
  2005-04-05  9:06       ` Chris
  2 siblings, 2 replies; 9+ messages in thread
From: Chris @ 2005-04-04 14:32 UTC (permalink / raw)
  To: linux-c-programming

Hi all,
Lets assume we have a very very big array with sequential integer numbers
from 1-30000, but we have some slots that are empty.
Which is the faster way(algorithm maybe) that we can track those empty
slots???


Best regards,
Chris.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Array Empty Slots
  2005-04-04 14:32     ` Array Empty Slots Chris
@ 2005-04-05  8:39       ` M.Baris Demiray
  2005-04-05  9:06       ` Chris
  1 sibling, 0 replies; 9+ messages in thread
From: M.Baris Demiray @ 2005-04-05  8:39 UTC (permalink / raw)
  To: Chris; +Cc: linux-c-programming

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]


Chris wrote:
> Hi all,

Hi,

> Lets assume we have a very very big array with sequential integer numbers
> from 1-30000, but we have some slots that are empty.
> Which is the faster way(algorithm maybe) that we can track those empty
> slots???

A very common approach is using a linked list. Also, if you implement
a separate list for empty slots, your searches will be much faster.
OTOH, as you may guess, additional overhead will occur because of the
maintenance of the extra list.

Another option could be using a bitmap for _all_ (not only for empty
ones) slots. There are special instructions in many architectures
(like bsfl in i386) for the job "find first bit set" (hint, this is
the search keyword) and could be used inlined. I think that will be
much faster than searching a linked list.

Regards

> 
> 
> Best regards,
> Chris.

-- 
"You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
                                                         Morpheus

[-- Attachment #2: baris.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]

begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Labris Teknoloji
adr:;;Teknokent Silikon Bina No:24 ODTU;Ankara;;06531;Turkey
email;internet:baris@labristeknoloji.com
title:Yazilim Gelistirme Uzmani
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE
url:http://www.labristeknoloji.com
version:2.1
end:vcard


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Array Empty Slots
  2005-04-04 14:32     ` Array Empty Slots Chris
  2005-04-05  8:39       ` M.Baris Demiray
@ 2005-04-05  9:06       ` Chris
  2005-04-05 15:03         ` M.Baris Demiray
  1 sibling, 1 reply; 9+ messages in thread
From: Chris @ 2005-04-05  9:06 UTC (permalink / raw)
  To: linux-c-programming

Hi all, thanks for your quick responses on the subject.
What i am looking for is a procedural algorithm that has to provide a fast
solution.The well known constraints are small memory footprint and lack of
computing power is really a concern, but most of all is that the array is
bigger and bigger over time, because it is and array constructed from a
database query through a C API interface.
The bottleneck in the final application is this point, where the algorithm
searches the array to find the empty slots and then fill those slots with
data.
Is there really sth that can 'dissapear' that bottleneck? Do u have any
suggestions??


Best regards,
Chris.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Array Empty Slots
  2005-04-05  9:06       ` Chris
@ 2005-04-05 15:03         ` M.Baris Demiray
  0 siblings, 0 replies; 9+ messages in thread
From: M.Baris Demiray @ 2005-04-05 15:03 UTC (permalink / raw)
  To: Chris; +Cc: linux-c-programming

[-- Attachment #1: Type: text/plain, Size: 1612 bytes --]


Hi Chris,

Chris wrote:
 > ..
> The well known constraints are small memory footprint 

Well, then using a bitmap looks like a better solution. Since a minimal
node (a integer value and the next one's address) in a linked list takes
~64 bits but it'll take 1 bit in a bitmap.

But, you should calculate and compare the possible memory requirements
before ignoring the use of separate empty record list method. Since its
implementation will be much more easier than the former.

> and lack of
> computing power is really a concern, 

I think the computer itself is the real bottleneck :-)

 > but most of all is that the array is
> bigger and bigger over time, because it is and array constructed from a
> database query through a C API interface.

May be you should leave the job to DBMS by querying empty
records. I'm sure that it'll handle it more efficiently.

Also, adding a Boolean field for empty/full status and creating
an index for it will also be a good solution. But, this path ends
in off-topic.

Some benchmarking is required to tell the final word.

Regards.

> The bottleneck in the final application is this point, where the algorithm
> searches the array to find the empty slots and then fill those slots with
> data.
> Is there really sth that can 'dissapear' that bottleneck? Do u have any
> suggestions??
> 
> 
> Best regards,
> Chris.

-- 
"You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
                                                         Morpheus

[-- Attachment #2: baris.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]

begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Labris Teknoloji
adr:;;Teknokent Silikon Bina No:24 ODTU;Ankara;;06531;Turkey
email;internet:baris@labristeknoloji.com
title:Yazilim Gelistirme Uzmani
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE
url:http://www.labristeknoloji.com
version:2.1
end:vcard


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-04-05 15:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-22 17:05 strace write/read output Fabio Miranda Hamburger
2005-03-22 19:05 ` Eric Bambach
2005-03-22 18:16   ` Fabio Miranda Hamburger
2005-03-23  2:17     ` Eric Bambach
2005-03-23 17:34     ` Rechberger Markus
2005-04-04 14:32     ` Array Empty Slots Chris
2005-04-05  8:39       ` M.Baris Demiray
2005-04-05  9:06       ` Chris
2005-04-05 15:03         ` M.Baris Demiray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).