Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » patch Gdb_MI parser
patch Gdb_MI parser [message #44531] Tue, 24 March 2015 17:12 Go to next message
omari is currently offline  omari
Messages: 193
Registered: March 2010
Experienced Member
Hi,
I am playing with gdb MI, with the command "file-list-exec-source-files"
and i found that, gdb split the output, 1024 character per line.
if a line has more than 1024 character, gdb insert an "\n" and continue in the next line.

here a part of the output:

^done,files=[{file="../../../../../src/gcc-4.9.2/libgcc/libgcc2.c",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/libgcc2.c"},{file="../../../../../src/gcc-4.9.2/libgcc/../libgcc/config/i386/shmem-win32.c",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/../libgcc/config/i386/shmem-win32.c"},{file="../../../../../src/gcc-4.9.2/libgcc/libgcc2.c",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/libgcc2.c"},{file="../../../../../src/gcc-4.9.2/libgcc/libgcc2.c",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/libgcc2.c"},{file="../../../../../src/gcc-4.9.2/libgcc/libgcc2.c",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/libgcc2.c"},{file="../../../../../src/gcc-4.9.2/libgcc/config/i386/cygwin.S",fullname="C:\\crossdev\\gccmaster\\buil
d-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/config/i386/cygwin.S"},{file="../../../../../src/gcc-4.9.2/libgcc/unwind.inc",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/unwind.inc"},{file="./gthr-default.h",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/./gthr-default.h"},{file="../../../../../src/gcc-4.9.2/libgcc/unwind-sjlj.c",fullname="C:\\crossdev\\gccmaster\\build-tdm32\\gcc\\mingw32\\libgcc/../../../../../src/gcc-4.9.2/libgcc/unwind-sjlj.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_xclass.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_xclass.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_version.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_version.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_valid_utf8.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_valid_utf8.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_try_flipped.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_try_flippe
d.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_study.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_study.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_refcount.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_refcount.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_ord2utf8.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_ord2utf8.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_newline.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_newline.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_maketables.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_maketables.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_info.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_info.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_get.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_get.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_fullinfo.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_fullinfo.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_exec.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\
pcre_exec.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_dfa_exec.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_dfa_exec.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_config.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_config.c"},{file="C:/upp/uppsrc/plugin/pcre/lib/pcre_compile.c",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib\\pcre_compile.c"},{file="C:/upp/uppsrc/plugin/pcre/lib.cpp",fullname="C:\\upp\\uppsrc\\plugin\\pcre\\lib.cpp"},{file="C:/upp/uppsrc/Core/Defs.h",fullname="C:\\upp\\uppsrc\\Core\\Defs.h"},{file="C:/upp/uppsrc/Core/Cbgen.h",fullname="C:\\upp\\uppsrc\\Core\\Cbgen.h"},{file="C:/upp/uppsrc/Core/Vcont.hpp",fullname="C:\\upp\\uppsrc\\Core\\Vcont.hpp"},{file="C:/upp/uppsrc/Core/Vcont.h",fullname="C:\\upp\\uppsrc\\Core\\Vcont.h"},{file="C:/upp/uppsrc/Core/Value.hpp",fullname="C:\\upp\\uppsrc\\Core\\Value.hpp"},{file="C:/upp/uppsrc/Core/AString.hpp",fullname="C:\\upp\\uppsrc\\Core\\AString.hpp"},{file="C:/upp/uppsrc/Core/Format.h",fullname="C:\\upp\\uppsrc\\Core\\Format.h"},{file="
...
...
...
(gdb)



then i propose this patch:

in function Gdb_MI2::ParseGdb
file Gdb_MI2Gdb.cpp
line 51:
		String s = TrimBoth(ss.GetLine());

to be replaced by:
		String s;
		String str = ss.GetLine();
		s = str;
		while(str.GetCount() == 1024 && !ss.IsEof())
		{
			str = ss.GetLine();
			s << str;
		}
		
		s = TrimBoth(s);



best regards
omari.
Re: patch Gdb_MI parser [message #44533 is a reply to message #44531] Tue, 24 March 2015 17:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12122
Registered: November 2005
Ultimate Member
Thanks, patch applied.

Mirek
Re: patch Gdb_MI parser [message #44569 is a reply to message #44533] Wed, 01 April 2015 19:27 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 193
Registered: March 2010
Experienced Member
Thanks you Mirek,

more investigation, the origine of the 1024 character per line is the AProcess::Read(String&), the internal buffer size of this function is 1024.

then the patch can be reverted, and replaced by this one:

in function
MIValue Gdb_MI2::ReadGdb(bool wait)

replace :
		dbg->Read(s);
		StringStream ss(s);



by
		String sc;
		do
		{
			s = "";
			dbg->Read(s);
			sc << s;
		}while(s.GetCount());
		
		StringStream ss(sc);



call dbg-Read() in a loop in order to read all available data.


I think it is interesting to add a function String AProcess::ReadAllAvailable(), or a global function String ReadAvailable(AProcess&).

this patch resolve the issue described in MIValue Gdb_MI2::MICmd( const char *cmdLine) as a comment:
	// consume previous output from gdb... don't know why sometimes
	// is there and gives problems to MI interface. We shall maybe
	// parse and store it somewhere
	ReadGdb(false);



with this patch, the call to ReadGdb(false) in not needed.


regards
omari.

[Updated on: Wed, 01 April 2015 19:31]

Report message to a moderator

Re: patch Gdb_MI parser [message #44572 is a reply to message #44569] Thu, 02 April 2015 10:13 Go to previous message
omari is currently offline  omari
Messages: 193
Registered: March 2010
Experienced Member
discussion continues in another thread : http:// www.ultimatepp.org/forums/index.php?t=msg&goto=44571& ;#msg_44571

regards
omari.
Previous Topic: apps built depends on libstdc++
Next Topic: [BUG?] MIValue
Goto Forum:
  


Current Time: Tue Dec 10 12:16:34 CET 2019

Total time taken to generate the page: 0.01508 seconds