VELT-0.1.5开发: gdb串口调试内核时信息丢失的问题

快乐虾

http://blog.csdn.net/lights_joy/(QQ群:Visual EmbedLinux Tools 375515651)

欢迎转载,但请保留作者信息

本文仅适用于vs2013 + velt-0.1.5



VELT的全称是Visual EmbedLinuxTools,它是一个与visual gdb类似的visual studio插件,用以辅助完成Linux开发。利用这个插件,将可以在visual studioIDE中进行Linux应用程序的开发(包括编译和调试),也可以进行ubootlinux内核的编译,并根据编译时的错误信息正确定位到源码。目前的版本是0.1.4,仅支持vs2013。此插件可以在CSDN下载频道下载(http://download.csdn.net/detail/lights_joy/8429771。下面是它的基本功能:

  1. 支持x86 Linux,海思hi3516/hi3520MinGW这几个平台,提供这几个平台的项目模板。

  2. 完成UBOOT的编译,并根据编译的错误信息自动定位到相应的文件位置。

  3. 完成LINUX内核的编译,并根据编译的错误信息自动定位到相应的文件位置。

  4. VS下完成Linux内核的配置。

  5. 不使用Makefile进行Linux应用程序的编译。

  6. 使用Makefile进行Linux应用程序的开发。

  7. 使用SSH连接目标机器并用gdb进行应用程序的调试。

  8. 使用Telnet连接目标机器并用gdb进行应用程序的调试。

  9. VS中集成Linux终端(Poderosa),支持SSH/Telnet/Com,在打开终端时自动将VS的变量导出为bash里的变量,如ProjectDir等。 



当用gdb-7.8.2通过串口调试内核时,gdb并不显示内核的输出信息,或者仅能显示部分的输出信息,这对于内核调试而言很不方便。查了下gdb的代码,当gdb从串口上读取字符时是这样的:


static int
getpkt_or_notif_sane_1(char **buf, long *sizeof_buf, int forever,
int expecting_notif, int *is_notif)
{
......

	/* Process any number of notifications, and then return when
	   we get a packet.  */
	for (;;)
	{
		/* If we get a timeout or bad checksum, retry up to MAX_TRIES
	   times.  */
		for (tries = 1; tries <= MAX_TRIES; tries++)
		{
			/* This can loop forever if the remote side sends us
			   characters continuously, but if it pauses, we'll get
			   SERIAL_TIMEOUT from readchar because of timeout.  Then
			   we'll count that as a retry.

			   Note that even when forever is set, we will only wait
			   forever prior to the start of a packet.  After that, we
			   expect characters to arrive at a brisk pace.  They should
			   show up within remote_timeout intervals.  */
			do
				c = readchar(timeout);
			} while (c != SERIAL_TIMEOUT && c != '$' && c != '%');

			if (c == SERIAL_TIMEOUT)
			{
......
			}
			else
			{
				/* We've found the start of a packet or notification.
			   Now collect the data.  */
				val = read_frame(buf, sizeof_buf);
				if (val >= 0)
					break;
			}

			remote_serial_write("-", 1);
		}
......
	}
}

当接收到的数据不是$或者%时,gdb直接丢弃,内核的输出信息就此惨遭毒手!


输出这些信息:

			/* This can loop forever if the remote side sends us
			   characters continuously, but if it pauses, we'll get
			   SERIAL_TIMEOUT from readchar because of timeout.  Then
			   we'll count that as a retry.

			   Note that even when forever is set, we will only wait
			   forever prior to the start of a packet.  After that, we
			   expect characters to arrive at a brisk pace.  They should
			   show up within remote_timeout intervals.  */
			do
			{
				c = readchar(timeout);
				if (c != SERIAL_TIMEOUT && c != '$' && c != '%')
					putchar(c);
			} while (c != SERIAL_TIMEOUT && c != '$' && c != '%');



这样就没问题了!
















你可能感兴趣的:(linux,VS2013,velt)