Bug 478211

Summary: Redundant code for vgdb.c and Valgrind core tools
Product: [Developer tools] valgrind Reporter: Alexandra Hajkova <ahajkova>
Component: generalAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal CC: mark
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: patch

Description Alexandra Hajkova 2023-12-07 13:17:15 UTC
Created attachment 163977 [details]
patch

There are some redundancies, some functions that are already present in remote-utils.c, used by valgrind were copied to vgdb.c. remote-utils.c/server.h provides functions for core valgrind code and tools. The reason vgdb can't directly use the functions provided there is that valgrind gdbserver cannot use libc, but vgdb can and does. 

The patch attached adds remote-utils-shared.c/.h for sharing code between vgdb.c and m_gdbserver/server.c. This removes code redundancies that was introduced for vgdb.c by vgdb --multi implementation.
Comment 1 Mark Wielaard 2023-12-08 13:32:08 UTC
Very nice. Hopefully we can share more utility functions in the future.
Since remote-utils-shared.c is based on some functions from remote-utils.c I have also copied the Copyright header from that file.

commit ec73dcb1826091b3cbdd43a4a37522e33c3ce786 (HEAD -> master, origin/master, origin/HEAD)
Author: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Date:   Wed Dec 6 03:14:53 2023 -0500

    remote-utils-shared: Created files for sharing code
    
    between vgdb.c and m_gdbserver/server.c. This removes code
    redundancies that was introduced for vgdb.c by vgdb --multi
    implementation.