Commit 3fa09cb1 authored by Xiao Shi's avatar Xiao Shi Committed by Facebook GitHub Bot

fix inline asm syntax on MSVC

Summary:
This diff moves the gdb related test into `folly/support/test` (as opposed to
`tests`) so that CMake rules
[here](https://github.com/facebook/folly/blob/194b7732bd65d56b4afb58b6d9e411c1b014b3e3/CMakeLists.txt#L155)
will exclude these files from OSS library builds--also to maintain consistency
with other test folder names under folly.

I still separated out the auto gdb breakpoint functionality into GdbUtil.h so
that if MSVC users want to manually compile and use the gdb script tests, they
have the option to do so.

Re: asm syntax on MSVC:
https://gcc.godbolt.org/z/1rMh4v

Fixes #1515.

Reviewed By: Orvid

Differential Revision: D25947735

fbshipit-source-id: 97e75e972fcf8eea280df804c98c400f03c37496
parent f184a28f
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <folly/CPortability.h>
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace folly {
// Auto breakpoint in gdb.
FOLLY_ALWAYS_INLINE void asm_gdb_breakpoint() {
#ifdef _MSC_VER
__debugbreak();
#else
__asm__ volatile("int $3");
#endif
}
} // namespace folly
......@@ -22,6 +22,7 @@
#include <folly/container/F14Map.h>
#include <folly/container/F14Set.h>
#include <folly/dynamic.h>
#include <folly/support/test/GdbUtil.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
......@@ -95,6 +96,7 @@ int main() {
const F14FastSet<int>& const_ref = s_fval;
__asm__ volatile("int $3"); // Auto breakpoint in gdb.
asm_gdb_breakpoint();
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment