Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367456 - MIParser translateCString backslash parsing issue
Summary: MIParser translateCString backslash parsing issue
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.1.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on: 222568
Blocks: 307311
  Show dependency tree
 
Reported: 2011-12-22 15:16 EST by Mathias Kunter CLA
Modified: 2012-03-06 09:55 EST (History)
2 users (show)

See Also:


Attachments
Proposed fix for bug 367456 (3.31 KB, patch)
2011-12-22 15:22 EST, Mathias Kunter CLA
marc.khouzam: iplog+
marc.khouzam: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Kunter CLA 2011-12-22 15:16:59 EST
Build Identifier: I20110613-1736

This bug is related to Bug 222568 and Bug 307311. MIParser's translateCString function doesn't properly parse the gdb/MI backslash escaping.

The issue is that gdb doesn't escape backslashes within stream records, while it does escape them within result and out of band records. Steps to reproduce:

Compiling and debugging the following simple test program

int main()
{
	const char *s = "back\\slash";
	return 0;
}

and looking at the gdb/MI traces shows that the backslash is escaped by gdb by using 4 backslashes:

737,828 23-stack-list-locals --thread 1 --frame 0 1
737,828 23^done,locals=[{name="s",value="0x403064 \"back\\\\slash\""}]

However, compare that to the gdb/MI traces of a simple gdb echo command:

835,421 29-interpreter-exec console "echo back\\\\slash"
835,437 ~"back\\slash"
835,437 29^done

Now gdb uses 2 backslashes to escape the single backslash. However, both the

"0x403064 \"back\\\\slash\""

and the

~"back\\slash"

string are parsed by translateCStrings(). So translateCStrings() obviously must differ between those two situations in order to properly parse the gdb/MI backslash escaping.

The reason why the current implementation works is that the MIConst class itself cares about the gdb/MI backslash escaping as well. But that's a quite unclean implementation. A proper handling of the MI backslash escaping is furthermore required to fix Bug 307311.

A proposed fix for this bug is attached. It simply adds a boolean parameter to the translateCStrings() function which switches the backslash escaping on or off, depending on the current gdb record type.

Note that this fix relies on the proposed fix for Bug 307311.

Reproducible: Always
Comment 1 Mathias Kunter CLA 2011-12-22 15:22:27 EST
Created attachment 208751 [details]
Proposed fix for bug 367456
Comment 2 Marc Khouzam CLA 2012-02-01 10:40:20 EST
I'm ok with this patch, but as you pointed out, we need to commit it at the same time as Bug 307311.

Could you include this patch in the patch for Bug 307311, so that they happen in the same commit.  Once the one commit is done, we'll mark both bugs as resolved.

Thanks!
Comment 3 Mathias Kunter CLA 2012-02-08 08:12:33 EST
(In reply to comment #2)
> Could you include this patch in the patch for Bug 307311

Just for the records: this has been done by 2012-02-01. So please see bug 307311 for any further details about this issue.
Comment 4 Marc Khouzam CLA 2012-03-06 09:53:50 EST
This bug has been fixed as part of bug 307311.

Thanks Mathias for your efforts.