|
本人在学习gdbserver的代码,由于本人在linux是一个尚未入门的新手,所以遇到了很多困难,我一般采取一边上网查资料,一边把自己的立即注释上去,虽然可能是错的,嘻嘻。
但是还是有许多不理解的地方,希望大家能帮帮我,先谢谢了。
- static unsigned char
- linux_wait (char *status)
- {
- int w;
- struct thread_info *child = NULL;
- retry:
- /* If we were only supposed to resume one thread, only wait for
- that thread - if it's still alive. If it died, however - which
- can happen if we're coming from the thread death case below -
- then we need to make sure we restart the other threads. We could
- pick a thread at random or restart all; restarting all is less
- arbitrary. */
- fprintf(stderr,"cont_thread = %d\n",cont_thread);
- if (cont_thread > 0)
- {
- child = (struct thread_info *) find_inferior_id (&all_threads,
- cont_thread);
- /* No stepping, no signal - unless one is pending already, of course. */
- if (child == NULL)
- {
- struct thread_resume resume_info;
- resume_info.thread = -1;
- resume_info.step = resume_info.sig = resume_info.leave_stopped = 0;
- linux_resume (&resume_info);
- }
- }
- /*使能异步阻塞处理:置标志async_io_enabled为1,指定对信号SIGIO的处理*/
- /*这个信号是如何产生的?可能是客户端发送连接请求或发送数据时产生的?*/
- enable_async_io ();
- /*解除对SIGSIO信号的阻塞*/
- unblock_async_io ();
- w = linux_wait_for_event (child);
- /*停止所有进程,发送SIGSTOP信号*/
- stop_all_processes ();
- /*非使能异步阻塞处理主要就是忽略对SIGIO信号的处理*/
- disable_async_io ();
- /* If we are waiting for a particular child, and it exited,
- linux_wait_for_event will return its exit status. Similarly if
- the last child exited. If this is not the last child, however,
- do not report it as exited until there is a 'thread exited' response
- available in the remote protocol. Instead, just wait for another event.
- This should be safe, because if the thread crashed we will already
- have reported the termination signal to GDB; that should stop any
- in-progress stepping operations, etc.
- Report the exit status of the last thread to exit. This matches
- LinuxThreads' behavior. */
- if (all_threads.head == all_threads.tail)
- {
- if (WIFEXITED (w))
- {
- fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
- *status = 'W';
- clear_inferiors ();
- free (all_processes.head);
- all_processes.head = all_processes.tail = NULL;
- return ((unsigned char) WEXITSTATUS (w));
- }
- else if (!WIFSTOPPED (w))
- {
- fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
- *status = 'X';
- clear_inferiors ();
- free (all_processes.head);
- all_processes.head = all_processes.tail = NULL;
- return ((unsigned char) WTERMSIG (w));
- }
- }
- else
- {
- if (!WIFSTOPPED (w))
- goto retry;
- }
- *status = 'T';
- return ((unsigned char) WSTOPSIG (w));
- }
复制代码
我想问的是sigio信号是如何产生的,如果我是主机与gdbserver通讯的话,何时产生sigio信号,是谁产生的?还有就是大家都说sigint是键盘中断,这个中断又是如何和sigint信号挂上钩的?我问的问题可能比较弱,别笑,我刚学。。。在此拜谢了 |
|