Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix err syntax #35609

Closed
DiskGetor opened this issue Nov 15, 2019 · 4 comments

Comments

@DiskGetor
Copy link

@DiskGetor DiskGetor commented Nov 15, 2019

like this:

#pragma warning(disable:4996)

int OpenError() {
return 1+1;
}

int ok() {
auto f = OpenError();
if (f == 2) {
_asm {
MOV EAX,ESP
JMP EAX
}
}
std::cout << "Hello 1!\n";
}

int main(){
ok();
std::cout << "Hello 2!\n";
}

func (ddk) CheckErrWithCtx(ctx interface{}, err error) interface{} {
if err != nil {
W.LogError(错误 , err.Error())
//debug.PrintStack()
//用汇编改RIP为rsp+8的值?
panic(err.Error())
}
return ctx
}

@DiskGetor

This comment has been minimized.

Copy link
Author

@DiskGetor DiskGetor commented Nov 15, 2019

最后变成这样:
Hostname := W.CheckErrWithCtx(os.Hostname()).(string)

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Nov 15, 2019

I'm sorry, I don't understand this. You are showing C code. Are you reporting a problem in Go? What is the problem?

@DiskGetor

This comment has been minimized.

Copy link
Author

@DiskGetor DiskGetor commented Nov 15, 2019

对不起,我很难表达,请看例子:

package main

import (
"log"
"os"
"runtime/debug"
)

func main() {
CallMain()
}
func CallMain() {
Hostname()
log.Println(if err go to here)
}

func Hostname(){
//if err != nil {
//
//}
Hostname := CheckErrWithCtx(os.Hostname()).(string)
log.Println(Hostname)
}

func CheckErrWithCtx(ctx interface{}, err error) interface{} {
if err != nil {
debug.PrintStack()
//asm to-->return rsp //怎么实现汇编改变rip? goto-->log.Println(if err go to here)
}
return ctx
}

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Nov 15, 2019

For questions about Go, see https://golang.org/wiki/Questions.

We don't use the issue tracker for general questions about Go.

@bradfitz bradfitz closed this Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.