<commit_before>﻿"""
Test calling a function that hits a signal set to auto-restart, make sure the call completes.
"""

from __future__ import print_function


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class ExprCommandThatRestartsTestCase(TestBase):

    mydir = TestBase.compute_mydir(__file__)

    def setUp(self):
        # Call super's setUp().
        TestBase.setUp(self)

        self.main_source = "lotta-signals.c"
        self.main_source_spec = lldb.SBFileSpec(self.main_source)

    @skipIfFreeBSD  # llvm.org/pr19246: intermittent failure
    @skipIfDarwin  # llvm.org/pr19246: intermittent failure
    @skipIfWindows  # Test relies on signals, unsupported on Windows
    def test(self):
        """Test calling function that hits a signal and restarts."""
        self.build()
        self.call_function()

    def check_after_call(self, num_sigchld):
        after_call = self.sigchld_no.GetValueAsSigned(-1)
        self.assertTrue(
            after_call -
            self.start_sigchld_no == num_sigchld,
            "Really got %d SIGCHLD signals through the call." %
            (num_sigchld))
        self.start_sigchld_no = after_call

        # Check that we are back where we were before:
        frame = self.thread.GetFrameAtIndex(0)
        self.assertTrue(
            self.orig_frame_pc == frame.GetPC(),
            "Restored the zeroth frame correctly")

    def call_function(self):
        exe_name = "a.out"
        exe = os.path.join(os.getcwd(), exe_name)

        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)
        empty = lldb.SBFileSpec()
        breakpoint = target.BreakpointCreateBySourceRegex(<commit_msg>Propagating prior merge from 'llvm.org/master'.<commit_after>﻿"""
Test calling a function that hits a signal set to auto-restart, make sure the call completes.
"""

from __future__ import print_function


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class ExprCommandThatRestartsTestCase(TestBase):

    mydir = TestBase.compute_mydir(__file__)
    NO_DEBUG_INFO_TESTCASE = True

    def setUp(self):
        # Call super's setUp().
        TestBase.setUp(self)

        self.main_source = "lotta-signals.c"
        self.main_source_spec = lldb.SBFileSpec(self.main_source)

    @skipIfFreeBSD  # llvm.org/pr19246: intermittent failure
    @skipIfDarwin  # llvm.org/pr19246: intermittent failure
    @skipIfWindows  # Test relies on signals, unsupported on Windows
    @expectedFlakeyAndroid(bugnumber="llvm.org/pr19246")
    def test(self):
        """Test calling function that hits a signal and restarts."""
        self.build()
        self.call_function()

    def check_after_call(self, num_sigchld):
        after_call = self.sigchld_no.GetValueAsSigned(-1)
        self.assertTrue(
            after_call -
            self.start_sigchld_no == num_sigchld,
            "Really got %d SIGCHLD signals through the call." %
            (num_sigchld))
        self.start_sigchld_no = after_call

        # Check that we are back where we were before:
        frame = self.thread.GetFrameAtIndex(0)
        self.assertTrue(
            self.orig_frame_pc == frame.GetPC(),
            "Restored the zeroth frame correctly")

    def call_function(self):
        exe_name = "a.out"
        exe = os.path.join(os.getcwd(), exe_name)

        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)
        empty = lldb.SBFileSpec()
        breakpoint = target.BreakpointCreateBySourceRegex(
{'fraction_non_alphanumeric': 0.0892517006802721, 'fraction_numerical': 0.007891156462585034, 'mean_word_length': 2.8291666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '263527', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1137, 'n_words': 266}