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

debug: openocd: Fix building for SMP platforms #18125

Conversation

abrodkin
Copy link
Collaborator

@abrodkin abrodkin commented Aug 8, 2019

struct k_thread *current is only defined for !SMP platforms
leading to the following build-time failure:

| openocd.c:39:35: error: 'struct z_kernel' has no member named 'current'
| [OPENOCD_OFFSET_K_CURR_THREAD] = offsetof(struct z_kernel, current),
^~~~~~~~

Disable calculation of meaningless offset then.

Fixes #18124.

@abrodkin abrodkin added the area: SMP Symmetric multiprocessing label Aug 8, 2019
@abrodkin abrodkin added this to the v2.0.0 milestone Aug 8, 2019
@abrodkin abrodkin requested a review from nashif as a code owner August 8, 2019 12:11
@galak galak requested a review from MaureenHelm August 8, 2019 12:15
@@ -36,7 +36,9 @@ __attribute__((used, section(".openocd_dbg")))
size_t _kernel_openocd_offsets[] = {
/* Version 0 starts */
[OPENOCD_OFFSET_VERSION] = 1,
#ifndef CONFIG_SMP
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this going to cause issues w/openocd and the assumed layout of this data? Wondering if setting the value to 0 is better?

Copy link
Member

Choose a reason for hiding this comment

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

0 is probably better, though might break things as well (don't know if openocd/gdb zephyr awareness relies on this).
Openocd Zephyr-SMP support might require more. Maybe instead of working around this, do not allow/use combination of SMP and openocd zephyr awareness for now?

Copy link
Member

Choose a reason for hiding this comment

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

OPENOCD_UNIMPLEMENTED would be better than zero, but I also like @abrodkin's idea to handle this in KConfig.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Aug 8, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

@ioannisg ioannisg added the bug The issue is a bug, or the PR is fixing a bug label Aug 8, 2019
@abrodkin
Copy link
Collaborator Author

abrodkin commented Aug 8, 2019

@galak @ruuddw so maybe something like this until we really make sure OpenOCD works with Zephyr-aware on SMP systems?

diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig
index a55d0f3350..a5dff0ad4f 100644
--- a/subsys/debug/Kconfig
+++ b/subsys/debug/Kconfig
@@ -223,6 +223,7 @@ config EXCEPTION_STACK_TRACE

 config OPENOCD_SUPPORT
        bool "OpenOCD support [EXPERIMENTAL]"
+       depends on !SMP
        select THREAD_MONITOR
        select THREAD_NAME
        help

@vonhust vonhust force-pushed the topic-synchronization-openocd-smp-build branch from 700782c to 3d21cb1 Compare August 11, 2019 09:38
@ioannisg ioannisg requested review from ruuddw and galak August 18, 2019 16:45
@ioannisg
Copy link
Member

@nashif @galak @ruuddw could you finalize reviewing this bug-fix of a a high priority bug?

@ioannisg
Copy link
Member

ioannisg commented Sep 3, 2019

Moving to next release since the review was not finalized for v.2.0.0

@ioannisg ioannisg modified the milestones: v2.0.0, v2.1.0 Sep 3, 2019
@galak
Copy link
Collaborator

galak commented Sep 19, 2019

Any updates on this?

@abrodkin
Copy link
Collaborator Author

@EvgeniiDidin could you please take a look at this one since you anyways deal with OpenOCD/GDB thingy these days?

@galak
Copy link
Collaborator

galak commented Nov 6, 2019

@abrodkin, @EvgeniiDidin any update on this?

@galak galak removed this from the v2.1.0 milestone Nov 13, 2019
@EvgeniiDidin
Copy link
Contributor

Hi,

I tested SMP Zephyr smp/pi example with these changes on HSDK(4 core) board using OpenOCD/ gdb. It is possible to load and start the application on all cores, also I was able to get callee registers from stack. But after stopping execution "continue" command failed with next message:

(gdb) c
Cannot execute this command without a live selected thread.

I guess it is related to the lack of current_thread{id} values in OpenOCD, which come from "current" struct.

If incomplete smp aware support is permissible for Zephyr/OpenOCD, this commit is fine. Otherwise we should disable simultaneous usage of CONFIG_SMP and CONFIG_OPENOCD options.

@galak
Copy link
Collaborator

galak commented Apr 17, 2020

@abrodkin, @EvgeniiDidin any update on this?

@abrodkin
Copy link
Collaborator Author

@galak I think the most recent comment of Eugeniy (#18125 (comment)) still valid. We either declare SMP mode doesn't support additional OpenOCD-related visibility options or ignore pointer to the "current thread" implemented in this commit. I now lean towards making CONFIG_OPENOCD incompatible with CONFIG_SMP as at least it won't introduce any funky behavior.

@ruuddw
Copy link
Member

ruuddw commented May 8, 2020

Let's prevent openocd and SMP / multiple CPUs in kconfig.
SMP/multi-core is simply not yet supported. See also PR #23503 : adds a #error in openocd.c.

In case of SMP (i.e. multiple execution units processing
the same list of tasks) we cannot use the same data structures for
getting data about active tasks as with just one processor (UP).

So until explicit support of SMP is added make sure we don't allow
to select both OPENOCD & SMP simultaneously.

Moreover starting from
commit a203d21 ("kernel: remove legacy fields in _kernel")
this will lead to build-time error if MP_NUM_CPUS > 1.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
@abrodkin abrodkin force-pushed the topic-synchronization-openocd-smp-build branch from 3d21cb1 to 69af584 Compare May 8, 2020 18:52
@galak galak added this to the v2.3.0 milestone May 9, 2020
@carlescufi carlescufi requested review from andyross and andrewboie May 10, 2020 08:52
@carlescufi carlescufi requested a review from erwango May 10, 2020 08:52
@carlescufi carlescufi merged commit bf98113 into zephyrproject-rtos:master May 10, 2020
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

LGTM but I need @andrewboie, @MaureenHelm, @galak or @nashif to approve

@abrodkin abrodkin deleted the topic-synchronization-openocd-smp-build branch March 14, 2022 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SMP Symmetric multiprocessing bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

synchronization example fails to build for SMP platforms
9 participants