多进程调试问题!

在QNX下,对多进程程序的动态调试可以采用何种方式?可以说的具体一点吗?
法一:我在一个资料上看到说IDE中有一个线程监控工具,但是如何设置?
法二:在另一份资料上看到了一个Watcom Debugger(WD)多进程程序的动态调试工具。但是,为什么我输入#wd后提示无此命令。
情大家帮忙!
多谢!

和用IDE作一般的DEBUG差不多.

多进程,比如两个进程,可以先跑一个,再跑另一个.他们互不影响,会停在自己的断点处.你可以开两个DEBUG VIEW来观察它们.

多线程,需要知道一点.同一进程里,当一个线程停在断点上,其它线程也会停在它们当前的位置.
如果是跑同一段代码的多线程.可以在断点上点右键,加上一些条件,如Breakpoint properties → Condition: pthread_self()==2 等.

为什么我的没有WD命令呢 ?
我刚开始接触进程/线程,但是习惯了main函数的顺序结构。看书上线程的文字介绍,很形象,很生动,但到了程序编写上就乱了,逻辑总是转不过来。能给点建议吗?最好给个典型的程序!我看了资料上关于抢占优先级的进程/ 线程设计,没有给过什么典型的例子,那位帮个忙,抛块砖呀!!谢了!

/*
 * This program executes the program and arguments
 * specified by argv[1..argc].  The standard input
 * of the executed program is converted to upper
 * case.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <process.h>
#include <sys/wait.h>

int main( int argc, char **argv )
  {
    pid_t pid;
    pid_t wpid;
    int   fd[2];
    char  buffer[80];
    int   i, len;
    int   status;

    if( pipe( fd ) == -1 ) {
       perror( "pipe" );
       return EXIT_FAILURE;
    }

    if( ( pid = fork() ) == -1 ) {
       perror( "fork" );
       return EXIT_FAILURE;
    }

    if( pid == 0 ) {
      /* This is the child process.
       * Move read end of the pipe to stdin ( 0 ),
       * close any extraneous file descriptors,
       * then use exec to 'become' the command.
       */
      dup2( fd[0], 0 );
      close( fd[1] );
      execvp( argv[1], argv+1 );

  /* This can only happen if exec fails; print message
   * and exit.
   */
      perror( argv[1] );
      return EXIT_FAILURE;
    } else {
      /* This is the parent process.
       * Remove extraneous file descriptors,
       * read descriptor 0, write into pipe,
       * close pipe, and wait for child to die.
       */
      close( fd[0] );
      while( ( len = read( 0, buffer, sizeof( buffer ) )
          ) > 0 ) {
        for( i = 0; i < len; i++ ) {
          if( isupper( buffer[i] ) )
            buffer[i] = tolower( buffer[i] );
        }
        write( fd[1], buffer, len );
      }
      close( fd[1] );
      do {
        wpid = waitpid( pid, &status, 0 );
      } while( WIFEXITED( status ) == 0 );
      return WEXITSTATUS( status );
    }
  }

QNX HELP 上关于 fork() 的一个例子.搞明白了多进程,多线程也容易理解.如果一时搞不清楚多进程是怎么运行的.把这个代码打印两份.用笔写运行的线.一条跑parent process一条跑child process.也就是在fork的时候它们一分为二了,各跑各的.
多线程也差不多.只不过多线程有时候跑的是同一份代码.想不明白的时候打印两份好了.应该是不错的方法吧.

wd 是QNX版本4里的东西,在QNX6里被gdb和ide所代替。