Skip to content

Use target remote for remote connections #1151

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

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

hugsy
Copy link
Owner

@hugsy hugsy commented Nov 3, 2024

Description

This PR obsoletes gef-remote to be completely replaced by pre and post hooks on target remote directly.
We use some heuristics to determine what type of remote we're connected to reliably.
In some old qemu, we still have to mock a memory layout, but the whole sync thing is not necessary any longer.

Fixes #1080
Fixes #1128

Checklist

  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • If my change adds new code, adequate tests have been added.
  • I have read and agree to the CONTRIBUTING document.

@hugsy hugsy mentioned this pull request Nov 3, 2024
8 tasks
@hugsy hugsy self-assigned this Nov 3, 2024
Copy link

github-actions bot commented Nov 3, 2024

🤖 Coverage update for a277661 🔴

Old New
Commit 9fb1d71 a277661
Score 71.2662% 71.197% (-0.0692)

Copy link

github-actions bot commented Nov 4, 2024

🤖 Coverage update for 6d166f0 🔴

Old New
Commit 9fb1d71 6d166f0
Score 71.2662% 71.197% (-0.0692)

Copy link

github-actions bot commented Nov 5, 2024

🤖 Coverage update for 79447be 🔴

Old New
Commit 9fb1d71 79447be
Score 71.2662% 71.197% (-0.0692)

@hugsy hugsy linked an issue Nov 5, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Nov 7, 2024

🤖 Coverage update for ea873bb 🔴

Old New
Commit 9fb1d71 ea873bb
Score 71.2662% 71.197% (-0.0692)

Copy link

github-actions bot commented Nov 7, 2024

🤖 Coverage update for 4ae683f 🔴

Old New
Commit 9fb1d71 4ae683f
Score 71.2662% 71.197% (-0.0692)

Copy link

github-actions bot commented Nov 7, 2024

🤖 Coverage update for 8130895 🔴

Old New
Commit 9fb1d71 8130895
Score 71.2662% 71.2358% (-0.0304)

Copy link

github-actions bot commented Nov 7, 2024

🤖 Coverage update for 7973a3f 🔴

Old New
Commit 9fb1d71 7973a3f
Score 71.2662% 71.197% (-0.0692)

Copy link

🤖 Coverage update for 02af4d4 🟢

Old New
Commit 0f21eea 02af4d4
Score 71.2413% 71.2413% (0)

Copy link

🤖 Coverage update for c89c280 🟢

Old New
Commit 0f21eea c89c280
Score 71.2413% 71.2607% (0.0194)

Copy link

🤖 Coverage update for 77aa954 🟢

Old New
Commit 0f21eea 77aa954
Score 71.2413% 71.2413% (0)

Copy link

🤖 Coverage update for 623ebf1 🟢

Old New
Commit 0f21eea 623ebf1
Score 71.2413% 71.2413% (0)

Copy link

🤖 Coverage update for 532e45d 🟢

Old New
Commit 0f21eea 532e45d
Score 71.2413% 71.2413% (0)

Copy link

🤖 Coverage update for fd0bf0a 🟢

Old New
Commit 0f21eea fd0bf0a
Score 71.2413% 71.2413% (0)

Copy link

🤖 Coverage update for d262ca5 🟢

Old New
Commit 9f2737a d262ca5
Score 71.1786% 71.1786% (0)

Copy link

🤖 Coverage update for 7a9e494 🟢

Old New
Commit 9f2737a 7a9e494
Score 71.1786% 71.1786% (0)

Copy link

🤖 Coverage update for b9f564f 🟢

Old New
Commit 9f2737a b9f564f
Score 71.1786% 71.1786% (0)

Copy link

🤖 Coverage update for 7ea8588 🟢

Old New
Commit 9f2737a 7ea8588
Score 71.1786% 71.1786% (0)

Copy link

🤖 Coverage update for 7ea8588 🟢

Old New
Commit 9f2737a 7ea8588
Score 71.1786% 71.2367% (0.0581)

Copy link
Collaborator

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work pretty well even with an openocd gdb server. Will have to do more testing but we can probably remove the 'special' gef remote commands in gef-extras

traditional `target remote` command. For many reasons, you **should not** use `target remote` alone
with GEF. It is still important to note that the default `target remote` command has been
overwritten by a minimal copy `gef-remote`, in order to make most tools relying on this command work.
📝 **IMPORTANT NOTE**: `gef-remote` is deprecated since 2024.09 in favor of `target remote`. The
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it'll be the next release

# pre-hooks
gdb.execute(hook.format("remote", ""))
gdb.execute(hook.format("extended-remote", ""))
# post-hooks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably OK if we update what versions of GDB are supported.

Copy link

github-actions bot commented Apr 5, 2025

🤖 Coverage update for 7d2ef17 🟢

Old New
Commit 5404b6f 7d2ef17
Score 71.0651% 71.0651% (0)

Copy link

github-actions bot commented Apr 5, 2025

🤖 Coverage update for 7d2ef17 🟢

Old New
Commit 5404b6f 7d2ef17
Score 71.0651% 71.1126% (0.0475)

@micsthepick
Copy link

when running the following arm program:

sudo chroot squashfs_root_bb qemu-arm-static -g 241 /usr/bin/env -i HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin "SHELL=/bin/sh" LD_PRELOAD=/fw_hacks.so datalib

the main branch works fine with the follwing:

gdb-multiarch -nx -ex "source ~/.gef-main.py" -ex "set sysroot $(pwd)/squashfs_root_bb/" -ex "gef-remote --qemu-user --qemu-binary squashfs_root_bb/usr/bin/env localhost 241"

but using the gef from this branch is failing:

gdb-multiarch -nx -ex "source ~/.gef-revisit-target-remote.py" -ex "set sysroot $(pwd)/squashfs_root_bb/" -ex "target remote :241"

will there be a workaround?
image

@hugsy
Copy link
Owner Author

hugsy commented Apr 23, 2025

@micsthepick I think you need to provide the file

@micsthepick
Copy link

micsthepick commented Apr 23, 2025

gdb-multiarch -nx -ex "source ~/.gef-revisit-target-remote.py" -ex "set sysroot $(pwd)/squashfs_root_bb/" -ex "file squashfs_root_bb/lib/libc.so" @hugsy you were right, the above works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants