Re: [fossil-users] cgi.c

2010-05-25 Thread Richard Hipp
The debugging technique I normally use is to run the "fossil http" command
directly from the debugger.  The HTTP request can be either manually typed
in, or redirected from a file.

-- 
-
D. Richard Hipp
d...@sqlite.org
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] cgi.c

2010-05-25 Thread zachtodd
Hey,

Thanks for the link.  I eventually came around to the same technique in ddd, 
putting a sleep call in the function that the child executes, using ps to find 
the parent process id, and then attaching to the child with ddd.



___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] cgi.c

2010-05-25 Thread Rüdiger Härtel
Hi!

If you want to debug a child process then you have to tell gdb to do so. See 
this website:

http://www.delorie.com/gnu/docs/gdb/gdb_26.html

Ruediger


Am Mittwoch 12 Mai 2010 17:41:00 schrieb zacht...@cis-partners.com:
> I don't understand how the fossil web server is interacting with the child
>  processes that it launches.  I see the code in cgi.c that does the
>  launching, but I don't see how the child processes actually know what it
>  is they should be doing.
> 
> if( select( listener+1, &readfds, 0, 0, &delay) ){
>   lenaddr = sizeof(inaddr);
>   connection = accept(listener, (struct sockaddr*)&inaddr,
> (socklen_t*) &lenaddr);
>   if( connection>=0 ){
> child = fork();
> if( child!=0 ){
>   if( child>0 ) nchildren++;
>   close(connection);
> }else{
>   close(0);
>   dup(connection);
>   close(1);
>   dup(connection);
>   if( !g.fHttpTrace && !g.fSqlTrace ){
> close(2);
> dup(connection);
>   }
>   close(connection);
>   return 0;
> }
>   }
> }
> 
> Furthermore, I am trying to debug some web functions that I have written
>  using ddd, but that is monitoring only the server process.  Does anyone
>  have some advice on how I might debug my web functions?
> 
> Thanks.
> 
> ___
> fossil-users mailing list
> fossil-users@lists.fossil-scm.org
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
> 
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] cgi.c

2010-05-12 Thread Eric

> I don't understand how the fossil web server is interacting with the child
> processes that it launches.  I see the code in cgi.c that does the
> launching, but I don't see how the child processes actually know what it
> is they should be doing.
>
> if( select( listener+1, &readfds, 0, 0, &delay) ){
>   lenaddr = sizeof(inaddr);
>   connection = accept(listener, (struct sockaddr*)&inaddr,
> (socklen_t*) &lenaddr);
>   if( connection>=0 ){
> child = fork();
> if( child!=0 ){
>   if( child>0 ) nchildren++;
>   close(connection);
> }else{
>   close(0);
>   dup(connection);
>   close(1);
>   dup(connection);
>   if( !g.fHttpTrace && !g.fSqlTrace ){
> close(2);
> dup(connection);
>   }
>   close(connection);
>   return 0;
> }
>   }
> }
>
> Furthermore, I am trying to debug some web functions that I have written
> using ddd, but that is monitoring only the server process.  Does anyone
> have some advice on how I might debug my web functions?
>
> Thanks.
>

The code you have included is all the interaction there is! It shows the
child process getting the connection it has been given and attaching it to
stdin and stdout (and maybe stderr). The code then just returns from the
function cgi_http_server which contains it (the server never returns, it
is in an infinite loop just listening). This means that you have to look
just after where cgi_http_server is called in main.c . There you will see
that it finds its repository, enters the chroot jail (if appropriate),
uses cgi_handle_http_request to parse the incoming HTTP request (which it
gets from stdin, i.e. the connection socket), then calls
process_one_web_page to do whatever the global variables resulting from
the parse tell it to do.

I don't know the answer to your debugging question, but you might benefit
from fossil's approach - there is a way to run pretty much any code
without being in server mode!

HTH

Eric

-- 


___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


[fossil-users] cgi.c

2010-05-12 Thread zachtodd
I don't understand how the fossil web server is interacting with the child 
processes that it launches.  I see the code in cgi.c that does the launching, 
but I don't see how the child processes actually know what it is they should be 
doing.

if( select( listener+1, &readfds, 0, 0, &delay) ){
  lenaddr = sizeof(inaddr);
  connection = accept(listener, (struct sockaddr*)&inaddr,
(socklen_t*) &lenaddr);
  if( connection>=0 ){
child = fork();
if( child!=0 ){
  if( child>0 ) nchildren++;
  close(connection);
}else{
  close(0);
  dup(connection);
  close(1);
  dup(connection);
  if( !g.fHttpTrace && !g.fSqlTrace ){
close(2);
dup(connection);
  }
  close(connection);
  return 0;
}
  }
} 

Furthermore, I am trying to debug some web functions that I have written using 
ddd, but that is monitoring only the server process.  Does anyone have some 
advice on how I might debug my web functions?

Thanks.

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users