Menu

#449 GDB Server Should Return an Empty Response for Undefined GDB Packets

0.10.0
new
nobody
None
2025-02-12
2025-02-12
No

Hi.
Not all undefined GDB packets return an empty response.
This is issue when debugging using LLDB. Since the openocd does not immediately return an empty response, each nexti command becomes very slow due to LLDB waiting for a receive timeout.

Eg:

(gdb) maintenance packet jThreadsInfo
sending: jThreadsInfo
Ignoring packet error, continuing...
error while fetching packet from remote target

(gdb) maintenance packet xxx
sending: xxx
received: ""

(gdb) maintenance packet jxxx
sending: jxxx
Ignoring packet error, continuing...
error while fetching packet from remote target

I found out, a lot of gdb packets in openocd has missing else with empty response.

Discussion

  • patryk sondej

    patryk sondej - 2025-02-12
    int gdb_read_smp_packet(struct connection *connection,
            char const *packet, int packet_size)
    {
        struct target *target = get_target_from_connection(connection);
        int retval = ERROR_OK;
    
        LOG_WARNING(DEPRECATED_MSG);
    
        if (target->smp) {
            if (strncmp(packet, "jc", 2) == 0) {
                const uint32_t len = sizeof(target->gdb_service->core[0]);
                char hex_buffer[len * 2 + 1];
                uint8_t buffer[len];
                buf_set_u32(buffer, 0, len * 8, target->gdb_service->core[0]);
                size_t pkt_len = hexify(hex_buffer, buffer, sizeof(buffer),
                    sizeof(hex_buffer));
    
                retval = gdb_put_packet(connection, hex_buffer, pkt_len);
            }
            // BUG: <-- MISSING ELSE HERE
        } else
            retval = gdb_put_packet(connection, "E01", 3);
        return retval;
    }
    

    should have else with:

    gdb_put_packet(connection, "", 0);
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.