Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Amdahl

macrumors 65816
Original poster
Jul 28, 2004
1,438
1
I've got Xcode 3 on MBP. I was able to compile a ppc-only console app by using vi to edit the project file and specify ppc as the arch. (Instead of the NATIVE_ARCH).

The app runs correctly, so I believe it is built properly.

Can gdb be used either in Xcode or terminal to debug a ppc-only app on an i386 platform?

The gdb takes parameters that would make it appear this is possible (--translate & -arch), but when I try, I get some bizarre errors from gdb as the program starts running, and it then hangs and has to be killed.

I'm doing: gdb --translate -arch=ppc myprog

Any comments appreciated.
 

Krevnik

macrumors 601
Sep 8, 2003
4,100
1,308
I've got Xcode 3 on MBP. I was able to compile a ppc-only console app by using vi to edit the project file and specify ppc as the arch. (Instead of the NATIVE_ARCH).

The app runs correctly, so I believe it is built properly.

Can gdb be used either in Xcode or terminal to debug a ppc-only app on an i386 platform?

The gdb takes parameters that would make it appear this is possible (--translate & -arch), but when I try, I get some bizarre errors from gdb as the program starts running, and it then hangs and has to be killed.

I'm doing: gdb --translate -arch=ppc myprog

Any comments appreciated.

First off, you don't need to edit the project file by hand like that. There is a build option in XCode (2 & 3) that lets you specify the build architectures.

Secondly, the easiest way to find out if it works is to setup the arch in XCode, clean the project, and then build it. Set a breakpoint, kick off the app and see if it breaks on the breakpoint.
 

Amdahl

macrumors 65816
Original poster
Jul 28, 2004
1,438
1
First off, you don't need to edit the project file by hand like that. There is a build option in XCode (2 & 3) that lets you specify the build architectures.
I guess I should have explained. Xcode 3 GUI appears to be incapable of setting a project to build to only the opposite architecture. Try it yourself. I'm using a command-line project template.

Secondly, the easiest way to find out if it works is to setup the arch in XCode, clean the project, and then build it. Set a breakpoint, kick off the app and see if it breaks on the breakpoint.

It doesn't even start running in gdb. It says Bad CPU type in executable. Perhaps I need to edit something else in the project? But in any case, I still can't seem to get it to work in gdb from command line, while the parameters seem to indicate it should work. It actually starts as a PPC app, but it craps out with some bizarre errors.
Code:
warning: error on line 139 of "/SourceCache/gdb/gdb-768/src/gdb/macosx/macosx-nat-infthread.c" in function "modify_trace_bit": (os/kern) invalid argument (0x4x)
warning: error on line 233 of "/SourceCache/gdb/gdb-768/src/gdb/macosx/macosx-nat-infthread.c" in function "prepare_threads_after_stop": (os/kern) invalid argument (0x4x)
Error calling thread_get_state for GP registers for thread 0x15635lxerror on line 81 of "/SourceCache/gdb/gdb-768/src/gdb/macosx/ppc-macosx-nat-exec.c" in function "fetch_inferior_registers": (os/kern) invalid argument (0x4)
 

Krevnik

macrumors 601
Sep 8, 2003
4,100
1,308
I guess I should have explained. Xcode 3 GUI appears to be incapable of setting a project to build to only the opposite architecture. Try it yourself. I'm using a command-line project template.

I just did it with an Obj-C template. You do have to be building and editing the same configuration, however.

I was unable to debug a PPC-only binary using XCode, so the odds are that any debugger support for it is incomplete.

My next question is: Why do you need to debug a PPC-only binary on an x86? Are you running into a PPC-only bug?
 

Amdahl

macrumors 65816
Original poster
Jul 28, 2004
1,438
1
I just did it with an Obj-C template. You do have to be building and editing the same configuration, however.
You got it to show just "ppc" under the "Architectures" setting?

My next question is: Why do you need to debug a PPC-only binary on an x86? Are you running into a PPC-only bug?

I'm working on PPC optimization for a program with asm. I usually am working on a G5, but my only laptop is x86. It would be nice to be able to work on it there, even if it is emulation. I'll try Xcode 2.4 on Tiger/x86 in the next couple of days and see if it works.
 

Amdahl

macrumors 65816
Original poster
Jul 28, 2004
1,438
1
I just downloaded Xcode 2.5 and installed on Tiger/x86. Xcode 2.5 does not have the bug that prevents building PPC only.

But the debugger doesn't work on it, either in Xcode or command line. It gives roughly the same error. Oh well. Guess you need a PPC to debug for PPC.
 

Krevnik

macrumors 601
Sep 8, 2003
4,100
1,308
But the debugger doesn't work on it, either in Xcode or command line. It gives roughly the same error. Oh well. Guess you need a PPC to debug for PPC.

There is the option to do remote debugging (I believe), but that probably won't work in your case.

In any case, trying to do PPC optimization using an emulator is not going to give you a lot of accurate data. The sort of optimizations that help PPC code run faster on x86 don't always apply for live PPC processors.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.