How is GDP counted between different countries? Sorry if this question is dumb, but I did not manage to find the answer on the web. The questions is as follows:

As far as I understand, GDP is the total value of a country's production. It includes all the output, and thus it represents the cost of all the wages and primary ressources used to produce this output. But how is this cost passed from one country on other countries, considering a globalized economy?

For example, let's say that country A as a 3 000 $ GDP. And country B as a 2 000 GDP.
But country A's economy consists only in producing computers, which are built with processors built by country B: For one computer, cost = 3, two processors (each cost = 1) are needed.
So in the end, when country A sells 1 000 computers which gives 3 000 GDP, 2 000 of this GDP is buying the GDP of country 's B (2 00 processors = 2 000 of GDP).

In the end, A's GDP is higher than B's GDP but A's income is lower than B's income. And somehow, A's GDP is (B's GDP + A's working value) with A's working value being only 1 000, while B's GDP is (B's working value) with B's working value being higher (2 000) than A's.

Is all this analysis true in the real world?
And example in the real world: China has a big GDP but it consists mainly of B2B sellings to other countries: are those sellings, sold again in other countries (let's say USA), counted as GDP for USA?
So, from the link posted by @Brian Romanchuk, I got this paper and got the answer:

GDP = Consumption + Investment + Government spending + eXports – iMports

So in the example, country A GDP would end up to be:
GDPA_A = 3 000 - 2 000 = 1 000 and being correctly a smaller quantity than country B's GDP.

Thanks to contributors