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

Added dynamic TargetDescription #3780

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

theIDinside
Copy link
Contributor

TargetDescription dynamically generates the "master" target description contents (target.xml), so that we only have to manage the individual concrete CPU features (like foo-sse.xml, for instance). TargetDescription will generate the xml contents that includes the used features.

Removed combinatorial target.xml files

These are now handled by TargetDescription instead.

This unblocks the #3776 PR (AVX512 support) from getting pulled in, though that PR will need to take this PR into account.

Note:
The GdbServerRegister should probably be rewritten/removed and then rely on a TargetDescription that provides a "static" array of GdbServerValue since once we know the target description, it won't change during a replay, so dynamically allocating like we do now (in dispatch_regs_request) is not really necessary. But these are just loose thoughts I have, I haven't really verified that this would be a better approach.

TargetDescription dynamically generates the "master" target description
contents (target.xml), so that we only have to manage the individual
concrete CPU features (like foo-sse.xml, for instance). TargetDescription
will generate the xml contents that includes the used features.

Removed combinatorial target.xml files

These are now handled by `TargetDescription` instead.

This unblocks the rr-debugger#3776 PR (AVX512 support) from getting pulled in,
though that PR will need to take this PR into account.
@theIDinside
Copy link
Contributor Author

theIDinside commented Jul 11, 2024

@rocallahan || @khuey
Does the tests run on actual hardware or some emulation? The errors are confusing; I just can't see how that can possibly be true without there actually existing RR bugs, and that now, with this patch we actually provide aarch64 target descriptions and that's why gdb asserts saying it expects 268 bytes (which is the total size of all registers defined in aarch64-core.xml size) but got 788 (which I think is just x86 or some variant, possibly without a few registers)

I don't even know how we have sent this before or why this hasn't been a bug prior to this.
@theIDinside
Copy link
Contributor Author

theIDinside commented Jul 11, 2024

Prior to this patch, I have no idea how RR informed GDB on aarch64 that the g packet contains the aarch64-fpu.xml because the only file it ever should have transferred using xfer was aarch64-core.xml. But with this patch, I forgot to add the fpu.xml in the dynamically generated target description and the tests for aarch64 failed. Now with the latest commit it works. But it does puzzle me why it hasn't failed before (since fpu.xml was never actually sent before).

@@ -111,7 +112,8 @@ unique_ptr<GdbServerConnection> GdbServerConnection::await_connection(
Task* t, ScopedFd& listen_fd, const GdbServerConnection::Features& features) {
auto dbg = unique_ptr<GdbServerConnection>(
new GdbServerConnection(t->thread_group()->tguid(), features));
dbg->set_cpu_features(get_cpu_features(t->arch()));
const auto arch = t->arch();
dbg->set_cpu_features(arch, get_cpu_features(arch));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can just drop this hunk.

src/GdbServerConnection.cc Outdated Show resolved Hide resolved
src/GdbServerConnection.h Outdated Show resolved Hide resolved
src/TargetDescription.h Outdated Show resolved Hide resolved
src/TargetDescription.h Outdated Show resolved Hide resolved
src/TargetDescription.cc Outdated Show resolved Hide resolved
src/TargetDescription.cc Outdated Show resolved Hide resolved
src/TargetDescription.cc Outdated Show resolved Hide resolved
}
}

static constexpr auto Header = R"(<?xml version="1.0"?>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't need to make this constexpr or auto. Also, name should be header or possibly HEADER. E.g. use
static const char header[] = ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

... or else just write it inline, that's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to header, but refrained from inlining it directly as raw string literals make code look weird, though that's a personal taste though, and I'll gladly change if it you like.

src/TargetDescription.h Outdated Show resolved Hide resolved
@rocallahan
Copy link
Collaborator

Also, it looks like tests are failing in CI on x86-64?

@theIDinside
Copy link
Contributor Author

Also, it looks like tests are failing in CI on x86-64?

Where can I see these tests? It says "All checks have passed" here.

@@ -0,0 +1,27 @@
#pragma once
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't use this. Use #define guards instead like our other .h files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, put

/* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */

on the first line like our other source files.

@@ -0,0 +1,128 @@
#include "TargetDescription.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put

/* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */

on the first line like our other .cc files.

#include "TargetDescription.h"
#include "GdbServerConnection.h"
#include "kernel_abi.h"
#include <sstream>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Order #includes like our other files: first TargetDescription.h, then the C++ library headers, then the rr headers.

@@ -0,0 +1,27 @@
#pragma once
#include "kernel_abi.h"
#include <cstdint>
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above, reorder these includes.


namespace rr {

struct GdbServerRegisterValue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can remove this since it's not used.

};

class TargetDescription {
SupportedArch arch;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put this below the public members in a private: section.


class FeatureStream {
public:
std::string result() { return stream.str(); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add using namespace std; after the includes and don't use the std:: prefix (except for std::move where clang requires it...)

@rocallahan
Copy link
Collaborator

Where can I see these tests? It says "All checks have passed" here.

Yep, that looks good!

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

Successfully merging this pull request may close these issues.

2 participants