Re: I'd like to be able to set registers directly
Re: I'd like to be able to set registers directly
- Subject: Re: I'd like to be able to set registers directly
- From: Gordo Cath <email@hidden>
- Date: Thu, 07 Jul 2016 09:25:18 -0400
Hi William,
Thanks for the help. I'm guessing the register keyword doesn't address variables directly or doesn't do what I thought it was doing. I'm a bit new to apple.
What I've discovered is in my thread is I have no standard I/O where I'm crashing so I have no print or logging capability. Thus I'm now leaning towards using unused registers to figure out where its crashing. I also don't have a good way to use a debugger afaik unless I could trigger the debugger at crash time. it used to do so but for some reason it isn't doing it now. I have the nvram settings setup to do so but its not triggering.
gordo
> -------Original Message-------
> From: William Kucharski <email@hidden>
> To: Gordo Cath <email@hidden>
> Cc: email@hidden
> Subject: Re: I'd like to be able to set registers directly
> Sent: Jul 07 '16 08:56
>
>
> > On Jul 7, 2016, at 6:36 AM, Gordo Cath <email@hidden> wrote:
> >
> > Hi,
> > I'd like to be able to set a register directly from my c code. I'm using the llvm compiler in a x86_64 build/run environment.
> >
> > When I compile and link the following code I get no errors or warnings:
> >
> > I used the thread_create_running function and during setup set the r11 register to 0xBEAD as a start state using x86_thread_state64_t .
> >
> > ///snippet---- at the very start of my thread I have the following tidbit of code:
> > register uint64_t r11 asm("r11");
> > r11=0xfade; // some value -- don't care about the value, just want my value set.
> > //end snippet
>
> What, precisely, are you trying to do? As far as I know, that asm syntax is just wrong.
>
> I would expect to see something like this for x86_64:
>
> #include <stdio.h>
> #include <sys/types.h>
>
> int
> main()
> {
> int64_t r11;
>
> r11 = 0xc01ddeadbeef; /* init r11 */
>
> asm ("movq %0, %%r11" :: "r"(r11) : "r11"); /* move r11 to %r11 */
> r11 = 0; /* zero r11 */
> asm ("movq %%r11, %0" : "=r"(r11) ::); /* move %r11 to r11 */
>
> (void) printf("%llx\n", r11); /* verify %r11 */
> return 0;
> }
>
>
> William Kucharski
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden