moshebe/gebug

Debugger with aws-lambda-rie

Closed this issue · 3 comments

When running the config below with the debugger enabled I get the following error:

could not launch process: could not open debug info - debuggee must not be built with 'go run' or -ldflags='-s -w', which strip debug info

If I run it with debug disabled, it builds and works correctly. I was using a simple hello world main. Is there a way to have debugging with rie?

Thanks

name: relay
output_binary: /usr/local/bin/aws-lambda-rie /var/task/main
build_command: go build -o /var/task/main
build_dir: /src
run_command: '{{.output_binary}}'
runtime_image: golang:1.20.4
debugger_enabled: true
debugger_port: 40000
expose_ports:
  - "8080:8080"
networks: []
environment: []
pre_run_commands:
  - mkdir -p /var/task
  - curl -sLo /tmp/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && mv /tmp/aws-lambda-rie /usr/local/bin/aws-lambda-rie && chmod +x /usr/local/bin/aws-lambda-rie

Hi @pixie79,
I believe the issue is that the aws-lambda-rie executable was built without the debug symbols as suggested by the message you attached.
It acts like a proxy for simulating the AWS lambda infrastructure when testing your function.
I actually wrote a small blog post regarding using aws-lambda-rie and gebug you can take a look:
https://moshe-beladev-mb.medium.com/debug-aws-lambda-functions-with-gebug-bc643788c247

Hi,

Thanks, that was the blog post I was following and where I downloaded the aws-lambda-rie from so I guess the main project no longer includes the debug symbols. Is there any other option?

Regards

Mark

Actually I re-checked it and it looks like the the configuration I used back-then was also without debugger:

name: lambdagebug
output_binary: /usr/local/bin/aws-lambda-rie /var/task/main
build_command: go build -o /var/task/main
build_dir: /src
run_command: '{{.output_binary}}'
runtime_image: golang:1.15.2
debugger_enabled: false
debugger_port: 0
expose_ports:
- 8080:8080
networks: []
environment: []
pre_run_commands:
- curl -sLo /tmp/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && mv /tmp/aws-lambda-rie /usr/local/bin/aws-lambda-rie && chmod +x /usr/local/bin/aws-lambda-rie

which is makes sense as it's not so common to release an official binary with the debug symbols.

Unfortunately, not sure any standard way using delve and regular Go application will work for you the way you are looking for.
But, you can use Gebug for live reload (dynamically edit you Go code and it will automatically build and run your latest changes).
Hope you will find it useful for your needs 🙏