Bug 382 - oprofile-viewer connect to oprofile-server takes forever for PPC
Summary: oprofile-viewer connect to oprofile-server takes forever for PPC
Status: VERIFIED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: 1.0
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.0 M2
Assignee: Lianhao Lu
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2010-10-01 10:27 UTC by Jessica
Modified: 2010-12-28 23:29 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified: Program Management
Documentation change: ---


Attachments
0001-Fixed-bug-382-and-other-critical-errors (16.70 KB, patch)
2010-11-16 21:58 UTC, Lianhao Lu
no flags Details | Diff
Patch for bug 382 and other critical errors (16.02 KB, patch)
2010-12-02 19:08 UTC, Lianhao Lu
no flags Details | Diff
Patch for bug 382 and other critical errors (16.03 KB, patch)
2010-12-05 19:36 UTC, Lianhao Lu
no flags Details | Diff
Patch for bug 382 and other critical errors (16.31 KB, patch)
2010-12-08 18:54 UTC, Lianhao Lu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jessica 2010-10-01 10:27:02 UTC
During testing of oprofile for PPC, once hit connect from oprofile-viewer to the remote oprofile-server, it sits there and never comes back nor time out.  Checking on ppc in qemu, the oprofileserver is started and the right port 4224 shows established
Comment 1 Lianhao Lu 2010-10-08 00:39:38 UTC
This is a bug in both oprofile-server & oprofile-viewer. It happens when the host and target architectures have different endians. The protocol used between oprofile-server & oprofile-viewer seems not defines the endian format, so both ther server & viewer treats the integer fields in the protocol packet in their native endian. This incompatibility causes this bug.
Comment 2 Dexuan Cui 2010-10-08 22:30:02 UTC
(In reply to comment #1)
> This is a bug in both oprofile-server & oprofile-viewer. It happens when the
> host and target architectures have different endians. The protocol used between
> oprofile-server & oprofile-viewer seems not defines the endian format, so both
> ther server & viewer treats the integer fields in the protocol packet in their
> native endian. This incompatibility causes this bug.

Thanks a lot to Lianhao's analysis! 

Let me make the bug's cause clearer:
1) ppc is big-endian system, so the binary oprofile-server in the target is build with big-endian;

2) Lianhao is corss-debugging the ppc target from an i386 system, so he builds a little-endian binary oprofile-viewer and uses it;

3) Because in oprofile-ui, the codes of oprofile-server and oprofile-viewer don't consider the conversion between host byte order and network byte order (Big-endian order) at all, so Lianhao gets the bug. Looks this is a desgin issue of oprofileui -- no cross-debugging was considered at all?  Maybe we should implement some macros like cpu_to_be and be_to_cpu and fix every places when oprofile-server/viewer sending/recving data to/from socket?

BTW: I heard arm and mips systems could be configured to either big-endian or little-endian?

Hi Josh, looks you were a main contributor to oprofile-ui. Could you please give some suggestions? Thanks a lot!
Comment 3 Dexuan Cui 2010-10-20 00:32:31 UTC
Hi Jessia, I saw you changed "Target Milestone" from "1.0 M1" to "0.9 M4". Do you mean we should still fix this bug in 0.9?
Comment 4 Jessica 2010-10-21 09:37:06 UTC
No, just bring it back to make it documented in the release note.
Comment 5 Dexuan Cui 2010-11-03 23:42:17 UTC
Lianhao would like to fix it, so let me re-assign back to him now. :-)
Comment 6 Lianhao Lu 2010-11-16 21:58:20 UTC
Created attachment 69 [details]
0001-Fixed-bug-382-and-other-critical-errors

This patch should be applied to oprofileUI svn rev 197 plus the patch of bug#493.(http://bugzilla.pokylinux.org/attachment.cgi?id=67)

1. Changed packet layout comptible for common network packet layout, and upgraded the protocol version to 5.

2. Changed server/client code to do endian conversion between host/net endian of integer field of protocol packet.

3. In client, fixed an original array dereference error when it needed multiple read operations to get a full response header.

4. In client, fixed an original error happened in the archive->filestat->get command chain. The error happened due to the mismatch of command and response.

5. In both server/code, fixed an error of misusing memset.
Comment 7 Lianhao Lu 2010-11-16 21:58:57 UTC
The patch is put here temporarily until we get it upstreamed.
Comment 8 Joshua Lock - Disabled 2010-12-02 06:40:48 UTC
Hi Lianhao,

First of all great work, some excellent debugging and bug fixes here.

As per bug#493 could you please adapt the patch to follow the style of the rest of the code. Specifically:

* the return type of a function should be on the line above the function name
* ensure there are spaces before opening brackets, ('s
* ensure there are spaces around =
* Please use C style (/* foo */) rather than 'C++'/C99 style (//) comments
* Ensure there are spaces between the comment symbol and them comment (i.e. 
// some comment 
and not 
//a comment
* The comments could be more informative - telling me what the code does is generally not very helpful, please explain why the code does that if there's a need to comment :-)
* Braces should be indented two spaces
* Please use a space after argument separators (,'s)
* As you've used g_warning() to print warning messages it seems right that g_debug() should be used in place of printf() for printing debug messages. That way you get the benefit of not polluting logs with debug messages on most systems. IIRC g_debug() also takes care of newlines

Also please check your patches for accidental introduction of inconsistent whitespaces, such as Ln696 in the patched server/opserver.c
Comment 9 Lianhao Lu 2010-12-02 19:08:03 UTC
Created attachment 74 [details]
Patch for bug 382 and other critical errors

This patch should be applied to oprofileUI svn rev 197 plus the patch of
bug#493.(http://bugzilla.pokylinux.org/attachment.cgi?id=73)

This patch added coding style fixing to the obsoleted patch which was committed in comment #6.

See comment #6 for details.
Comment 10 Joshua Lock - Disabled 2010-12-03 05:00:52 UTC
Thanks, this is looking better but you still have some incorrect indentation in places, such as line 112 in utils.c:

http://bugzilla.pokylinux.org/attachment.cgi?id=74&action=diff#a/protocol/util.c_sec2
Comment 11 Lianhao Lu 2010-12-05 19:36:33 UTC
Created attachment 75 [details]
Patch for bug 382 and other critical errors

This patch should be applied to oprofileUI svn rev 197 plus the patch of
bug#493.(http://bugzilla.pokylinux.org/attachment.cgi?id=73)

This patch added coding style fixing to the obsoleted patch which was committed
in comment #6.

Added spaces around "=".
Comment 12 Lianhao Lu 2010-12-08 18:54:49 UTC
Created attachment 77 [details]
Patch for bug 382 and other critical errors

This patch should be applied to oprofileUI svn rev 197 plus the patch of
bug#493.(http://bugzilla.pokylinux.org/attachment.cgi?id=73)

This patch added coding style fixing to the obsoleted patch.(using 2 whitespace indentation instead of 4).

See comment #6 for details.
Comment 13 Joshua Lock - Disabled 2010-12-10 07:39:38 UTC
Merged into the new oprofileui git repo
Comment 14 Jessica 2010-12-13 16:32:14 UTC
verified 12-13-10